andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 1 | # ScaleOutTemplate -> flowTP |
| 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 flowTP1g: |
| 12 | |
| 13 | def __init__( self ): |
| 14 | self.default = '' |
| 15 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 16 | def CASE1( self, main ): |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 17 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 18 | import time |
| 19 | global init |
| 20 | try: |
| 21 | if type(init) is not bool: |
| 22 | init = False |
| 23 | except NameError: |
| 24 | init = False |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 25 | |
| 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 | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 30 | Apps = main.params[ 'ENV' ][ 'cellApps' ] |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -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' ]) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 35 | skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ] |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 36 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 37 | |
| 38 | main.log.info("==========DEBUG VERSION 3===========") |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 39 | |
cameron@onlab.us | 412e956 | 2015-05-13 16:04:34 -0700 | [diff] [blame] | 40 | main.exceptions = [0]*11 |
| 41 | main.warnings = [0]*11 |
| 42 | main.errors = [0]*11 |
| 43 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 44 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 45 | if init == False: |
| 46 | init = True |
| 47 | global clusterCount #number of nodes running |
| 48 | global ONOSIp #list of ONOS IP addresses |
| 49 | global scale |
cameron@onlab.us | c80a8c8 | 2015-04-15 14:57:37 -0700 | [diff] [blame] | 50 | global commit |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 51 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 52 | clusterCount = 0 |
| 53 | ONOSIp = [ 0 ] |
| 54 | scale = (main.params[ 'SCALE' ]).split(",") |
| 55 | clusterCount = int(scale[0]) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 56 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 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 ]) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 61 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 62 | #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test |
| 63 | if skipMvn != "yes": |
| 64 | mvnResult = main.ONOSbench.cleanInstall() |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 65 | |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 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" ) |
cameron@onlab.us | c80a8c8 | 2015-04-15 14:57:37 -0700 | [diff] [blame] | 76 | |
| 77 | commit = main.ONOSbench.getVersion() |
| 78 | commit = (commit.split(" "))[1] |
| 79 | |
| 80 | resultsDB = open("flowTP1gDB", "w+") |
| 81 | resultsDB.close() |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 82 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 83 | # -- END OF INIT SECTION --# |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 84 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 85 | clusterCount = int(scale[0]) |
| 86 | scale.remove(scale[0]) |
| 87 | main.log.info("CLUSTER COUNT: " + str(clusterCount)) |
| 88 | |
| 89 | #kill off all onos processes |
| 90 | main.log.step("Safety check, killing all ONOS processes") |
| 91 | main.log.step("before initiating enviornment setup") |
| 92 | for node in range(1, maxNodes + 1): |
| 93 | main.ONOSbench.onosDie(ONOSIp[node]) |
| 94 | |
| 95 | #Uninstall everywhere |
| 96 | main.log.step( "Cleaning Enviornment..." ) |
| 97 | for i in range(1, maxNodes + 1): |
| 98 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 99 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
| 100 | |
| 101 | #construct the cell file |
| 102 | main.log.info("Creating cell file") |
| 103 | cellIp = [] |
| 104 | for node in range (1, clusterCount + 1): |
| 105 | cellIp.append(ONOSIp[node]) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 106 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 107 | main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp) |
| 108 | main.log.info("Cell Ip list: " + str(cellIp)) |
| 109 | |
| 110 | main.step( "Set Cell" ) |
| 111 | main.ONOSbench.setCell(cellName) |
| 112 | |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 113 | main.step( "Creating ONOS package" ) |
| 114 | packageResult = main.ONOSbench.onosPackage() |
| 115 | |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 116 | main.step( "verify cells" ) |
| 117 | verifyCellResult = main.ONOSbench.verifyCell() |
| 118 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 119 | main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." ) |
| 120 | for node in range(1, clusterCount + 1): |
| 121 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
| 122 | main.ONOSbench.onosInstall( ONOSIp[node]) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 123 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 124 | for node in range(1, clusterCount + 1): |
| 125 | for i in range( 2 ): |
| 126 | isup = main.ONOSbench.isup( ONOSIp[node] ) |
| 127 | if isup: |
| 128 | main.log.info("ONOS " + str(node) + " is up\n") |
| 129 | break |
| 130 | if not isup: |
| 131 | main.log.report( "ONOS " + str(node) + " didn't start!" ) |
| 132 | |
| 133 | for node in range(1, clusterCount + 1): |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 134 | exec "a = main.ONOS%scli.startOnosCli" %str(node) |
| 135 | a(ONOSIp[node]) |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 136 | |
| 137 | main.log.info("Startup sequence complete") |
cameron@onlab.us | 412e956 | 2015-05-13 16:04:34 -0700 | [diff] [blame] | 138 | main.ONOSbench.onosErrorLog(ONOSIp[1]) |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 139 | |
| 140 | def CASE2( self, main ): |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 141 | # |
| 142 | # This is the flow TP test |
| 143 | # |
| 144 | import os.path |
| 145 | import numpy |
| 146 | import math |
| 147 | import time |
| 148 | import datetime |
| 149 | import traceback |
| 150 | |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 151 | global currentNeighbors |
| 152 | try: |
cameron@onlab.us | 50dacf8 | 2015-05-08 14:56:42 -0700 | [diff] [blame] | 153 | currentNeighbors |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 154 | except: |
cameron@onlab.us | 50dacf8 | 2015-05-08 14:56:42 -0700 | [diff] [blame] | 155 | currentNeighbors = "0" |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 156 | else: |
cameron@onlab.us | 50dacf8 | 2015-05-08 14:56:42 -0700 | [diff] [blame] | 157 | if currentNeighbors == "r": #reset |
| 158 | currentNeighbors = "0" |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 159 | else: |
cameron@onlab.us | 50dacf8 | 2015-05-08 14:56:42 -0700 | [diff] [blame] | 160 | currentNeighbors = "a" |
| 161 | |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 162 | testCMD = [ 0,0,0,0 ] |
| 163 | warmUp = int(main.params[ 'TEST' ][ 'warmUp' ]) |
| 164 | sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ]) |
| 165 | switches = int(main.params[ 'TEST' ][ 'switches' ]) |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 166 | neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",") |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 167 | testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ] |
| 168 | testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ] |
| 169 | maxNodes = main.params[ 'availableNodes' ] |
| 170 | onBaremetal = main.params['isOnBaremetal'] |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 171 | cooldown = main.params[ 'TEST' ][ 'cooldown' ] |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 172 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 173 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 174 | BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 175 | MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 176 | maxNodes = int(main.params[ 'availableNodes' ]) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 177 | homeDir = os.path.expanduser('~') |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 178 | flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ]) |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 179 | main.log.info("Flow Rule Backup is set to:" + flowRuleBackup) |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 180 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 181 | servers = str(clusterCount) |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 182 | |
| 183 | if clusterCount == 1: |
| 184 | neighborList = ['0'] |
cameron@onlab.us | 50dacf8 | 2015-05-08 14:56:42 -0700 | [diff] [blame] | 185 | currentNeighbors = "r" |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 186 | else: |
| 187 | if currentNeighbors == "a": |
cameron@onlab.us | 50dacf8 | 2015-05-08 14:56:42 -0700 | [diff] [blame] | 188 | neighborList = [str(clusterCount-1)] |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 189 | currentNeighbors = "r" |
cameron@onlab.us | 50dacf8 | 2015-05-08 14:56:42 -0700 | [diff] [blame] | 190 | else: |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 191 | neighborList = ['0'] |
cameron@onlab.us | 50dacf8 | 2015-05-08 14:56:42 -0700 | [diff] [blame] | 192 | |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 193 | main.log.info("neightborlist: " + str(neighborList)) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 194 | |
| 195 | ts = time.time() |
| 196 | st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 197 | |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 198 | #write file to change mem limit to 32 gigs (BAREMETAL ONLY!) |
| 199 | if onBaremetal == "true": |
| 200 | filename = "/onos/tools/package/bin/onos-service" |
| 201 | serviceConfig = open(homeDir + filename, 'w+') |
| 202 | serviceConfig.write("#!/bin/bash\n ") |
| 203 | serviceConfig.write("#------------------------------------- \n ") |
| 204 | serviceConfig.write("# Starts ONOS Apache Karaf container\n ") |
| 205 | serviceConfig.write("#------------------------------------- \n ") |
| 206 | serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ") |
jenkins | 399e251 | 2015-03-24 10:31:57 -0700 | [diff] [blame] | 207 | serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 208 | serviceConfig.write("") |
| 209 | serviceConfig.write("ONOS_HOME=/opt/onos \n ") |
| 210 | serviceConfig.write("") |
| 211 | serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n") |
| 212 | serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """) |
| 213 | serviceConfig.close() |
| 214 | |
| 215 | for n in neighborList: |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 216 | main.log.step("\tSTARTING TEST") |
| 217 | main.log.step("\tLOADING FROM SERVERS: \t" + str(clusterCount) ) |
| 218 | main.log.step("\tNEIGHBORS:\t" + n ) |
| 219 | main.log.info("=============================================================") |
| 220 | main.log.info("=============================================================") |
| 221 | #write file to configure nil link |
| 222 | ipCSV = "" |
| 223 | for i in range (1, int(maxNodes) + 1): |
| 224 | tempstr = "ip" + str(i) |
| 225 | ipCSV += main.params[ 'CTRL' ][ tempstr ] |
| 226 | if i < int(maxNodes): |
| 227 | ipCSV +="," |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 228 | |
| 229 | |
cameron@onlab.us | c80a8c8 | 2015-04-15 14:57:37 -0700 | [diff] [blame] | 230 | main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount 35" """) |
| 231 | main.ONOSbench.handle.expect(":~") |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 232 | time.sleep(3) |
cameron@onlab.us | c80a8c8 | 2015-04-15 14:57:37 -0700 | [diff] [blame] | 233 | main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """) |
| 234 | main.ONOSbench.handle.expect(":~") |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 235 | time.sleep(3) |
cameron@onlab.us | c80a8c8 | 2015-04-15 14:57:37 -0700 | [diff] [blame] | 236 | main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """) |
| 237 | main.ONOSbench.handle.expect(":~") |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 238 | time.sleep(3) |
cameron@onlab.us | c80a8c8 | 2015-04-15 14:57:37 -0700 | [diff] [blame] | 239 | main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """) |
| 240 | main.ONOSbench.handle.expect(":~") |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 241 | time.sleep(3) |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 242 | main.log.info("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBackup + """" """) |
| 243 | main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBackup + """" """) |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 244 | main.ONOSbench.handle.expect(":~") |
| 245 | |
| 246 | main.ONOSbench.handle.sendline("onos $OC1 summary") |
| 247 | main.ONOSbench.handle.expect(":~") |
| 248 | check = main.ONOSbench.handle.before |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 249 | |
| 250 | main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """) |
| 251 | main.ONOSbench.handle.expect(":~") |
| 252 | check = main.ONOSbench.handle.before |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 253 | main.log.info("\nStart up check: \n" + check + "\n") |
| 254 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 255 | #devide flows |
| 256 | flows = int(main.params[ 'TEST' ][ 'flows' ]) |
| 257 | main.log.info("Flow Target = " + str(flows)) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 258 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 259 | flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches)) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 260 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 261 | main.log.info("Flows per switch = " + str(flows)) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 262 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 263 | #build list of servers in "$OC1, $OC2...." format |
| 264 | serverEnvVars = "" |
| 265 | for i in range (1,int(servers)+1): |
| 266 | serverEnvVars += ("-s " + ONOSIp[i] + " ") |
| 267 | |
| 268 | data = [[""]*int(servers)]*int(sampleSize) |
| 269 | maxes = [""]*int(sampleSize) |
| 270 | |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 271 | flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/" |
| 272 | flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1] |
| 273 | flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j" |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 274 | |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 275 | main.log.info(flowCMD) |
| 276 | #time.sleep(60) |
| 277 | |
| 278 | for test in range(0, warmUp + sampleSize): |
| 279 | if test < warmUp: |
| 280 | main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp)) |
| 281 | else: |
| 282 | main.log.info("====== Test run: " + str(test-warmUp+1) + " ======") |
| 283 | |
| 284 | main.ONOSbench.handle.sendline(flowCMD) |
| 285 | main.ONOSbench.handle.expect(":~") |
| 286 | rawResult = main.ONOSbench.handle.before |
| 287 | main.log.info("Raw results: \n" + rawResult + "\n") |
| 288 | |
| 289 | if "failed" in rawResult: |
| 290 | main.log.report("FLOW_TESTER.PY FAILURE") |
| 291 | main.log.report( " \n" + rawResult + " \n") |
| 292 | break |
| 293 | |
| 294 | ######################################################################################## |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 295 | result = [""]*(clusterCount) |
| 296 | rawResult = rawResult.splitlines() |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 297 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 298 | for node in range(1, clusterCount + 1): |
cameron@onlab.us | c80a8c8 | 2015-04-15 14:57:37 -0700 | [diff] [blame] | 299 | for line in rawResult: |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 300 | #print("line: " + line) |
| 301 | if ONOSIp[node] in line and "server" in line: |
| 302 | temp = line.split(" ") |
| 303 | for word in temp: |
| 304 | #print ("word: " + word) |
| 305 | if "elapsed" in repr(word): |
| 306 | #print("in elapsed ==========") |
| 307 | index = temp.index(word) + 1 |
| 308 | #print ("index: " + str(index)) |
| 309 | #print ("temp[index]: " + temp[index]) |
| 310 | myParsed = (temp[index]).replace(",","") |
| 311 | myParsed = myParsed.replace("}","") |
| 312 | myParsed = int(myParsed) |
| 313 | result[node-1] = myParsed |
| 314 | main.log.info( ONOSIp[node] + " : " + str(myParsed)) |
| 315 | break |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 316 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 317 | if test >= warmUp: |
| 318 | for i in result: |
| 319 | if i == "": |
| 320 | main.log.error("Missing data point, critical failure incoming") |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 321 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 322 | print result |
| 323 | maxes[test-warmUp] = max(result) |
| 324 | main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize)) |
| 325 | main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)") |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 326 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 327 | data[test-warmUp] = result |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 328 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 329 | # wait for flows = 0 |
cameron@onlab.us | cd4e8a2 | 2015-05-11 10:58:43 -0700 | [diff] [blame] | 330 | for checkCount in range(0,5): |
| 331 | time.sleep(10) |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 332 | main.ONOSbench.handle.sendline("onos $OC1 summary") |
| 333 | main.ONOSbench.handle.expect(":~") |
| 334 | flowCheck = main.ONOSbench.handle.before |
| 335 | if "flows=0," in flowCheck: |
| 336 | main.log.info("Flows removed") |
| 337 | break |
| 338 | else: |
| 339 | for line in flowCheck.splitlines(): |
| 340 | if "flows=" in line: |
| 341 | main.log.info("Current Summary: " + line) |
| 342 | if checkCount == 2: |
| 343 | main.log.info("Flows are stuck, moving on ") |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 344 | |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 345 | |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 346 | time.sleep(5) |
| 347 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 348 | main.log.info("raw data: " + str(data)) |
| 349 | main.log.info("maxes:" + str(maxes)) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 350 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 351 | |
| 352 | # report data |
| 353 | print("") |
| 354 | main.log.info("\t Results (measurments are in milliseconds)") |
| 355 | print("") |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 356 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 357 | nodeString = "" |
| 358 | for i in range(1, int(servers) + 1): |
| 359 | nodeString += ("\tNode " + str(i)) |
| 360 | |
| 361 | for test in range(0, sampleSize ): |
| 362 | main.log.info("\t Test iteration " + str(test + 1) ) |
| 363 | main.log.info("\t------------------") |
| 364 | main.log.info(nodeString) |
| 365 | resultString = "" |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 366 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 367 | for i in range(0, int(servers) ): |
| 368 | resultString += ("\t" + str(data[test][i]) ) |
| 369 | main.log.info(resultString) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 370 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 371 | print("\n") |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 372 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 373 | avgOfMaxes = numpy.mean(maxes) |
| 374 | main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes)) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 375 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 376 | stdOfMaxes = numpy.std(maxes) |
| 377 | main.log.info("Standard Deviation of max values: " + str(stdOfMaxes)) |
| 378 | print("\n\n") |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 379 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 380 | avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second |
| 381 | |
| 382 | tp = [] |
| 383 | for i in maxes: |
| 384 | tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i )) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 385 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 386 | stdTP = numpy.std(tp) |
andrew@onlab.us | 5cdb285 | 2015-03-11 15:11:10 -0700 | [diff] [blame] | 387 | |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 388 | main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" ) |
| 389 | main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second") |
| 390 | |
cameron@onlab.us | c80a8c8 | 2015-04-15 14:57:37 -0700 | [diff] [blame] | 391 | resultsLog = open("flowTP1gDB","a") |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 392 | resultString = ("'" + commit + "',") |
| 393 | resultString += ("'1gig',") |
| 394 | resultString += ((main.params[ 'TEST' ][ 'flows' ]) + ",") |
| 395 | resultString += (str(clusterCount) + ",") |
| 396 | resultString += (str(n) + ",") |
| 397 | resultString += (str(avgTP) + "," + str(stdTP) + "\n") |
| 398 | resultsLog.write(resultString) |
cameron@onlab.us | 1949421 | 2015-04-01 16:12:07 -0700 | [diff] [blame] | 399 | resultsLog.close() |
cameron@onlab.us | b5eb9f4 | 2015-05-06 13:55:45 -0700 | [diff] [blame] | 400 | |
| 401 | main.log.report("Result line to file: " + resultString) |
| 402 | |
cameron@onlab.us | 412e956 | 2015-05-13 16:04:34 -0700 | [diff] [blame] | 403 | main.ONOSbench.onosErrorLog(ONOSIp[1]) |