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 |
| 45 | |
| 46 | clusterCount = 0 |
| 47 | ONOSIp = [ 0 ] |
| 48 | scale = (main.params[ 'SCALE' ]).split(",") |
| 49 | clusterCount = int(scale[0]) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 50 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 51 | #Populate ONOSIp with ips from params |
| 52 | for i in range(1, maxNodes + 1): |
| 53 | ipString = 'ip' + str(i) |
| 54 | ONOSIp.append(main.params[ 'CTRL' ][ ipString ]) |
| 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() |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 59 | |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 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" ) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 70 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 71 | # -- END OF INIT SECTION --# |
| 72 | |
| 73 | clusterCount = int(scale[0]) |
| 74 | scale.remove(scale[0]) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 75 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 76 | #kill off all onos processes |
| 77 | main.log.step("Safety check, killing all ONOS processes") |
| 78 | main.log.step("before initiating enviornment setup") |
| 79 | for node in range(1, maxNodes + 1): |
| 80 | main.ONOSbench.onosDie(ONOSIp[node]) |
| 81 | |
| 82 | #Uninstall everywhere |
| 83 | main.log.step( "Cleaning Enviornment..." ) |
| 84 | for i in range(1, maxNodes + 1): |
| 85 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 86 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
| 87 | |
| 88 | #construct the cell file |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 89 | main.log.info("Creating cell file") |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 90 | cellIp = [] |
| 91 | for node in range (1, clusterCount + 1): |
| 92 | cellIp.append(ONOSIp[node]) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 93 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 94 | main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 95 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 96 | main.step( "Set Cell" ) |
| 97 | main.ONOSbench.setCell(cellName) |
| 98 | |
| 99 | main.ONOSbench.createLinkGraphFile(BENCHIp, cellIp, switchCount) |
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.step( "Creating ONOS package" ) |
| 102 | packageResult = main.ONOSbench.onosPackage() |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 103 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 104 | main.step( "verify cells" ) |
| 105 | verifyCellResult = main.ONOSbench.verifyCell() |
| 106 | |
| 107 | main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." ) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 108 | for node in range(1, clusterCount + 1): |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 109 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
| 110 | main.ONOSbench.onosInstall( ONOSIp[node]) |
| 111 | |
| 112 | for node in range(1, clusterCount + 1): |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 113 | for i in range( 2 ): |
| 114 | isup = main.ONOSbench.isup( ONOSIp[node] ) |
| 115 | if isup: |
| 116 | main.log.info("ONOS " + str(node) + " is up\n") |
| 117 | break |
| 118 | if not isup: |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 119 | main.log.report( "ONOS " + str(node) + " didn't start!" ) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 120 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 121 | main.ONOS1cli.startOnosCli( ONOSIp[1] ) |
| 122 | main.log.info("Startup sequence complete") |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 123 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 124 | main.ONOSbench.configNullDev(cellIp, switchCount) |
| 125 | |
| 126 | def CASE2( self, main ): |
| 127 | |
| 128 | import time |
| 129 | import numpy |
| 130 | |
| 131 | sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ]) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 132 | warmUp = int(main.params[ 'TEST' ][ 'warmUp' ]) |
| 133 | intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",") |
| 134 | switchCount = int(main.params[ 'TEST' ][ 'switchCount' ]) |
| 135 | debug = main.params[ 'TEST' ][ 'switchCount' ] |
| 136 | for i in range(0,len(intentsList)): |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 137 | intentsList[i] = int(intentsList[i]) |
| 138 | |
| 139 | if debug == "True": |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 140 | debug = True |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 141 | else: |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 142 | debug = False |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 143 | |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 144 | linkCount = 0 |
| 145 | for i in range(0,10): |
| 146 | main.ONOSbench.handle.sendline("onos $OC1 links|wc -l") |
| 147 | main.ONOSbench.handle.expect(":~") |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 148 | linkCount = main.ONOSbench.handle.before |
| 149 | if debug: main.log.info("Link Count check: " + linkCount) |
| 150 | if str((switchCount*2)-2) in linkCount: |
| 151 | break |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 152 | time.sleep(2) |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 153 | |
| 154 | links = "--" |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 155 | while "=null:" not in links: |
| 156 | if debug: main.log.info("top of loop") |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 157 | main.ONOSbench.handle.sendline("onos $OC1 links") |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 158 | main.ONOSbench.handle.expect(":~") |
| 159 | links = main.ONOSbench.handle.before |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 160 | if debug: main.log.info(str(links)) |
| 161 | time.sleep(1) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 162 | links = links.splitlines() |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 163 | templinks = links |
| 164 | |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 165 | tempDevices = [] |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 166 | for line in links: |
| 167 | temp = line.split(" ") |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 168 | temp[0].replace("src=","") |
| 169 | temp[0] = (temp[0].split("/"))[0] |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 170 | tempDevices.append(temp[0]) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 171 | |
| 172 | tempDevices.sort() |
| 173 | devices = [] |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 174 | for i in tempDevices: |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 175 | if "src=null" in i: |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 176 | devices.append(i.replace("src=", "")) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 177 | if debug: main.log.info(str(devices)) |
| 178 | |
| 179 | ingress = devices[0] |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 180 | egress = devices.pop() |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 181 | if debug: main.log.info(ingress) |
| 182 | if debug: main.log.info(egress) |
| 183 | |
| 184 | for intentSize in intentsList: |
| 185 | cmd = "onos $OC1 push-test-intents " |
| 186 | cmd += ingress + "/6 " |
| 187 | cmd += egress + "/5 " |
| 188 | cmd += str(intentSize) + " 1" |
| 189 | installed = [] |
| 190 | withdrawn = [] |
| 191 | |
| 192 | for run in range(0, (warmUp + sampleSize)): |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 193 | if run > warmUp: |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 194 | time.sleep(5) |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 195 | |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 196 | myRawResult = "--" |
| 197 | while "ms" not in myRawResult: |
| 198 | main.ONOSbench.handle.sendline(cmd) |
| 199 | main.ONOSbench.handle.expect(":~") |
| 200 | myRawResult = main.ONOSbench.handle.before |
| 201 | if debug: main.log.info(myRawResult) |
| 202 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 203 | if debug: main.log.info(myRawResult) |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 204 | |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 205 | if run >= warmUp: |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 206 | myRawResult = myRawResult.splitlines() |
| 207 | for line in myRawResult: |
| 208 | if "install" in line: |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 209 | installed.append(int(line.split(" ")[5])) |
| 210 | |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 211 | for line in myRawResult: |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 212 | if "withdraw" in line: |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 213 | withdrawn.append(int(line.split(" ")[5])) |
| 214 | |
| 215 | print("installed: " + str(installed)) |
| 216 | print("withraw: " + str(withdrawn) + "\n") |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 217 | |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 218 | main.log.report("----------------------------------------------------") |
cameron@onlab.us | 61e0603 | 2015-04-02 10:54:26 -0700 | [diff] [blame] | 219 | main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize)) |
| 220 | 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] | 221 | main.log.report("Installed average: " + str(numpy.mean(installed))) |
| 222 | main.log.report("Installed standard deviation: " + str(numpy.std(installed))) |
| 223 | main.log.report("Withdraw average: " + str(numpy.mean(withdrawn))) |
| 224 | main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn))) |
| 225 | main.log.report(" ") |
| 226 | |