blob: 06fc028389ac247c113bb55c41efece762a8095b [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
cameron@onlab.usaaecfd72015-07-08 12:27:26 -07009import time
andrew@onlab.us10332202015-03-11 15:04:43 -070010
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080011
suibin7f2c9cd2015-07-08 17:34:59 -070012class SCPFintentEventTp:
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080013
14 def __init__( self ):
15 self.default = ''
16
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070017 def CASE1( self, main ):
18 import sys
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070019 import os.path
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070020 import time
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070021
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070022 global init
23 try:
24 if type(init) is not bool:
25 init = Fals
26 except NameError:
27 init = False
28
andrew@onlab.us10332202015-03-11 15:04:43 -070029 #Load values from params file
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080030 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
31 gitPull = main.params[ 'GIT' ][ 'autopull' ]
32 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070033 Apps = main.params[ 'ENV' ][ 'cellApps' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080034 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
35 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070036 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070037 maxNodes = int(main.params[ 'max' ])
38 main.maxNodes = maxNodes
andrew@onlab.us10332202015-03-11 15:04:43 -070039 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070040 cellName = main.params[ 'ENV' ][ 'cellName' ]
jenkins3af0cd82015-03-24 10:27:16 -070041 numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -070042 flowRuleBU = main.params[ 'TEST' ][ 'flowRuleBUEnabled' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070043 onBaremetal = main.params['isOnBaremetal']
44 homeDir = os.path.expanduser('~')
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080045
cameron@onlab.us412e9562015-05-13 16:04:34 -070046 main.exceptions = [0]*11
47 main.warnings = [0]*11
48 main.errors = [0]*11
49
cameron@onlab.us059c2562015-04-02 14:12:51 -070050 # -- INIT SECTION, ONLY RUNS ONCE -- #
51 if init == False:
52 init = True
53 global clusterCount #number of nodes running
54 global ONOSIp #list of ONOS IP addresses
55 global scale
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070056 global commit
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070057
cameron@onlab.us059c2562015-04-02 14:12:51 -070058 clusterCount = 0
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070059 ONOSIp = main.ONOSbench.getOnosIps()
60 print ONOSIp
61 print main.ONOSbench.onosIps.values()
62
cameron@onlab.us059c2562015-04-02 14:12:51 -070063 scale = (main.params[ 'SCALE' ]).split(",")
64 clusterCount = int(scale[0])
65
66 #Populate ONOSIp with ips from params
jenkins15b2b132015-06-23 14:04:09 -070067 ONOSIp.extend(main.ONOSbench.getOnosIps())
jenkins15b2b132015-06-23 14:04:09 -070068
cameron@onlab.us059c2562015-04-02 14:12:51 -070069 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
70 if skipMvn != "yes":
71 mvnResult = main.ONOSbench.cleanInstall()
72
73 #git
74 main.step( "Git checkout and pull " + checkoutBranch )
75 if gitPull == 'on':
76 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
77 pullResult = main.ONOSbench.gitPull()
78
79 else:
80 checkoutResult = main.TRUE
81 pullResult = main.TRUE
82 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070083
84 main.log.step("Grabbing commit number")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070085 commit = main.ONOSbench.getVersion()
86 commit = (commit.split(" "))[1]
87
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070088 main.log.step("Creating results file")
suibin584c0702015-07-14 15:57:27 -070089 resultsDB = open("/tmp/IntentEventTPDB", "w+")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070090 resultsDB.close()
91
cameron@onlab.us059c2562015-04-02 14:12:51 -070092 # -- END OF INIT SECTION --#
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070093
94 main.log.step("Adjusting scale")
95 print str(scale)
96 print str(ONOSIp)
cameron@onlab.us059c2562015-04-02 14:12:51 -070097 clusterCount = int(scale[0])
98 scale.remove(scale[0])
jenkins5a771992015-06-24 13:53:27 -070099
100 MN1Ip = ONOSIp[len(ONOSIp) -1]
101 BENCHIp = ONOSIp[len(ONOSIp) -2]
102
cameron@onlab.us059c2562015-04-02 14:12:51 -0700103 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -0700104 main.log.step("Safety check, killing all ONOS processes")
105 main.log.step("before initiating enviornment setup")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700106 for node in range(maxNodes):
andrew@onlab.us10332202015-03-11 15:04:43 -0700107 main.ONOSbench.onosDie(ONOSIp[node])
jenkins8f8f4f32015-06-24 14:05:04 -0700108
109 MN1Ip = ONOSIp[len(ONOSIp) -1]
110 BENCHIp = ONOSIp[len(ONOSIp) -2]
111
andrew@onlab.us10332202015-03-11 15:04:43 -0700112 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800113 main.log.step( "Cleaning Enviornment..." )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700114 for i in range(maxNodes):
andrew@onlab.us10332202015-03-11 15:04:43 -0700115 main.log.info(" Uninstalling ONOS " + str(i) )
116 main.ONOSbench.onosUninstall( ONOSIp[i] )
suibine1a104d2015-07-08 15:58:29 -0700117 main.log.info("Sleep 10 second for uninstall to settle...")
118 time.sleep(10)
119 main.ONOSbench.handle.sendline(" ")
120 main.ONOSbench.handle.expect(":~")
121
cameron@onlab.us059c2562015-04-02 14:12:51 -0700122 #construct the cell file
123 main.log.info("Creating cell file")
124 cellIp = []
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700125 for node in range (clusterCount):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700126 cellIp.append(ONOSIp[node])
jenkins5a771992015-06-24 13:53:27 -0700127
cameron@onlab.usc5bf8192015-07-13 13:36:05 -0700128 main.ONOSbench.createCellFile("localhost",cellName,MN1Ip,str(Apps), cellIp)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700129
130 main.step( "Set Cell" )
131 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800132
jenkins3af0cd82015-03-24 10:27:16 -0700133 myDistribution = []
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700134 for node in range (clusterCount):
135 myDistribution.append(numSwitches[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800136
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700137 #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700138
139 if onBaremetal == "True":
140 filename = "/onos/tools/package/bin/onos-service"
141 serviceConfig = open(homeDir + filename, 'w+')
142 serviceConfig.write("#!/bin/bash\n ")
143 serviceConfig.write("#------------------------------------- \n ")
144 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
145 serviceConfig.write("#------------------------------------- \n ")
146 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
147 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
148 serviceConfig.write("")
149 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
150 serviceConfig.write("")
151 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
152 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
153 serviceConfig.close()
154 main.log.info("Set /onos/tools/package/bin/onos-service with 8G Xms/Xmx Options.")
155
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800156 main.step( "Creating ONOS package" )
157 packageResult = main.ONOSbench.onosPackage()
158
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800159 main.step( "verify cells" )
160 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700161
162 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700163 for node in range(clusterCount):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700164 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700165 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700166
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700167 for node in range(clusterCount):
andrew@onlab.us10332202015-03-11 15:04:43 -0700168 for i in range( 2 ):
169 isup = main.ONOSbench.isup( ONOSIp[node] )
170 if isup:
171 main.log.info("ONOS " + str(node) + " is up\n")
172 break
173 if not isup:
174 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700175 main.log.info("Startup sequence complete")
176
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700177 time.sleep(20)
178
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700179 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.store.flow.impl.NewDistributedFlowRuleStore", "backupEnabled false")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700180
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700181 main.log.step("Setting up null provider")
182 for i in range(3):
183 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "deviceCount 8")
184 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
185 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "enabled true")
186 time.sleep(5)
187
188 main.ONOSbench.handle.sendline("onos $OC1 summary")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700189 main.ONOSbench.handle.expect(":~")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700190
191 before = main.ONOSbench.handle.before
192 if "devices=8" in before and "links=14" in before:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700193 break
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700194
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700195 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
196 main.ONOSbench.handle.expect(":~")
197 print main.ONOSbench.handle.before
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700198
andrew@onlab.us10332202015-03-11 15:04:43 -0700199 lastOutput = "--"
200 origin = time.time()
201 clockStarted = False
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700202 while True:
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700203
204 main.ONOSbench.handle.sendline("")
205 main.ONOSbench.handle.expect(":~")
206
andrew@onlab.us10332202015-03-11 15:04:43 -0700207 main.ONOSbench.handle.sendline("onos $OC1 summary")
208 main.ONOSbench.handle.expect(":~")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700209
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700210 main.log.info("before" + main.ONOSbench.handle.before)
Jon Hallf57a5ef2015-07-07 17:56:16 -0700211 clusterCheck = main.ONOSbench.handle.before
andrew@onlab.us10332202015-03-11 15:04:43 -0700212 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.usaaecfd72015-07-08 12:27:26 -0700221 if time.time() > (start + 30):
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
suibine1e58772015-07-15 09:52:59 -0700343 resultsDB = open("/tmp/IntentEventTPDB", "a")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700344 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