blob: a5944ac78433fd0c36a1ad62a33e057f61b7cf9a [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:
GlennRCf9ef27d2015-09-16 12:08:38 -070025 init = False
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070026 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' ])
Jon Hall4ba53f02015-07-29 13:07:41 -070038 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' ]
suibin zhangd1f03802016-02-25 11:48:58 -080043 skipRelRsrc = main.params[ 'TEST'][ 'skipReleaseResourcesOnWithdrawal']
YPZhange6ef82a2016-07-05 16:48:15 -070044
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070045 homeDir = os.path.expanduser('~')
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080046
YPZhange6ef82a2016-07-05 16:48:15 -070047 main.flowObj = main.params['TEST']['flowObj']
48 if main.flowObj == "True":
49 main.flowObj = True
50 main.dbFileName = main.params['DATABASE']['dbFlowObj']
51 else:
52 main.flowObj = False
53 main.dbFileName = main.params['DATABASE']['dbName']
54
cameron@onlab.us412e9562015-05-13 16:04:34 -070055 main.exceptions = [0]*11
56 main.warnings = [0]*11
57 main.errors = [0]*11
58
Jon Hall4ba53f02015-07-29 13:07:41 -070059 # -- INIT SECTION, ONLY RUNS ONCE -- #
60 if init == False:
cameron@onlab.us059c2562015-04-02 14:12:51 -070061 init = True
62 global clusterCount #number of nodes running
63 global ONOSIp #list of ONOS IP addresses
Jon Hall4ba53f02015-07-29 13:07:41 -070064 global scale
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070065 global commit
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070066
cameron@onlab.us059c2562015-04-02 14:12:51 -070067 clusterCount = 0
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070068 ONOSIp = main.ONOSbench.getOnosIps()
69 print ONOSIp
70 print main.ONOSbench.onosIps.values()
71
Jon Hall4ba53f02015-07-29 13:07:41 -070072 scale = (main.params[ 'SCALE' ]).split(",")
cameron@onlab.us059c2562015-04-02 14:12:51 -070073 clusterCount = int(scale[0])
74
Jon Hall4ba53f02015-07-29 13:07:41 -070075 #Populate ONOSIp with ips from params
jenkins15b2b132015-06-23 14:04:09 -070076 ONOSIp.extend(main.ONOSbench.getOnosIps())
jenkins15b2b132015-06-23 14:04:09 -070077
cameron@onlab.us059c2562015-04-02 14:12:51 -070078 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
79 if skipMvn != "yes":
80 mvnResult = main.ONOSbench.cleanInstall()
81
82 #git
83 main.step( "Git checkout and pull " + checkoutBranch )
84 if gitPull == 'on':
85 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
86 pullResult = main.ONOSbench.gitPull()
87
88 else:
89 checkoutResult = main.TRUE
90 pullResult = main.TRUE
91 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070092
Jon Hall6509dbf2016-06-21 17:01:17 -070093 main.step("Grabbing commit number")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070094 commit = main.ONOSbench.getVersion()
95 commit = (commit.split(" "))[1]
Jon Hall4ba53f02015-07-29 13:07:41 -070096
Jon Hall6509dbf2016-06-21 17:01:17 -070097 main.step("Creating results file")
YPZhange6ef82a2016-07-05 16:48:15 -070098 resultsDB = open(main.dbFileName, "w+")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070099 resultsDB.close()
100
cameron@onlab.us059c2562015-04-02 14:12:51 -0700101 # -- END OF INIT SECTION --#
cameron@onlab.usc5bf8192015-07-13 13:36:05 -0700102
Jon Hall6509dbf2016-06-21 17:01:17 -0700103 main.step("Adjusting scale")
Jon Hall4ba53f02015-07-29 13:07:41 -0700104 print str(scale)
cameron@onlab.usc5bf8192015-07-13 13:36:05 -0700105 print str(ONOSIp)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700106 clusterCount = int(scale[0])
Jon Hall4ba53f02015-07-29 13:07:41 -0700107 scale.remove(scale[0])
108
jenkins5a771992015-06-24 13:53:27 -0700109 MN1Ip = ONOSIp[len(ONOSIp) -1]
110 BENCHIp = ONOSIp[len(ONOSIp) -2]
Jon Hall4ba53f02015-07-29 13:07:41 -0700111
112 #kill off all onos processes
Jon Hall6509dbf2016-06-21 17:01:17 -0700113 main.step("Safety check, killing all ONOS processes")
114 main.step("before initiating environment setup")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700115 for node in range(maxNodes):
andrew@onlab.us10332202015-03-11 15:04:43 -0700116 main.ONOSbench.onosDie(ONOSIp[node])
Jon Hall4ba53f02015-07-29 13:07:41 -0700117
jenkins8f8f4f32015-06-24 14:05:04 -0700118 MN1Ip = ONOSIp[len(ONOSIp) -1]
119 BENCHIp = ONOSIp[len(ONOSIp) -2]
120
andrew@onlab.us10332202015-03-11 15:04:43 -0700121 #Uninstall everywhere
Jon Hall6509dbf2016-06-21 17:01:17 -0700122 main.step( "Cleaning Enviornment..." )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700123 for i in range(maxNodes):
andrew@onlab.us10332202015-03-11 15:04:43 -0700124 main.log.info(" Uninstalling ONOS " + str(i) )
125 main.ONOSbench.onosUninstall( ONOSIp[i] )
suibine1a104d2015-07-08 15:58:29 -0700126 main.log.info("Sleep 10 second for uninstall to settle...")
127 time.sleep(10)
128 main.ONOSbench.handle.sendline(" ")
129 main.ONOSbench.handle.expect(":~")
Jon Hall4ba53f02015-07-29 13:07:41 -0700130
cameron@onlab.us059c2562015-04-02 14:12:51 -0700131 #construct the cell file
132 main.log.info("Creating cell file")
133 cellIp = []
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700134 for node in range (clusterCount):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700135 cellIp.append(ONOSIp[node])
Jon Hall4ba53f02015-07-29 13:07:41 -0700136
cameron@onlab.usc5bf8192015-07-13 13:36:05 -0700137 main.ONOSbench.createCellFile("localhost",cellName,MN1Ip,str(Apps), cellIp)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700138
139 main.step( "Set Cell" )
140 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800141
jenkins3af0cd82015-03-24 10:27:16 -0700142 myDistribution = []
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700143 for node in range (clusterCount):
144 myDistribution.append(numSwitches[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800145
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800146 main.step( "Creating ONOS package" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700147 packageResult = main.ONOSbench.onosPackage()
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800148
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800149 main.step( "verify cells" )
150 verifyCellResult = main.ONOSbench.verifyCell()
Jon Hall4ba53f02015-07-29 13:07:41 -0700151
cameron@onlab.us059c2562015-04-02 14:12:51 -0700152 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700153 for node in range(clusterCount):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700154 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700155 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700156
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700157 for node in range(clusterCount):
andrew@onlab.us10332202015-03-11 15:04:43 -0700158 for i in range( 2 ):
159 isup = main.ONOSbench.isup( ONOSIp[node] )
160 if isup:
161 main.log.info("ONOS " + str(node) + " is up\n")
162 break
163 if not isup:
164 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700165 main.log.info("Startup sequence complete")
166
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700167 time.sleep(20)
168
YPZhangf1153fb2016-04-26 10:58:56 -0700169 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled " + str(flowRuleBU))
suibin zhangd1f03802016-02-25 11:48:58 -0800170 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.net.intent.impl.IntentManager", "skipReleaseResourcesOnWithdrawal " + skipRelRsrc)
YPZhange6ef82a2016-07-05 16:48:15 -0700171 if main.flowObj:
172 main.step("Set Intent Compiler use Flow Object")
173 stepResult = utilities.retry(main.ONOSbench.onosCfgSet,
174 main.FALSE,
175 args=[ONOSIp[0],
176 "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
177 "useFlowObjectives true"],
178 sleep=3,
179 attempts=3)
180 utilities.assert_equals(expect=main.TRUE,
181 actual=stepResult,
182 onpass="Successfully set Intent compiler use Flow object",
183 onfail="Failed to set up")
Jon Hall4ba53f02015-07-29 13:07:41 -0700184 devices = int(clusterCount)*10
cameron@onlab.useae03dc2015-07-29 11:51:28 -0700185
Jon Hall6509dbf2016-06-21 17:01:17 -0700186 main.step("Setting up null provider")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700187 for i in range(3):
cameron@onlab.useae03dc2015-07-29 11:51:28 -0700188 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(devices))
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700189 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
190 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "enabled true")
191 time.sleep(5)
192
193 main.ONOSbench.handle.sendline("onos $OC1 summary")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700194 main.ONOSbench.handle.expect(":~")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700195
196 before = main.ONOSbench.handle.before
cameron@onlab.useae03dc2015-07-29 11:51:28 -0700197 if ("devices=" + str(devices)) in before:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700198 break
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700199
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700200 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
201 main.ONOSbench.handle.expect(":~")
202 print main.ONOSbench.handle.before
You Wang3b148ea2016-06-20 20:33:42 -0700203 time.sleep(5)
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700204
GlennRCf9ef27d2015-09-16 12:08:38 -0700205 for i in range(3):
206 passed = main.ONOSbench.verifySummary( ONOSIp[0] )
207 if passed:
208 main.log.info("Clusters have converged")
andrew@onlab.us10332202015-03-11 15:04:43 -0700209 break
GlennRCf9ef27d2015-09-16 12:08:38 -0700210 else:
211 main.log.error("Clusters have not converged, retying...")
212 time.sleep(3)
213
jenkins50379942015-06-19 13:36:43 -0700214 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
GlennRCf9ef27d2015-09-16 12:08:38 -0700215
Jon Hall4ba53f02015-07-29 13:07:41 -0700216 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700217 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800218 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700219 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700220 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700221 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700222 import os.path
223
224 global currentNeighbors
225 neighbors = []
226
227 try:
228 currentNeighbors
229 except:
230 currentNeighbors = "0"
231 neighbors = ['0']
232 else:
233 if currentNeighbors == "r": #reset
234 currentNeighbors = "a"
235 neighbors = ['0']
236 else:
Jon Hall4ba53f02015-07-29 13:07:41 -0700237 currentNeighbors = "r"
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700238 neighbors = ['a']
239
240 if clusterCount == 1:
241 currentNeighbors = "r"
andrew@onlab.us10332202015-03-11 15:04:43 -0700242
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800243 main.log.info("Cluster Count = " + str(clusterCount))
244
andrew@onlab.us10332202015-03-11 15:04:43 -0700245 intentsRate = main.params['METRICS']['intents_rate']
246 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
247 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
248 testDuration = main.params[ 'TEST' ][ 'duration' ]
249 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
250 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700251 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
252 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
Jon Hall4ba53f02015-07-29 13:07:41 -0700253 #neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700254 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700255
Jon Hall4ba53f02015-07-29 13:07:41 -0700256 for n in range(0, len(neighbors)):
257 if neighbors[n] == 'a':
cameron@onlab.us059c2562015-04-02 14:12:51 -0700258 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700259 if int(clusterCount) == 1:
260 neighbors = neighbors.pop()
Jon Hall4ba53f02015-07-29 13:07:41 -0700261
cameron@onlab.us059c2562015-04-02 14:12:51 -0700262 for n in neighbors:
Jon Hall4ba53f02015-07-29 13:07:41 -0700263 main.log.info("Run with " + n + " neighbors")
cameron@onlab.us059c2562015-04-02 14:12:51 -0700264 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700265 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700266 main.ONOSbench.handle.expect(":~")
Jon Hall4ba53f02015-07-29 13:07:41 -0700267 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700268 main.ONOSbench.handle.expect(":~")
269 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
270 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700271
cameron@onlab.us059c2562015-04-02 14:12:51 -0700272 cmd = "onos $OC1 intent-perf-start"
273 main.ONOSbench.handle.sendline(cmd)
274 main.ONOSbench.handle.expect(":~")
275 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700276
cameron@onlab.us059c2562015-04-02 14:12:51 -0700277 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
278 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700279
cameron@onlab.us059c2562015-04-02 14:12:51 -0700280 while time.time() < stop:
281 time.sleep( float( logInterval ) )
282 groupResult = []
283 for node in range (1, clusterCount + 1):
284 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700285
GlennRCb0773152015-09-13 21:02:11 -0700286 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "Throughput:" | tail -1 """
cameron@onlab.us059c2562015-04-02 14:12:51 -0700287 main.log.info("COMMAND: " + str(cmd))
288
289 x = 0
290 while True:
291 main.ONOSbench.handle.sendline(cmd)
jenkins50379942015-06-19 13:36:43 -0700292 time.sleep(6)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700293 main.ONOSbench.handle.expect(":~")
294 raw = main.ONOSbench.handle.before
295 if "OVERALL=" in raw:
296 break
297 x += 1
298 if x > 10:
299 main.log.error("Expected output not being recieved... continuing")
300 break
301 time.sleep(2)
302
303 raw = raw.splitlines()
304 splitResults = []
305 for line in raw:
306 splitResults.extend(line.split(" "))
307
308 myResult = "--"
309 for field in splitResults:
310 if "OVERALL" in field:
311 myResult = field
312
313 if myResult == "--":
314 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
315
316 myResult = myResult.replace(";", "")
317 myResult = myResult.replace("OVERALL=","")
318 myResult = float(myResult)
319 groupResult[len(groupResult) -1] = myResult
320
321 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
322
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700323 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700324 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700325 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700326
cameron@onlab.us059c2562015-04-02 14:12:51 -0700327 cmd = "onos $OC1 intent-perf-stop"
328 main.ONOSbench.handle.sendline(cmd)
329 main.ONOSbench.handle.expect(":~")
330 main.log.info("Stopping intentperf" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700331
YPZhange6ef82a2016-07-05 16:48:15 -0700332 with open(main.dbFileName, "a") as resultsDB:
GlennRC47736b82015-09-16 14:27:51 -0700333 for node in groupResult:
334 resultString = "'" + commit + "',"
335 resultString += "'1gig',"
336 resultString += str(clusterCount) + ","
337 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
338 resultString += n + ","
339 resultString += str(node) + ","
340 resultString += str(0) + "\n" #no stddev
341 resultsDB.write(resultString)
Jon Hall4ba53f02015-07-29 13:07:41 -0700342
343 resultsDB.close()
344
345 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700346