blob: 99332f7eb243f044c2f9681748aa9721c90e06f4 [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
62 for i in range(1, maxNodes + 1):
63 ipString = 'ip' + str(i)
64 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
65
66 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
67 if skipMvn != "yes":
68 mvnResult = main.ONOSbench.cleanInstall()
69
70 #git
71 main.step( "Git checkout and pull " + checkoutBranch )
72 if gitPull == 'on':
73 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
74 pullResult = main.ONOSbench.gitPull()
75
76 else:
77 checkoutResult = main.TRUE
78 pullResult = main.TRUE
79 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us10332202015-03-11 15:04:43 -070080
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070081 commit = main.ONOSbench.getVersion()
82 commit = (commit.split(" "))[1]
83
84 resultsDB = open("IntentEventTPDB", "w+")
85 resultsDB.close()
86
cameron@onlab.us059c2562015-04-02 14:12:51 -070087 # -- END OF INIT SECTION --#
88
89 clusterCount = int(scale[0])
90 scale.remove(scale[0])
91
92 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -070093 main.log.step("Safety check, killing all ONOS processes")
94 main.log.step("before initiating enviornment setup")
95 for node in range(1, maxNodes + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -070096 main.ONOSbench.onosDie(ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -070097
andrew@onlab.us10332202015-03-11 15:04:43 -070098 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080099 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700100 for i in range(1, maxNodes + 1):
101 main.log.info(" Uninstalling ONOS " + str(i) )
102 main.ONOSbench.onosUninstall( ONOSIp[i] )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700103
104 #construct the cell file
105 main.log.info("Creating cell file")
106 cellIp = []
107 for node in range (1, clusterCount + 1):
108 cellIp.append(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800109
cameron@onlab.us059c2562015-04-02 14:12:51 -0700110 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
111
112 main.step( "Set Cell" )
113 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800114
jenkins3af0cd82015-03-24 10:27:16 -0700115 myDistribution = []
116 for node in range (1, clusterCount + 1):
117 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800118
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700119 #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700120
121 if onBaremetal == "True":
122 filename = "/onos/tools/package/bin/onos-service"
123 serviceConfig = open(homeDir + filename, 'w+')
124 serviceConfig.write("#!/bin/bash\n ")
125 serviceConfig.write("#------------------------------------- \n ")
126 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
127 serviceConfig.write("#------------------------------------- \n ")
128 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
129 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
130 serviceConfig.write("")
131 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
132 serviceConfig.write("")
133 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
134 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
135 serviceConfig.close()
136 main.log.info("Set /onos/tools/package/bin/onos-service with 8G Xms/Xmx Options.")
137
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800138 main.step( "Creating ONOS package" )
139 packageResult = main.ONOSbench.onosPackage()
140
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800141 main.step( "verify cells" )
142 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700143
144 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700145 for node in range(1, clusterCount + 1):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700146 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700147 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700148
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700149 for node in range(1, clusterCount + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700150 for i in range( 2 ):
151 isup = main.ONOSbench.isup( ONOSIp[node] )
152 if isup:
153 main.log.info("ONOS " + str(node) + " is up\n")
154 break
155 if not isup:
156 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700157 main.log.info("Startup sequence complete")
158
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700159 time.sleep(20)
160
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700161
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700162 while True:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700163 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(clusterCount*10) + """ " """)
164 main.ONOSbench.handle.expect(":~")
165 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
166 main.ONOSbench.handle.expect(":~")
167 if ("value=" + str(clusterCount*10)) in main.ONOSbench.handle.before:
168 main.log.info("Device count set")
169 main.log.info("before" + main.ONOSbench.handle.before)
170 break
171 time.sleep(10)
172 main.log.info("cfg set failure, retrying")
173 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700174
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700175 while True:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700176 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
177 main.ONOSbench.handle.expect(":~")
178 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
179 main.ONOSbench.handle.expect(":~")
180 if ("value=linear") in main.ONOSbench.handle.before:
181 main.log.info("Device count set")
182 main.log.info("before" + main.ONOSbench.handle.before)
183 break
184 time.sleep(10)
185 main.log.info("cfg set failure, retrying")
186 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700187
188 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBU + """" """)
189 main.ONOSbench.handle.expect(":~")
190 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """)
191 main.ONOSbench.handle.expect(":~")
192 main.log.info(main.ONOSbench.handle.before)
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700193
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700194 time.sleep(10)
195 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
196 main.ONOSbench.handle.expect(":~")
197 print main.ONOSbench.handle.before
198 time.sleep(10)
199 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
200 main.ONOSbench.handle.expect(":~")
201 print main.ONOSbench.handle.before
202
andrew@onlab.us10332202015-03-11 15:04:43 -0700203 lastOutput = "--"
204 origin = time.time()
205 clockStarted = False
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700206 while True:
andrew@onlab.us10332202015-03-11 15:04:43 -0700207 main.ONOSbench.handle.sendline("onos $OC1 summary")
208 main.ONOSbench.handle.expect(":~")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700209 main.log.info("before" + main.ONOSbench.handle.before)
andrew@onlab.us10332202015-03-11 15:04:43 -0700210 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
211 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700212 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700213 break
214 if clusterCheck != lastOutput:
215 sameOutput = False
216 elif clusterCheck == lastOutput:
217 if clockStarted == False:
218 start = time.time()
219 clockStarted = True
cameron@onlab.us059c2562015-04-02 14:12:51 -0700220 if time.time() > (start + 10):
andrew@onlab.us10332202015-03-11 15:04:43 -0700221 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
222 break
223 lastOutput = clusterCheck
224 time.sleep(5)
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700225 main.ONOSbench.onosErrorLog(ONOSIp[1])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700226
227 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)
303 main.ONOSbench.handle.expect(":~")
304 raw = main.ONOSbench.handle.before
305 if "OVERALL=" in raw:
306 break
307 x += 1
308 if x > 10:
309 main.log.error("Expected output not being recieved... continuing")
310 break
311 time.sleep(2)
312
313 raw = raw.splitlines()
314 splitResults = []
315 for line in raw:
316 splitResults.extend(line.split(" "))
317
318 myResult = "--"
319 for field in splitResults:
320 if "OVERALL" in field:
321 myResult = field
322
323 if myResult == "--":
324 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
325
326 myResult = myResult.replace(";", "")
327 myResult = myResult.replace("OVERALL=","")
328 myResult = float(myResult)
329 groupResult[len(groupResult) -1] = myResult
330
331 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
332
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700333 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700334 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700335 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700336
cameron@onlab.us059c2562015-04-02 14:12:51 -0700337 cmd = "onos $OC1 intent-perf-stop"
338 main.ONOSbench.handle.sendline(cmd)
339 main.ONOSbench.handle.expect(":~")
340 main.log.info("Stopping intentperf" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700341
342 resultsDB = open("IntentEventTPDB", "a")
343 for node in groupResult:
344
345 resultString = "'" + commit + "',"
346 resultString += "'1gig',"
347 resultString += str(clusterCount) + ","
348 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
349 resultString += n + ","
350 resultString += str(node) + ","
351 resultString += str(0) + "\n" #no stddev
352 resultsDB.write(resultString)
353
354 resultsDB.close()
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700355
356 main.ONOSbench.onosErrorLog(ONOSIp[1])
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700357
358