blob: fc52a7e4587b45163c010c8727092a3e18168890 [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.us059c2562015-04-02 14:12:51 -070044 # -- INIT SECTION, ONLY RUNS ONCE -- #
45 if init == False:
46 init = True
47 global clusterCount #number of nodes running
48 global ONOSIp #list of ONOS IP addresses
49 global scale
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070050 global commit
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070051
52 main.exceptions = [0]*11
53 main.warnings = [0]*11
54 main.errors = [0]*11
cameron@onlab.us059c2562015-04-02 14:12:51 -070055 clusterCount = 0
56 ONOSIp = [ 0 ]
57 scale = (main.params[ 'SCALE' ]).split(",")
58 clusterCount = int(scale[0])
59
60 #Populate ONOSIp with ips from params
61 for i in range(1, maxNodes + 1):
62 ipString = 'ip' + str(i)
63 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
64
65 #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])
cameron@onlab.us059c2562015-04-02 14:12:51 -070096
andrew@onlab.us10332202015-03-11 15:04:43 -070097 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080098 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us10332202015-03-11 15:04:43 -070099 for i in range(1, maxNodes + 1):
100 main.log.info(" Uninstalling ONOS " + str(i) )
101 main.ONOSbench.onosUninstall( ONOSIp[i] )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700102
103 #construct the cell file
104 main.log.info("Creating cell file")
105 cellIp = []
106 for node in range (1, clusterCount + 1):
107 cellIp.append(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800108
cameron@onlab.us059c2562015-04-02 14:12:51 -0700109 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
110
111 main.step( "Set Cell" )
112 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800113
jenkins3af0cd82015-03-24 10:27:16 -0700114 myDistribution = []
115 for node in range (1, clusterCount + 1):
116 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800117
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700118 #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700119
120 if onBaremetal == "True":
121 filename = "/onos/tools/package/bin/onos-service"
122 serviceConfig = open(homeDir + filename, 'w+')
123 serviceConfig.write("#!/bin/bash\n ")
124 serviceConfig.write("#------------------------------------- \n ")
125 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
126 serviceConfig.write("#------------------------------------- \n ")
127 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
128 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
129 serviceConfig.write("")
130 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
131 serviceConfig.write("")
132 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
133 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
134 serviceConfig.close()
135 main.log.info("Set /onos/tools/package/bin/onos-service with 8G Xms/Xmx Options.")
136
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800137 main.step( "Creating ONOS package" )
138 packageResult = main.ONOSbench.onosPackage()
139
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800140 main.step( "verify cells" )
141 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700142
143 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700144 for node in range(1, clusterCount + 1):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700145 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700146 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700147
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700148 for node in range(1, clusterCount + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700149 for i in range( 2 ):
150 isup = main.ONOSbench.isup( ONOSIp[node] )
151 if isup:
152 main.log.info("ONOS " + str(node) + " is up\n")
153 break
154 if not isup:
155 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700156 main.log.info("Startup sequence complete")
157
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700158 time.sleep(20)
159
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700160
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700161 while True:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700162 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(clusterCount*10) + """ " """)
163 main.ONOSbench.handle.expect(":~")
164 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
165 main.ONOSbench.handle.expect(":~")
166 if ("value=" + str(clusterCount*10)) in main.ONOSbench.handle.before:
167 main.log.info("Device count set")
168 main.log.info("before" + main.ONOSbench.handle.before)
169 break
170 time.sleep(10)
171 main.log.info("cfg set failure, retrying")
172 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700173
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700174 while True:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700175 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
176 main.ONOSbench.handle.expect(":~")
177 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
178 main.ONOSbench.handle.expect(":~")
179 if ("value=linear") in main.ONOSbench.handle.before:
180 main.log.info("Device count set")
181 main.log.info("before" + main.ONOSbench.handle.before)
182 break
183 time.sleep(10)
184 main.log.info("cfg set failure, retrying")
185 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700186
187 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBU + """" """)
188 main.ONOSbench.handle.expect(":~")
189 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """)
190 main.ONOSbench.handle.expect(":~")
191 main.log.info(main.ONOSbench.handle.before)
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700192
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700193 time.sleep(10)
194 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
195 main.ONOSbench.handle.expect(":~")
196 print main.ONOSbench.handle.before
197 time.sleep(10)
198 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
199 main.ONOSbench.handle.expect(":~")
200 print main.ONOSbench.handle.before
201
andrew@onlab.us10332202015-03-11 15:04:43 -0700202 lastOutput = "--"
203 origin = time.time()
204 clockStarted = False
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700205 while True:
andrew@onlab.us10332202015-03-11 15:04:43 -0700206 main.ONOSbench.handle.sendline("onos $OC1 summary")
207 main.ONOSbench.handle.expect(":~")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700208 main.log.info("before" + main.ONOSbench.handle.before)
andrew@onlab.us10332202015-03-11 15:04:43 -0700209 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
210 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700211 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700212 break
213 if clusterCheck != lastOutput:
214 sameOutput = False
215 elif clusterCheck == lastOutput:
216 if clockStarted == False:
217 start = time.time()
218 clockStarted = True
cameron@onlab.us059c2562015-04-02 14:12:51 -0700219 if time.time() > (start + 10):
andrew@onlab.us10332202015-03-11 15:04:43 -0700220 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
221 break
222 lastOutput = clusterCheck
223 time.sleep(5)
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700224 main.ONOSbench.onosErrorLog(ONOSIp[1])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700225
226 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700227 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800228 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700229 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700230 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700231 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700232 import os.path
233
234 global currentNeighbors
235 neighbors = []
236
237 try:
238 currentNeighbors
239 except:
240 currentNeighbors = "0"
241 neighbors = ['0']
242 else:
243 if currentNeighbors == "r": #reset
244 currentNeighbors = "a"
245 neighbors = ['0']
246 else:
247 currentNeighbors = "r"
248 neighbors = ['a']
249
250 if clusterCount == 1:
251 currentNeighbors = "r"
andrew@onlab.us10332202015-03-11 15:04:43 -0700252
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800253 main.log.info("Cluster Count = " + str(clusterCount))
254
andrew@onlab.us10332202015-03-11 15:04:43 -0700255 intentsRate = main.params['METRICS']['intents_rate']
256 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
257 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
258 testDuration = main.params[ 'TEST' ][ 'duration' ]
259 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
260 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700261 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
262 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700263 #neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700264 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700265
cameron@onlab.us059c2562015-04-02 14:12:51 -0700266 for n in range(0, len(neighbors)):
267 if neighbors[n] == 'a':
268 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700269 if int(clusterCount) == 1:
270 neighbors = neighbors.pop()
271
cameron@onlab.us059c2562015-04-02 14:12:51 -0700272 for n in neighbors:
273 main.log.info("Run with " + n + " neighbors")
274 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700275 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700276 main.ONOSbench.handle.expect(":~")
277 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
278 main.ONOSbench.handle.expect(":~")
279 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
280 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700281
cameron@onlab.us059c2562015-04-02 14:12:51 -0700282 cmd = "onos $OC1 intent-perf-start"
283 main.ONOSbench.handle.sendline(cmd)
284 main.ONOSbench.handle.expect(":~")
285 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700286
cameron@onlab.us059c2562015-04-02 14:12:51 -0700287 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
288 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700289
cameron@onlab.us059c2562015-04-02 14:12:51 -0700290 while time.time() < stop:
291 time.sleep( float( logInterval ) )
292 groupResult = []
293 for node in range (1, clusterCount + 1):
294 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700295
cameron@onlab.us059c2562015-04-02 14:12:51 -0700296 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
297 main.log.info("COMMAND: " + str(cmd))
298
299 x = 0
300 while True:
301 main.ONOSbench.handle.sendline(cmd)
302 main.ONOSbench.handle.expect(":~")
303 raw = main.ONOSbench.handle.before
304 if "OVERALL=" in raw:
305 break
306 x += 1
307 if x > 10:
308 main.log.error("Expected output not being recieved... continuing")
309 break
310 time.sleep(2)
311
312 raw = raw.splitlines()
313 splitResults = []
314 for line in raw:
315 splitResults.extend(line.split(" "))
316
317 myResult = "--"
318 for field in splitResults:
319 if "OVERALL" in field:
320 myResult = field
321
322 if myResult == "--":
323 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
324
325 myResult = myResult.replace(";", "")
326 myResult = myResult.replace("OVERALL=","")
327 myResult = float(myResult)
328 groupResult[len(groupResult) -1] = myResult
329
330 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
331
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700332 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700333 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700334 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700335
336 main.ONOSbench.onosErrorLog(ONOSIp[1])
337
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
357 main.ONOSbench.onosErrorLog(ONOSIp[1])
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700358
359