andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 1 | # ScaleOutTemplate |
| 2 | # |
| 3 | # CASE1 starts number of nodes specified in param file |
| 4 | # |
| 5 | # cameron@onlab.us |
| 6 | |
| 7 | import sys |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 8 | import os.path |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 9 | |
| 10 | |
| 11 | class pushTestIntents: |
| 12 | |
| 13 | def __init__( self ): |
| 14 | self.default = '' |
| 15 | |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 16 | def CASE1( self, main ): #This is the initialization case |
| 17 | #this case will clean up all nodes |
| 18 | import time #but only node 1 is started in this case |
| 19 | |
| 20 | global clusterCount #number of nodes running |
| 21 | global ONOSIp #list of ONOS IP addresses |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 22 | clusterCount = 1 |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 23 | ONOSIp = [ 0 ] |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 24 | |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 25 | |
| 26 | #Load values from params file |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 27 | checkoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
| 28 | gitPull = main.params[ 'GIT' ][ 'autopull' ] |
| 29 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 30 | Features= main.params[ 'ENV' ][ 'cellFeatures' ] |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 31 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 32 | BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 33 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 34 | maxNodes = int(main.params[ 'availableNodes' ]) |
| 35 | Features = main.params[ 'ENV' ][ 'cellFeatures' ] |
| 36 | skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ] |
| 37 | switchCount = main.params[ 'TEST' ][ 'switchCount' ] |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 38 | |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 39 | #Populate ONOSIp with ips from params |
| 40 | for i in range(1, maxNodes + 1): |
| 41 | ipString = 'ip' + str(i) |
| 42 | ONOSIp.append(main.params[ 'CTRL' ][ ipString ]) |
| 43 | |
| 44 | tempIp = [] |
| 45 | for node in range( 1, clusterCount + 1): |
| 46 | tempIp.append(ONOSIp[node]) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 47 | |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 48 | #kill off all onos processes |
| 49 | main.log.step("Safety check, killing all ONOS processes") |
| 50 | main.log.step("before initiating enviornment setup") |
| 51 | for node in range(1, maxNodes + 1): |
| 52 | main.ONOSbench.onosDie(ONOSIp[node]) |
| 53 | |
| 54 | #construct the cell file |
| 55 | main.log.info("Creating cell file") |
| 56 | exec "a = main.ONOSbench.createCellFile" |
| 57 | cellIp = [] |
| 58 | for node in range (1, clusterCount + 1): |
| 59 | cellIp.append(ONOSIp[node]) |
| 60 | a(BENCHIp,cellName,MN1Ip,str(Features), *cellIp) |
| 61 | |
| 62 | main.step( "Applying cell file to environment" ) |
| 63 | cellApplyResult = main.ONOSbench.setCell( cellName ) |
| 64 | |
| 65 | #Uninstall everywhere |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 66 | main.log.step( "Cleaning Enviornment..." ) |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 67 | for i in range(1, maxNodes + 1): |
| 68 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 69 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
| 70 | |
| 71 | #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test |
| 72 | if skipMvn != "yes": |
| 73 | mvnResult = main.ONOSbench.cleanInstall() |
| 74 | |
| 75 | #git |
| 76 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 77 | if gitPull == 'on': |
| 78 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 79 | pullResult = main.ONOSbench.gitPull() |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 80 | |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 81 | else: |
| 82 | checkoutResult = main.TRUE |
| 83 | pullResult = main.TRUE |
| 84 | main.log.info( "Skipped git checkout and pull" ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 85 | |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 86 | main.ONOSbench.createLinkGraphFile(BENCHIp, tempIp, switchCount) |
| 87 | main.ONOSbench.createNullDevProviderFile(BENCHIp, tempIp, switchCount) |
| 88 | main.ONOSbench.createNullLinkProviderFile(BENCHIp) |
| 89 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 90 | main.step( "Creating ONOS package" ) |
| 91 | packageResult = main.ONOSbench.onosPackage() |
| 92 | |
| 93 | main.step( "Installing ONOS package" ) |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 94 | install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 95 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 96 | main.step( "verify cells" ) |
| 97 | verifyCellResult = main.ONOSbench.verifyCell() |
| 98 | |
| 99 | main.step( "Set cell for ONOS cli env" ) |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 100 | cli1 = main.ONOS1cli.startOnosCli( ONOSIp[1] ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 101 | |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 102 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 103 | def CASE2( self, main ): |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 104 | # This case increases the cluster size by whatever scale is |
| 105 | # Note: 'scale' is the size of the step |
| 106 | # if scaling is not a part of your test, simply run this case |
| 107 | # once after CASE1 to set up your enviornment for your desired |
| 108 | # cluster size. If scaling is a part of you test call this case each time |
| 109 | # you want to increase cluster size |
| 110 | |
| 111 | '' |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 112 | 'Increase number of nodes and initiate CLI' |
| 113 | '' |
| 114 | import time |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 115 | global clusterCount |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 116 | |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 117 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 118 | scale = int( main.params[ 'SCALE' ] ) |
| 119 | clusterCount += scale |
| 120 | switchCount = main.params[ 'TEST' ][ 'switchCount' ] |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 121 | |
andrew@onlab.us | 24e2f00 | 2015-03-11 15:06:12 -0700 | [diff] [blame] | 122 | main.log.info("Creating cell file") |
| 123 | exec "a = main.ONOSbench.createCellFile" |
| 124 | cellIp = [] |
| 125 | for node in range (1, clusterCount + 1): |
| 126 | cellIp.append(ONOSIp[node]) |
| 127 | a(BENCHIp,cellName,MN1Ip,str(Features), *cellIp) |
| 128 | |
| 129 | main.step( "Applying cell file to environment" ) |
| 130 | cellApplyResult = main.ONOSbench.setCell( cellName ) |
| 131 | |
| 132 | #Uninstall everywhere |
| 133 | main.log.step( "Cleaning Enviornment..." ) |
| 134 | for node in range(1, maxNodes + 1): |
| 135 | main.ONOSbench.onosDie(ONOSIp[node]) |
| 136 | main.log.info(" Uninstalling ONOS " + str(node) ) |
| 137 | main.ONOSbench.onosUninstall( ONOSIp[node] ) |
| 138 | |
| 139 | tempIp = [] |
| 140 | for node in range( 1, clusterCount + 1): |
| 141 | tempIp.append(ONOSIp[node]) |
| 142 | |
| 143 | main.ONOSbench.createLinkGraphFile(BENCHIp, tempIp, switchCount) |
| 144 | main.ONOSbench.createNullDevProviderFile(BENCHIp, tempIp, switchCount) |
| 145 | main.ONOSbench.createNullLinkProviderFile(BENCHIp) |
| 146 | |
| 147 | main.ONOSbench.onosPackage() |
| 148 | |
| 149 | main.log.report( "Increasing cluster size to " + str( clusterCount ) ) |
| 150 | for node in range(1, clusterCount + 1): |
| 151 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
| 152 | main.ONOSbench.onosInstall( node=ONOSIp[node]) |
| 153 | if node == 1: |
| 154 | main.ONOS1cli.startOnosCli( ONOSIp[1] ) |
| 155 | |
| 156 | for node in range(1, clusterCount + 1): |
| 157 | for i in range( 2 ): |
| 158 | isup = main.ONOSbench.isup( ONOSIp[node] ) |
| 159 | if isup: |
| 160 | main.log.info("ONOS " + str(node) + " is up\n") |
| 161 | break |
| 162 | if not isup: |
| 163 | main.log.report( "ONOS " + str(node) + " didn't start!" ) |
| 164 | |
| 165 | def CASE3( self, main ): |
| 166 | |
| 167 | import time |
| 168 | import numpy |
| 169 | |
| 170 | |
| 171 | sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ]) |
| 172 | warmUp = int(main.params[ 'TEST' ][ 'warmUp' ]) |
| 173 | intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",") |
| 174 | switchCount = int(main.params[ 'TEST' ][ 'switchCount' ]) |
| 175 | debug = main.params[ 'TEST' ][ 'switchCount' ] |
| 176 | for i in range(0,len(intentsList)): |
| 177 | intentsList[i] = int(intentsList[i]) |
| 178 | |
| 179 | |
| 180 | linkCount = 0 |
| 181 | while True: |
| 182 | main.ONOSbench.handle.sendline("onos $OC1 links|wc -l") |
| 183 | main.ONOSbench.handle.expect(":~") |
| 184 | linkCount = main.ONOSbench.handle.before |
| 185 | if debug: main.log.info("Link Count check: " + linkCount) |
| 186 | if str((switchCount*2)-2) in linkCount: |
| 187 | break |
| 188 | |
| 189 | links = "--" |
| 190 | while "=null:" not in links: |
| 191 | if debug: main.log.info("top of loop") |
| 192 | main.ONOSbench.handle.sendline("onos $OC1 links") |
| 193 | main.ONOSbench.handle.expect(":~") |
| 194 | links = main.ONOSbench.handle.before |
| 195 | if debug: main.log.info(str(links)) |
| 196 | time.sleep(1) |
| 197 | links = links.splitlines() |
| 198 | templinks = links |
| 199 | |
| 200 | tempDevices = [] |
| 201 | for line in links: |
| 202 | temp = line.split(" ") |
| 203 | temp[0].replace("src=","") |
| 204 | temp[0] = (temp[0].split("/"))[0] |
| 205 | tempDevices.append(temp[0]) |
| 206 | |
| 207 | tempDevices.sort() |
| 208 | devices = [] |
| 209 | for i in tempDevices: |
| 210 | if "src=null" in i: |
| 211 | devices.append(i.replace("src=", "")) |
| 212 | if debug: main.log.info(str(devices)) |
| 213 | |
| 214 | ingress = devices[0] |
| 215 | egress = devices.pop() |
| 216 | if debug: main.log.info(ingress) |
| 217 | if debug: main.log.info(egress) |
| 218 | |
| 219 | for intentSize in intentsList: |
| 220 | cmd = "onos $OC1 push-test-intents " |
| 221 | cmd += ingress + "/6 " |
| 222 | cmd += egress + "/5 " |
| 223 | cmd += str(intentSize) + " 1" |
| 224 | installed = [] |
| 225 | withdrawn = [] |
| 226 | |
| 227 | for run in range(0, (warmUp + sampleSize)): |
| 228 | |
| 229 | myRawResult = "--" |
| 230 | while "ms" not in myRawResult: |
| 231 | main.ONOSbench.handle.sendline(cmd) |
| 232 | main.ONOSbench.handle.expect(":~") |
| 233 | myRawResult = main.ONOSbench.handle.before |
| 234 | if debug: main.log.info(myRawResult) |
| 235 | |
| 236 | main.log.info(myRawResult) |
| 237 | |
| 238 | if run >= warmUp: |
| 239 | myRawResult = myRawResult.splitlines() |
| 240 | for line in myRawResult: |
| 241 | if "install" in line: |
| 242 | installed.append(line.split(" ")[5]) |
| 243 | if "withdrawn" in line: |
| 244 | withdrawn.append(line.split(" ")[5]) |
| 245 | print(installed) |
| 246 | print(withdrawn) |
| 247 | |
| 248 | main.log.info("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize)) |
| 249 | |
| 250 | |
| 251 | time.sleep(5) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |