blob: 85f55cf3511217731e2fb29abd219b74172e226a [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" )
Jon Hall88de9ee2016-03-04 12:29:56 -080014 main.log.demoSummary( "DEMO:Mininet: Setup the Mininet testbed" )
Jon Hallbc401252016-03-03 14:44:04 -080015 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" )
Jon Hall88de9ee2016-03-04 12:29:56 -080031 main.log.demoSummary( "DEMO:Mininet: Connecting switches to controllers" )
Jon Hallbc401252016-03-03 14:44:04 -080032
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" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800139 main.log.demoSummary( "DEMO:ONOS1: Installing ONOS" )
Jon Hallbc401252016-03-03 14:44:04 -0800140 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
141 node=ONOS1Ip )
Jon Hall88de9ee2016-03-04 12:29:56 -0800142 main.log.demoSummary( "DEMO:ONOS2: Installing ONOS" )
Jon Hallbc401252016-03-03 14:44:04 -0800143 onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
144 node=ONOS2Ip )
Jon Hall88de9ee2016-03-04 12:29:56 -0800145 main.log.demoSummary( "DEMO:ONOS3: Installing ONOS" )
Jon Hallbc401252016-03-03 14:44:04 -0800146 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'] ) )
Jon Hall776bfc52016-03-04 13:51:47 -0800213 summaryResult = main.ONOScli1.summary()
214 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hallbc401252016-03-03 14:44:04 -0800215 listResult = main.ONOScli1.links( jsonFormat=False )
Jon Hall776bfc52016-03-04 13:51:47 -0800216 main.log.info( linkNum )
Jon Hallbc401252016-03-03 14:44:04 -0800217 main.log.info( listResult )
218 main.cleanup()
219 main.exit()
220
221 main.step( "Activate sdn-ip application" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800222 main.log.demoSummary( "DEMO:ONOS1: Activate sdn-ip application" )
Jon Hallbc401252016-03-03 14:44:04 -0800223 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
224 utilities.assert_equals( expect=main.TRUE,
225 actual=activeSDNIPresult,
226 onpass="Activate SDN-IP succeeded",
227 onfail="Activate SDN-IP failed" )
228 if not activeSDNIPresult:
229 main.log.info( "Activate SDN-IP failed!" )
230 main.cleanup()
231 main.exit()
232
233
234 def CASE102( self, main ):
235 '''
236 This test case is to load the methods from other Python files, and create
237 tunnels from mininet host to onos nodes.
238 '''
239 import time
240 main.case( "Load methods from other Python file and create tunnels" )
241 # load the methods from other file
242 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
243 main.Functions = imp.load_source( wrapperFile1,
244 main.dependencyPath +
245 wrapperFile1 +
246 ".py" )
247 # Create tunnels
Jon Hall88de9ee2016-03-04 12:29:56 -0800248 main.log.demoSummary( "DEMO:Mininet: Creating tunnels between bgp speakers" )
Jon Hallbc401252016-03-03 14:44:04 -0800249 # ONOS1
250 main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
251 # ONOS2
252 main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
253 # ONOS3
254 main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
255
256 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
257 and the BGP paths in data plane are ready..." )
258 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
259
260 main.log.info( "Wait Quagga to finish delivery all routes to each \
261 other and to sdn-ip, plus finish installing all intents..." )
262 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
263
264 def CASE1( self, main ):
265 '''
266 ping test from 3 bgp peers to BGP speaker
267 '''
268
269 main.case( "Ping between BGP peers and speakers" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800270 main.log.demoSummary( "DEMO:Mininet: Ping between bgp peers and speakers" )
Jon Hallbc401252016-03-03 14:44:04 -0800271 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
272 peers=["peer64514", "peer64515", "peer64516"],
273 expectAllSuccess=True )
274 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
275 peers=[peer64514, peer64515, peer64516],
276 expectAllSuccess=True )
277 main.stop()
278
Jon Hallbc401252016-03-03 14:44:04 -0800279 def CASE2( self, main ):
280 '''
281 point-to-point intents test for each BGP peer and BGP speaker pair
282 '''
283 import time
284 main.case( "Check point-to-point intents" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800285 main.log.demoSummary( "DEMO:ONOS1: Verify Point-to-Point intents" )
Jon Hallbc401252016-03-03 14:44:04 -0800286 main.log.info( "There are %s BGP peers in total "
287 % main.params[ 'config' ][ 'peerNum' ] )
288 main.step( "Check P2P intents number from ONOS CLI" )
289
290 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
291 bgpIntentsActualNum = \
292 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
293 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 3
294 if bgpIntentsActualNum != bgpIntentsExpectedNum:
295 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
296 bgpIntentsActualNum = \
297 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
298 main.log.info( "bgpIntentsExpected num is:" )
299 main.log.info( bgpIntentsExpectedNum )
300 main.log.info( "bgpIntentsActual num is:" )
301 main.log.info( bgpIntentsActualNum )
302 utilities.assertEquals( \
303 expect=True,
304 actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
305 onpass="PointToPointIntent Intent Num is correct!",
306 onfail="PointToPointIntent Intent Num is wrong!" )
307
308
309 def CASE3( self, main ):
310 '''
311 routes and intents check to all BGP peers
312 '''
313 import time
314 main.case( "Check routes and M2S intents to all BGP peers" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800315 main.log.demoSummary( "DEMO:ONOS1: Check BGP routes and Multi-point intents" )
Jon Hallbc401252016-03-03 14:44:04 -0800316
317 allRoutesExpected = []
318 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
319 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
320 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
321
322 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
323 allRoutesActual = \
324 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
325 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
326 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
327 if allRoutesStrActual != allRoutesStrExpected:
328 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
329 allRoutesActual = \
330 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
331 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
332
333 main.step( "Check routes installed" )
334 main.log.info( "Routes expected:" )
335 main.log.info( allRoutesStrExpected )
336 main.log.info( "Routes get from ONOS CLI:" )
337 main.log.info( allRoutesStrActual )
338 utilities.assertEquals( \
339 expect=allRoutesStrExpected, actual=allRoutesStrActual,
340 onpass="Routes are correct!",
341 onfail="Routes are wrong!" )
342
343 main.step( "Check M2S intents installed" )
344 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
345 routeIntentsActualNum = \
346 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
347 routeIntentsExpectedNum = 3
348 if routeIntentsActualNum != routeIntentsExpectedNum:
349 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
350 routeIntentsActualNum = \
351 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
352
353 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
354 main.log.info( routeIntentsExpectedNum )
355 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
356 main.log.info( routeIntentsActualNum )
357 utilities.assertEquals( \
358 expect=routeIntentsExpectedNum,
359 actual=routeIntentsActualNum,
360 onpass="MultiPointToSinglePoint Intent Num is correct!",
361 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
362
363 main.step( "Check whether all flow status are ADDED" )
364 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
365 main.FALSE,
366 kwargs={'isPENDING':False},
367 attempts=10 )
368 utilities.assertEquals( \
369 expect=main.TRUE,
370 actual=flowCheck,
371 onpass="Flow status is correct!",
372 onfail="Flow status is wrong!" )
373
374
375 def CASE4( self, main ):
376 '''
377 Ping test in data plane for each route
378 '''
379 main.case( "Ping test for each route, all hosts behind BGP peers" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800380 main.log.demoSummary( "DEMO:Mininet: Pinging across BGP routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800381 main.Functions.pingHostToHost( main,
382 hosts=["host64514", "host64515", "host64516"],
383 expectAllSuccess=True )
384
385
386 def CASE5( self, main ):
387 '''
388 Cut links to peers one by one, check routes/intents
389 '''
390 import time
391 main.case( "Bring down links and check routes/intents" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800392 main.log.demoSummary( "DEMO:Mininet: Bringing down links between Quagga and the network" )
Jon Hallbc401252016-03-03 14:44:04 -0800393 main.step( "Bring down the link between sw32 and peer64514" )
394 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
395 OPTION="down" )
396 utilities.assertEquals( expect=main.TRUE,
397 actual=linkResult1,
398 onpass="Bring down link succeeded!",
399 onfail="Bring down link failed!" )
400
401 if linkResult1 == main.TRUE:
402 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
403 main.log.debug( main.ONOScli1.links() ) #FIXME: DEBUG
404 main.Functions.checkRouteNum( main, 2 )
405 main.Functions.checkM2SintentNum( main, 2 )
406 else:
407 main.log.error( "Bring down link failed!" )
408 main.cleanup()
409 main.exit()
410
411 main.step( "Bring down the link between sw8 and peer64515" )
412 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
413 OPTION="down" )
414 utilities.assertEquals( expect=main.TRUE,
415 actual=linkResult2,
416 onpass="Bring down link succeeded!",
417 onfail="Bring down link failed!" )
418 if linkResult2 == main.TRUE:
419 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
420 main.Functions.checkRouteNum( main, 1 )
421 main.Functions.checkM2SintentNum( main, 1 )
422 else:
423 main.log.error( "Bring down link failed!" )
424 main.cleanup()
425 main.exit()
426
427 main.step( "Bring down the link between sw28 and peer64516" )
428 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
429 OPTION="down" )
430 utilities.assertEquals( expect=main.TRUE,
431 actual=linkResult3,
432 onpass="Bring down link succeeded!",
433 onfail="Bring down link failed!" )
434 if linkResult3 == main.TRUE:
435 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
436 main.Functions.checkRouteNum( main, 0 )
437 main.Functions.checkM2SintentNum( main, 0 )
438 else:
439 main.log.error( "Bring down link failed!" )
440 main.cleanup()
441 main.exit()
442
443 main.step( "Check whether all flow status are ADDED" )
444 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
445 main.FALSE,
446 kwargs={'isPENDING':False},
447 attempts=10 )
448 utilities.assertEquals( \
449 expect=main.TRUE,
450 actual=flowCheck,
451 onpass="Flow status is correct!",
452 onfail="Flow status is wrong!" )
453
454 # Ping test
Jon Hall88de9ee2016-03-04 12:29:56 -0800455 main.log.demoSummary( "DEMO:Mininet: Verify lost connectivity across routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800456 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
457 peers=["peer64514", "peer64515", "peer64516"],
458 expectAllSuccess=False )
459 main.Functions.pingHostToHost( main,
460 hosts=["host64514", "host64515", "host64516"],
461 expectAllSuccess=False )
462
463
464 def CASE6( self, main ):
465 '''
466 Recover links to peers one by one, check routes/intents
467 '''
468 import time
469 main.case( "Bring up links and check routes/intents" )
470 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800471 main.log.demoSummary( "DEMO:Mininet: Bring back up links between Quagga and the network" )
Jon Hallbc401252016-03-03 14:44:04 -0800472 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
473 OPTION="up" )
474 utilities.assertEquals( expect=main.TRUE,
475 actual=linkResult1,
476 onpass="Bring up link succeeded!",
477 onfail="Bring up link failed!" )
478 if linkResult1 == main.TRUE:
479 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
480 main.Functions.checkRouteNum( main, 1 )
481 main.Functions.checkM2SintentNum( main, 1 )
482 else:
483 main.log.error( "Bring up link failed!" )
484 main.cleanup()
485 main.exit()
486
487 main.step( "Bring up the link between sw8 and peer64515" )
488 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
489 OPTION="up" )
490 utilities.assertEquals( expect=main.TRUE,
491 actual=linkResult2,
492 onpass="Bring up link succeeded!",
493 onfail="Bring up link failed!" )
494 if linkResult2 == main.TRUE:
495 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
496 main.Functions.checkRouteNum( main, 2 )
497 main.Functions.checkM2SintentNum( main, 2 )
498 else:
499 main.log.error( "Bring up link failed!" )
500 main.cleanup()
501 main.exit()
502
503 main.step( "Bring up the link between sw28 and peer64516" )
504 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
505 OPTION="up" )
506 utilities.assertEquals( expect=main.TRUE,
507 actual=linkResult3,
508 onpass="Bring up link succeeded!",
509 onfail="Bring up link failed!" )
510 if linkResult3 == main.TRUE:
511 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
512 main.Functions.checkRouteNum( main, 3 )
513 main.Functions.checkM2SintentNum( main, 3 )
514 else:
515 main.log.error( "Bring up link failed!" )
516 main.cleanup()
517 main.exit()
518
519 main.step( "Check whether all flow status are ADDED" )
520 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
521 main.FALSE,
522 kwargs={'isPENDING':False},
523 attempts=10 )
524 utilities.assertEquals( \
525 expect=main.TRUE,
526 actual=flowCheck,
527 onpass="Flow status is correct!",
528 onfail="Flow status is wrong!" )
529
530 # Ping test
Jon Hall88de9ee2016-03-04 12:29:56 -0800531 main.log.demoSummary( "DEMO:Mininet: Verify connectivity is restored across routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800532 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
533 peers=["peer64514", "peer64515", "peer64516"],
534 expectAllSuccess=True )
535 main.Functions.pingHostToHost( main,
536 hosts=["host64514", "host64515", "host64516"],
537 expectAllSuccess=True )
538
539
540 def CASE7( self, main ):
541 '''
542 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
543 '''
544 import time
545 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
546 main.step( "Stop sw32" )
547 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
548 utilities.assertEquals( expect=main.TRUE, actual=result,
549 onpass="Stopping switch succeeded!",
550 onfail="Stopping switch failed!" )
551
552 if result == main.TRUE:
553 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
554 main.Functions.checkRouteNum( main, 2 )
555 main.Functions.checkM2SintentNum( main, 2 )
556 main.Functions.checkP2PintentNum( main, 12 * 2 )
557 else:
558 main.log.error( "Stopping switch failed!" )
559 main.cleanup()
560 main.exit()
561
562 main.step( "Check ping between hosts behind BGP peers" )
563 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
564 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
565 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
566
567 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
568 and ( result3 == main.FALSE )
569 utilities.assert_equals( expect=True, actual=pingResult1,
570 onpass="Ping test result is correct",
571 onfail="Ping test result is wrong" )
572
573 if pingResult1 == False:
574 main.cleanup()
575 main.exit()
576
577 main.step( "Check ping between BGP peers and speaker1" )
578 result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" )
579 result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" )
580 result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" )
581
582 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
583 and ( result6 == main.TRUE )
584 utilities.assert_equals( expect=True, actual=pingResult2,
585 onpass="Speaker1 ping peers successful",
586 onfail="Speaker1 ping peers NOT successful" )
587
588 if pingResult2 == False:
589 main.cleanup()
590 main.exit()
591
592 main.step( "Check ping between BGP peers and speaker2" )
593 # TODO
594 result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 )
595 result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 )
596 result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 )
597
598 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
599 and ( result9 == main.TRUE )
600 utilities.assert_equals( expect=True, actual=pingResult2,
601 onpass="Speaker2 ping peers successful",
602 onfail="Speaker2 ping peers NOT successful" )
603
604 if pingResult3 == False:
605 main.cleanup()
606 main.exit()
607
608 main.step( "Check whether all flow status are ADDED" )
609 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
610 main.FALSE,
611 kwargs={'isPENDING':False},
612 attempts=10 )
613 utilities.assertEquals( \
614 expect=main.TRUE,
615 actual=flowCheck,
616 onpass="Flow status is correct!",
617 onfail="Flow status is wrong!" )
618
619
620 def CASE8( self, main ):
621 '''
622 Bring up the edge switch (sw32) which was shut down in CASE7,
623 check P-2-P and M-2-S intents, ping test
624 '''
625 import time
626 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
627 main.step( "Start sw32" )
628 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
629 utilities.assertEquals( \
630 expect=main.TRUE,
631 actual=result1,
632 onpass="Starting switch succeeded!",
633 onfail="Starting switch failed!" )
634
635 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
636 utilities.assertEquals( \
637 expect=main.TRUE,
638 actual=result2,
639 onpass="Connect switch to ONOS succeeded!",
640 onfail="Connect switch to ONOS failed!" )
641
642 if result1 and result2:
643 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
644 main.Functions.checkRouteNum( main, 3 )
645 main.Functions.checkM2SintentNum( main, 3 )
646 main.Functions.checkP2PintentNum( main, 18 * 2 )
647 else:
648 main.log.error( "Starting switch failed!" )
649 main.cleanup()
650 main.exit()
651
652 main.step( "Check whether all flow status are ADDED" )
653 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
654 main.FALSE,
655 kwargs={'isPENDING':False},
656 attempts=10 )
657 utilities.assertEquals( \
658 expect=main.TRUE,
659 actual=flowCheck,
660 onpass="Flow status is correct!",
661 onfail="Flow status is wrong!" )
662
663 # Ping test
664 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
665 peers=["peer64514", "peer64515", "peer64516"],
666 expectAllSuccess=True )
667 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
668 peers=[peer64514, peer64515, peer64516],
669 expectAllSuccess=True )
670 main.Functions.pingHostToHost( main,
671 hosts=["host64514", "host64515", "host64516"],
672 expectAllSuccess=True )
673
674
675 def CASE9( self, main ):
676 '''
677 Bring down a switch in best path, check:
678 route number, P2P intent number, M2S intent number, ping test
679 '''
680 main.case( "Stop sw11 located in best path, \
681 check route number, P2P intent number, M2S intent number, ping test" )
682
683 main.log.info( "Check the flow number correctness before stopping sw11" )
684 main.Functions.checkFlowNum( main, "sw11", 19 )
685 main.Functions.checkFlowNum( main, "sw1", 3 )
686 main.Functions.checkFlowNum( main, "sw7", 3 )
687
688 main.step( "Stop sw11" )
689 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
690 utilities.assertEquals( expect=main.TRUE, actual=result,
691 onpass="Stopping switch succeeded!",
692 onfail="Stopping switch failed!" )
693 if result:
694 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
695 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
696 main.Functions.checkRouteNum( main, 3 )
697 main.Functions.checkM2SintentNum( main, 3 )
698 main.Functions.checkP2PintentNum( main, 18 * 2 )
699 else:
700 main.log.error( "Stopping switch failed!" )
701 main.cleanup()
702 main.exit()
703
704 main.step( "Check whether all flow status are ADDED" )
705 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
706 main.FALSE,
707 kwargs={'isPENDING':False},
708 attempts=10 )
709 utilities.assertEquals( \
710 expect=main.TRUE,
711 actual=flowCheck,
712 onpass="Flow status is correct!",
713 onfail="Flow status is wrong!" )
714 # Ping test
715 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
716 peers=["peer64514", "peer64515", "peer64516"],
717 expectAllSuccess=True )
718 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
719 peers=[peer64514, peer64515, peer64516],
720 expectAllSuccess=True )
721 main.Functions.pingHostToHost( main,
722 hosts=["host64514", "host64515", "host64516"],
723 expectAllSuccess=True )
724
725
726 def CASE10( self, main ):
727 '''
728 Bring up the switch which was stopped in CASE9, check:
729 route number, P2P intent number, M2S intent number, ping test
730 '''
731 main.case( "Start sw11 which was stopped in CASE9, \
732 check route number, P2P intent number, M2S intent number, ping test" )
733
734 main.log.info( "Check the flow status before starting sw11" )
735 main.Functions.checkFlowNum( main, "sw1", 17 )
736 main.Functions.checkFlowNum( main, "sw7", 5 )
737
738 main.step( "Start sw11" )
739 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
740 utilities.assertEquals( expect=main.TRUE, actual=result1,
741 onpass="Starting switch succeeded!",
742 onfail="Starting switch failed!" )
743 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
744 utilities.assertEquals( expect=main.TRUE, actual=result2,
745 onpass="Connect switch to ONOS succeeded!",
746 onfail="Connect switch to ONOS failed!" )
747 if result1 and result2:
748 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
749 main.Functions.checkRouteNum( main, 3 )
750 main.Functions.checkM2SintentNum( main, 3 )
751 main.Functions.checkP2PintentNum( main, 18 * 2 )
752
753 else:
754 main.log.error( "Starting switch failed!" )
755 main.cleanup()
756 main.exit()
757
758 main.step( "Check whether all flow status are ADDED" )
759 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
760 main.FALSE,
761 kwargs={'isPENDING':False},
762 attempts=10 )
763 utilities.assertEquals( \
764 expect=main.TRUE,
765 actual=flowCheck,
766 onpass="Flow status is correct!",
767 onfail="Flow status is wrong!" )
768 # Ping test
769 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
770 peers=["peer64514", "peer64515", "peer64516"],
771 expectAllSuccess=True )
772 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
773 peers=[peer64514, peer64515, peer64516],
774 expectAllSuccess=True )
775 main.Functions.pingHostToHost( main,
776 hosts=["host64514", "host64515", "host64516"],
777 expectAllSuccess=True )
778
779
780 def CASE11(self, main):
781 import time
782 main.case( "Kill speaker1, check:\
783 route number, P2P intent number, M2S intent number, ping test" )
784 main.log.info( "Check network status before killing speaker1" )
785 main.Functions.checkRouteNum( main, 3 )
786 main.Functions.checkM2SintentNum( main, 3 )
787 main.Functions.checkP2PintentNum( main, 18 * 2 )
788 main.step( "Check whether all flow status are ADDED" )
789 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
790 main.FALSE,
791 kwargs={'isPENDING':False},
792 attempts=10 )
793 utilities.assertEquals( \
794 expect=main.TRUE,
795 actual=flowCheck,
796 onpass="Flow status is correct!",
797 onfail="Flow status is wrong!" )
798
799 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
800 peers=["peer64514", "peer64515", "peer64516"],
801 expectAllSuccess=True )
802 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
803 peers=[peer64514, peer64515, peer64516],
804 expectAllSuccess=True )
805 main.Functions.pingHostToHost( main,
806 hosts=["host64514", "host64515", "host64516"],
807 expectAllSuccess=True )
808
809 main.step( "Kill speaker1" )
810 command1 = "ps -e | grep bgp -c"
811 result1 = main.Mininet.node( "root", command1 )
812
813 # The total BGP daemon number in this test environment is 5.
814 if "5" in result1:
815 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
816 else:
817 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
818 main.log.info( result1 )
819
820 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
821 result2 = main.Mininet.node( "root", command2 )
822
823 result3 = main.Mininet.node( "root", command1 )
824
825 utilities.assert_equals( expect=True,
826 actual=( "4" in result3 ),
827 onpass="Kill speaker1 succeeded",
828 onfail="Kill speaker1 failed" )
829 if ( "4" not in result3 ) :
830 main.log.info( result3 )
831 main.cleanup()
832 main.exit()
833
834 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
835 main.Functions.checkRouteNum( main, 3 )
836 main.Functions.checkM2SintentNum( main, 3 )
837 main.Functions.checkP2PintentNum( main, 18 * 2 )
838
839 main.step( "Check whether all flow status are ADDED" )
840 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
841 main.FALSE,
842 kwargs={'isPENDING':False},
843 attempts=10 )
844 utilities.assertEquals( \
845 expect=main.TRUE,
846 actual=flowCheck,
847 onpass="Flow status is correct!",
848 onfail="Flow status is wrong!" )
849
850 '''
851 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
852 peers=["peer64514", "peer64515", "peer64516"],
853 expectAllSuccess=False )
854 '''
855 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
856 peers=[peer64514, peer64515, peer64516],
857 expectAllSuccess=True )
858 main.Functions.pingHostToHost( main,
859 hosts=["host64514", "host64515", "host64516"],
860 expectAllSuccess=True )
861
862
863 def CASE12( self, main ):
864 import time
865 import json
866 main.case( "Bring down leader ONOS node, check: \
867 route number, P2P intent number, M2S intent number, ping test" )
868 main.step( "Find out ONOS leader node" )
869 result = main.ONOScli1.leaders()
870 jsonResult = json.loads( result )
871 leaderIP = ""
872 for entry in jsonResult:
873 if entry["topic"] == "org.onosproject.sdnip":
874 leaderIP = entry["leader"]
875 main.log.info( "leaderIP is: " )
876 main.log.info( leaderIP )
877
878 main.step( "Uninstall ONOS/SDN-IP leader node" )
879 if leaderIP == ONOS1Ip:
880 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
881 elif leaderIP == ONOS2Ip:
882 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
883 else:
884 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
885
886 utilities.assert_equals( expect=main.TRUE,
887 actual=uninstallResult,
888 onpass="Uninstall ONOS leader succeeded",
889 onfail="Uninstall ONOS leader failed" )
890 if uninstallResult != main.TRUE:
891 main.cleanup()
892 main.exit()
893 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
894
895 if leaderIP == ONOS1Ip:
896 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
897 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
898 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
899
900 main.step( "Check whether all flow status are ADDED" )
901 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
902 main.FALSE,
903 kwargs={'isPENDING':False},
904 attempts=10 )
905 utilities.assertEquals( \
906 expect=main.TRUE,
907 actual=flowCheck,
908 onpass="Flow status is correct!",
909 onfail="Flow status is wrong!" )
910 else:
911 main.Functions.checkRouteNum( main, 3 )
912 main.Functions.checkM2SintentNum( main, 3 )
913 main.Functions.checkP2PintentNum( main, 18 * 2 )
914
915 main.step( "Check whether all flow status are ADDED" )
916 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
917 main.FALSE,
918 kwargs={'isPENDING':False},
919 attempts=10 )
920 utilities.assertEquals( \
921 expect=main.TRUE,
922 actual=flowCheck,
923 onpass="Flow status is correct!",
924 onfail="Flow status is wrong!" )
925
926 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
927 peers=["peer64514", "peer64515", "peer64516"],
928 expectAllSuccess=True )
929 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
930 peers=[peer64514, peer64515, peer64516],
931 expectAllSuccess=True )
932 main.Functions.pingHostToHost( main,
933 hosts=["host64514", "host64515", "host64516"],
934 expectAllSuccess=True )