blob: 96825078ca7a6619df9f3224b0d25d359b2434fb [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())
jenkins15b2b132015-06-23 14:04:09 -070064
cameron@onlab.us059c2562015-04-02 14:12:51 -070065 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
66 if skipMvn != "yes":
67 mvnResult = main.ONOSbench.cleanInstall()
68
69 #git
70 main.step( "Git checkout and pull " + checkoutBranch )
71 if gitPull == 'on':
72 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
73 pullResult = main.ONOSbench.gitPull()
74
75 else:
76 checkoutResult = main.TRUE
77 pullResult = main.TRUE
78 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us10332202015-03-11 15:04:43 -070079
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070080 commit = main.ONOSbench.getVersion()
81 commit = (commit.split(" "))[1]
82
83 resultsDB = open("IntentEventTPDB", "w+")
84 resultsDB.close()
85
cameron@onlab.us059c2562015-04-02 14:12:51 -070086 # -- END OF INIT SECTION --#
87
88 clusterCount = int(scale[0])
89 scale.remove(scale[0])
90
91 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -070092 main.log.step("Safety check, killing all ONOS processes")
93 main.log.step("before initiating enviornment setup")
94 for node in range(1, maxNodes + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -070095 main.ONOSbench.onosDie(ONOSIp[node])
jenkins8f8f4f32015-06-24 14:05:04 -070096
97 MN1Ip = ONOSIp[len(ONOSIp) -1]
98 BENCHIp = ONOSIp[len(ONOSIp) -2]
99
andrew@onlab.us10332202015-03-11 15:04:43 -0700100 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800101 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700102 for i in range(1, maxNodes + 1):
103 main.log.info(" Uninstalling ONOS " + str(i) )
104 main.ONOSbench.onosUninstall( ONOSIp[i] )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700105
106 #construct the cell file
107 main.log.info("Creating cell file")
108 cellIp = []
109 for node in range (1, clusterCount + 1):
110 cellIp.append(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800111
cameron@onlab.us059c2562015-04-02 14:12:51 -0700112 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
113
114 main.step( "Set Cell" )
115 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800116
jenkins3af0cd82015-03-24 10:27:16 -0700117 myDistribution = []
118 for node in range (1, clusterCount + 1):
119 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800120
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700121 #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700122
123 if onBaremetal == "True":
124 filename = "/onos/tools/package/bin/onos-service"
125 serviceConfig = open(homeDir + filename, 'w+')
126 serviceConfig.write("#!/bin/bash\n ")
127 serviceConfig.write("#------------------------------------- \n ")
128 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
129 serviceConfig.write("#------------------------------------- \n ")
130 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
131 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
132 serviceConfig.write("")
133 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
134 serviceConfig.write("")
135 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
136 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
137 serviceConfig.close()
138 main.log.info("Set /onos/tools/package/bin/onos-service with 8G Xms/Xmx Options.")
139
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800140 main.step( "Creating ONOS package" )
141 packageResult = main.ONOSbench.onosPackage()
142
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800143 main.step( "verify cells" )
144 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700145
146 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700147 for node in range(1, clusterCount + 1):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700148 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700149 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700150
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700151 for node in range(1, clusterCount + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700152 for i in range( 2 ):
153 isup = main.ONOSbench.isup( ONOSIp[node] )
154 if isup:
155 main.log.info("ONOS " + str(node) + " is up\n")
156 break
157 if not isup:
158 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700159 main.log.info("Startup sequence complete")
160
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700161 time.sleep(20)
162
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700163
jenkins50379942015-06-19 13:36:43 -0700164 for i in range(5):
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700165 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(clusterCount*10) + """ " """)
166 main.ONOSbench.handle.expect(":~")
167 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
168 main.ONOSbench.handle.expect(":~")
169 if ("value=" + str(clusterCount*10)) in main.ONOSbench.handle.before:
170 main.log.info("Device count set")
171 main.log.info("before" + main.ONOSbench.handle.before)
172 break
173 time.sleep(10)
174 main.log.info("cfg set failure, retrying")
175 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700176
jenkins50379942015-06-19 13:36:43 -0700177 for i in range(5):
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700178 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
179 main.ONOSbench.handle.expect(":~")
180 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
181 main.ONOSbench.handle.expect(":~")
182 if ("value=linear") in main.ONOSbench.handle.before:
183 main.log.info("Device count set")
184 main.log.info("before" + main.ONOSbench.handle.before)
185 break
186 time.sleep(10)
187 main.log.info("cfg set failure, retrying")
188 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700189
190 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBU + """" """)
191 main.ONOSbench.handle.expect(":~")
192 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """)
193 main.ONOSbench.handle.expect(":~")
194 main.log.info(main.ONOSbench.handle.before)
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700195
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700196 time.sleep(10)
197 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
198 main.ONOSbench.handle.expect(":~")
199 print main.ONOSbench.handle.before
200 time.sleep(10)
201 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
202 main.ONOSbench.handle.expect(":~")
203 print main.ONOSbench.handle.before
204
andrew@onlab.us10332202015-03-11 15:04:43 -0700205 lastOutput = "--"
206 origin = time.time()
207 clockStarted = False
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700208 while True:
andrew@onlab.us10332202015-03-11 15:04:43 -0700209 main.ONOSbench.handle.sendline("onos $OC1 summary")
210 main.ONOSbench.handle.expect(":~")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700211 main.log.info("before" + main.ONOSbench.handle.before)
andrew@onlab.us10332202015-03-11 15:04:43 -0700212 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
213 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700214 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700215 break
216 if clusterCheck != lastOutput:
217 sameOutput = False
218 elif clusterCheck == lastOutput:
219 if clockStarted == False:
220 start = time.time()
221 clockStarted = True
cameron@onlab.us059c2562015-04-02 14:12:51 -0700222 if time.time() > (start + 10):
andrew@onlab.us10332202015-03-11 15:04:43 -0700223 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
224 break
225 lastOutput = clusterCheck
226 time.sleep(5)
jenkins50379942015-06-19 13:36:43 -0700227 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700228 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700229 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800230 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700231 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700232 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700233 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700234 import os.path
235
236 global currentNeighbors
237 neighbors = []
238
239 try:
240 currentNeighbors
241 except:
242 currentNeighbors = "0"
243 neighbors = ['0']
244 else:
245 if currentNeighbors == "r": #reset
246 currentNeighbors = "a"
247 neighbors = ['0']
248 else:
249 currentNeighbors = "r"
250 neighbors = ['a']
251
252 if clusterCount == 1:
253 currentNeighbors = "r"
andrew@onlab.us10332202015-03-11 15:04:43 -0700254
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800255 main.log.info("Cluster Count = " + str(clusterCount))
256
andrew@onlab.us10332202015-03-11 15:04:43 -0700257 intentsRate = main.params['METRICS']['intents_rate']
258 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
259 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
260 testDuration = main.params[ 'TEST' ][ 'duration' ]
261 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
262 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700263 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
264 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700265 #neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700266 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700267
cameron@onlab.us059c2562015-04-02 14:12:51 -0700268 for n in range(0, len(neighbors)):
269 if neighbors[n] == 'a':
270 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700271 if int(clusterCount) == 1:
272 neighbors = neighbors.pop()
273
cameron@onlab.us059c2562015-04-02 14:12:51 -0700274 for n in neighbors:
275 main.log.info("Run with " + n + " neighbors")
276 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700277 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700278 main.ONOSbench.handle.expect(":~")
279 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
280 main.ONOSbench.handle.expect(":~")
281 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
282 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700283
cameron@onlab.us059c2562015-04-02 14:12:51 -0700284 cmd = "onos $OC1 intent-perf-start"
285 main.ONOSbench.handle.sendline(cmd)
286 main.ONOSbench.handle.expect(":~")
287 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700288
cameron@onlab.us059c2562015-04-02 14:12:51 -0700289 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
290 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700291
cameron@onlab.us059c2562015-04-02 14:12:51 -0700292 while time.time() < stop:
293 time.sleep( float( logInterval ) )
294 groupResult = []
295 for node in range (1, clusterCount + 1):
296 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700297
cameron@onlab.us059c2562015-04-02 14:12:51 -0700298 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
299 main.log.info("COMMAND: " + str(cmd))
300
301 x = 0
302 while True:
303 main.ONOSbench.handle.sendline(cmd)
jenkins50379942015-06-19 13:36:43 -0700304 time.sleep(6)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700305 main.ONOSbench.handle.expect(":~")
306 raw = main.ONOSbench.handle.before
307 if "OVERALL=" in raw:
308 break
309 x += 1
310 if x > 10:
311 main.log.error("Expected output not being recieved... continuing")
312 break
313 time.sleep(2)
314
315 raw = raw.splitlines()
316 splitResults = []
317 for line in raw:
318 splitResults.extend(line.split(" "))
319
320 myResult = "--"
321 for field in splitResults:
322 if "OVERALL" in field:
323 myResult = field
324
325 if myResult == "--":
326 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
327
328 myResult = myResult.replace(";", "")
329 myResult = myResult.replace("OVERALL=","")
330 myResult = float(myResult)
331 groupResult[len(groupResult) -1] = myResult
332
333 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
334
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700335 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700336 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700337 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700338
cameron@onlab.us059c2562015-04-02 14:12:51 -0700339 cmd = "onos $OC1 intent-perf-stop"
340 main.ONOSbench.handle.sendline(cmd)
341 main.ONOSbench.handle.expect(":~")
342 main.log.info("Stopping intentperf" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700343
344 resultsDB = open("IntentEventTPDB", "a")
345 for node in groupResult:
346
347 resultString = "'" + commit + "',"
348 resultString += "'1gig',"
349 resultString += str(clusterCount) + ","
350 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
351 resultString += n + ","
352 resultString += str(node) + ","
353 resultString += str(0) + "\n" #no stddev
354 resultsDB.write(resultString)
355
356 resultsDB.close()
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700357
jenkins50379942015-06-19 13:36:43 -0700358 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700359