andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 1 | # ScaleOutTemplate -> NullProviderTest |
| 2 | # |
| 3 | # CASE1 starts number of nodes specified in param file |
| 4 | # |
| 5 | # cameron@onlab.us |
| 6 | |
| 7 | |
| 8 | class IntentEventTP: |
| 9 | |
| 10 | def __init__( self ): |
| 11 | self.default = '' |
| 12 | |
| 13 | def CASE1( self, main ): |
| 14 | import os.path |
| 15 | global clusterCount |
| 16 | global ONOSIp |
| 17 | clusterCount = 1 |
| 18 | ONOSIp = [] |
| 19 | checkoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
| 20 | gitPull = main.params[ 'GIT' ][ 'autopull' ] |
| 21 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 22 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 23 | BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 24 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 25 | ONOSIp.append(ONOS1Ip) |
| 26 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 27 | ONOSIp.append(ONOS2Ip) |
| 28 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 29 | ONOSIp.append(ONOS3Ip) |
| 30 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 31 | Features= main.params[ 'ENV' ][ 'cellFeatures' ] |
| 32 | |
| 33 | |
| 34 | main.ONOSbench.createCellFile(BENCHIp, cellName, MN1Ip,str(Features), ONOS1Ip, ONOS2Ip, ONOS3Ip) |
| 35 | |
| 36 | main.log.step( "Cleaning Enviornment..." ) |
| 37 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 38 | main.ONOSbench.onosUninstall( ONOS2Ip ) |
| 39 | main.ONOSbench.onosUninstall( ONOS3Ip ) |
| 40 | |
| 41 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 42 | if gitPull == 'on': |
| 43 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 44 | pullResult = main.ONOSbench.gitPull() |
| 45 | |
| 46 | else: |
| 47 | checkoutResult = main.TRUE |
| 48 | pullResult = main.TRUE |
| 49 | main.log.info( "Skipped git checkout and pull" ) |
| 50 | |
| 51 | #mvnResult = main.ONOSbench.cleanInstall() |
| 52 | |
| 53 | main.step( "Set cell for ONOS cli env" ) |
| 54 | main.ONOS1cli.setCell( cellName ) |
| 55 | main.ONOS2cli.setCell( cellName ) |
| 56 | main.ONOS3cli.setCell( cellName ) |
| 57 | |
| 58 | main.log.info("Modifying org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg: Turning off flicker ") |
| 59 | homeDir = os.path.expanduser('~') |
| 60 | main.log.info(homeDir) |
| 61 | localPath = "/ONOS/tools/package/etc/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg" |
| 62 | filePath = homeDir + localPath |
| 63 | main.log.info(filePath) |
| 64 | |
| 65 | configFile = open(filePath, 'w+') |
| 66 | main.log.info("file opened") |
| 67 | configFile.write("# Sample configurations for the NullLinkProvider.\n") |
| 68 | configFile.write("# \n") |
| 69 | configFile.write("# If enabled, generates LinkDetected and LinkVanished events\n") |
| 70 | configFile.write("# to make the link appear to be flapping.\n") |
| 71 | configFile.write("#\n") |
| 72 | configFile.write("# flicker = true\n") |
| 73 | configFile.write("#\n") |
| 74 | configFile.write("# If enabled, sets the time between LinkEvent generation,\n") |
| 75 | configFile.write("# in milliseconds.\n") |
| 76 | configFile.write("#\n") |
| 77 | configFile.write("# eventRate = 2000\n") |
| 78 | |
| 79 | configFile.close() |
| 80 | main.log.info("Closing config file") |
| 81 | |
| 82 | main.step( "Creating ONOS package" ) |
| 83 | packageResult = main.ONOSbench.onosPackage() |
| 84 | |
| 85 | main.step( "Installing ONOS package" ) |
| 86 | install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip ) |
| 87 | |
| 88 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 89 | main.step( "Applying cell file to environment" ) |
| 90 | cellApplyResult = main.ONOSbench.setCell( cellName ) |
| 91 | main.step( "verify cells" ) |
| 92 | verifyCellResult = main.ONOSbench.verifyCell() |
| 93 | |
| 94 | main.step( "Set cell for ONOS cli env" ) |
| 95 | cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip ) |
| 96 | |
| 97 | ###### UPGRADE FOR SCALABLILTY ###### |
| 98 | jenkinsReport = open('IntentEventTP.csv', 'w') |
| 99 | jenkinsReport.write("T1 - Node 1, T2 - Node 1, T2 - Node 2, T3 - Node 1, T3 - Node 2, T3 - Node 3\n") |
| 100 | jenkinsReport.close |
| 101 | ##################################### |
| 102 | |
| 103 | def CASE2( self, main ): |
| 104 | '' |
| 105 | 'Increase number of nodes and initiate CLI' |
| 106 | '' |
| 107 | import time |
| 108 | |
| 109 | global clusterCount |
| 110 | |
| 111 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 112 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 113 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 114 | #ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 115 | #ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 116 | #ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 117 | #ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
| 118 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 119 | scale = int( main.params[ 'SCALE' ] ) |
| 120 | |
| 121 | # Cluster size increased everytime the case is defined |
| 122 | clusterCount += scale |
| 123 | |
| 124 | main.log.report( "Increasing cluster size to " + |
| 125 | str( clusterCount ) ) |
| 126 | installResult = main.FALSE |
| 127 | |
| 128 | if scale == 2: |
| 129 | if clusterCount == 3: |
| 130 | main.log.info( "Installing nodes 2 and 3" ) |
| 131 | install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip ) |
| 132 | install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip ) |
| 133 | cli2 = main.ONOS2cli.startOnosCli(ONOS2Ip) |
| 134 | cli3 = main.ONOS3cli.startOnosCli(ONOS3Ip) |
| 135 | |
| 136 | |
| 137 | #elif clusterCount == 5: |
| 138 | |
| 139 | # main.log.info( "Installing nodes 4 and 5" ) |
| 140 | # node4Result = main.ONOSbench.onosInstall( node=ONOS4Ip ) |
| 141 | # node5Result = main.ONOSbench.onosInstall( node=ONOS5Ip ) |
| 142 | # installResult = node4Result and node5Result |
| 143 | # time.sleep( 5 ) |
| 144 | |
| 145 | # main.ONOS4cli.startOnosCli( ONOS4Ip ) |
| 146 | # main.ONOS5cli.startOnosCli( ONOS5Ip ) |
| 147 | |
| 148 | #elif clusterCount == 7: |
| 149 | |
| 150 | # main.log.info( "Installing nodes 4 and 5" ) |
| 151 | # node6Result = main.ONOSbench.onosInstall( node=ONOS6Ip ) |
| 152 | # node7Result = main.ONOSbench.onosInstall( node=ONOS7Ip ) |
| 153 | # installResult = node6Result and node7Result |
| 154 | # time.sleep( 5 ) |
| 155 | |
| 156 | # main.ONOS6cli.startOnosCli( ONOS6Ip ) |
| 157 | # main.ONOS7cli.startOnosCli( ONOS7Ip ) |
| 158 | # |
| 159 | |
| 160 | if scale == 1: |
| 161 | if clusterCount == 2: |
| 162 | main.log.info( "Installing node 2" ) |
| 163 | install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip ) |
| 164 | cli2 = main.ONOS2cli.startOnosCli(ONOS2Ip) |
| 165 | |
| 166 | if clusterCount == 3: main.log.info( "Installing node 3" ) |
| 167 | install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip ) |
| 168 | cli3 = main.ONOS3cli.startOnosCli(ONOS3Ip) |
| 169 | |
| 170 | |
| 171 | def CASE3( self, main ): |
| 172 | |
| 173 | import os.path |
| 174 | import sys |
| 175 | import json |
| 176 | import time |
| 177 | |
| 178 | main.log.info("Cluster Count = " + str(clusterCount)) |
| 179 | |
| 180 | defaultSwPort = main.params[ 'CTRL' ][ 'port1' ] |
| 181 | intentsRate = main.params['JSON']['intents_rate'] |
| 182 | |
| 183 | for i in range( 0,clusterCount ): #iterates over nodes |
| 184 | switchNum = i |
| 185 | while switchNum < 7: #iterates over applicable switches |
| 186 | main.Mininet1.assignSwController(sw = switchNum + 1, ip1 = ONOSIp[i], port1 = defaultSwPort) |
| 187 | main.log.info("ONOS " + str(i + 1) + " assigned switch : " + str(switchNum+1)) |
| 188 | switchNum += clusterCount |
| 189 | |
| 190 | main.log.info("running arping") |
| 191 | mnArp = main.params['TEST']['arping'] |
| 192 | main.Mininet1.handle.sendline( mnArp ) |
| 193 | |
| 194 | generateLoad = main.params[ 'TEST' ][ 'loadstart' ] |
| 195 | |
| 196 | for node in range(1, clusterCount+1): |
| 197 | exec "a = main.ONOS%s.handle.sendline" %str(node) |
| 198 | a(generateLoad) |
| 199 | main.log.info("Load initiated on node " + str(node)) |
| 200 | |
| 201 | # |
| 202 | # TODO: Confirm Load somehow |
| 203 | # |
| 204 | |
| 205 | getMetric = main.params[ 'TEST' ][ 'metric1' ] |
| 206 | testDuration = main.params[ 'TEST' ][ 'duration' ] |
| 207 | stop = time.time() + float( testDuration ) |
| 208 | |
| 209 | main.log.info( "Starting test loop for " + str(testDuration) + " seconds..." ) |
| 210 | logInterval = main.params[ 'TEST' ][ 'log_interval' ] |
| 211 | |
| 212 | |
| 213 | rateResult = [0,0,0,0,0,0,0,0] |
| 214 | while time.time() < stop: |
| 215 | time.sleep( float( logInterval ) ) |
| 216 | for node in range (1, clusterCount + 1): |
| 217 | exec "a = main.ONOS%scli.intentsEventsMetrics" %str(node) |
| 218 | intentsJsonObj = json.loads(a()) |
| 219 | |
| 220 | main.log.info( "Node " + str(node) + " rate: " + str( intentsJsonObj[ intentsRate ][ 'm1_rate' ] ) ) |
| 221 | rateResult[node] = round(intentsJsonObj[ intentsRate ][ 'm1_rate' ], 2) |
| 222 | |
| 223 | stopLoad = main.params[ 'TEST' ][ 'loadstop' ] |
| 224 | |
| 225 | jenkinsReport = open('IntentEventTP.csv', 'a') |
| 226 | for node in range(1, clusterCount + 1): |
| 227 | main.log.report("Cluster Size = " + str(clusterCount) + " Final on node " + str(node) + ": " + str(rateResult[node])) |
| 228 | exec "a = main.ONOS%s.handle.sendline" %str(node) |
| 229 | a(stopLoad) |
| 230 | jenkinsReport.write(str(rateResult[node])) |
| 231 | jenkinsReport.write(", ") |
| 232 | jenkinsReport.close() |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |