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