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