cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 1 | # ScaleOutTemplate |
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 |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 8 | import os.path |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 9 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 10 | |
| 11 | class IntentEventTP: |
| 12 | |
| 13 | def __init__( self ): |
| 14 | self.default = '' |
| 15 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -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 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 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' ] |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 30 | Apps = main.params[ 'ENV' ][ 'cellApps' ] |
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' ] |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 33 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 34 | maxNodes = int(main.params[ 'availableNodes' ]) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 35 | skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ] |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 36 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 37 | numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",") |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 38 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 39 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 40 | # ?? homeDir = os.path.expanduser('~') |
| 41 | # ?? main.ONOSbench.handle.sendline("export TERM=vt100") |
| 42 | # ?^ dump = main.ONOSbench.handle.expect(":~") |
| 43 | |
| 44 | |
| 45 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 46 | if init == False: |
| 47 | init = True |
| 48 | global clusterCount #number of nodes running |
| 49 | global ONOSIp #list of ONOS IP addresses |
| 50 | global scale |
| 51 | |
| 52 | clusterCount = 0 |
| 53 | ONOSIp = [ 0 ] |
| 54 | scale = (main.params[ 'SCALE' ]).split(",") |
| 55 | clusterCount = int(scale[0]) |
| 56 | |
| 57 | #Populate ONOSIp with ips from params |
| 58 | for i in range(1, maxNodes + 1): |
| 59 | ipString = 'ip' + str(i) |
| 60 | ONOSIp.append(main.params[ 'CTRL' ][ ipString ]) |
| 61 | |
| 62 | #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test |
| 63 | if skipMvn != "yes": |
| 64 | mvnResult = main.ONOSbench.cleanInstall() |
| 65 | |
| 66 | #git |
| 67 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 68 | if gitPull == 'on': |
| 69 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 70 | pullResult = main.ONOSbench.gitPull() |
| 71 | |
| 72 | else: |
| 73 | checkoutResult = main.TRUE |
| 74 | pullResult = main.TRUE |
| 75 | main.log.info( "Skipped git checkout and pull" ) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 76 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 77 | # -- END OF INIT SECTION --# |
| 78 | |
| 79 | clusterCount = int(scale[0]) |
| 80 | scale.remove(scale[0]) |
| 81 | |
| 82 | #kill off all onos processes |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 83 | main.log.step("Safety check, killing all ONOS processes") |
| 84 | main.log.step("before initiating enviornment setup") |
| 85 | for node in range(1, maxNodes + 1): |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 86 | main.ONOSbench.onosDie(ONOSIp[node]) |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 87 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 88 | #Uninstall everywhere |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 89 | main.log.step( "Cleaning Enviornment..." ) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 90 | for i in range(1, maxNodes + 1): |
| 91 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 92 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 93 | |
| 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]) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 99 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 100 | main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp) |
| 101 | |
| 102 | main.step( "Set Cell" ) |
| 103 | main.ONOSbench.setCell(cellName) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 104 | |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 105 | myDistribution = [] |
| 106 | for node in range (1, clusterCount + 1): |
| 107 | myDistribution.append(numSwitches[node-1]) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 108 | |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 109 | main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution) |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 110 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 111 | main.step( "Creating ONOS package" ) |
| 112 | packageResult = main.ONOSbench.onosPackage() |
| 113 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 114 | main.step( "verify cells" ) |
| 115 | verifyCellResult = main.ONOSbench.verifyCell() |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 116 | |
| 117 | main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." ) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 118 | for node in range(1, clusterCount + 1): |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 119 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 120 | main.ONOSbench.onosInstall( ONOSIp[node]) |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 121 | |
cameron@onlab.us | 1201bc4 | 2015-04-01 16:30:05 -0700 | [diff] [blame] | 122 | for node in range(1, clusterCount + 1): |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 123 | for i in range( 2 ): |
| 124 | isup = main.ONOSbench.isup( ONOSIp[node] ) |
| 125 | if isup: |
| 126 | main.log.info("ONOS " + str(node) + " is up\n") |
| 127 | break |
| 128 | if not isup: |
| 129 | main.log.report( "ONOS " + str(node) + " didn't start!" ) |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 130 | main.log.info("Startup sequence complete") |
| 131 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 132 | lastOutput = "--" |
| 133 | origin = time.time() |
| 134 | clockStarted = False |
| 135 | while True: |
| 136 | main.ONOSbench.handle.sendline("onos $OC1 summary") |
| 137 | main.ONOSbench.handle.expect(":~") |
| 138 | clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3] |
| 139 | print("\nBefore: " + str(clusterCheck)) |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 140 | if ("SCC(s)=1,") in clusterCheck: |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 141 | break |
| 142 | if clusterCheck != lastOutput: |
| 143 | sameOutput = False |
| 144 | elif clusterCheck == lastOutput: |
| 145 | if clockStarted == False: |
| 146 | start = time.time() |
| 147 | clockStarted = True |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 148 | if time.time() > (start + 10): |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 149 | main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...") |
| 150 | break |
| 151 | lastOutput = clusterCheck |
| 152 | time.sleep(5) |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 153 | |
| 154 | main.ONOSbench.configNullDev(cellIp, myDistribution) |
| 155 | |
| 156 | def CASE2( self, main ): |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 157 | import time |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 158 | import json |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 159 | import string |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 160 | import csv |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 161 | import numpy |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 162 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 163 | main.log.info("Cluster Count = " + str(clusterCount)) |
| 164 | |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 165 | intentsRate = main.params['METRICS']['intents_rate'] |
| 166 | intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ] |
| 167 | intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ] |
| 168 | testDuration = main.params[ 'TEST' ][ 'duration' ] |
| 169 | logInterval = main.params[ 'TEST' ][ 'log_interval' ] |
| 170 | debug = main.params[ 'debugMode' ] |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 171 | numKeys = main.params[ 'TEST' ][ 'numKeys' ] |
| 172 | cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ] |
| 173 | neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",") |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 174 | metricList = [intentsRate, intentsWithdrawn, intentsFailed] |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 175 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 176 | for n in range(0, len(neighbors)): |
| 177 | if neighbors[n] == 'a': |
| 178 | neighbors[n] = str(clusterCount -1) |
| 179 | print str(neighbors) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 180 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 181 | for n in neighbors: |
| 182 | main.log.info("Run with " + n + " neighbors") |
| 183 | time.sleep(5) |
| 184 | main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys ) |
| 185 | main.ONOSbench.handle.expect(":~") |
| 186 | main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n ) |
| 187 | main.ONOSbench.handle.expect(":~") |
| 188 | main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod ) |
| 189 | main.ONOSbench.handle.expect(":~") |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 190 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 191 | cmd = "onos $OC1 intent-perf-start" |
| 192 | main.ONOSbench.handle.sendline(cmd) |
| 193 | main.ONOSbench.handle.expect(":~") |
| 194 | main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" ) |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 195 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 196 | main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" ) |
| 197 | stop = time.time() + float( testDuration ) |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 198 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 199 | while time.time() < stop: |
| 200 | time.sleep( float( logInterval ) ) |
| 201 | groupResult = [] |
| 202 | for node in range (1, clusterCount + 1): |
| 203 | groupResult.append(0) |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 204 | |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 205 | cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """ |
| 206 | main.log.info("COMMAND: " + str(cmd)) |
| 207 | |
| 208 | x = 0 |
| 209 | while True: |
| 210 | main.ONOSbench.handle.sendline(cmd) |
| 211 | main.ONOSbench.handle.expect(":~") |
| 212 | raw = main.ONOSbench.handle.before |
| 213 | if "OVERALL=" in raw: |
| 214 | break |
| 215 | x += 1 |
| 216 | if x > 10: |
| 217 | main.log.error("Expected output not being recieved... continuing") |
| 218 | break |
| 219 | time.sleep(2) |
| 220 | |
| 221 | raw = raw.splitlines() |
| 222 | splitResults = [] |
| 223 | for line in raw: |
| 224 | splitResults.extend(line.split(" ")) |
| 225 | |
| 226 | myResult = "--" |
| 227 | for field in splitResults: |
| 228 | if "OVERALL" in field: |
| 229 | myResult = field |
| 230 | |
| 231 | if myResult == "--": |
| 232 | main.log.error("Parsing/Pexpect error\n" + str(splitResults)) |
| 233 | |
| 234 | myResult = myResult.replace(";", "") |
| 235 | myResult = myResult.replace("OVERALL=","") |
| 236 | myResult = float(myResult) |
| 237 | groupResult[len(groupResult) -1] = myResult |
| 238 | |
| 239 | main.log.info("Node " + str(node) + " overall rate: " + str(myResult)) |
| 240 | |
| 241 | main.log.report("Results from this round of polling: " + str(groupResult)) |
| 242 | main.log.report("Cluster Total: " + str(numpy.sum(groupResult)) + "\n") |
| 243 | |
| 244 | cmd = "onos $OC1 intent-perf-stop" |
| 245 | main.ONOSbench.handle.sendline(cmd) |
| 246 | main.ONOSbench.handle.expect(":~") |
| 247 | main.log.info("Stopping intentperf" ) |
| 248 | |