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