blob: fe5e2157e20530ce2ba1e4d33e908e4a544e4d02 [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])
jenkins5a771992015-06-24 13:53:27 -070092
93 MN1Ip = ONOSIp[len(ONOSIp) -1]
94 BENCHIp = ONOSIp[len(ONOSIp) -2]
95
cameron@onlab.us059c2562015-04-02 14:12:51 -070096 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -070097 main.log.step("Safety check, killing all ONOS processes")
98 main.log.step("before initiating enviornment setup")
99 for node in range(1, maxNodes + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700100 main.ONOSbench.onosDie(ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700101
andrew@onlab.us10332202015-03-11 15:04:43 -0700102 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800103 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700104 for i in range(1, maxNodes + 1):
105 main.log.info(" Uninstalling ONOS " + str(i) )
106 main.ONOSbench.onosUninstall( ONOSIp[i] )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700107
108 #construct the cell file
109 main.log.info("Creating cell file")
110 cellIp = []
111 for node in range (1, clusterCount + 1):
112 cellIp.append(ONOSIp[node])
jenkins5a771992015-06-24 13:53:27 -0700113
cameron@onlab.us059c2562015-04-02 14:12:51 -0700114 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
115
116 main.step( "Set Cell" )
117 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800118
jenkins3af0cd82015-03-24 10:27:16 -0700119 myDistribution = []
120 for node in range (1, clusterCount + 1):
121 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800122
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700123 #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700124
125 if onBaremetal == "True":
126 filename = "/onos/tools/package/bin/onos-service"
127 serviceConfig = open(homeDir + filename, 'w+')
128 serviceConfig.write("#!/bin/bash\n ")
129 serviceConfig.write("#------------------------------------- \n ")
130 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
131 serviceConfig.write("#------------------------------------- \n ")
132 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
133 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
134 serviceConfig.write("")
135 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
136 serviceConfig.write("")
137 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
138 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
139 serviceConfig.close()
140 main.log.info("Set /onos/tools/package/bin/onos-service with 8G Xms/Xmx Options.")
141
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800142 main.step( "Creating ONOS package" )
143 packageResult = main.ONOSbench.onosPackage()
144
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800145 main.step( "verify cells" )
146 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700147
148 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700149 for node in range(1, clusterCount + 1):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700150 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700151 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700152
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700153 for node in range(1, clusterCount + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700154 for i in range( 2 ):
155 isup = main.ONOSbench.isup( ONOSIp[node] )
156 if isup:
157 main.log.info("ONOS " + str(node) + " is up\n")
158 break
159 if not isup:
160 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700161 main.log.info("Startup sequence complete")
162
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700163 time.sleep(20)
164
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700165
jenkins50379942015-06-19 13:36:43 -0700166 for i in range(5):
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700167 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(clusterCount*10) + """ " """)
168 main.ONOSbench.handle.expect(":~")
169 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
170 main.ONOSbench.handle.expect(":~")
171 if ("value=" + str(clusterCount*10)) in main.ONOSbench.handle.before:
172 main.log.info("Device count set")
173 main.log.info("before" + main.ONOSbench.handle.before)
174 break
175 time.sleep(10)
176 main.log.info("cfg set failure, retrying")
177 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700178
jenkins50379942015-06-19 13:36:43 -0700179 for i in range(5):
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700180 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
181 main.ONOSbench.handle.expect(":~")
182 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
183 main.ONOSbench.handle.expect(":~")
184 if ("value=linear") in main.ONOSbench.handle.before:
185 main.log.info("Device count set")
186 main.log.info("before" + main.ONOSbench.handle.before)
187 break
188 time.sleep(10)
189 main.log.info("cfg set failure, retrying")
190 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700191
192 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBU + """" """)
193 main.ONOSbench.handle.expect(":~")
194 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """)
195 main.ONOSbench.handle.expect(":~")
196 main.log.info(main.ONOSbench.handle.before)
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700197
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700198 time.sleep(10)
199 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
200 main.ONOSbench.handle.expect(":~")
201 print main.ONOSbench.handle.before
202 time.sleep(10)
203 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
204 main.ONOSbench.handle.expect(":~")
205 print main.ONOSbench.handle.before
206
andrew@onlab.us10332202015-03-11 15:04:43 -0700207 lastOutput = "--"
208 origin = time.time()
209 clockStarted = False
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700210 while True:
andrew@onlab.us10332202015-03-11 15:04:43 -0700211 main.ONOSbench.handle.sendline("onos $OC1 summary")
212 main.ONOSbench.handle.expect(":~")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700213 main.log.info("before" + main.ONOSbench.handle.before)
andrew@onlab.us10332202015-03-11 15:04:43 -0700214 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
215 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700216 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700217 break
218 if clusterCheck != lastOutput:
219 sameOutput = False
220 elif clusterCheck == lastOutput:
221 if clockStarted == False:
222 start = time.time()
223 clockStarted = True
cameron@onlab.us059c2562015-04-02 14:12:51 -0700224 if time.time() > (start + 10):
andrew@onlab.us10332202015-03-11 15:04:43 -0700225 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
226 break
227 lastOutput = clusterCheck
228 time.sleep(5)
jenkins50379942015-06-19 13:36:43 -0700229 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700230 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700231 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800232 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700233 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700234 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700235 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700236 import os.path
237
238 global currentNeighbors
239 neighbors = []
240
241 try:
242 currentNeighbors
243 except:
244 currentNeighbors = "0"
245 neighbors = ['0']
246 else:
247 if currentNeighbors == "r": #reset
248 currentNeighbors = "a"
249 neighbors = ['0']
250 else:
251 currentNeighbors = "r"
252 neighbors = ['a']
253
254 if clusterCount == 1:
255 currentNeighbors = "r"
andrew@onlab.us10332202015-03-11 15:04:43 -0700256
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800257 main.log.info("Cluster Count = " + str(clusterCount))
258
andrew@onlab.us10332202015-03-11 15:04:43 -0700259 intentsRate = main.params['METRICS']['intents_rate']
260 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
261 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
262 testDuration = main.params[ 'TEST' ][ 'duration' ]
263 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
264 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700265 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
266 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700267 #neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700268 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700269
cameron@onlab.us059c2562015-04-02 14:12:51 -0700270 for n in range(0, len(neighbors)):
271 if neighbors[n] == 'a':
272 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700273 if int(clusterCount) == 1:
274 neighbors = neighbors.pop()
275
cameron@onlab.us059c2562015-04-02 14:12:51 -0700276 for n in neighbors:
277 main.log.info("Run with " + n + " neighbors")
278 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700279 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700280 main.ONOSbench.handle.expect(":~")
281 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
282 main.ONOSbench.handle.expect(":~")
283 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
284 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700285
cameron@onlab.us059c2562015-04-02 14:12:51 -0700286 cmd = "onos $OC1 intent-perf-start"
287 main.ONOSbench.handle.sendline(cmd)
288 main.ONOSbench.handle.expect(":~")
289 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700290
cameron@onlab.us059c2562015-04-02 14:12:51 -0700291 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
292 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700293
cameron@onlab.us059c2562015-04-02 14:12:51 -0700294 while time.time() < stop:
295 time.sleep( float( logInterval ) )
296 groupResult = []
297 for node in range (1, clusterCount + 1):
298 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700299
cameron@onlab.us059c2562015-04-02 14:12:51 -0700300 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
301 main.log.info("COMMAND: " + str(cmd))
302
303 x = 0
304 while True:
305 main.ONOSbench.handle.sendline(cmd)
jenkins50379942015-06-19 13:36:43 -0700306 time.sleep(6)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700307 main.ONOSbench.handle.expect(":~")
308 raw = main.ONOSbench.handle.before
309 if "OVERALL=" in raw:
310 break
311 x += 1
312 if x > 10:
313 main.log.error("Expected output not being recieved... continuing")
314 break
315 time.sleep(2)
316
317 raw = raw.splitlines()
318 splitResults = []
319 for line in raw:
320 splitResults.extend(line.split(" "))
321
322 myResult = "--"
323 for field in splitResults:
324 if "OVERALL" in field:
325 myResult = field
326
327 if myResult == "--":
328 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
329
330 myResult = myResult.replace(";", "")
331 myResult = myResult.replace("OVERALL=","")
332 myResult = float(myResult)
333 groupResult[len(groupResult) -1] = myResult
334
335 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
336
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700337 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700338 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700339 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700340
cameron@onlab.us059c2562015-04-02 14:12:51 -0700341 cmd = "onos $OC1 intent-perf-stop"
342 main.ONOSbench.handle.sendline(cmd)
343 main.ONOSbench.handle.expect(":~")
344 main.log.info("Stopping intentperf" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700345
346 resultsDB = open("IntentEventTPDB", "a")
347 for node in groupResult:
348
349 resultString = "'" + commit + "',"
350 resultString += "'1gig',"
351 resultString += str(clusterCount) + ","
352 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
353 resultString += n + ","
354 resultString += str(node) + ","
355 resultString += str(0) + "\n" #no stddev
356 resultsDB.write(resultString)
357
358 resultsDB.close()
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700359
jenkins50379942015-06-19 13:36:43 -0700360 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700361