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