blob: 5536e6b50dc4443b79bab90058413c706a6d3761 [file] [log] [blame]
Jon Hallbc401252016-03-03 14:44:04 -08001# Testing the functionality of SDN-IP with single ONOS instance
2class DEMO_SDNIP:
3
4 def __init__( self ):
5 self.default = ''
6 global branchName
7
8 def CASE100( self, main ):
9 """
10 Start mininet
11 """
12 import imp
13 main.case( "Setup the Mininet testbed" )
14 main.log.info( "DEMO:Mininet: Setup the Mininet testbed" )
15 main.dependencyPath = main.testDir + \
16 main.params[ 'DEPENDENCY' ][ 'path' ]
17 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
18
19 main.step( "Starting Mininet Topology" )
20 topology = main.dependencyPath + main.topology
21 topoResult = main.Mininet.startNet( topoFile=topology )
22 utilities.assert_equals( expect=main.TRUE,
23 actual=topoResult,
24 onpass="Successfully loaded topology",
25 onfail="Failed to load topology" )
26 # Exit if topology did not load properly
27 if not topoResult:
28 main.cleanup()
29 main.exit()
30 main.step( "Connect switches to controllers" )
31 main.log.info( "DEMO:Mininet: Connecting switches to controllers" )
32
33 # connect all switches to controllers
34 swResult = main.TRUE
35 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
36 sw = "sw%s" % ( i )
37 swResult = swResult and main.Mininet.assignSwController( sw,
38 [ONOS1Ip, ONOS2Ip, ONOS3Ip] )
39
40 utilities.assert_equals( expect=main.TRUE,
41 actual=swResult,
42 onpass="Successfully connect all switches to ONOS",
43 onfail="Failed to connect all switches to ONOS" )
44 if not swResult:
45 main.cleanup()
46 main.exit()
47
48
49 def CASE101( self, main ):
50 """
51 Package ONOS and install it
52 Startup sequence:
53 cell <name>
54 onos-verify-cell
55 onos-package
56 onos-install -f
57 onos-wait-for-start
58 """
59 import json
60 import time
61 import os
62 from operator import eq
63
64 main.case( "Setting up ONOS environment" )
65
66 cellName = main.params[ 'ENV' ][ 'cellName' ]
67 global ONOS1Ip
68 global ONOS2Ip
69 global ONOS3Ip
70 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
71 ONOS2Ip = os.getenv( main.params[ 'CTRL' ][ 'ip2' ] )
72 ONOS3Ip = os.getenv( main.params[ 'CTRL' ][ 'ip3' ] )
73 ipList = [ ONOS1Ip, ONOS2Ip, ONOS3Ip ]
74
75 global peer64514
76 global peer64515
77 global peer64516
78 peer64514 = main.params['config']['peer64514']
79 peer64515 = main.params['config']['peer64515']
80 peer64516 = main.params['config']['peer64516']
81
82 main.step( "Create cell file" )
83 cellAppString = main.params[ 'ENV' ][ 'appString' ]
84 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
85 main.Mininet.ip_address,
86 cellAppString, ipList )
87
88 main.step( "Applying cell variable to environment" )
89 cellResult = main.ONOSbench.setCell( cellName )
90 utilities.assert_equals( expect=main.TRUE,
91 actual=cellResult,
92 onpass="Set cell succeeded",
93 onfail="Set cell failed" )
94
95 verifyResult = main.ONOSbench.verifyCell()
96 utilities.assert_equals( expect=main.TRUE,
97 actual=verifyResult,
98 onpass="Verify cell succeeded",
99 onfail="Verify cell failed" )
100
101 branchName = main.ONOSbench.getBranchName()
102 main.log.report( "ONOS is on branch: " + branchName )
103
104 main.log.step( "Stop ONOS" )
105 stopResult = main.ONOSbench.onosDie( ONOS1Ip ) \
106 and main.ONOSbench.onosDie( ONOS2Ip ) \
107 and main.ONOSbench.onosDie( ONOS3Ip )
108 utilities.assert_equals( expect=main.TRUE,
109 actual=stopResult,
110 onpass="Stop ONOS nodes succeeded",
111 onfail="Stop ONOS nodes failed" )
112
113 main.log.step( "Uninstalling ONOS" )
114 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) \
115 and main.ONOSbench.onosUninstall( ONOS2Ip ) \
116 and main.ONOSbench.onosUninstall( ONOS3Ip )
117 utilities.assert_equals( expect=main.TRUE,
118 actual=uninstallResult,
119 onpass="Uninstall ONOS from nodes succeeded",
120 onfail="Uninstall ONOS form nodes failed" )
121
122 main.ONOSbench.getVersion( report=True )
123
124 main.step( "Copying ONOS config file" )
125 # TODO: clean this up
126 main.ONOSbench.handle.sendline( "cp ~/TestON/tests/DEMO_SDNIP/Dependency/network-cfg.json ~/onos/tools/package/config/network-cfg.json" )
127 main.ONOSbench.handle.expect( "\$" )
128 main.log.debug( main.ONOSbench.handle.before )
129
130 main.step( "Creating ONOS package" )
131 if main.params[ 'ENV' ][ 'package' ] == "True":
132 packageResult = main.ONOSbench.onosPackage( opTimeout=500 )
133 utilities.assert_equals( expect=main.TRUE,
134 actual=packageResult,
135 onpass="Package ONOS succeeded",
136 onfail="Package ONOS failed" )
137
138 main.step( "Installing ONOS package" )
139 main.log.info( "DEMO:ONOS1: Installing ONOS" )
140 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
141 node=ONOS1Ip )
142 main.log.info( "DEMO:ONOS2: Installing ONOS" )
143 onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
144 node=ONOS2Ip )
145 main.log.info( "DEMO:ONOS3: Installing ONOS" )
146 onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
147 node=ONOS3Ip )
148 onosInstallResult = onos1InstallResult and onos2InstallResult \
149 and onos3InstallResult
150 utilities.assert_equals( expect=main.TRUE,
151 actual=onosInstallResult,
152 onpass="Install ONOS to nodes succeeded",
153 onfail="Install ONOS to nodes failed" )
154
155 main.step( "Checking if ONOS is up yet" )
156 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
157 onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
158 onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout=420 )
159 onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult
160 utilities.assert_equals( expect=main.TRUE,
161 actual=onosUpResult,
162 onpass="ONOS nodes are up",
163 onfail="ONOS nodes are NOT up" )
164
165 main.step( "Checking if ONOS CLI is ready" )
166 main.CLIs = []
167 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
168 commandlineTimeout=100, onosStartTimeout=600 )
169 main.CLIs.append( main.ONOScli1 )
170 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
171 commandlineTimeout=100, onosStartTimeout=600 )
172 main.CLIs.append( main.ONOScli2 )
173 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
174 commandlineTimeout=100, onosStartTimeout=600 )
175 main.CLIs.append( main.ONOScli3 )
176 cliResult = cliResult1 and cliResult2 and cliResult3
177 utilities.assert_equals( expect=main.TRUE,
178 actual=cliResult,
179 onpass="ONOS CLI is ready",
180 onfail="ONOS CLI is not ready" )
181
182 for i in range( 10 ):
183 ready = True
184 for cli in main.CLIs:
185 output = cli.summary()
186 if not output:
187 ready = False
188 if ready:
189 break
190 time.sleep( 30 )
191 utilities.assert_equals( expect=True, actual=ready,
192 onpass="ONOS summary command succeded",
193 onfail="ONOS summary command failed" )
194
195 if not ready:
196 main.log.error( "ONOS startup failed!" )
197 main.cleanup()
198 main.exit()
199
200 def CASE200( self, main ):
201 main.case( "Activate sdn-ip application" )
202 main.log.info( "waiting link discovery......" )
203 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
204
205 main.log.info( "Get links in the network" )
206 summaryResult = main.ONOScli1.summary()
207 linkNum = json.loads( summaryResult )[ "links" ]
208 listResult = main.ONOScli1.links( jsonFormat=False )
209 main.log.info( listResult )
210 if linkNum < 100:
211 main.log.error( "Link number is wrong!" )
212 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
213 listResult = main.ONOScli1.links( jsonFormat=False )
214 main.log.info( listResult )
215 main.cleanup()
216 main.exit()
217
218 main.step( "Activate sdn-ip application" )
219 main.log.info( "DEMO:ONOS1: Activate sdn-ip application" )
220 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
221 utilities.assert_equals( expect=main.TRUE,
222 actual=activeSDNIPresult,
223 onpass="Activate SDN-IP succeeded",
224 onfail="Activate SDN-IP failed" )
225 if not activeSDNIPresult:
226 main.log.info( "Activate SDN-IP failed!" )
227 main.cleanup()
228 main.exit()
229
230
231 def CASE102( self, main ):
232 '''
233 This test case is to load the methods from other Python files, and create
234 tunnels from mininet host to onos nodes.
235 '''
236 import time
237 main.case( "Load methods from other Python file and create tunnels" )
238 # load the methods from other file
239 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
240 main.Functions = imp.load_source( wrapperFile1,
241 main.dependencyPath +
242 wrapperFile1 +
243 ".py" )
244 # Create tunnels
245 main.log.info( "DEMO:Mininet: Creating tunnels between bgp speakers" )
246 # ONOS1
247 main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
248 # ONOS2
249 main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
250 # ONOS3
251 main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
252
253 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
254 and the BGP paths in data plane are ready..." )
255 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
256
257 main.log.info( "Wait Quagga to finish delivery all routes to each \
258 other and to sdn-ip, plus finish installing all intents..." )
259 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
260
261 def CASE1( self, main ):
262 '''
263 ping test from 3 bgp peers to BGP speaker
264 '''
265
266 main.case( "Ping between BGP peers and speakers" )
267 main.log.info( "DEMO:Mininet: Ping between bgp peers and speakers" )
268 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
269 peers=["peer64514", "peer64515", "peer64516"],
270 expectAllSuccess=True )
271 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
272 peers=[peer64514, peer64515, peer64516],
273 expectAllSuccess=True )
274 main.stop()
275
276
277 def CASE2( self, main ):
278 '''
279 point-to-point intents test for each BGP peer and BGP speaker pair
280 '''
281 import time
282 main.case( "Check point-to-point intents" )
283 main.log.info( "DEMO:ONOS1: Verify Point-to-Point intents" )
284 main.log.info( "There are %s BGP peers in total "
285 % main.params[ 'config' ][ 'peerNum' ] )
286 main.step( "Check P2P intents number from ONOS CLI" )
287
288 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
289 bgpIntentsActualNum = \
290 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
291 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 3
292 if bgpIntentsActualNum != bgpIntentsExpectedNum:
293 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
294 bgpIntentsActualNum = \
295 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
296 main.log.info( "bgpIntentsExpected num is:" )
297 main.log.info( bgpIntentsExpectedNum )
298 main.log.info( "bgpIntentsActual num is:" )
299 main.log.info( bgpIntentsActualNum )
300 utilities.assertEquals( \
301 expect=True,
302 actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
303 onpass="PointToPointIntent Intent Num is correct!",
304 onfail="PointToPointIntent Intent Num is wrong!" )
305
306
307 def CASE3( self, main ):
308 '''
309 routes and intents check to all BGP peers
310 '''
311 import time
312 main.case( "Check routes and M2S intents to all BGP peers" )
313 main.log.info( "DEMO:ONOS1: Check BGP routes and Multi-point intents" )
314
315 allRoutesExpected = []
316 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
317 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
318 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
319
320 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
321 allRoutesActual = \
322 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
323 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
324 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
325 if allRoutesStrActual != allRoutesStrExpected:
326 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
327 allRoutesActual = \
328 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
329 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
330
331 main.step( "Check routes installed" )
332 main.log.info( "Routes expected:" )
333 main.log.info( allRoutesStrExpected )
334 main.log.info( "Routes get from ONOS CLI:" )
335 main.log.info( allRoutesStrActual )
336 utilities.assertEquals( \
337 expect=allRoutesStrExpected, actual=allRoutesStrActual,
338 onpass="Routes are correct!",
339 onfail="Routes are wrong!" )
340
341 main.step( "Check M2S intents installed" )
342 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
343 routeIntentsActualNum = \
344 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
345 routeIntentsExpectedNum = 3
346 if routeIntentsActualNum != routeIntentsExpectedNum:
347 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
348 routeIntentsActualNum = \
349 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
350
351 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
352 main.log.info( routeIntentsExpectedNum )
353 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
354 main.log.info( routeIntentsActualNum )
355 utilities.assertEquals( \
356 expect=routeIntentsExpectedNum,
357 actual=routeIntentsActualNum,
358 onpass="MultiPointToSinglePoint Intent Num is correct!",
359 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
360
361 main.step( "Check whether all flow status are ADDED" )
362 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
363 main.FALSE,
364 kwargs={'isPENDING':False},
365 attempts=10 )
366 utilities.assertEquals( \
367 expect=main.TRUE,
368 actual=flowCheck,
369 onpass="Flow status is correct!",
370 onfail="Flow status is wrong!" )
371
372
373 def CASE4( self, main ):
374 '''
375 Ping test in data plane for each route
376 '''
377 main.case( "Ping test for each route, all hosts behind BGP peers" )
378 main.log.info( "DEMO:Mininet: Pinging across BGP routes" )
379 main.Functions.pingHostToHost( main,
380 hosts=["host64514", "host64515", "host64516"],
381 expectAllSuccess=True )
382
383
384 def CASE5( self, main ):
385 '''
386 Cut links to peers one by one, check routes/intents
387 '''
388 import time
389 main.case( "Bring down links and check routes/intents" )
390 main.log.info( "DEMO:Mininet: Bringing down links between Quagga and the network" )
391 main.step( "Bring down the link between sw32 and peer64514" )
392 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
393 OPTION="down" )
394 utilities.assertEquals( expect=main.TRUE,
395 actual=linkResult1,
396 onpass="Bring down link succeeded!",
397 onfail="Bring down link failed!" )
398
399 if linkResult1 == main.TRUE:
400 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
401 main.log.debug( main.ONOScli1.links() ) #FIXME: DEBUG
402 main.Functions.checkRouteNum( main, 2 )
403 main.Functions.checkM2SintentNum( main, 2 )
404 else:
405 main.log.error( "Bring down link failed!" )
406 main.cleanup()
407 main.exit()
408
409 main.step( "Bring down the link between sw8 and peer64515" )
410 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
411 OPTION="down" )
412 utilities.assertEquals( expect=main.TRUE,
413 actual=linkResult2,
414 onpass="Bring down link succeeded!",
415 onfail="Bring down link failed!" )
416 if linkResult2 == main.TRUE:
417 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
418 main.Functions.checkRouteNum( main, 1 )
419 main.Functions.checkM2SintentNum( main, 1 )
420 else:
421 main.log.error( "Bring down link failed!" )
422 main.cleanup()
423 main.exit()
424
425 main.step( "Bring down the link between sw28 and peer64516" )
426 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
427 OPTION="down" )
428 utilities.assertEquals( expect=main.TRUE,
429 actual=linkResult3,
430 onpass="Bring down link succeeded!",
431 onfail="Bring down link failed!" )
432 if linkResult3 == main.TRUE:
433 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
434 main.Functions.checkRouteNum( main, 0 )
435 main.Functions.checkM2SintentNum( main, 0 )
436 else:
437 main.log.error( "Bring down link failed!" )
438 main.cleanup()
439 main.exit()
440
441 main.step( "Check whether all flow status are ADDED" )
442 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
443 main.FALSE,
444 kwargs={'isPENDING':False},
445 attempts=10 )
446 utilities.assertEquals( \
447 expect=main.TRUE,
448 actual=flowCheck,
449 onpass="Flow status is correct!",
450 onfail="Flow status is wrong!" )
451
452 # Ping test
453 main.log.info( "DEMO:Mininet: Verify lost connectivity across routes" )
454 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
455 peers=["peer64514", "peer64515", "peer64516"],
456 expectAllSuccess=False )
457 main.Functions.pingHostToHost( main,
458 hosts=["host64514", "host64515", "host64516"],
459 expectAllSuccess=False )
460
461
462 def CASE6( self, main ):
463 '''
464 Recover links to peers one by one, check routes/intents
465 '''
466 import time
467 main.case( "Bring up links and check routes/intents" )
468 main.step( "Bring up the link between sw32 and peer64514" )
469 main.log.info( "DEMO:Mininet: Bring back up links between Quagga and the network" )
470 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
471 OPTION="up" )
472 utilities.assertEquals( expect=main.TRUE,
473 actual=linkResult1,
474 onpass="Bring up link succeeded!",
475 onfail="Bring up link failed!" )
476 if linkResult1 == main.TRUE:
477 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
478 main.Functions.checkRouteNum( main, 1 )
479 main.Functions.checkM2SintentNum( main, 1 )
480 else:
481 main.log.error( "Bring up link failed!" )
482 main.cleanup()
483 main.exit()
484
485 main.step( "Bring up the link between sw8 and peer64515" )
486 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
487 OPTION="up" )
488 utilities.assertEquals( expect=main.TRUE,
489 actual=linkResult2,
490 onpass="Bring up link succeeded!",
491 onfail="Bring up link failed!" )
492 if linkResult2 == main.TRUE:
493 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
494 main.Functions.checkRouteNum( main, 2 )
495 main.Functions.checkM2SintentNum( main, 2 )
496 else:
497 main.log.error( "Bring up link failed!" )
498 main.cleanup()
499 main.exit()
500
501 main.step( "Bring up the link between sw28 and peer64516" )
502 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
503 OPTION="up" )
504 utilities.assertEquals( expect=main.TRUE,
505 actual=linkResult3,
506 onpass="Bring up link succeeded!",
507 onfail="Bring up link failed!" )
508 if linkResult3 == main.TRUE:
509 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
510 main.Functions.checkRouteNum( main, 3 )
511 main.Functions.checkM2SintentNum( main, 3 )
512 else:
513 main.log.error( "Bring up link failed!" )
514 main.cleanup()
515 main.exit()
516
517 main.step( "Check whether all flow status are ADDED" )
518 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
519 main.FALSE,
520 kwargs={'isPENDING':False},
521 attempts=10 )
522 utilities.assertEquals( \
523 expect=main.TRUE,
524 actual=flowCheck,
525 onpass="Flow status is correct!",
526 onfail="Flow status is wrong!" )
527
528 # Ping test
529 main.log.info( "DEMO:Mininet: Verify connectivity is restored across routes" )
530 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
531 peers=["peer64514", "peer64515", "peer64516"],
532 expectAllSuccess=True )
533 main.Functions.pingHostToHost( main,
534 hosts=["host64514", "host64515", "host64516"],
535 expectAllSuccess=True )
536
537
538 def CASE7( self, main ):
539 '''
540 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
541 '''
542 import time
543 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
544 main.step( "Stop sw32" )
545 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
546 utilities.assertEquals( expect=main.TRUE, actual=result,
547 onpass="Stopping switch succeeded!",
548 onfail="Stopping switch failed!" )
549
550 if result == main.TRUE:
551 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
552 main.Functions.checkRouteNum( main, 2 )
553 main.Functions.checkM2SintentNum( main, 2 )
554 main.Functions.checkP2PintentNum( main, 12 * 2 )
555 else:
556 main.log.error( "Stopping switch failed!" )
557 main.cleanup()
558 main.exit()
559
560 main.step( "Check ping between hosts behind BGP peers" )
561 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
562 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
563 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
564
565 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
566 and ( result3 == main.FALSE )
567 utilities.assert_equals( expect=True, actual=pingResult1,
568 onpass="Ping test result is correct",
569 onfail="Ping test result is wrong" )
570
571 if pingResult1 == False:
572 main.cleanup()
573 main.exit()
574
575 main.step( "Check ping between BGP peers and speaker1" )
576 result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" )
577 result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" )
578 result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" )
579
580 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
581 and ( result6 == main.TRUE )
582 utilities.assert_equals( expect=True, actual=pingResult2,
583 onpass="Speaker1 ping peers successful",
584 onfail="Speaker1 ping peers NOT successful" )
585
586 if pingResult2 == False:
587 main.cleanup()
588 main.exit()
589
590 main.step( "Check ping between BGP peers and speaker2" )
591 # TODO
592 result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 )
593 result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 )
594 result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 )
595
596 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
597 and ( result9 == main.TRUE )
598 utilities.assert_equals( expect=True, actual=pingResult2,
599 onpass="Speaker2 ping peers successful",
600 onfail="Speaker2 ping peers NOT successful" )
601
602 if pingResult3 == False:
603 main.cleanup()
604 main.exit()
605
606 main.step( "Check whether all flow status are ADDED" )
607 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
608 main.FALSE,
609 kwargs={'isPENDING':False},
610 attempts=10 )
611 utilities.assertEquals( \
612 expect=main.TRUE,
613 actual=flowCheck,
614 onpass="Flow status is correct!",
615 onfail="Flow status is wrong!" )
616
617
618 def CASE8( self, main ):
619 '''
620 Bring up the edge switch (sw32) which was shut down in CASE7,
621 check P-2-P and M-2-S intents, ping test
622 '''
623 import time
624 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
625 main.step( "Start sw32" )
626 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
627 utilities.assertEquals( \
628 expect=main.TRUE,
629 actual=result1,
630 onpass="Starting switch succeeded!",
631 onfail="Starting switch failed!" )
632
633 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
634 utilities.assertEquals( \
635 expect=main.TRUE,
636 actual=result2,
637 onpass="Connect switch to ONOS succeeded!",
638 onfail="Connect switch to ONOS failed!" )
639
640 if result1 and result2:
641 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
642 main.Functions.checkRouteNum( main, 3 )
643 main.Functions.checkM2SintentNum( main, 3 )
644 main.Functions.checkP2PintentNum( main, 18 * 2 )
645 else:
646 main.log.error( "Starting switch failed!" )
647 main.cleanup()
648 main.exit()
649
650 main.step( "Check whether all flow status are ADDED" )
651 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
652 main.FALSE,
653 kwargs={'isPENDING':False},
654 attempts=10 )
655 utilities.assertEquals( \
656 expect=main.TRUE,
657 actual=flowCheck,
658 onpass="Flow status is correct!",
659 onfail="Flow status is wrong!" )
660
661 # Ping test
662 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
663 peers=["peer64514", "peer64515", "peer64516"],
664 expectAllSuccess=True )
665 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
666 peers=[peer64514, peer64515, peer64516],
667 expectAllSuccess=True )
668 main.Functions.pingHostToHost( main,
669 hosts=["host64514", "host64515", "host64516"],
670 expectAllSuccess=True )
671
672
673 def CASE9( self, main ):
674 '''
675 Bring down a switch in best path, check:
676 route number, P2P intent number, M2S intent number, ping test
677 '''
678 main.case( "Stop sw11 located in best path, \
679 check route number, P2P intent number, M2S intent number, ping test" )
680
681 main.log.info( "Check the flow number correctness before stopping sw11" )
682 main.Functions.checkFlowNum( main, "sw11", 19 )
683 main.Functions.checkFlowNum( main, "sw1", 3 )
684 main.Functions.checkFlowNum( main, "sw7", 3 )
685
686 main.step( "Stop sw11" )
687 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
688 utilities.assertEquals( expect=main.TRUE, actual=result,
689 onpass="Stopping switch succeeded!",
690 onfail="Stopping switch failed!" )
691 if result:
692 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
693 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
694 main.Functions.checkRouteNum( main, 3 )
695 main.Functions.checkM2SintentNum( main, 3 )
696 main.Functions.checkP2PintentNum( main, 18 * 2 )
697 else:
698 main.log.error( "Stopping switch failed!" )
699 main.cleanup()
700 main.exit()
701
702 main.step( "Check whether all flow status are ADDED" )
703 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
704 main.FALSE,
705 kwargs={'isPENDING':False},
706 attempts=10 )
707 utilities.assertEquals( \
708 expect=main.TRUE,
709 actual=flowCheck,
710 onpass="Flow status is correct!",
711 onfail="Flow status is wrong!" )
712 # Ping test
713 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
714 peers=["peer64514", "peer64515", "peer64516"],
715 expectAllSuccess=True )
716 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
717 peers=[peer64514, peer64515, peer64516],
718 expectAllSuccess=True )
719 main.Functions.pingHostToHost( main,
720 hosts=["host64514", "host64515", "host64516"],
721 expectAllSuccess=True )
722
723
724 def CASE10( self, main ):
725 '''
726 Bring up the switch which was stopped in CASE9, check:
727 route number, P2P intent number, M2S intent number, ping test
728 '''
729 main.case( "Start sw11 which was stopped in CASE9, \
730 check route number, P2P intent number, M2S intent number, ping test" )
731
732 main.log.info( "Check the flow status before starting sw11" )
733 main.Functions.checkFlowNum( main, "sw1", 17 )
734 main.Functions.checkFlowNum( main, "sw7", 5 )
735
736 main.step( "Start sw11" )
737 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
738 utilities.assertEquals( expect=main.TRUE, actual=result1,
739 onpass="Starting switch succeeded!",
740 onfail="Starting switch failed!" )
741 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
742 utilities.assertEquals( expect=main.TRUE, actual=result2,
743 onpass="Connect switch to ONOS succeeded!",
744 onfail="Connect switch to ONOS failed!" )
745 if result1 and result2:
746 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
747 main.Functions.checkRouteNum( main, 3 )
748 main.Functions.checkM2SintentNum( main, 3 )
749 main.Functions.checkP2PintentNum( main, 18 * 2 )
750
751 else:
752 main.log.error( "Starting switch failed!" )
753 main.cleanup()
754 main.exit()
755
756 main.step( "Check whether all flow status are ADDED" )
757 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
758 main.FALSE,
759 kwargs={'isPENDING':False},
760 attempts=10 )
761 utilities.assertEquals( \
762 expect=main.TRUE,
763 actual=flowCheck,
764 onpass="Flow status is correct!",
765 onfail="Flow status is wrong!" )
766 # Ping test
767 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
768 peers=["peer64514", "peer64515", "peer64516"],
769 expectAllSuccess=True )
770 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
771 peers=[peer64514, peer64515, peer64516],
772 expectAllSuccess=True )
773 main.Functions.pingHostToHost( main,
774 hosts=["host64514", "host64515", "host64516"],
775 expectAllSuccess=True )
776
777
778 def CASE11(self, main):
779 import time
780 main.case( "Kill speaker1, check:\
781 route number, P2P intent number, M2S intent number, ping test" )
782 main.log.info( "Check network status before killing speaker1" )
783 main.Functions.checkRouteNum( main, 3 )
784 main.Functions.checkM2SintentNum( main, 3 )
785 main.Functions.checkP2PintentNum( main, 18 * 2 )
786 main.step( "Check whether all flow status are ADDED" )
787 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
788 main.FALSE,
789 kwargs={'isPENDING':False},
790 attempts=10 )
791 utilities.assertEquals( \
792 expect=main.TRUE,
793 actual=flowCheck,
794 onpass="Flow status is correct!",
795 onfail="Flow status is wrong!" )
796
797 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
798 peers=["peer64514", "peer64515", "peer64516"],
799 expectAllSuccess=True )
800 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
801 peers=[peer64514, peer64515, peer64516],
802 expectAllSuccess=True )
803 main.Functions.pingHostToHost( main,
804 hosts=["host64514", "host64515", "host64516"],
805 expectAllSuccess=True )
806
807 main.step( "Kill speaker1" )
808 command1 = "ps -e | grep bgp -c"
809 result1 = main.Mininet.node( "root", command1 )
810
811 # The total BGP daemon number in this test environment is 5.
812 if "5" in result1:
813 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
814 else:
815 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
816 main.log.info( result1 )
817
818 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
819 result2 = main.Mininet.node( "root", command2 )
820
821 result3 = main.Mininet.node( "root", command1 )
822
823 utilities.assert_equals( expect=True,
824 actual=( "4" in result3 ),
825 onpass="Kill speaker1 succeeded",
826 onfail="Kill speaker1 failed" )
827 if ( "4" not in result3 ) :
828 main.log.info( result3 )
829 main.cleanup()
830 main.exit()
831
832 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
833 main.Functions.checkRouteNum( main, 3 )
834 main.Functions.checkM2SintentNum( main, 3 )
835 main.Functions.checkP2PintentNum( main, 18 * 2 )
836
837 main.step( "Check whether all flow status are ADDED" )
838 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
839 main.FALSE,
840 kwargs={'isPENDING':False},
841 attempts=10 )
842 utilities.assertEquals( \
843 expect=main.TRUE,
844 actual=flowCheck,
845 onpass="Flow status is correct!",
846 onfail="Flow status is wrong!" )
847
848 '''
849 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
850 peers=["peer64514", "peer64515", "peer64516"],
851 expectAllSuccess=False )
852 '''
853 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
854 peers=[peer64514, peer64515, peer64516],
855 expectAllSuccess=True )
856 main.Functions.pingHostToHost( main,
857 hosts=["host64514", "host64515", "host64516"],
858 expectAllSuccess=True )
859
860
861 def CASE12( self, main ):
862 import time
863 import json
864 main.case( "Bring down leader ONOS node, check: \
865 route number, P2P intent number, M2S intent number, ping test" )
866 main.step( "Find out ONOS leader node" )
867 result = main.ONOScli1.leaders()
868 jsonResult = json.loads( result )
869 leaderIP = ""
870 for entry in jsonResult:
871 if entry["topic"] == "org.onosproject.sdnip":
872 leaderIP = entry["leader"]
873 main.log.info( "leaderIP is: " )
874 main.log.info( leaderIP )
875
876 main.step( "Uninstall ONOS/SDN-IP leader node" )
877 if leaderIP == ONOS1Ip:
878 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
879 elif leaderIP == ONOS2Ip:
880 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
881 else:
882 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
883
884 utilities.assert_equals( expect=main.TRUE,
885 actual=uninstallResult,
886 onpass="Uninstall ONOS leader succeeded",
887 onfail="Uninstall ONOS leader failed" )
888 if uninstallResult != main.TRUE:
889 main.cleanup()
890 main.exit()
891 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
892
893 if leaderIP == ONOS1Ip:
894 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
895 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
896 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
897
898 main.step( "Check whether all flow status are ADDED" )
899 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
900 main.FALSE,
901 kwargs={'isPENDING':False},
902 attempts=10 )
903 utilities.assertEquals( \
904 expect=main.TRUE,
905 actual=flowCheck,
906 onpass="Flow status is correct!",
907 onfail="Flow status is wrong!" )
908 else:
909 main.Functions.checkRouteNum( main, 3 )
910 main.Functions.checkM2SintentNum( main, 3 )
911 main.Functions.checkP2PintentNum( main, 18 * 2 )
912
913 main.step( "Check whether all flow status are ADDED" )
914 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
915 main.FALSE,
916 kwargs={'isPENDING':False},
917 attempts=10 )
918 utilities.assertEquals( \
919 expect=main.TRUE,
920 actual=flowCheck,
921 onpass="Flow status is correct!",
922 onfail="Flow status is wrong!" )
923
924 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
925 peers=["peer64514", "peer64515", "peer64516"],
926 expectAllSuccess=True )
927 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
928 peers=[peer64514, peer64515, peer64516],
929 expectAllSuccess=True )
930 main.Functions.pingHostToHost( main,
931 hosts=["host64514", "host64515", "host64516"],
932 expectAllSuccess=True )