blob: 2fafc1e589d74ac7f49ef5488415d624484f5ab2 [file] [log] [blame]
GlennRCb3202c52015-08-24 14:43:30 -07001
2# This is a performance scale intent that test onos to see how many intents can
3# be installed and rerouted using the null provider and mininet.
4
5class SCPFmaxIntents:
6
7 def __init__( self ):
8 self.default = ''
9
10 def CASE0( self, main ):
11 import time
12 import os
13 import imp
14
15 """
16 - Construct tests variables
17 - GIT ( optional )
18 - Checkout ONOS master branch
19 - Pull latest ONOS code
20 - Building ONOS ( optional )
21 - Install ONOS package
22 - Build ONOS package
GlennRCec6c7612015-08-31 14:52:10 -070023 - Set up cell
24 - Create cell file
25 - Set cell file
26 - Verify cell file
27 - Kill ONOS process
GlennRCb3202c52015-08-24 14:43:30 -070028 """
29
30 main.case( "Constructing test variables and building ONOS package" )
31 main.step( "Constructing test variables" )
32 stepResult = main.FALSE
33
34 # Test variables
35 main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
36 main.dependencyPath = main.testOnDirectory + \
37 main.params['DEPENDENCY']['path']
38 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
39 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
40 gitBranch = main.params[ 'GIT' ][ 'branch' ]
41 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
42 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
43 main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
44 main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
45 main.timeout = int(main.params['SLEEP']['timeout'])
46 main.minIntents = int(main.params['TEST']['min_intents'])
GlennRC9882f352015-08-27 18:03:28 -070047 main.maxIntents = int(main.params['TEST']['max_intents'])
GlennRCb3202c52015-08-24 14:43:30 -070048 main.checkInterval = int(main.params['TEST']['check_interval'])
49 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
50 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
51 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
52 main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
53 main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
54 main.rerouteSleep = int ( main.params['SLEEP']['reroute'] )
55 gitPull = main.params[ 'GIT' ][ 'pull' ]
56 main.batchSize = int(main.params['TEST']['batch_size'])
57 main.cellData = {} # for creating cell file
58 main.CLIs = []
59 main.ONOSip = []
60 main.maxNumBatch = 0
61
62 main.ONOSip = main.ONOSbench.getOnosIps()
63 main.log.info(main.ONOSip)
64
GlennRCec6c7612015-08-31 14:52:10 -070065 # main.scale[ 0 ] determines the current number of ONOS controller
66 main.numCtrls = int( main.scale[ 0 ] )
67
GlennRCb3202c52015-08-24 14:43:30 -070068 # Assigning ONOS cli handles to a list
69 for i in range( 1, main.maxNodes + 1 ):
70 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
71
72 # -- INIT SECTION, ONLY RUNS ONCE -- #
73 main.startUp = imp.load_source( wrapperFile1,
74 main.dependencyPath +
75 wrapperFile1 +
76 ".py" )
77
78 main.intentFunctions = imp.load_source( wrapperFile2,
79 main.dependencyPath +
80 wrapperFile2 +
81 ".py" )
82
83 copyResult = main.ONOSbench.copyMininetFile( main.topology,
84 main.dependencyPath,
85 main.Mininet1.user_name,
86 main.Mininet1.ip_address )
87
88 if main.CLIs:
89 stepResult = main.TRUE
90 else:
91 main.log.error( "Did not properly created list of ONOS CLI handle" )
92 stepResult = main.FALSE
93
94 utilities.assert_equals( expect=main.TRUE,
95 actual=stepResult,
96 onpass="Successfully construct " +
97 "test variables ",
98 onfail="Failed to construct test variables" )
99
100 if gitPull == 'True':
101 main.step( "Building ONOS in " + gitBranch + " branch" )
102 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
103 stepResult = onosBuildResult
104 utilities.assert_equals( expect=main.TRUE,
105 actual=stepResult,
106 onpass="Successfully compiled " +
107 "latest ONOS",
108 onfail="Failed to compile " +
109 "latest ONOS" )
110 else:
111 main.log.warn( "Did not pull new code so skipping mvn " +
112 "clean install" )
113
GlennRCb3202c52015-08-24 14:43:30 -0700114 main.case( "Starting up " + str( main.numCtrls ) +
115 " node(s) ONOS cluster" )
116
117 # kill off all onos processes
118 main.log.info( "Safety check, killing all ONOS processes" +
119 " before initiating enviornment setup" )
120
121 for i in range( main.maxNodes ):
122 main.ONOSbench.onosDie( main.ONOSip[ i ] )
123
124 main.log.info( "NODE COUNT = " + str( main.numCtrls))
125
126 tempOnosIp = []
127 for i in range( main.numCtrls ):
128 tempOnosIp.append( main.ONOSip[i] )
129
130 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
131 "temp",
132 main.Mininet1.ip_address,
133 main.apps,
134 tempOnosIp )
135
136 main.step( "Apply cell to environment" )
137 cellResult = main.ONOSbench.setCell( "temp" )
138 verifyResult = main.ONOSbench.verifyCell()
139 stepResult = cellResult and verifyResult
140 utilities.assert_equals( expect=main.TRUE,
141 actual=stepResult,
142 onpass="Successfully applied cell to " + \
143 "environment",
144 onfail="Failed to apply cell to environment " )
145
146 main.step( "Creating ONOS package" )
147 packageResult = main.ONOSbench.onosPackage()
148 stepResult = packageResult
149 utilities.assert_equals( expect=main.TRUE,
150 actual=stepResult,
151 onpass="Successfully created ONOS package",
152 onfail="Failed to create ONOS package" )
153
GlennRCec6c7612015-08-31 14:52:10 -0700154 commit = main.ONOSbench.getVersion()
155 commit = commit.split(" ")[1]
156
GlennRC58ea2542015-09-02 14:23:34 -0700157 main.log.info("Creating DB file")
158 nic = main.params['DATABASE']['nic']
159 node = main.params['DATABASE']['node']
GlennRCec6c7612015-08-31 14:52:10 -0700160 try:
161 dbFileName="/tmp/MaxIntentDB"
162 dbfile = open(dbFileName, "w+")
163 temp = "'" + commit + "',"
GlennRC58ea2542015-09-02 14:23:34 -0700164 temp += "'" + nic + "',"
165 temp += str(main.numCtrls) + ","
166 temp += "'" + node + "1" + "',"
GlennRCec6c7612015-08-31 14:52:10 -0700167 dbfile.write(temp)
168 dbfile.close()
169 except IOError:
170 main.log.warn("Error opening " + dbFileName + " to write results.")
171
172 def CASE1( self, main ):
173 """
174 - Uninstall ONOS cluster
175 - Verify ONOS start up
176 - Install ONOS cluster
177 - Connect to cli
178 """
GlennRCb3202c52015-08-24 14:43:30 -0700179 main.step( "Uninstalling ONOS package" )
180 onosUninstallResult = main.TRUE
181 for i in range( main.maxNodes ):
182 onosUninstallResult = onosUninstallResult and \
183 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
184 stepResult = onosUninstallResult
185 utilities.assert_equals( expect=main.TRUE,
186 actual=stepResult,
187 onpass="Successfully uninstalled ONOS package",
188 onfail="Failed to uninstall ONOS package" )
189
190 time.sleep( main.startUpSleep )
191 main.step( "Installing ONOS package" )
192 onosInstallResult = main.TRUE
193 for i in range( main.numCtrls ):
194 onosInstallResult = onosInstallResult and \
195 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
196 stepResult = onosInstallResult
197 utilities.assert_equals( expect=main.TRUE,
198 actual=stepResult,
199 onpass="Successfully installed ONOS package",
200 onfail="Failed to install ONOS package" )
201
202 main.step( "Starting ONOS service" )
203 stopResult = main.TRUE
204 startResult = main.TRUE
205 onosIsUp = main.TRUE
206
207 for i in range( main.numCtrls ):
208 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
209 if onosIsUp == main.TRUE:
210 main.log.report( "ONOS instance is up and ready" )
211 else:
212 main.log.report( "ONOS instance may not be up, stop and " +
213 "start ONOS again " )
214 for i in range( main.numCtrls ):
215 stopResult = stopResult and \
216 main.ONOSbench.onosStop( main.ONOSip[ i ] )
217 for i in range( main.numCtrls ):
218 startResult = startResult and \
219 main.ONOSbench.onosStart( main.ONOSip[ i ] )
220 stepResult = onosIsUp and stopResult and startResult
221 utilities.assert_equals( expect=main.TRUE,
222 actual=stepResult,
223 onpass="ONOS service is ready",
224 onfail="ONOS service did not start properly" )
225
226 main.step( "Start ONOS cli" )
227 cliResult = main.TRUE
228 for i in range( main.numCtrls ):
229 cliResult = cliResult and \
230 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
231 stepResult = cliResult
232 utilities.assert_equals( expect=main.TRUE,
233 actual=stepResult,
234 onpass="Successfully start ONOS cli",
235 onfail="Failed to start ONOS cli" )
236
237 def CASE10( self, main ):
238 """
239 Setting up null-provider
240 """
241 import json
242 import pexpect
243
244 # Activate apps
245 main.log.step("Activating apps")
246 stepResult = main.CLIs[0].activateApp('org.onosproject.null')
247 utilities.assert_equals( expect=main.TRUE,
248 actual=stepResult,
249 onpass="Successfully activated null-provider",
250 onfail="Failed to activate null-provider")
251
252 # Setup the null-provider
253 main.log.step("Configuring null-provider")
254 stepResult = main.FALSE
255 for i in range(3):
256 main.ONOSbench.onosCfgSet( main.ONOSip[0],
257 'org.onosproject.provider.nil.NullProviders',
258 'deviceCount 3' )
259 main.ONOSbench.onosCfgSet( main.ONOSip[0],
260 'org.onosproject.provider.nil.NullProviders',
261 'topoShape reroute' )
262 main.ONOSbench.onosCfgSet( main.ONOSip[0],
263 'org.onosproject.provider.nil.NullProviders',
264 'enabled true' )
265 # give onos some time to settle
266 time.sleep(main.startUpSleep)
267 jsonSum = json.loads(main.CLIs[0].summary())
268 if jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1:
269 stepResult = main.TRUE
270 break
271 utilities.assert_equals( expect=stepResult,
272 actual=stepResult,
273 onpass="Successfully configured the null-provider",
274 onfail="Failed to configure the null-provider")
275
276
277 main.log.step("Get default flows")
278 jsonSum = json.loads(main.CLIs[0].summary())
279
280 # flows installed by the null-provider
281 main.defaultFlows = jsonSum["flows"]
282 main.ingress = ":0000000000000001/3"
283 main.egress = ":0000000000000003/2"
284 main.switch = "null"
285 main.linkUpCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 up"
286 main.linkDownCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 down"
287
288 def CASE11( self, main ):
289 '''
290 Setting up mininet
291 '''
292 import json
293 import time
294
295 # Activate apps
296 main.log.step("Activating apps")
297 stepResult = main.CLIs[0].activateApp('org.onosproject.openflow')
298
299 utilities.assert_equals( expect=main.TRUE,
300 actual=stepResult,
301 onpass="Successfully activated openflow",
302 onfail="Failed to activate openflow")
303 # give onos some time settle
304 time.sleep(main.startUpSleep)
305
306 main.log.step('Starting mininet topology')
307 main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py')
308 main.Mininet1.assignSwController(sw='s1', ip=main.ONOSip[0])
309 main.Mininet1.assignSwController(sw='s2', ip=main.ONOSip[0])
310 main.Mininet1.assignSwController(sw='s3', ip=main.ONOSip[0])
311 time.sleep(main.startUpSleep)
312
313 jsonSum = json.loads(main.CLIs[0].summary())
314 if jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1:
315 stepResult = main.TRUE
316
317 utilities.assert_equals( expect=stepResult,
318 actual=stepResult,
319 onpass="Successfully assigned switches to their master",
320 onfail="Failed to assign switches")
321
322 main.log.step("Get default flows")
323 jsonSum = json.loads(main.CLIs[0].summary())
324
325 # flows installed by the null-provider
326 main.defaultFlows = jsonSum["flows"]
327 main.ingress = ":0000000000000001/3"
328 main.egress = ":0000000000000003/2"
329 main.switch = "of"
330 main.linkDownCmd = 'link s1 s3 down'
331 main.linkUpCmd = 'link s1 s3 up'
332
333
334 def CASE20( self, main ):
335 import pexpect
336 '''
337 Pushing intents
338 '''
339 # the index where the next intents will be installed
340 offset = 0
341 # the number of intents we expect to be in the installed state
342 expectedIntents = 0
343 # the number of flows we expect to be in the added state
344 expectedFlows = main.defaultFlows
GlennRC9882f352015-08-27 18:03:28 -0700345 # limit for the number of intents that can be installed
346 limit = main.maxIntents / main.batchSize
GlennRCb3202c52015-08-24 14:43:30 -0700347 try:
GlennRC9882f352015-08-27 18:03:28 -0700348 for i in range(limit):
GlennRCb3202c52015-08-24 14:43:30 -0700349 # Push intents
350 main.log.step("Pushing intents")
351 stepResult = main.intentFunctions.pushIntents( main,
352 main.switch,
353 main.ingress,
354 main.egress,
355 main.batchSize,
356 offset,
357 sleep=main.installSleep,
358 timeout=main.timeout,
359 options="-i" )
360 utilities.assert_equals( expect=main.TRUE,
361 actual=stepResult,
362 onpass="Successfully pushed intents",
363 onfail="Failed to push intents")
364 if stepResult == main.FALSE:
365 break
366
367 offset += main.batchSize
368 expectedIntents = offset
369 expectedFlows += main.batchSize*2
370
371 if offset >= main.minIntents and offset % main.checkInterval == 0:
372 # Verifying intents
373 main.log.step("Verifying intents")
374 main.log.info("Expected intents: " + str(expectedIntents))
375 stepResult = main.intentFunctions.verifyIntents( main,
376 expectedIntents,
377 sleep=main.verifySleep,
378 timeout=main.timeout)
379 utilities.assert_equals( expect=main.TRUE,
380 actual=stepResult,
381 onpass="Successfully verified intents",
382 onfail="Failed to verify intents")
383
384 if stepResult == main.FALSE:
385 break
386
387 # Verfying flows
388 main.log.step("Verifying flows")
389 main.log.info("Expected Flows: " + str(expectedFlows))
390 stepResult = main.intentFunctions.verifyFlows( main,
391 expectedFlows,
392 sleep=main.verifySleep,
393 timeout=main.timeout)
394
395 utilities.assert_equals( expect=main.TRUE,
396 actual=stepResult,
397 onpass="Successfully verified flows",
398 onfail="Failed to verify flows")
399
400 if stepResult == main.FALSE:
401 break
402
403 except pexpect.TIMEOUT:
404 main.log.exception("Timeout exception caught")
405
GlennRCec6c7612015-08-31 14:52:10 -0700406 maxIntents = main.intentFunctions.getIntents( main )
407 maxFlows = main.intentFunctions.getFlows( main )
408
GlennRCb3202c52015-08-24 14:43:30 -0700409 main.log.report("Done pushing intents")
410 main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows))
GlennRCec6c7612015-08-31 14:52:10 -0700411 main.log.info("Installed intents: " + str(maxIntents) +
412 "\nAdded flows: " + str(maxFlows))
413
GlennRC58ea2542015-09-02 14:23:34 -0700414 main.log.info("Writing results to DB file")
GlennRCec6c7612015-08-31 14:52:10 -0700415 try:
416 dbFileName="/tmp/MaxIntentDB"
GlennRC58ea2542015-09-02 14:23:34 -0700417 dbfile = open(dbFileName, "a")
418 temp = str(maxIntents) + ","
GlennRC14d54f72015-09-03 10:51:37 -0700419 temp += str(maxFlows) + ","
GlennRCec6c7612015-08-31 14:52:10 -0700420 dbfile.write(temp)
421 dbfile.close()
422 except IOError:
423 main.log.warn("Error opening " + dbFileName + " to write results.")
GlennRCb3202c52015-08-24 14:43:30 -0700424
425 # Stopping mininet
426 if main.switch == "of":
427 main.log.info("Stopping mininet")
428 main.Mininet1.stopNet()
429
430 def CASE21( self, main ):
431 import pexpect
432 import time
433 '''
434 Reroute
435 '''
436 # the index where the next intents will be installed
437 offset = 0
438 # the number of intents we expect to be in the installed state
439 expectedIntents = 0
440 # the number of flows we expect to be in the added state
441 expectedFlows = main.defaultFlows
GlennRC9882f352015-08-27 18:03:28 -0700442 # limit for the number of intents that can be installed
443 limit = main.maxIntents / main.batchSize
GlennRCb3202c52015-08-24 14:43:30 -0700444 try:
GlennRC9882f352015-08-27 18:03:28 -0700445 for i in range(limit):
GlennRCb3202c52015-08-24 14:43:30 -0700446 # Push intents
447 main.log.step("Pushing intents")
448 stepResult = main.intentFunctions.pushIntents( main,
449 main.switch,
450 main.ingress,
451 main.egress,
452 main.batchSize,
453 offset,
454 sleep=main.installSleep,
455 options="-i",
456 timeout=main.timeout )
457 utilities.assert_equals( expect=main.TRUE,
458 actual=stepResult,
459 onpass="Successfully pushed intents",
460 onfail="Failed to push intents")
461 if stepResult == main.FALSE:
462 break
463
464 offset += main.batchSize
465 expectedIntents = offset
466 expectedFlows += main.batchSize*2
467
468 # Verifying intents
469 main.log.step("Verifying intents")
470 main.log.info("Expected intents: " + str(expectedIntents))
471 stepResult = main.intentFunctions.verifyIntents( main,
472 expectedIntents,
473 sleep=main.verifySleep,
474 timeout=main.timeout )
475 utilities.assert_equals( expect=main.TRUE,
476 actual=stepResult,
477 onpass="Successfully verified intents",
478 onfail="Failed to verify intents")
479
480 if stepResult == main.FALSE:
481 break
482
483 # Verfying flows
484 main.log.step("Verifying flows")
485 main.log.info("Expected Flows: " + str(expectedFlows))
486 stepResult = main.intentFunctions.verifyFlows( main,
487 expectedFlows,
488 sleep=main.verifySleep,
489 timeout=main.timeout )
490 utilities.assert_equals( expect=main.TRUE,
491 actual=stepResult,
492 onpass="Successfully verified flows",
493 onfail="Failed to verify flows")
494
495 if stepResult == main.FALSE:
496 break
497
498 # tear down a link
499 main.log.step("Tearing down link")
500 if main.switch == "of":
501 main.log.info("Sending: " + main.linkDownCmd)
502 main.Mininet1.handle.sendline(main.linkDownCmd)
503 main.Mininet1.handle.expect('mininet>')
504 else:
505 main.log.info("Sending: " + main.linkDownCmd)
506 main.CLIs[0].handle.sendline(main.linkDownCmd)
507 main.CLIs[0].handle.expect('onos>')
508 time.sleep(main.rerouteSleep)
509
510 # rerouting adds a 1000 flows
511 expectedFlows += 1000
512
513 # Verfying flows
514 main.log.step("Verifying flows")
515 main.log.info("Expected Flows: " + str(expectedFlows))
516 stepResult = main.intentFunctions.verifyFlows( main,
517 expectedFlows,
518 sleep=main.verifySleep,
519 timeout=main.timeout)
520 utilities.assert_equals( expect=main.TRUE,
521 actual=stepResult,
522 onpass="Successfully verified flows",
523 onfail="Failed to verify flows")
524
525 if stepResult == main.FALSE:
526 break
527
528 # Bring link back up
529 main.log.step("Tearing down link")
530 if main.switch == "of":
531 main.log.info("Sending: " + main.linkUpCmd)
532 main.Mininet1.handle.sendline(main.linkUpCmd)
533 main.Mininet1.handle.expect('mininet>')
534 else:
535 main.log.info("Sending: " + main.linkUpCmd)
536 main.CLIs[0].handle.sendline(main.linkUpCmd)
537 main.CLIs[0].handle.expect('onos>')
538 time.sleep(main.rerouteSleep)
539
540 except pexpect.TIMEOUT:
541 main.log.exception("Timeout exception caught")
542
GlennRCec6c7612015-08-31 14:52:10 -0700543 maxIntents = main.intentFunctions.getIntents( main )
544 maxFlows = main.intentFunctions.getFlows( main )
545
GlennRCb3202c52015-08-24 14:43:30 -0700546 main.log.report("Done pushing intents")
547 main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows))
GlennRCec6c7612015-08-31 14:52:10 -0700548 main.log.info("Installed intents: " + str(maxIntents) +
549 "\nAdded flows: " + str(maxFlows))
550
GlennRC14d54f72015-09-03 10:51:37 -0700551 try:
552 dbFileName="/tmp/MaxIntentDB"
553 dbfile = open(dbFileName, "a")
554 temp = str(maxIntents) + ","
555 temp += str(maxFlows) + "\n"
556 dbfile.write(temp)
557 dbfile.close()
558 except IOError:
559 main.log.warn("Error opening " + dbFileName + " to write results.")
560
GlennRCb3202c52015-08-24 14:43:30 -0700561 # Stopping mininet
562 if main.switch == "of":
563 main.log.info("Stopping mininet")
564 main.Mininet1.stopNet()
565
566 def CASE100( self, main ):
567 '''
568 Report errors/warnings/exceptions
569 '''
570 main.log.info("Error report: \n")
571 main.ONOSbench.logReport( main.ONOSip[ 0 ],
572 [ "INFO",
573 "FOLLOWER",
574 "WARN",
575 "flow",
576 "ERROR",
577 "Except" ],
578 "s" )