blob: 6134ed3229e23c8c6dbd01c24064f6376f06982a [file] [log] [blame]
cameron@onlab.us059c2562015-04-02 14:12:51 -07001# ScaleOutTemplate
andrew@onlab.us2ae3a112015-02-02 11:24:32 -08002#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
andrew@onlab.us10332202015-03-11 15:04:43 -07007import sys
cameron@onlab.us059c2562015-04-02 14:12:51 -07008import os.path
andrew@onlab.us10332202015-03-11 15:04:43 -07009
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080010
11class IntentEventTP:
12
13 def __init__( self ):
14 self.default = ''
15
cameron@onlab.us059c2562015-04-02 14:12:51 -070016 def CASE1( self, main ):
17
18 import time
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070019 import os.path
20
cameron@onlab.us059c2562015-04-02 14:12:51 -070021 global init
22 try:
23 if type(init) is not bool:
24 init = False
25 except NameError:
26 init = False
27
andrew@onlab.us10332202015-03-11 15:04:43 -070028 #Load values from params file
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080029 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
30 gitPull = main.params[ 'GIT' ][ 'autopull' ]
31 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070032 Apps = main.params[ 'ENV' ][ 'cellApps' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080033 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
34 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070035 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
andrew@onlab.us10332202015-03-11 15:04:43 -070036 maxNodes = int(main.params[ 'availableNodes' ])
andrew@onlab.us10332202015-03-11 15:04:43 -070037 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070038 cellName = main.params[ 'ENV' ][ 'cellName' ]
jenkins3af0cd82015-03-24 10:27:16 -070039 numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -070040 flowRuleBU = main.params[ 'TEST' ][ 'flowRuleBUEnabled' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070041 onBaremetal = main.params['isOnBaremetal']
42 homeDir = os.path.expanduser('~')
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080043
cameron@onlab.us412e9562015-05-13 16:04:34 -070044 main.exceptions = [0]*11
45 main.warnings = [0]*11
46 main.errors = [0]*11
47
cameron@onlab.us059c2562015-04-02 14:12:51 -070048 # -- INIT SECTION, ONLY RUNS ONCE -- #
49 if init == False:
50 init = True
51 global clusterCount #number of nodes running
52 global ONOSIp #list of ONOS IP addresses
53 global scale
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070054 global commit
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070055
cameron@onlab.us059c2562015-04-02 14:12:51 -070056 clusterCount = 0
57 ONOSIp = [ 0 ]
58 scale = (main.params[ 'SCALE' ]).split(",")
59 clusterCount = int(scale[0])
60
61 #Populate ONOSIp with ips from params
jenkins15b2b132015-06-23 14:04:09 -070062 ONOSIp = [0]
63 ONOSIp.extend(main.ONOSbench.getOnosIps())
64 MN1Ip = ONOSIp[len(ONOSIp) -1]
65 BENCHIp = ONOSIp[len(ONOSIp) -2]
66
cameron@onlab.us059c2562015-04-02 14:12:51 -070067 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
68 if skipMvn != "yes":
69 mvnResult = main.ONOSbench.cleanInstall()
70
71 #git
72 main.step( "Git checkout and pull " + checkoutBranch )
73 if gitPull == 'on':
74 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
75 pullResult = main.ONOSbench.gitPull()
76
77 else:
78 checkoutResult = main.TRUE
79 pullResult = main.TRUE
80 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us10332202015-03-11 15:04:43 -070081
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070082 commit = main.ONOSbench.getVersion()
83 commit = (commit.split(" "))[1]
84
85 resultsDB = open("IntentEventTPDB", "w+")
86 resultsDB.close()
87
cameron@onlab.us059c2562015-04-02 14:12:51 -070088 # -- END OF INIT SECTION --#
89
90 clusterCount = int(scale[0])
91 scale.remove(scale[0])
92
93 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -070094 main.log.step("Safety check, killing all ONOS processes")
95 main.log.step("before initiating enviornment setup")
96 for node in range(1, maxNodes + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -070097 main.ONOSbench.onosDie(ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -070098
andrew@onlab.us10332202015-03-11 15:04:43 -070099 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800100 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700101 for i in range(1, maxNodes + 1):
102 main.log.info(" Uninstalling ONOS " + str(i) )
103 main.ONOSbench.onosUninstall( ONOSIp[i] )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700104
105 #construct the cell file
106 main.log.info("Creating cell file")
107 cellIp = []
108 for node in range (1, clusterCount + 1):
109 cellIp.append(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800110
cameron@onlab.us059c2562015-04-02 14:12:51 -0700111 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
112
113 main.step( "Set Cell" )
114 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800115
jenkins3af0cd82015-03-24 10:27:16 -0700116 myDistribution = []
117 for node in range (1, clusterCount + 1):
118 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800119
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700120 #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700121
122 if onBaremetal == "True":
123 filename = "/onos/tools/package/bin/onos-service"
124 serviceConfig = open(homeDir + filename, 'w+')
125 serviceConfig.write("#!/bin/bash\n ")
126 serviceConfig.write("#------------------------------------- \n ")
127 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
128 serviceConfig.write("#------------------------------------- \n ")
129 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
130 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
131 serviceConfig.write("")
132 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
133 serviceConfig.write("")
134 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
135 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
136 serviceConfig.close()
137 main.log.info("Set /onos/tools/package/bin/onos-service with 8G Xms/Xmx Options.")
138
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800139 main.step( "Creating ONOS package" )
140 packageResult = main.ONOSbench.onosPackage()
141
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800142 main.step( "verify cells" )
143 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700144
145 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700146 for node in range(1, clusterCount + 1):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700147 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700148 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700149
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700150 for node in range(1, clusterCount + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700151 for i in range( 2 ):
152 isup = main.ONOSbench.isup( ONOSIp[node] )
153 if isup:
154 main.log.info("ONOS " + str(node) + " is up\n")
155 break
156 if not isup:
157 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700158 main.log.info("Startup sequence complete")
159
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700160 time.sleep(20)
161
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700162
jenkins50379942015-06-19 13:36:43 -0700163 for i in range(5):
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700164 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(clusterCount*10) + """ " """)
165 main.ONOSbench.handle.expect(":~")
166 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
167 main.ONOSbench.handle.expect(":~")
168 if ("value=" + str(clusterCount*10)) in main.ONOSbench.handle.before:
169 main.log.info("Device count set")
170 main.log.info("before" + main.ONOSbench.handle.before)
171 break
172 time.sleep(10)
173 main.log.info("cfg set failure, retrying")
174 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700175
jenkins50379942015-06-19 13:36:43 -0700176 for i in range(5):
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700177 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
178 main.ONOSbench.handle.expect(":~")
179 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
180 main.ONOSbench.handle.expect(":~")
181 if ("value=linear") in main.ONOSbench.handle.before:
182 main.log.info("Device count set")
183 main.log.info("before" + main.ONOSbench.handle.before)
184 break
185 time.sleep(10)
186 main.log.info("cfg set failure, retrying")
187 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700188
189 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBU + """" """)
190 main.ONOSbench.handle.expect(":~")
191 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """)
192 main.ONOSbench.handle.expect(":~")
193 main.log.info(main.ONOSbench.handle.before)
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700194
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700195 time.sleep(10)
196 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
197 main.ONOSbench.handle.expect(":~")
198 print main.ONOSbench.handle.before
199 time.sleep(10)
200 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
201 main.ONOSbench.handle.expect(":~")
202 print main.ONOSbench.handle.before
203
andrew@onlab.us10332202015-03-11 15:04:43 -0700204 lastOutput = "--"
205 origin = time.time()
206 clockStarted = False
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700207 while True:
andrew@onlab.us10332202015-03-11 15:04:43 -0700208 main.ONOSbench.handle.sendline("onos $OC1 summary")
209 main.ONOSbench.handle.expect(":~")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700210 main.log.info("before" + main.ONOSbench.handle.before)
andrew@onlab.us10332202015-03-11 15:04:43 -0700211 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
212 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700213 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700214 break
215 if clusterCheck != lastOutput:
216 sameOutput = False
217 elif clusterCheck == lastOutput:
218 if clockStarted == False:
219 start = time.time()
220 clockStarted = True
cameron@onlab.us059c2562015-04-02 14:12:51 -0700221 if time.time() > (start + 10):
andrew@onlab.us10332202015-03-11 15:04:43 -0700222 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
223 break
224 lastOutput = clusterCheck
225 time.sleep(5)
jenkins50379942015-06-19 13:36:43 -0700226 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700227 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700228 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800229 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700230 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700231 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700232 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700233 import os.path
234
235 global currentNeighbors
236 neighbors = []
237
238 try:
239 currentNeighbors
240 except:
241 currentNeighbors = "0"
242 neighbors = ['0']
243 else:
244 if currentNeighbors == "r": #reset
245 currentNeighbors = "a"
246 neighbors = ['0']
247 else:
248 currentNeighbors = "r"
249 neighbors = ['a']
250
251 if clusterCount == 1:
252 currentNeighbors = "r"
andrew@onlab.us10332202015-03-11 15:04:43 -0700253
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800254 main.log.info("Cluster Count = " + str(clusterCount))
255
andrew@onlab.us10332202015-03-11 15:04:43 -0700256 intentsRate = main.params['METRICS']['intents_rate']
257 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
258 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
259 testDuration = main.params[ 'TEST' ][ 'duration' ]
260 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
261 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700262 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
263 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700264 #neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700265 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700266
cameron@onlab.us059c2562015-04-02 14:12:51 -0700267 for n in range(0, len(neighbors)):
268 if neighbors[n] == 'a':
269 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700270 if int(clusterCount) == 1:
271 neighbors = neighbors.pop()
272
cameron@onlab.us059c2562015-04-02 14:12:51 -0700273 for n in neighbors:
274 main.log.info("Run with " + n + " neighbors")
275 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700276 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700277 main.ONOSbench.handle.expect(":~")
278 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
279 main.ONOSbench.handle.expect(":~")
280 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
281 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700282
cameron@onlab.us059c2562015-04-02 14:12:51 -0700283 cmd = "onos $OC1 intent-perf-start"
284 main.ONOSbench.handle.sendline(cmd)
285 main.ONOSbench.handle.expect(":~")
286 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700287
cameron@onlab.us059c2562015-04-02 14:12:51 -0700288 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
289 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700290
cameron@onlab.us059c2562015-04-02 14:12:51 -0700291 while time.time() < stop:
292 time.sleep( float( logInterval ) )
293 groupResult = []
294 for node in range (1, clusterCount + 1):
295 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700296
cameron@onlab.us059c2562015-04-02 14:12:51 -0700297 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
298 main.log.info("COMMAND: " + str(cmd))
299
300 x = 0
301 while True:
302 main.ONOSbench.handle.sendline(cmd)
jenkins50379942015-06-19 13:36:43 -0700303 time.sleep(6)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700304 main.ONOSbench.handle.expect(":~")
305 raw = main.ONOSbench.handle.before
306 if "OVERALL=" in raw:
307 break
308 x += 1
309 if x > 10:
310 main.log.error("Expected output not being recieved... continuing")
311 break
312 time.sleep(2)
313
314 raw = raw.splitlines()
315 splitResults = []
316 for line in raw:
317 splitResults.extend(line.split(" "))
318
319 myResult = "--"
320 for field in splitResults:
321 if "OVERALL" in field:
322 myResult = field
323
324 if myResult == "--":
325 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
326
327 myResult = myResult.replace(";", "")
328 myResult = myResult.replace("OVERALL=","")
329 myResult = float(myResult)
330 groupResult[len(groupResult) -1] = myResult
331
332 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
333
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700334 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700335 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700336 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700337
cameron@onlab.us059c2562015-04-02 14:12:51 -0700338 cmd = "onos $OC1 intent-perf-stop"
339 main.ONOSbench.handle.sendline(cmd)
340 main.ONOSbench.handle.expect(":~")
341 main.log.info("Stopping intentperf" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700342
343 resultsDB = open("IntentEventTPDB", "a")
344 for node in groupResult:
345
346 resultString = "'" + commit + "',"
347 resultString += "'1gig',"
348 resultString += str(clusterCount) + ","
349 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
350 resultString += n + ","
351 resultString += str(node) + ","
352 resultString += str(0) + "\n" #no stddev
353 resultsDB.write(resultString)
354
355 resultsDB.close()
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700356
jenkins50379942015-06-19 13:36:43 -0700357 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700358