blob: 1a6e3ab6247d6a0e2b9acdce12689ecd84b20182 [file] [log] [blame]
YPZhang737d0012016-03-24 13:56:24 -07001# ScaleOutTemplate
2#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
8import os.path
9import time
10
11
12class SCPFintentEventTpWithFlowObj:
13
14 def __init__( self ):
15 self.default = ''
16
17 def CASE1( self, main ):
18 import sys
19 import os.path
20 import time
21
22 global init
23 try:
24 if type(init) is not bool:
25 init = False
26 except NameError:
27 init = False
28
29 #Load values from params file
30 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
31 gitPull = main.params[ 'GIT' ][ 'autopull' ]
32 cellName = main.params[ 'ENV' ][ 'cellName' ]
33 Apps = main.params[ 'ENV' ][ 'cellApps' ]
34 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
35 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
36 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
37 maxNodes = int(main.params[ 'max' ])
38 main.maxNodes = maxNodes
39 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
40 cellName = main.params[ 'ENV' ][ 'cellName' ]
41 numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
42 flowRuleBU = main.params[ 'TEST' ][ 'flowRuleBUEnabled' ]
43 skipRelRsrc = main.params[ 'TEST'][ 'skipReleaseResourcesOnWithdrawal']
44 homeDir = os.path.expanduser('~')
45
46 main.exceptions = [0]*11
47 main.warnings = [0]*11
48 main.errors = [0]*11
49
50 # -- 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
56 global commit
57
58 clusterCount = 0
59 ONOSIp = main.ONOSbench.getOnosIps()
60 print ONOSIp
61 print main.ONOSbench.onosIps.values()
62
63 scale = (main.params[ 'SCALE' ]).split(",")
64 clusterCount = int(scale[0])
65
66 #Populate ONOSIp with ips from params
67 ONOSIp.extend(main.ONOSbench.getOnosIps())
68
69 #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" )
83
Jon Hall6509dbf2016-06-21 17:01:17 -070084 main.step("Grabbing commit number")
YPZhang737d0012016-03-24 13:56:24 -070085 commit = main.ONOSbench.getVersion()
86 commit = (commit.split(" "))[1]
87
Jon Hall6509dbf2016-06-21 17:01:17 -070088 main.step("Creating results file")
YPZhang737d0012016-03-24 13:56:24 -070089 # Create results file with flow object
90 flowObjResultsDB = open("/tmp/IntentEventTPflowObjDB", "w+")
91 flowObjResultsDB.close()
92
93 # -- END OF INIT SECTION --#
94
Jon Hall6509dbf2016-06-21 17:01:17 -070095 main.step("Adjusting scale")
YPZhang737d0012016-03-24 13:56:24 -070096 print str(scale)
97 print str(ONOSIp)
98 clusterCount = int(scale[0])
99 scale.remove(scale[0])
100
101 MN1Ip = ONOSIp[len(ONOSIp) -1]
102 BENCHIp = ONOSIp[len(ONOSIp) -2]
103
104 #kill off all onos processes
Jon Hall6509dbf2016-06-21 17:01:17 -0700105 main.step("Safety check, killing all ONOS processes")
106 main.step("before initiating environment setup")
YPZhang737d0012016-03-24 13:56:24 -0700107 for node in range(maxNodes):
108 main.ONOSbench.onosDie(ONOSIp[node])
109
110 MN1Ip = ONOSIp[len(ONOSIp) -1]
111 BENCHIp = ONOSIp[len(ONOSIp) -2]
112
113 #Uninstall everywhere
Jon Hall6509dbf2016-06-21 17:01:17 -0700114 main.step( "Cleaning Enviornment..." )
YPZhang737d0012016-03-24 13:56:24 -0700115 for i in range(maxNodes):
116 main.log.info(" Uninstalling ONOS " + str(i) )
117 main.ONOSbench.onosUninstall( ONOSIp[i] )
118 main.log.info("Sleep 10 second for uninstall to settle...")
119 time.sleep(10)
120 main.ONOSbench.handle.sendline(" ")
121 main.ONOSbench.handle.expect(":~")
122
123 #construct the cell file
124 main.log.info("Creating cell file")
125 cellIp = []
126 for node in range (clusterCount):
127 cellIp.append(ONOSIp[node])
128
129 main.ONOSbench.createCellFile("localhost",cellName,MN1Ip,str(Apps), cellIp)
130
131 main.step( "Set Cell" )
132 main.ONOSbench.setCell(cellName)
133
134 myDistribution = []
135 for node in range (clusterCount):
136 myDistribution.append(numSwitches[node])
137
138 main.step( "Creating ONOS package" )
139 packageResult = main.ONOSbench.onosPackage()
140
141 main.step( "verify cells" )
142 verifyCellResult = main.ONOSbench.verifyCell()
143
144 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
145 for node in range(clusterCount):
146 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
147 main.ONOSbench.onosInstall( ONOSIp[node])
148
149 for node in range(clusterCount):
150 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!" )
157 main.log.info("Startup sequence complete")
158
159 time.sleep(20)
160
YPZhangf1153fb2016-04-26 10:58:56 -0700161 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled " + str(flowRuleBU))
YPZhang737d0012016-03-24 13:56:24 -0700162 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.net.intent.impl.IntentManager", "skipReleaseResourcesOnWithdrawal " + skipRelRsrc)
163 devices = int(clusterCount)*10
164
Jon Hall6509dbf2016-06-21 17:01:17 -0700165 main.step("Setting up null provider")
YPZhang737d0012016-03-24 13:56:24 -0700166 for i in range(3):
167 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(devices))
168 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
169 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "enabled true")
170 time.sleep(5)
171
172 main.ONOSbench.handle.sendline("onos $OC1 summary")
173 main.ONOSbench.handle.expect(":~")
174
175 before = main.ONOSbench.handle.before
176 if ("devices=" + str(devices)) in before:
177 break
178
179 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
180 main.ONOSbench.handle.expect(":~")
181 print main.ONOSbench.handle.before
182
183 for i in range(3):
184 passed = main.ONOSbench.verifySummary( ONOSIp[0] )
185 if passed:
186 main.log.info("Clusters have converged")
187 break
188 else:
189 main.log.error("Clusters have not converged, retying...")
190 time.sleep(3)
191
192 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
193
194 def CASE2( self, main ):
195 import time
196 import json
197 import string
198 import csv
199 import numpy
200 import os.path
201
202 global currentNeighbors
203 neighbors = []
204
205 try:
206 currentNeighbors
207 except:
208 currentNeighbors = "0"
209 neighbors = ['0']
210 else:
211 if currentNeighbors == "r": #reset
212 currentNeighbors = "a"
213 neighbors = ['0']
214 else:
215 currentNeighbors = "r"
216 neighbors = ['a']
217
218 if clusterCount == 1:
219 currentNeighbors = "r"
220
221 main.log.info("Cluster Count = " + str(clusterCount))
222
223 intentsRate = main.params['METRICS']['intents_rate']
224 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
225 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
226 testDuration = main.params[ 'TEST' ][ 'duration' ]
227 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
228 debug = main.params[ 'debugMode' ]
229 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
230 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
231 #neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
232 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
233
234 for n in range(0, len(neighbors)):
235 if neighbors[n] == 'a':
236 neighbors[n] = str(clusterCount -1)
237 if int(clusterCount) == 1:
238 neighbors = neighbors.pop()
239
240 for n in neighbors:
241 main.log.info("Run with " + n + " neighbors")
242 time.sleep(5)
243 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
244 main.ONOSbench.handle.expect(":~")
245 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
246 main.ONOSbench.handle.expect(":~")
247 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
248 main.ONOSbench.handle.expect(":~")
249
250 cmd = "onos $OC1 intent-perf-start"
251 main.ONOSbench.handle.sendline(cmd)
252 main.ONOSbench.handle.expect(":~")
253 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
254
255 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
256 stop = time.time() + float( testDuration )
257
258 while time.time() < stop:
259 time.sleep( float( logInterval ) )
260 groupResult = []
261 for node in range (1, clusterCount + 1):
262 groupResult.append(0)
263
264 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "Throughput:" | tail -1 """
265 main.log.info("COMMAND: " + str(cmd))
266
267 x = 0
268 while True:
269 main.ONOSbench.handle.sendline(cmd)
270 time.sleep(6)
271 main.ONOSbench.handle.expect(":~")
272 raw = main.ONOSbench.handle.before
273 if "OVERALL=" in raw:
274 break
275 x += 1
276 if x > 10:
277 main.log.error("Expected output not being recieved... continuing")
278 break
279 time.sleep(2)
280
281 raw = raw.splitlines()
282 splitResults = []
283 for line in raw:
284 splitResults.extend(line.split(" "))
285
286 myResult = "--"
287 for field in splitResults:
288 if "OVERALL" in field:
289 myResult = field
290
291 if myResult == "--":
292 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
293
294 myResult = myResult.replace(";", "")
295 myResult = myResult.replace("OVERALL=","")
296 myResult = float(myResult)
297 groupResult[len(groupResult) -1] = myResult
298
299 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
300
301 clusterTotal = str(numpy.sum(groupResult))
302 main.log.report("Results from this round of polling: " + str(groupResult))
303 main.log.report("Cluster Total: " + clusterTotal + "\n")
304
305 cmd = "onos $OC1 intent-perf-stop"
306 main.ONOSbench.handle.sendline(cmd)
307 main.ONOSbench.handle.expect(":~")
308 main.log.info("Stopping intentperf" )
YPZhang8ee4a652016-03-30 12:18:27 -0700309
YPZhang737d0012016-03-24 13:56:24 -0700310 with open("/tmp/IntentEventTPflowObjDB", "a") as resultsDB:
311 for node in groupResult:
312 resultString = "'" + commit + "',"
313 resultString += "'1gig',"
314 resultString += str(clusterCount) + ","
315 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
316 resultString += n + ","
317 resultString += str(node) + ","
318 resultString += str(0) + "\n" #no stddev
319 resultsDB.write(resultString)
320 resultsDB.close()
YPZhang737d0012016-03-24 13:56:24 -0700321 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
YPZhang8ee4a652016-03-30 12:18:27 -0700322
YPZhang737d0012016-03-24 13:56:24 -0700323 def CASE3( self, main ):
YPZhang8ee4a652016-03-30 12:18:27 -0700324 main.step("Set Intent Compiler use Flow Object")
325 stepResult = utilities.retry( main.ONOSbench.onosCfgSet,
326 main.FALSE,
YPZhange589beb2016-04-11 11:47:07 -0700327 args=[ ONOSIp[0],
YPZhang8ee4a652016-03-30 12:18:27 -0700328 "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
329 "useFlowObjectives true" ],
330 sleep=3,
331 attempts=3 )
332 utilities.assert_equals( expect = main.TRUE,
333 actual = stepResult,
334 onpass = "Successfully set Intent compiler use Flow object",
335 onfail = "Failed to set up" )