andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 1 | # ScaleOutTemplate --> IntentEventTP |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 2 | # |
| 3 | # CASE1 starts number of nodes specified in param file |
| 4 | # |
| 5 | # cameron@onlab.us |
| 6 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 7 | import sys |
| 8 | import os |
| 9 | import time |
| 10 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 11 | |
| 12 | class IntentEventTP: |
| 13 | |
| 14 | def __init__( self ): |
| 15 | self.default = '' |
| 16 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 17 | def CASE1( self, main ): #This is the initialization case |
| 18 | import os.path #this case will clean up all nodes |
| 19 | import time #but only node 1 is started in this case |
| 20 | |
| 21 | global clusterCount #number of nodes running |
| 22 | global ONOSIp #list of ONOS IP addresses |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 23 | clusterCount = 1 |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 24 | ONOSIp = [ 0 ] |
| 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 | 1033220 | 2015-03-11 15:04:43 -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 | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 33 | maxNodes = int(main.params[ 'availableNodes' ]) |
| 34 | MNip = main.params[ 'MN' ][ 'ip1' ] |
| 35 | skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ] |
| 36 | numSwitches = main.params[ 'TEST' ][ 'numSwitches' ] |
| 37 | |
| 38 | homeDir = os.path.expanduser('~') |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 39 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 40 | main.ONOSbench.handle.sendline("export TERM=vt100") |
| 41 | dump = main.ONOSbench.handle.expect(":~") |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 42 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 43 | #Populate ONOSIp with ips from params |
| 44 | for i in range(1, maxNodes + 1): |
| 45 | ipString = 'ip' + str(i) |
| 46 | ONOSIp.append(main.params[ 'CTRL' ][ ipString ]) |
| 47 | |
| 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.log.info("killing node " + str(node)) |
| 53 | main.ONOSbench.onosDie(ONOSIp[node]) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 54 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 55 | #construct the cell file |
| 56 | main.log.info("Creating cell file") |
| 57 | exec "a = main.ONOSbench.createCellFile" |
| 58 | cellIp = [] |
| 59 | for node in range (1, clusterCount + 1): |
| 60 | cellIp.append(ONOSIp[node]) |
| 61 | a(BENCHIp,cellName,MNip,str(Features), *cellIp) |
| 62 | |
| 63 | main.step( "Set Cell" ) |
| 64 | main.ONOSbench.setCell(cellName) |
| 65 | |
| 66 | #Uninstall everywhere |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 67 | main.log.step( "Cleaning Enviornment..." ) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 68 | for i in range(1, maxNodes + 1): |
| 69 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 70 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 71 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 72 | #git |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 73 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 74 | if gitPull == 'on': |
| 75 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 76 | pullResult = main.ONOSbench.gitPull() |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 77 | else: |
| 78 | checkoutResult = main.TRUE |
| 79 | pullResult = main.TRUE |
| 80 | main.log.info( "Skipped git checkout and pull" ) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 81 | |
| 82 | #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test |
| 83 | if skipMvn != "yes": |
| 84 | mvnResult = main.ONOSbench.cleanInstall() |
| 85 | |
| 86 | #configure null device provider |
| 87 | switchList = [0,int(numSwitches),0,0,0,0,0,0] |
| 88 | devicesString = "" |
| 89 | for node in range(1, maxNodes + 1): |
| 90 | devicesString += (ONOSIp[node] + ":" + str(switchList[node] )) |
| 91 | if node < maxNodes: |
| 92 | devicesString += (",") |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 93 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 94 | main.log.info("Configuring device provider: ONOS 1 with " + (numSwitches) + " switches") |
| 95 | localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg" |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 96 | filePath = homeDir + localPath |
| 97 | main.log.info(filePath) |
| 98 | |
| 99 | configFile = open(filePath, 'w+') |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 100 | configFile.write("devConfigs = " + devicesString + "\n") |
| 101 | configFile.write("#numPorts = 8") |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 102 | configFile.close() |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 103 | main.log.info("DevConfig = " + devicesString) |
| 104 | main.log.info("Device provider file written and closed") |
| 105 | |
| 106 | ## configuring null link provider |
| 107 | main.log.info(" Configuring null provider to disable flicker" ) |
| 108 | homeDir = os.path.expanduser('~') |
| 109 | main.log.info(homeDir) |
| 110 | localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg" |
| 111 | filePath = homeDir + localPath |
| 112 | main.log.info(filePath) |
| 113 | |
| 114 | neighborsString = "" |
| 115 | for node in range(1, maxNodes + 1): |
| 116 | neighborsString += ONOSIp[node] |
| 117 | if node < maxNodes: |
| 118 | neighborsString += "," |
| 119 | |
| 120 | configFile = open(filePath, 'w+') |
| 121 | configFile.write("#eventRate =\n") |
| 122 | configFile.write("#cfgFile = /tmp/foo.cfg #If enabled, points to the full path to the topology file.\n") |
| 123 | configFile.write("#neighbors = ") |
| 124 | configFile.close() |
| 125 | main.log.info("Configuration completed") |
| 126 | |
| 127 | main.log.info("Writing link graph configuration file..." ) |
| 128 | homeDir = os.path.expanduser('~') |
| 129 | localPath = "/onos/tools/package/etc/linkGraph.cfg" |
| 130 | filePath = homeDir + localPath |
| 131 | linkGraph = open(filePath, 'w+') |
| 132 | linkGraph.write("# NullLinkProvider topology description (config file).\n") |
| 133 | linkGraph.write("# The NodeId is only added if the destination is another node's device.\n") |
| 134 | linkGraph.write("# Bugs: Comments cannot be appended to a line to be read.\n") |
| 135 | |
| 136 | myPort = 6 |
| 137 | for node in range(1, clusterCount+1): |
| 138 | linkGraph.write("graph " + ONOSIp[node] + " {\n") |
| 139 | for switch in range (0, switchList[node]-1): |
| 140 | line = "" |
| 141 | line = ("\t" + str(switch) + ":" + str(myPort)) |
| 142 | line += " -- " |
| 143 | line += (str(switch+1) + ":" + str(myPort-1) + "\n") |
| 144 | linkGraph.write(line) |
| 145 | linkGraph.write("}") |
| 146 | linkGraph.close() |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 147 | |
| 148 | main.step( "Creating ONOS package" ) |
| 149 | packageResult = main.ONOSbench.onosPackage() |
| 150 | |
| 151 | main.step( "Installing ONOS package" ) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 152 | install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 153 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 154 | main.step( "verify cells" ) |
| 155 | verifyCellResult = main.ONOSbench.verifyCell() |
| 156 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 157 | main.step( "Checking if ONOS is up yet" ) |
| 158 | for i in range( 2 ): |
| 159 | isup = main.ONOSbench.isup( ONOSIp[1] ) |
| 160 | if isup: |
| 161 | break |
| 162 | if not isup: |
| 163 | main.log.report( "ONOS1 didn't start!" ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 164 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 165 | lastOutput = "--" |
| 166 | origin = time.time() |
| 167 | clockStarted = False |
| 168 | while True: |
| 169 | main.ONOSbench.handle.sendline("onos $OC1 summary") |
| 170 | main.ONOSbench.handle.expect(":~") |
| 171 | clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3] |
| 172 | print("\nBefore: " + str(clusterCheck)) |
| 173 | if "SCC(s)=1," in clusterCheck and ("devices=" + str(numSwitches)) in clusterCheck: #check for links and devices too |
| 174 | break |
| 175 | if clusterCheck != lastOutput: |
| 176 | sameOutput = False |
| 177 | elif clusterCheck == lastOutput: |
| 178 | if clockStarted == False: |
| 179 | start = time.time() |
| 180 | clockStarted = True |
| 181 | if time.time() > (start + 30): |
| 182 | main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...") |
| 183 | break |
| 184 | lastOutput = clusterCheck |
| 185 | time.sleep(5) |
| 186 | |
| 187 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 188 | |
| 189 | def CASE2( self, main ): |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 190 | # This case increases the cluster size by whatever scale is |
| 191 | # Note: 'scale' is the size of the step |
| 192 | # if scaling is not a part of your test, simply run this case |
| 193 | # once after CASE1 to set up your enviornment for your desired |
| 194 | # cluster size. If scaling is a part of you test call this case each time |
| 195 | # you want to increase cluster size |
| 196 | |
| 197 | '' |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 198 | 'Increase number of nodes and initiate CLI' |
| 199 | '' |
| 200 | import time |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 201 | import os.path |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 202 | global clusterCount |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 203 | |
| 204 | Features= main.params[ 'ENV' ][ 'cellFeatures' ] |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 205 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 206 | MNip = main.params[ 'MN' ][ 'ip1' ] |
| 207 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 208 | numSwitches = int(main.params[ 'TEST' ][ 'numSwitches' ]) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 209 | scale = int( main.params[ 'SCALE' ] ) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 210 | maxNodes = int(main.params[ 'availableNodes' ]) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 211 | clusterCount += scale |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 212 | homeDir = os.path.expanduser('~') |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 213 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 214 | #kill off all onos processes |
| 215 | main.log.step("Safety check, killing all ONOS processes") |
| 216 | main.log.step("before initiating enviornment setup") |
| 217 | for node in range(1, maxNodes + 1): |
| 218 | main.ONOSbench.onosDie(ONOSIp[node]) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 219 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 220 | #Uninstall everywhere |
| 221 | main.log.step( "Cleaning Enviornment..." ) |
| 222 | for i in range(1, maxNodes + 1): |
| 223 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 224 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
| 225 | |
| 226 | #construct the cell file |
| 227 | main.log.info("Creating cell file") |
| 228 | exec "a = main.ONOSbench.createCellFile" |
| 229 | cellIp = [] |
| 230 | for node in range (1, clusterCount + 1): |
| 231 | cellIp.append(ONOSIp[node]) |
| 232 | a(BENCHIp,cellName,MNip,str(Features), *cellIp) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 233 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 234 | main.step( "Set Cell" ) |
| 235 | main.ONOSbench.setCell(cellName) |
| 236 | |
| 237 | baselineSwitchCount = numSwitches/clusterCount |
| 238 | switchList = [0,0,0,0,0,0,0,0] |
| 239 | |
| 240 | for node in range(1, clusterCount + 1): |
| 241 | switchList[node] = baselineSwitchCount |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 242 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 243 | for node in range(1, (numSwitches%clusterCount)+1): |
| 244 | switchList[node] += 1 |
| 245 | |
| 246 | devicesString = "" |
| 247 | for node in range(1, maxNodes + 1): |
| 248 | devicesString += (ONOSIp[node] + ":" + str(switchList[node] )) |
| 249 | if node < maxNodes: |
| 250 | devicesString += (",") |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 251 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 252 | main.log.info("Configuring device provider") |
| 253 | localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg" |
| 254 | filePath = homeDir + localPath |
| 255 | main.log.info(filePath) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 256 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 257 | configFile = open(filePath, 'w+') |
| 258 | configFile.write("devConfigs = " + devicesString +"\n") |
| 259 | configFile.write("# numPorts = 8") |
| 260 | configFile.close() |
| 261 | main.log.info("DevConfig = " + devicesString) |
| 262 | main.log.info("Device provider file written and closed") |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 263 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 264 | main.log.info("Writing link graph configuration file..." ) |
| 265 | homeDir = os.path.expanduser('~') |
| 266 | localPath = "/onos/tools/package/etc/linkGraph.cfg" |
| 267 | filePath = homeDir + localPath |
| 268 | linkGraph = open(filePath, 'w+') |
| 269 | linkGraph.write("# NullLinkProvider topology description (config file).\n") |
| 270 | linkGraph.write("# The NodeId is only added if the destination is another node's device.\n") |
| 271 | linkGraph.write("# Bugs: Comments cannot be appended to a line to be read.\n") |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 272 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 273 | myPort = 6 |
| 274 | for node in range(1, clusterCount+1): |
| 275 | linkGraph.write("graph " + ONOSIp[node] + " {\n") |
| 276 | for switch in range (0, switchList[node]-1): |
| 277 | line = "" |
| 278 | line = ("\t" + str(switch) + ":" + str(myPort)) |
| 279 | line += " -- " |
| 280 | line += (str(switch+1) + ":" + str(myPort-1) + "\n") |
| 281 | linkGraph.write(line) |
| 282 | linkGraph.write("}\n") |
| 283 | linkGraph.close() |
| 284 | |
| 285 | main.step( "Creating ONOS package, preparing to reinstall" ) |
| 286 | packageResult = main.ONOSbench.onosPackage() |
| 287 | |
| 288 | main.log.report( "Reinstalling on all nodes and increasing cluster size to " + str( clusterCount ) ) |
| 289 | for node in range(1, clusterCount + 1): |
| 290 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
| 291 | main.ONOSbench.onosInstall( ONOSIp[node]) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 292 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 293 | for i in range( 2 ): |
| 294 | isup = main.ONOSbench.isup( ONOSIp[node] ) |
| 295 | if isup: |
| 296 | main.log.info("ONOS " + str(node) + " is up\n") |
| 297 | break |
| 298 | if not isup: |
| 299 | main.log.report( "ONOS " + str(node) + " didn't start!" ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 300 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 301 | lastOutput = "--" |
| 302 | origin = time.time() |
| 303 | clockStarted = False |
| 304 | while True: |
| 305 | main.ONOSbench.handle.sendline("onos $OC1 summary") |
| 306 | main.ONOSbench.handle.expect(":~") |
| 307 | clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3] |
| 308 | print("\nBefore: " + str(clusterCheck)) |
| 309 | if "SCC(s)=1," in clusterCheck and ("nodes=" + str(clusterCount)) in clusterCheck and ("devices=" + str(numSwitches)) in clusterCheck: |
| 310 | break |
| 311 | if clusterCheck != lastOutput: |
| 312 | sameOutput = False |
| 313 | elif clusterCheck == lastOutput: |
| 314 | if clockStarted == False: |
| 315 | start = time.time() |
| 316 | clockStarted = True |
| 317 | if time.time() > (start + 60): |
| 318 | main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...") |
| 319 | break |
| 320 | lastOutput = clusterCheck |
| 321 | time.sleep(5) |
| 322 | |
| 323 | |
| 324 | def CASE3( self, main ): |
| 325 | import time |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 326 | import json |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 327 | import string |
| 328 | import csv |
| 329 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 330 | main.log.info("Cluster Count = " + str(clusterCount)) |
| 331 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 332 | intentsRate = main.params['METRICS']['intents_rate'] |
| 333 | intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ] |
| 334 | intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ] |
| 335 | testDuration = main.params[ 'TEST' ][ 'duration' ] |
| 336 | logInterval = main.params[ 'TEST' ][ 'log_interval' ] |
| 337 | debug = main.params[ 'debugMode' ] |
| 338 | |
| 339 | metricList = [intentsRate, intentsWithdrawn, intentsFailed] |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 340 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 341 | tempsleep =40 |
| 342 | main.log.info("sleeping " + str(tempsleep)) |
| 343 | time.sleep(tempsleep) |
| 344 | |
| 345 | loadFrom = ['0'] |
| 346 | loadFrom.extend((main.params[ 'TEST' ][ 'loadFrom' ]).split(",")) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 347 | |
| 348 | for node in range(1, clusterCount+1): |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 349 | if loadFrom[node] == "1": |
| 350 | cmd = "onos $OC" + str(node) + " feature:install onos-app-intent-perf" |
| 351 | main.ONOSbench.handle.sendline(cmd) |
| 352 | main.ONOSbench.handle.expect(":~") |
| 353 | main.log.info("Load initiated on node " + str(node)) |
| 354 | |
| 355 | main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 356 | stop = time.time() + float( testDuration ) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 357 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 358 | while time.time() < stop: |
| 359 | time.sleep( float( logInterval ) ) |
| 360 | for node in range (1, clusterCount + 1): |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 361 | myResults = ['0','0','0'] |
| 362 | for metric in metricList: |
| 363 | |
| 364 | onosEnv = "onos $OC" + str(node) |
| 365 | cmd = onosEnv + " " + metric |
| 366 | main.log.info("COMMAND: " + cmd) |
| 367 | main.ONOSbench.handle.sendline( cmd ) |
| 368 | time.sleep(10) |
| 369 | main.ONOSbench.handle.expect(":~") |
| 370 | rawResult = main.ONOSbench.handle.before |
| 371 | rawResult = (rawResult.splitlines()) |
| 372 | |
| 373 | tempResult = "--" |
| 374 | for word in rawResult: |
| 375 | if debug: print("word: " + word) |
| 376 | if "m1" in str(word): |
| 377 | tempResult = word |
| 378 | break |
| 379 | |
| 380 | if tempResult == "--": |
| 381 | main.log.error("WRONG pexepct.before data\n" + str(rawResult)) |
| 382 | main.log.info("retrying command... ") |
| 383 | main.ONOSbench.handle.sendline(cmd) |
| 384 | main.ONOSbench.handle.expect(":~") |
| 385 | test = main.ONOSbench.handle.before |
| 386 | print ("\n\n" + str(test)) |
| 387 | |
| 388 | tempResult = round(float(tempResult.replace("m1=","")),1) |
| 389 | tempResult = str(tempResult) # easy way to clean up number/prep to log |
| 390 | resultIndex = metricList.index(metric) |
| 391 | myResults[resultIndex] = tempResult |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 392 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 393 | main.log.info("\tNode " + str(node)) |
| 394 | main.log.info("Installed\tWithdrawn\tFailed") |
| 395 | main.log.info(myResults[0] + "\t\t " + myResults[1] + "\t\t" + myResults[2] + "\n") |
| 396 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 397 | |