cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 1 | # ScaleOutTemplate |
| 2 | # |
| 3 | # CASE1 starts number of nodes specified in param file |
| 4 | # |
| 5 | # cameron@onlab.us |
| 6 | |
| 7 | import sys |
| 8 | import os.path |
| 9 | |
| 10 | |
| 11 | class SCPFintentInstallWithdrawLat: |
| 12 | |
| 13 | def __init__( self ): |
| 14 | self.default = '' |
| 15 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 16 | def CASE1( self, main ): |
| 17 | |
| 18 | import time |
| 19 | global init |
| 20 | try: |
| 21 | if type(init) is not bool: |
| 22 | init = False |
| 23 | except NameError: |
| 24 | init = False |
| 25 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 26 | #Load values from params file |
| 27 | checkoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
| 28 | gitPull = main.params[ 'GIT' ][ 'autopull' ] |
| 29 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 30 | Apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 31 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 32 | BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 33 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
cameron@onlab.us | ceff56f | 2015-07-13 16:42:08 -0700 | [diff] [blame] | 34 | main.maxNodes = int(main.params[ 'max' ]) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 35 | skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 36 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 37 | switchCount = main.params[ 'TEST' ][ 'switchCount' ] |
| 38 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 39 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 40 | if init == False: |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 41 | init = True |
| 42 | global clusterCount #number of nodes running |
| 43 | global ONOSIp #list of ONOS IP addresses |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 44 | global scale |
| 45 | global commit |
| 46 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 47 | clusterCount = 0 |
| 48 | ONOSIp = [ 0 ] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 49 | scale = (main.params[ 'SCALE' ]).split(",") |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 50 | clusterCount = int(scale[0]) |
| 51 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 52 | #Populate ONOSIp with ips from params |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 53 | ONOSIp = [0] |
| 54 | ONOSIp.extend(main.ONOSbench.getOnosIps()) |
| 55 | |
| 56 | #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test |
| 57 | if skipMvn != "yes": |
| 58 | mvnResult = main.ONOSbench.cleanInstall() |
| 59 | |
| 60 | #git |
| 61 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 62 | if gitPull == 'on': |
| 63 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 64 | pullResult = main.ONOSbench.gitPull() |
| 65 | |
| 66 | else: |
| 67 | checkoutResult = main.TRUE |
| 68 | pullResult = main.TRUE |
| 69 | main.log.info( "Skipped git checkout and pull" ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 70 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 71 | commit = main.ONOSbench.getVersion() |
| 72 | commit = (commit.split(" "))[1] |
| 73 | |
suibin | 584c070 | 2015-07-14 15:57:27 -0700 | [diff] [blame] | 74 | resultsDB = open("/tmp/IntentInstallWithdrawLatDB", "w+") |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 75 | resultsDB.close() |
| 76 | |
| 77 | # -- END OF INIT SECTION --# |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 78 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 79 | clusterCount = int(scale[0]) |
| 80 | scale.remove(scale[0]) |
| 81 | |
| 82 | #kill off all onos processes |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 83 | main.log.step("Safety check, killing all ONOS processes") |
| 84 | main.log.step("before initiating enviornment setup") |
cameron@onlab.us | ceff56f | 2015-07-13 16:42:08 -0700 | [diff] [blame] | 85 | for node in range(1, main.maxNodes + 1): |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 86 | main.ONOSbench.onosDie(ONOSIp[node]) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 87 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 88 | #Uninstall everywhere |
| 89 | main.log.step( "Cleaning Enviornment..." ) |
cameron@onlab.us | ceff56f | 2015-07-13 16:42:08 -0700 | [diff] [blame] | 90 | for i in range(1, main.maxNodes + 1): |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 91 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 92 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 93 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 94 | #construct the cell file |
| 95 | main.log.info("Creating cell file") |
| 96 | cellIp = [] |
| 97 | for node in range (1, clusterCount + 1): |
| 98 | cellIp.append(ONOSIp[node]) |
| 99 | |
cameron@onlab.us | ceff56f | 2015-07-13 16:42:08 -0700 | [diff] [blame] | 100 | main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), cellIp) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 101 | |
| 102 | main.step( "Set Cell" ) |
| 103 | main.ONOSbench.setCell(cellName) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 104 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 105 | main.step( "Creating ONOS package" ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 106 | packageResult = main.ONOSbench.onosPackage() |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 107 | |
| 108 | main.step( "verify cells" ) |
| 109 | verifyCellResult = main.ONOSbench.verifyCell() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 110 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 111 | main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." ) |
| 112 | for node in range(1, clusterCount + 1): |
| 113 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
| 114 | main.ONOSbench.onosInstall( ONOSIp[node]) |
| 115 | |
| 116 | for node in range(1, clusterCount + 1): |
| 117 | for i in range( 2 ): |
| 118 | isup = main.ONOSbench.isup( ONOSIp[node] ) |
| 119 | if isup: |
| 120 | main.log.info("ONOS " + str(node) + " is up\n") |
| 121 | break |
| 122 | if not isup: |
| 123 | main.log.report( "ONOS " + str(node) + " didn't start!" ) |
| 124 | |
| 125 | main.ONOS1cli.startOnosCli( ONOSIp[1] ) |
| 126 | main.log.info("Startup sequence complete") |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 127 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 128 | time.sleep(30) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 129 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 130 | for i in range(3): |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 131 | main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", ("deviceCount " + str(switchCount)) ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 132 | main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "topoShape linear") |
| 133 | main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "enabled true") |
| 134 | if main.ONOSbench.verifySummary(ONOSIp[1], switchCount): |
| 135 | break |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 136 | else: |
| 137 | print "Failed- looping" |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 138 | |
| 139 | main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """) |
| 140 | main.ONOSbench.handle.expect(":~") |
| 141 | main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"]) |
| 142 | |
| 143 | def CASE2( self, main ): |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 144 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 145 | import time |
| 146 | import numpy |
| 147 | |
| 148 | testStatus = "pass" |
| 149 | sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ]) |
| 150 | warmUp = int(main.params[ 'TEST' ][ 'warmUp' ]) |
| 151 | intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",") |
| 152 | switchCount = int(main.params[ 'TEST' ][ 'switchCount' ]) |
| 153 | debug = main.params[ 'TEST' ][ 'switchCount' ] |
| 154 | for i in range(0,len(intentsList)): |
| 155 | intentsList[i] = int(intentsList[i]) |
| 156 | |
| 157 | ###################### |
| 158 | debug = True |
| 159 | ###################### |
| 160 | |
| 161 | linkCount = 0 |
| 162 | for i in range(0,10): |
| 163 | main.ONOSbench.handle.sendline("onos $OC1 links|wc -l") |
| 164 | main.ONOSbench.handle.expect(":~") |
| 165 | linkCount = main.ONOSbench.handle.before |
| 166 | if debug: main.log.info("Link Count check: " + linkCount) |
| 167 | if str((switchCount*2)-2) in linkCount: |
| 168 | break |
| 169 | time.sleep(2) |
| 170 | |
| 171 | links = "--" |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 172 | for i in range(8): |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 173 | if debug: main.log.info("top of loop") |
| 174 | main.ONOSbench.handle.sendline("onos $OC1 links") |
| 175 | main.ONOSbench.handle.expect(":~") |
| 176 | links = main.ONOSbench.handle.before |
| 177 | if "=null:" in links: |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 178 | break |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 179 | if debug: main.log.info(str(links)) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 180 | if i > 3: |
| 181 | main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d") |
| 182 | if i == 7: |
| 183 | main.log.error("link data missing") |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 184 | time.sleep(3) |
| 185 | |
| 186 | links = links.splitlines() |
| 187 | templinks = links |
| 188 | |
| 189 | tempDevices = [] |
| 190 | for line in links: |
| 191 | temp = line.split(" ") |
| 192 | temp[0].replace("src=","") |
| 193 | temp[0] = (temp[0].split("/"))[0] |
| 194 | tempDevices.append(temp[0]) |
| 195 | |
| 196 | tempDevices.sort() |
| 197 | devices = [] |
| 198 | for i in tempDevices: |
| 199 | if "src=null" in i: |
| 200 | devices.append(i.replace("src=", "")) |
| 201 | if debug: main.log.info(str(devices)) |
| 202 | |
| 203 | ingress = devices[0] |
| 204 | egress = devices.pop() |
| 205 | if debug: main.log.info(ingress) |
| 206 | if debug: main.log.info(egress) |
| 207 | |
| 208 | for intentSize in intentsList: |
| 209 | cmd = "onos $OC1 push-test-intents " |
| 210 | cmd += ingress + "/6 " |
| 211 | cmd += egress + "/5 " |
| 212 | cmd += str(intentSize) + " 1" |
| 213 | installed = [] |
| 214 | withdrawn = [] |
GlennRC | 6018f84 | 2015-09-10 15:24:21 -0700 | [diff] [blame] | 215 | testStatus = "" |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 216 | |
| 217 | for run in range(0, (warmUp + sampleSize)): |
| 218 | if run > warmUp: |
| 219 | time.sleep(5) |
| 220 | |
| 221 | myRawResult = "--" |
GlennRC | d942a9f | 2015-08-25 13:00:49 -0700 | [diff] [blame] | 222 | |
| 223 | main.ONOSbench.handle.sendline(cmd) |
| 224 | main.ONOSbench.handle.expect(":~") |
| 225 | myRawResult = main.ONOSbench.handle.before |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 226 | |
| 227 | if debug: main.log.info(myRawResult) |
| 228 | |
| 229 | if run >= warmUp: |
| 230 | myRawResult = myRawResult.splitlines() |
| 231 | for line in myRawResult: |
GlennRC | 95f2bfb | 2015-09-11 09:53:33 -0700 | [diff] [blame] | 232 | if "Failure:" in line: |
| 233 | main.log.error("INTENT TEST FAILURE, ABORTING TESTCASE") |
| 234 | testStatus = "fail" |
| 235 | break |
| 236 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 237 | if "install" in line: |
| 238 | installed.append(int(line.split(" ")[5])) |
| 239 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 240 | if "withdraw" in line: |
| 241 | withdrawn.append(int(line.split(" ")[5])) |
| 242 | |
GlennRC | 6018f84 | 2015-09-10 15:24:21 -0700 | [diff] [blame] | 243 | if testStatus == "fail": |
| 244 | main.log.info("Installed: " + str(installed)) |
| 245 | main.log.info("Withdrawn: " + str(withdrawn)) |
| 246 | main.log.info("Scale: " + str(clusterCount)) |
| 247 | main.log.info("Warmup: " + str(warmUp) + " SampleSize: " + str(sampleSize)) |
| 248 | main.log.info("Run: " + str(run)) |
| 249 | main.log.error("Skipping test case") |
| 250 | main.skipCase() |
| 251 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 252 | main.log.report("----------------------------------------------------") |
| 253 | main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize)) |
| 254 | main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp)) |
| 255 | main.log.report("Installed average: " + str(numpy.mean(installed))) |
| 256 | main.log.report("Installed standard deviation: " + str(numpy.std(installed))) |
| 257 | main.log.report("Withdraw average: " + str(numpy.mean(withdrawn))) |
| 258 | main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn))) |
| 259 | main.log.report(" ") |
| 260 | |
| 261 | resultString = "'" + commit + "'," |
| 262 | resultString += str(clusterCount) + "," |
| 263 | resultString += str(intentSize) + "," |
| 264 | resultString += str(numpy.mean(installed)) + "," |
| 265 | resultString += str(numpy.std(installed)) + "," |
| 266 | resultString += str(numpy.mean(withdrawn)) + "," |
| 267 | resultString += str(numpy.std(withdrawn)) + "\n" |
suibin | e1e5877 | 2015-07-15 09:52:59 -0700 | [diff] [blame] | 268 | resultsDB = open("/tmp/IntentInstallWithdrawLatDB", "a") |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 269 | resultsDB.write(resultString) |
| 270 | resultsDB.close() |
| 271 | |
| 272 | main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"]) |
| 273 | time.sleep(20) |