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