blob: 1508a7ed2d40f31964e5d1034956c9316519365e [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
8 def CASE100( self, main ):
9 """
10 Start mininet
11 """
12 import imp
Jon Hall70b768c2016-04-19 08:38:29 -070013 main.case( "Setup the Mininet testbed" )
pingping-lin26990f02015-11-30 15:48:06 -080014 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
Jon Hall6e9897d2016-02-29 14:41:32 -080020 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" )
pingping-lin26990f02015-11-30 15:48:06 -080025 # Exit if topology did not load properly
26 if not topoResult:
27 main.cleanup()
28 main.exit()
pingping-lin14776632015-12-16 12:05:30 -080029 main.step( "Connect switches to FSFW" )
pingping-lin26990f02015-11-30 15:48:06 -080030
pingping-lin26990f02015-11-30 15:48:06 -080031 swResult = main.TRUE
32 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
33 sw = "sw%s" % ( i )
pingping-lin14776632015-12-16 12:05:30 -080034 swResult = swResult and main.Mininet.assignSwController( sw, fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -080035 port=fsfwPort )
pingping-lin26990f02015-11-30 15:48:06 -080036
Jon Hall6e9897d2016-02-29 14:41:32 -080037 utilities.assert_equals( expect=main.TRUE,
38 actual=swResult,
39 onpass="Successfully connect all switches to FSFW",
40 onfail="Failed to connect all switches to FSFW" )
pingping-lin26990f02015-11-30 15:48:06 -080041 if not swResult:
42 main.cleanup()
43 main.exit()
44
45
46 def CASE101( self, main ):
47 """
48 Package ONOS and install it
49 Startup sequence:
50 cell <name>
51 onos-verify-cell
52 onos-package
53 onos-install -f
54 onos-wait-for-start
55 """
56 import json
57 import time
58 import os
59 from operator import eq
pingping-lin14776632015-12-16 12:05:30 -080060 global pr64514
61 global pr64515
62 global pr64516
63 pr64514 = main.params['config']['pr64514']
64 pr64515 = main.params['config']['pr64515']
65 pr64516 = main.params['config']['pr64516']
66
67 global fsfwIp
68 global fsfwPort
69 fsfwIp = main.params[ 'CTRL' ][ 'fsfwIp' ]
70 fsfwPort = main.params[ 'CTRL' ][ 'fsfwPort' ]
pingping-lin26990f02015-11-30 15:48:06 -080071
Devin Lim58046fa2017-07-05 16:55:00 -070072 try:
73 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
74 except ImportError:
75 main.log.error( "sdnBase not found. exiting the test" )
pingping-lin26990f02015-11-30 15:48:06 -080076 main.exit()
Devin Lim58046fa2017-07-05 16:55:00 -070077 try:
78 main.sdnBase
79 except ( NameError, AttributeError ):
80 main.sdnBase = SdnBase()
81
82 main.sdnBase.initSetup()
83
pingping-lin26990f02015-11-30 15:48:06 -080084
pingping-lin26990f02015-11-30 15:48:06 -080085 def CASE200( self, main ):
86 main.case( "Activate sdn-ip application" )
87 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -080088 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-lin26990f02015-11-30 15:48:06 -080089
90 main.log.info( "Get links in the network" )
91 summaryResult = main.ONOScli1.summary()
92 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall6e9897d2016-02-29 14:41:32 -080093 listResult = main.ONOScli1.links( jsonFormat=False )
pingping-lin26990f02015-11-30 15:48:06 -080094 main.log.info( listResult )
pingping-lin26990f02015-11-30 15:48:06 -080095 if linkNum < 100:
96 main.log.error( "Link number is wrong!" )
Jon Hall6e9897d2016-02-29 14:41:32 -080097 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
98 listResult = main.ONOScli1.links( jsonFormat=False )
99 main.log.info( listResult )
pingping-lin26990f02015-11-30 15:48:06 -0800100 main.cleanup()
101 main.exit()
102
103 main.step( "Activate sdn-ip application" )
104 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800105 utilities.assert_equals( expect=main.TRUE,
106 actual=activeSDNIPresult,
107 onpass="Activate SDN-IP succeeded",
108 onfail="Activate SDN-IP failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800109 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800110 main.log.info( "Activate SDN-IP failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800111 main.cleanup()
112 main.exit()
113
114
115 def CASE102( self, main ):
116 '''
117 This test case is to load the methods from other Python files, and create
118 tunnels from mininet host to onos nodes.
119 '''
120 import time
121 main.case( "Load methods from other Python file and create tunnels" )
122 # load the methods from other file
123 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
124 main.Functions = imp.load_source( wrapperFile1,
125 main.dependencyPath +
126 wrapperFile1 +
127 ".py" )
128 # Create tunnels
Devin Lim58046fa2017-07-05 16:55:00 -0700129 for i in range ( len( main.ONOSip ) ):
130 main.Functions.setupTunnel( main, '1.1.1.' + str( ( i + 1 ) * 2 ), 2000, main.ONOSip[ i ], 2000 )
pingping-lin26990f02015-11-30 15:48:06 -0800131
132 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
133 and the BGP paths in data plane are ready..." )
134 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
135
136 main.log.info( "Wait Quagga to finish delivery all routes to each \
137 other and to sdn-ip, plus finish installing all intents..." )
138 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-lin26990f02015-11-30 15:48:06 -0800139
140 def CASE1( self, main ):
141 '''
142 ping test from 3 bgp peers to BGP speaker
143 '''
144
145 main.case( "Ping tests between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800146 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
147 peers=["pr64514", "pr64515", "pr64516"],
148 expectAllSuccess=True )
149 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
150 peers=[pr64514, pr64515, pr64516],
151 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800152
153 def CASE2( self, main ):
154 '''
155 point-to-point intents test for each BGP peer and BGP speaker pair
156 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700157 main.sdnBase.pToPIntentTest( 12 )
pingping-lin26990f02015-11-30 15:48:06 -0800158
159
160 def CASE3( self, main ):
161 '''
162 routes and intents check to all BGP peers
163 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800164 import time
pingping-lin26990f02015-11-30 15:48:06 -0800165 main.case( "Check routes and M2S intents to all BGP peers" )
166
167 allRoutesExpected = []
168 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
169 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
170 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
171
Devin Lim58046fa2017-07-05 16:55:00 -0700172 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 3 )
pingping-lin26990f02015-11-30 15:48:06 -0800173
174
175 def CASE4( self, main ):
176 '''
177 Ping test in data plane for each route
178 '''
179 main.case( "Ping test for each route, all hosts behind BGP peers" )
180 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800181 hosts=["host64514", "host64515", "host64516"],
182 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800183
pingping-lin26990f02015-11-30 15:48:06 -0800184 def CASE5( self, main ):
185 '''
186 Cut links to peers one by one, check routes/intents
187 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700188 main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516",
189 2, 2, 1, 1, 0, 0,
190 "speaker1", [ "host64514", "host64515", "host64516" ],
191 "down" )
pingping-lin26990f02015-11-30 15:48:06 -0800192
193 def CASE6( self, main ):
194 '''
195 Recover links to peers one by one, check routes/intents
196 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700197 main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516",
198 1, 1, 2, 2, 3, 3,
199 "speaker1", [ "host64514", "host64515", "host64516" ],
200 "up" )
pingping-lin26990f02015-11-30 15:48:06 -0800201
202 def CASE7( self, main ):
203 '''
204 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
205 '''
206 import time
207 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
208 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800209 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
210 utilities.assertEquals( expect=main.TRUE, actual=result,
211 onpass="Stopping switch succeeded!",
212 onfail="Stopping switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800213
214 if result == main.TRUE:
215 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
216 main.Functions.checkRouteNum( main, 2 )
217 main.Functions.checkM2SintentNum( main, 2 )
218 main.Functions.checkP2PintentNum( main, 12 * 2 )
219 else:
220 main.log.error( "Stopping switch failed!" )
221 main.cleanup()
222 main.exit()
223
224 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800225 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
226 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
227 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-lin26990f02015-11-30 15:48:06 -0800228
229 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
230 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800231 utilities.assert_equals( expect=True, actual=pingResult1,
232 onpass="Ping test result is correct",
233 onfail="Ping test result is wrong" )
pingping-lin26990f02015-11-30 15:48:06 -0800234
235 if pingResult1 == False:
236 main.cleanup()
237 main.exit()
238
239 main.step( "Check ping between BGP peers and speaker1" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800240 result4 = main.Mininet.pingHost( src="speaker1", target="pr64514" )
241 result5 = main.Mininet.pingHost( src="speaker1", target="pr64515" )
242 result6 = main.Mininet.pingHost( src="speaker1", target="pr64516" )
pingping-lin26990f02015-11-30 15:48:06 -0800243
244 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
245 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800246 utilities.assert_equals( expect=True, actual=pingResult2,
247 onpass="Speaker1 ping peers successful",
248 onfail="Speaker1 ping peers NOT successful" )
pingping-lin26990f02015-11-30 15:48:06 -0800249
250 if pingResult2 == False:
251 main.cleanup()
252 main.exit()
253
254 main.step( "Check ping between BGP peers and speaker2" )
255 # TODO
Jon Hall6e9897d2016-02-29 14:41:32 -0800256 result7 = main.Mininet.pingHost( src="speaker2", target=pr64514 )
257 result8 = main.Mininet.pingHost( src="speaker2", target=pr64515 )
258 result9 = main.Mininet.pingHost( src="speaker2", target=pr64516 )
pingping-lin26990f02015-11-30 15:48:06 -0800259
260 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
261 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800262 utilities.assert_equals( expect=True, actual=pingResult2,
263 onpass="Speaker2 ping peers successful",
264 onfail="Speaker2 ping peers NOT successful" )
pingping-lin26990f02015-11-30 15:48:06 -0800265
266 if pingResult3 == False:
267 main.cleanup()
268 main.exit()
269
270 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800271 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
272 main.FALSE,
273 kwargs={'isPENDING':False},
274 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800275 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800276 expect=main.TRUE,
277 actual=flowCheck,
278 onpass="Flow status is correct!",
279 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800280
281
282 def CASE8( self, main ):
283 '''
284 Bring up the edge switch (sw32) which was shut down in CASE7,
285 check P-2-P and M-2-S intents, ping test
286 '''
287 import time
288 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
289 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800290 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-lin26990f02015-11-30 15:48:06 -0800291 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800292 expect=main.TRUE,
293 actual=result1,
294 onpass="Starting switch succeeded!",
295 onfail="Starting switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800296
pingping-lin3806f112016-01-04 10:38:25 -0800297 result2 = main.Mininet.assignSwController( "sw32", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800298 port=fsfwPort )
pingping-lin26990f02015-11-30 15:48:06 -0800299 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800300 expect=main.TRUE,
301 actual=result2,
302 onpass="Connect switch to FSFW succeeded!",
303 onfail="Connect switch to FSFW failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800304
305 if result1 and result2:
306 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
307 main.Functions.checkRouteNum( main, 3 )
308 main.Functions.checkM2SintentNum( main, 3 )
309 main.Functions.checkP2PintentNum( main, 18 * 2 )
310 else:
311 main.log.error( "Starting switch failed!" )
312 main.cleanup()
313 main.exit()
314
315 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800316 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
317 main.FALSE,
318 kwargs={'isPENDING':False},
319 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800320 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800321 expect=main.TRUE,
322 actual=flowCheck,
323 onpass="Flow status is correct!",
324 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800325
326 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800327 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
328 peers=["pr64514", "pr64515", "pr64516"],
329 expectAllSuccess=True )
330 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
331 peers=[pr64514, pr64515, pr64516],
332 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800333 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800334 hosts=["host64514", "host64515", "host64516"],
335 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800336
337
338 def CASE9( self, main ):
339 '''
340 Bring down a switch in best path, check:
341 route number, P2P intent number, M2S intent number, ping test
342 '''
343 main.case( "Stop sw11 located in best path, \
344 check route number, P2P intent number, M2S intent number, ping test" )
345
346 main.log.info( "Check the flow number correctness before stopping sw11" )
347 main.Functions.checkFlowNum( main, "sw11", 19 )
348 main.Functions.checkFlowNum( main, "sw1", 3 )
349 main.Functions.checkFlowNum( main, "sw7", 3 )
350 main.log.info( main.Mininet.checkFlows( "sw11" ) )
351 main.log.info( main.Mininet.checkFlows( "sw1" ) )
352 main.log.info( main.Mininet.checkFlows( "sw7" ) )
353
354 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800355 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
356 utilities.assertEquals( expect=main.TRUE, actual=result,
357 onpass="Stopping switch succeeded!",
358 onfail="Stopping switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800359 if result:
360 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
361 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
362 main.Functions.checkRouteNum( main, 3 )
363 main.Functions.checkM2SintentNum( main, 3 )
364 main.Functions.checkP2PintentNum( main, 18 * 2 )
365 else:
366 main.log.error( "Stopping switch failed!" )
367 main.cleanup()
368 main.exit()
369
370 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800371 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
372 main.FALSE,
373 kwargs={'isPENDING':False},
374 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800375 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800376 expect=main.TRUE,
377 actual=flowCheck,
378 onpass="Flow status is correct!",
379 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800380 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800381 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
382 peers=["pr64514", "pr64515", "pr64516"],
383 expectAllSuccess=True )
384 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
385 peers=[pr64514, pr64515, pr64516],
386 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800387 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800388 hosts=["host64514", "host64515", "host64516"],
389 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800390
391
392 def CASE10( self, main ):
393 '''
394 Bring up the switch which was stopped in CASE9, check:
395 route number, P2P intent number, M2S intent number, ping test
396 '''
397 main.case( "Start sw11 which was stopped in CASE9, \
398 check route number, P2P intent number, M2S intent number, ping test" )
399
400 main.log.info( "Check the flow status before starting sw11" )
401 main.Functions.checkFlowNum( main, "sw1", 17 )
402 main.Functions.checkFlowNum( main, "sw7", 5 )
403 main.log.info( main.Mininet.checkFlows( "sw1" ) )
404 main.log.info( main.Mininet.checkFlows( "sw7" ) )
405
406 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800407 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
408 utilities.assertEquals( expect=main.TRUE, actual=result1,
409 onpass="Starting switch succeeded!",
410 onfail="Starting switch failed!" )
pingping-lin3806f112016-01-04 10:38:25 -0800411 result2 = main.Mininet.assignSwController( "sw11", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800412 port=fsfwPort )
413 utilities.assertEquals( expect=main.TRUE, actual=result2,
414 onpass="Connect switch to FSFW succeeded!",
415 onfail="Connect switch to FSFW failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800416 if result1 and result2:
417 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
418 main.Functions.checkRouteNum( main, 3 )
419 main.Functions.checkM2SintentNum( main, 3 )
420 main.Functions.checkP2PintentNum( main, 18 * 2 )
421
422 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
423 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
424 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
425 else:
426 main.log.error( "Starting switch failed!" )
427 main.cleanup()
428 main.exit()
429
430 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800431 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
432 main.FALSE,
433 kwargs={'isPENDING':False},
434 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800435 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800436 expect=main.TRUE,
437 actual=flowCheck,
438 onpass="Flow status is correct!",
439 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800440 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800441 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
442 peers=["pr64514", "pr64515", "pr64516"],
443 expectAllSuccess=True )
444 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
445 peers=[pr64514, pr64515, pr64516],
446 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800447 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800448 hosts=["host64514", "host64515", "host64516"],
449 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800450
451
452 def CASE11(self, main):
453 import time
454 main.case( "Kill speaker1, check:\
455 route number, P2P intent number, M2S intent number, ping test" )
456 main.log.info( "Check network status before killing speaker1" )
457 main.Functions.checkRouteNum( main, 3 )
458 main.Functions.checkM2SintentNum( main, 3 )
459 main.Functions.checkP2PintentNum( main, 18 * 2 )
460 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800461 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
462 main.FALSE,
463 kwargs={'isPENDING':False},
464 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800465 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800466 expect=main.TRUE,
467 actual=flowCheck,
468 onpass="Flow status is correct!",
469 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800470
Jon Hall6e9897d2016-02-29 14:41:32 -0800471 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
472 peers=["pr64514", "pr64515", "pr64516"],
473 expectAllSuccess=True )
474 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
475 peers=[pr64514, pr64515, pr64516],
476 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800477 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800478 hosts=["host64514", "host64515", "host64516"],
479 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800480
481 main.step( "Kill speaker1" )
482 command1 = "ps -e | grep bgp -c"
483 result1 = main.Mininet.node( "root", command1 )
484
485 # The total BGP daemon number in this test environment is 5.
486 if "5" in result1:
487 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
488 else:
489 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
490 main.log.info( result1 )
491
492 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
493 result2 = main.Mininet.node( "root", command2 )
494
495 result3 = main.Mininet.node( "root", command1 )
496
Jon Hall6e9897d2016-02-29 14:41:32 -0800497 utilities.assert_equals( expect=True,
498 actual=( "4" in result3 ),
499 onpass="Kill speaker1 succeeded",
500 onfail="Kill speaker1 failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800501 if ( "4" not in result3 ) :
502 main.log.info( result3 )
503 main.cleanup()
504 main.exit()
505
506 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
507 main.Functions.checkRouteNum( main, 3 )
508 main.Functions.checkM2SintentNum( main, 3 )
509 main.Functions.checkP2PintentNum( main, 18 * 2 )
510
511 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800512 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
513 main.FALSE,
514 kwargs={'isPENDING':False},
515 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800516 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800517 expect=main.TRUE,
518 actual=flowCheck,
519 onpass="Flow status is correct!",
520 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800521
522 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800523 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
524 peers=["pr64514", "pr64515", "pr64516"],
525 expectAllSuccess=False )
pingping-lin26990f02015-11-30 15:48:06 -0800526 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800527 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
528 peers=[pr64514, pr64515, pr64516],
529 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800530 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800531 hosts=["host64514", "host64515", "host64516"],
532 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800533
534
535 def CASE12( self, main ):
536 import time
537 import json
538 main.case( "Bring down leader ONOS node, check: \
539 route number, P2P intent number, M2S intent number, ping test" )
540 main.step( "Find out ONOS leader node" )
541 result = main.ONOScli1.leaders()
542 jsonResult = json.loads( result )
543 leaderIP = ""
544 for entry in jsonResult:
545 if entry["topic"] == "org.onosproject.sdnip":
546 leaderIP = entry["leader"]
547 main.log.info( "leaderIP is: " )
548 main.log.info( leaderIP )
549
Devin Lim58046fa2017-07-05 16:55:00 -0700550 main.step( "Uninstall ONOS/SDN-IP leader node" )
551 for ip in main.ONOSip:
552 if leaderIP == ip:
553 uninstallResult = main.ONOSbench.onosStop( ip )
pingping-lin26990f02015-11-30 15:48:06 -0800554
Jon Hall6e9897d2016-02-29 14:41:32 -0800555 utilities.assert_equals( expect=main.TRUE,
556 actual=uninstallResult,
557 onpass="Uninstall ONOS leader succeeded",
558 onfail="Uninstall ONOS leader failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800559 if uninstallResult != main.TRUE:
560 main.cleanup()
561 main.exit()
562 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
563
Devin Lim58046fa2017-07-05 16:55:00 -0700564 if leaderIP == main.ONOSip[ 0 ]:
Jon Hall6e9897d2016-02-29 14:41:32 -0800565 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
566 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
567 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
pingping-lin26990f02015-11-30 15:48:06 -0800568
569 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800570 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
571 main.FALSE,
572 kwargs={'isPENDING':False},
573 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800574 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800575 expect=main.TRUE,
576 actual=flowCheck,
577 onpass="Flow status is correct!",
578 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800579 else:
580 main.Functions.checkRouteNum( main, 3 )
581 main.Functions.checkM2SintentNum( main, 3 )
582 main.Functions.checkP2PintentNum( main, 18 * 2 )
583
584 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800585 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
586 main.FALSE,
587 kwargs={'isPENDING':False},
588 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800589 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800590 expect=main.TRUE,
591 actual=flowCheck,
592 onpass="Flow status is correct!",
593 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800594
Jon Hall6e9897d2016-02-29 14:41:32 -0800595 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
596 peers=["pr64514", "pr64515", "pr64516"],
597 expectAllSuccess=True )
598 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
599 peers=[pr64514, pr64515, pr64516],
600 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800601 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800602 hosts=["host64514", "host64515", "host64516"],
603 expectAllSuccess=True )