blob: bf6439b7a34d3bd34c1faff1a0d4c6e906d1ddc7 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2015 Open Networking Foundation (ONF)
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
21
pingping-lin26990f02015-11-30 15:48:06 -080022# Testing the functionality of SDN-IP with single ONOS instance
23class USECASE_SdnipFunctionCluster_fsfw:
24
25 def __init__( self ):
26 self.default = ''
27 global branchName
28
29 def CASE100( self, main ):
30 """
31 Start mininet
32 """
33 import imp
Jon Hall70b768c2016-04-19 08:38:29 -070034 main.case( "Setup the Mininet testbed" )
pingping-lin26990f02015-11-30 15:48:06 -080035 main.dependencyPath = main.testDir + \
36 main.params[ 'DEPENDENCY' ][ 'path' ]
37 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
38
39 main.step( "Starting Mininet Topology" )
40 topology = main.dependencyPath + main.topology
Jon Hall6e9897d2016-02-29 14:41:32 -080041 topoResult = main.Mininet.startNet( topoFile=topology )
42 utilities.assert_equals( expect=main.TRUE,
43 actual=topoResult,
44 onpass="Successfully loaded topology",
45 onfail="Failed to load topology" )
pingping-lin26990f02015-11-30 15:48:06 -080046 # Exit if topology did not load properly
47 if not topoResult:
48 main.cleanup()
49 main.exit()
pingping-lin14776632015-12-16 12:05:30 -080050 main.step( "Connect switches to FSFW" )
pingping-lin26990f02015-11-30 15:48:06 -080051
pingping-lin26990f02015-11-30 15:48:06 -080052 swResult = main.TRUE
53 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
54 sw = "sw%s" % ( i )
pingping-lin14776632015-12-16 12:05:30 -080055 swResult = swResult and main.Mininet.assignSwController( sw, fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -080056 port=fsfwPort )
pingping-lin26990f02015-11-30 15:48:06 -080057
Jon Hall6e9897d2016-02-29 14:41:32 -080058 utilities.assert_equals( expect=main.TRUE,
59 actual=swResult,
60 onpass="Successfully connect all switches to FSFW",
61 onfail="Failed to connect all switches to FSFW" )
pingping-lin26990f02015-11-30 15:48:06 -080062 if not swResult:
63 main.cleanup()
64 main.exit()
65
66
67 def CASE101( self, main ):
68 """
69 Package ONOS and install it
70 Startup sequence:
71 cell <name>
72 onos-verify-cell
73 onos-package
74 onos-install -f
75 onos-wait-for-start
76 """
77 import json
78 import time
79 import os
80 from operator import eq
pingping-lin14776632015-12-16 12:05:30 -080081 global pr64514
82 global pr64515
83 global pr64516
84 pr64514 = main.params['config']['pr64514']
85 pr64515 = main.params['config']['pr64515']
86 pr64516 = main.params['config']['pr64516']
87
88 global fsfwIp
89 global fsfwPort
90 fsfwIp = main.params[ 'CTRL' ][ 'fsfwIp' ]
91 fsfwPort = main.params[ 'CTRL' ][ 'fsfwPort' ]
pingping-lin26990f02015-11-30 15:48:06 -080092
Devin Lim58046fa2017-07-05 16:55:00 -070093 try:
94 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
95 except ImportError:
96 main.log.error( "sdnBase not found. exiting the test" )
pingping-lin26990f02015-11-30 15:48:06 -080097 main.exit()
Devin Lim58046fa2017-07-05 16:55:00 -070098 try:
99 main.sdnBase
100 except ( NameError, AttributeError ):
101 main.sdnBase = SdnBase()
102
103 main.sdnBase.initSetup()
104
pingping-lin26990f02015-11-30 15:48:06 -0800105
pingping-lin26990f02015-11-30 15:48:06 -0800106 def CASE200( self, main ):
107 main.case( "Activate sdn-ip application" )
108 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800109 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-lin26990f02015-11-30 15:48:06 -0800110
111 main.log.info( "Get links in the network" )
112 summaryResult = main.ONOScli1.summary()
113 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall6e9897d2016-02-29 14:41:32 -0800114 listResult = main.ONOScli1.links( jsonFormat=False )
pingping-lin26990f02015-11-30 15:48:06 -0800115 main.log.info( listResult )
pingping-lin26990f02015-11-30 15:48:06 -0800116 if linkNum < 100:
117 main.log.error( "Link number is wrong!" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800118 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
119 listResult = main.ONOScli1.links( jsonFormat=False )
120 main.log.info( listResult )
pingping-lin26990f02015-11-30 15:48:06 -0800121 main.cleanup()
122 main.exit()
123
124 main.step( "Activate sdn-ip application" )
125 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800126 utilities.assert_equals( expect=main.TRUE,
127 actual=activeSDNIPresult,
128 onpass="Activate SDN-IP succeeded",
129 onfail="Activate SDN-IP failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800130 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800131 main.log.info( "Activate SDN-IP failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800132 main.cleanup()
133 main.exit()
134
135
136 def CASE102( self, main ):
137 '''
138 This test case is to load the methods from other Python files, and create
139 tunnels from mininet host to onos nodes.
140 '''
141 import time
142 main.case( "Load methods from other Python file and create tunnels" )
143 # load the methods from other file
144 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
145 main.Functions = imp.load_source( wrapperFile1,
146 main.dependencyPath +
147 wrapperFile1 +
148 ".py" )
149 # Create tunnels
Devin Lim58046fa2017-07-05 16:55:00 -0700150 for i in range ( len( main.ONOSip ) ):
151 main.Functions.setupTunnel( main, '1.1.1.' + str( ( i + 1 ) * 2 ), 2000, main.ONOSip[ i ], 2000 )
pingping-lin26990f02015-11-30 15:48:06 -0800152
153 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
154 and the BGP paths in data plane are ready..." )
155 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
156
157 main.log.info( "Wait Quagga to finish delivery all routes to each \
158 other and to sdn-ip, plus finish installing all intents..." )
159 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-lin26990f02015-11-30 15:48:06 -0800160
161 def CASE1( self, main ):
162 '''
163 ping test from 3 bgp peers to BGP speaker
164 '''
165
166 main.case( "Ping tests between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800167 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
168 peers=["pr64514", "pr64515", "pr64516"],
169 expectAllSuccess=True )
170 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
171 peers=[pr64514, pr64515, pr64516],
172 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800173
174 def CASE2( self, main ):
175 '''
176 point-to-point intents test for each BGP peer and BGP speaker pair
177 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700178 main.sdnBase.pToPIntentTest( 12 )
pingping-lin26990f02015-11-30 15:48:06 -0800179
180
181 def CASE3( self, main ):
182 '''
183 routes and intents check to all BGP peers
184 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800185 import time
pingping-lin26990f02015-11-30 15:48:06 -0800186 main.case( "Check routes and M2S intents to all BGP peers" )
187
188 allRoutesExpected = []
189 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
190 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
191 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
192
Devin Lim58046fa2017-07-05 16:55:00 -0700193 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 3 )
pingping-lin26990f02015-11-30 15:48:06 -0800194
195
196 def CASE4( self, main ):
197 '''
198 Ping test in data plane for each route
199 '''
200 main.case( "Ping test for each route, all hosts behind BGP peers" )
201 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800202 hosts=["host64514", "host64515", "host64516"],
203 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800204
pingping-lin26990f02015-11-30 15:48:06 -0800205 def CASE5( self, main ):
206 '''
207 Cut links to peers one by one, check routes/intents
208 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700209 main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516",
210 2, 2, 1, 1, 0, 0,
211 "speaker1", [ "host64514", "host64515", "host64516" ],
212 "down" )
pingping-lin26990f02015-11-30 15:48:06 -0800213
214 def CASE6( self, main ):
215 '''
216 Recover links to peers one by one, check routes/intents
217 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700218 main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516",
219 1, 1, 2, 2, 3, 3,
220 "speaker1", [ "host64514", "host64515", "host64516" ],
221 "up" )
pingping-lin26990f02015-11-30 15:48:06 -0800222
223 def CASE7( self, main ):
224 '''
225 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
226 '''
227 import time
228 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
229 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800230 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
231 utilities.assertEquals( expect=main.TRUE, actual=result,
232 onpass="Stopping switch succeeded!",
233 onfail="Stopping switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800234
235 if result == main.TRUE:
236 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
237 main.Functions.checkRouteNum( main, 2 )
238 main.Functions.checkM2SintentNum( main, 2 )
239 main.Functions.checkP2PintentNum( main, 12 * 2 )
240 else:
241 main.log.error( "Stopping switch failed!" )
242 main.cleanup()
243 main.exit()
244
245 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800246 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
247 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
248 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-lin26990f02015-11-30 15:48:06 -0800249
250 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
251 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800252 utilities.assert_equals( expect=True, actual=pingResult1,
253 onpass="Ping test result is correct",
254 onfail="Ping test result is wrong" )
pingping-lin26990f02015-11-30 15:48:06 -0800255
256 if pingResult1 == False:
257 main.cleanup()
258 main.exit()
259
260 main.step( "Check ping between BGP peers and speaker1" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800261 result4 = main.Mininet.pingHost( src="speaker1", target="pr64514" )
262 result5 = main.Mininet.pingHost( src="speaker1", target="pr64515" )
263 result6 = main.Mininet.pingHost( src="speaker1", target="pr64516" )
pingping-lin26990f02015-11-30 15:48:06 -0800264
265 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
266 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800267 utilities.assert_equals( expect=True, actual=pingResult2,
268 onpass="Speaker1 ping peers successful",
269 onfail="Speaker1 ping peers NOT successful" )
pingping-lin26990f02015-11-30 15:48:06 -0800270
271 if pingResult2 == False:
272 main.cleanup()
273 main.exit()
274
275 main.step( "Check ping between BGP peers and speaker2" )
276 # TODO
Jon Hall6e9897d2016-02-29 14:41:32 -0800277 result7 = main.Mininet.pingHost( src="speaker2", target=pr64514 )
278 result8 = main.Mininet.pingHost( src="speaker2", target=pr64515 )
279 result9 = main.Mininet.pingHost( src="speaker2", target=pr64516 )
pingping-lin26990f02015-11-30 15:48:06 -0800280
281 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
282 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800283 utilities.assert_equals( expect=True, actual=pingResult2,
284 onpass="Speaker2 ping peers successful",
285 onfail="Speaker2 ping peers NOT successful" )
pingping-lin26990f02015-11-30 15:48:06 -0800286
287 if pingResult3 == False:
288 main.cleanup()
289 main.exit()
290
291 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800292 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
293 main.FALSE,
294 kwargs={'isPENDING':False},
295 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800296 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800297 expect=main.TRUE,
298 actual=flowCheck,
299 onpass="Flow status is correct!",
300 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800301
302
303 def CASE8( self, main ):
304 '''
305 Bring up the edge switch (sw32) which was shut down in CASE7,
306 check P-2-P and M-2-S intents, ping test
307 '''
308 import time
309 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
310 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800311 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-lin26990f02015-11-30 15:48:06 -0800312 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800313 expect=main.TRUE,
314 actual=result1,
315 onpass="Starting switch succeeded!",
316 onfail="Starting switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800317
pingping-lin3806f112016-01-04 10:38:25 -0800318 result2 = main.Mininet.assignSwController( "sw32", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800319 port=fsfwPort )
pingping-lin26990f02015-11-30 15:48:06 -0800320 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800321 expect=main.TRUE,
322 actual=result2,
323 onpass="Connect switch to FSFW succeeded!",
324 onfail="Connect switch to FSFW failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800325
326 if result1 and result2:
327 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
328 main.Functions.checkRouteNum( main, 3 )
329 main.Functions.checkM2SintentNum( main, 3 )
330 main.Functions.checkP2PintentNum( main, 18 * 2 )
331 else:
332 main.log.error( "Starting switch failed!" )
333 main.cleanup()
334 main.exit()
335
336 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800337 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
338 main.FALSE,
339 kwargs={'isPENDING':False},
340 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800341 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800342 expect=main.TRUE,
343 actual=flowCheck,
344 onpass="Flow status is correct!",
345 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800346
347 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800348 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
349 peers=["pr64514", "pr64515", "pr64516"],
350 expectAllSuccess=True )
351 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
352 peers=[pr64514, pr64515, pr64516],
353 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800354 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800355 hosts=["host64514", "host64515", "host64516"],
356 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800357
358
359 def CASE9( self, main ):
360 '''
361 Bring down a switch in best path, check:
362 route number, P2P intent number, M2S intent number, ping test
363 '''
364 main.case( "Stop sw11 located in best path, \
365 check route number, P2P intent number, M2S intent number, ping test" )
366
367 main.log.info( "Check the flow number correctness before stopping sw11" )
368 main.Functions.checkFlowNum( main, "sw11", 19 )
369 main.Functions.checkFlowNum( main, "sw1", 3 )
370 main.Functions.checkFlowNum( main, "sw7", 3 )
371 main.log.info( main.Mininet.checkFlows( "sw11" ) )
372 main.log.info( main.Mininet.checkFlows( "sw1" ) )
373 main.log.info( main.Mininet.checkFlows( "sw7" ) )
374
375 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800376 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
377 utilities.assertEquals( expect=main.TRUE, actual=result,
378 onpass="Stopping switch succeeded!",
379 onfail="Stopping switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800380 if result:
381 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
382 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
383 main.Functions.checkRouteNum( main, 3 )
384 main.Functions.checkM2SintentNum( main, 3 )
385 main.Functions.checkP2PintentNum( main, 18 * 2 )
386 else:
387 main.log.error( "Stopping switch failed!" )
388 main.cleanup()
389 main.exit()
390
391 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800392 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
393 main.FALSE,
394 kwargs={'isPENDING':False},
395 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800396 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800397 expect=main.TRUE,
398 actual=flowCheck,
399 onpass="Flow status is correct!",
400 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800401 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800402 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
403 peers=["pr64514", "pr64515", "pr64516"],
404 expectAllSuccess=True )
405 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
406 peers=[pr64514, pr64515, pr64516],
407 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800408 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800409 hosts=["host64514", "host64515", "host64516"],
410 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800411
412
413 def CASE10( self, main ):
414 '''
415 Bring up the switch which was stopped in CASE9, check:
416 route number, P2P intent number, M2S intent number, ping test
417 '''
418 main.case( "Start sw11 which was stopped in CASE9, \
419 check route number, P2P intent number, M2S intent number, ping test" )
420
421 main.log.info( "Check the flow status before starting sw11" )
422 main.Functions.checkFlowNum( main, "sw1", 17 )
423 main.Functions.checkFlowNum( main, "sw7", 5 )
424 main.log.info( main.Mininet.checkFlows( "sw1" ) )
425 main.log.info( main.Mininet.checkFlows( "sw7" ) )
426
427 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800428 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
429 utilities.assertEquals( expect=main.TRUE, actual=result1,
430 onpass="Starting switch succeeded!",
431 onfail="Starting switch failed!" )
pingping-lin3806f112016-01-04 10:38:25 -0800432 result2 = main.Mininet.assignSwController( "sw11", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800433 port=fsfwPort )
434 utilities.assertEquals( expect=main.TRUE, actual=result2,
435 onpass="Connect switch to FSFW succeeded!",
436 onfail="Connect switch to FSFW failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800437 if result1 and result2:
438 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
439 main.Functions.checkRouteNum( main, 3 )
440 main.Functions.checkM2SintentNum( main, 3 )
441 main.Functions.checkP2PintentNum( main, 18 * 2 )
442
443 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
444 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
445 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
446 else:
447 main.log.error( "Starting switch failed!" )
448 main.cleanup()
449 main.exit()
450
451 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800452 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
453 main.FALSE,
454 kwargs={'isPENDING':False},
455 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800456 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800457 expect=main.TRUE,
458 actual=flowCheck,
459 onpass="Flow status is correct!",
460 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800461 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800462 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
463 peers=["pr64514", "pr64515", "pr64516"],
464 expectAllSuccess=True )
465 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
466 peers=[pr64514, pr64515, pr64516],
467 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800468 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800469 hosts=["host64514", "host64515", "host64516"],
470 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800471
472
473 def CASE11(self, main):
474 import time
475 main.case( "Kill speaker1, check:\
476 route number, P2P intent number, M2S intent number, ping test" )
477 main.log.info( "Check network status before killing speaker1" )
478 main.Functions.checkRouteNum( main, 3 )
479 main.Functions.checkM2SintentNum( main, 3 )
480 main.Functions.checkP2PintentNum( main, 18 * 2 )
481 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800482 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
483 main.FALSE,
484 kwargs={'isPENDING':False},
485 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800486 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800487 expect=main.TRUE,
488 actual=flowCheck,
489 onpass="Flow status is correct!",
490 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800491
Jon Hall6e9897d2016-02-29 14:41:32 -0800492 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
493 peers=["pr64514", "pr64515", "pr64516"],
494 expectAllSuccess=True )
495 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
496 peers=[pr64514, pr64515, pr64516],
497 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800498 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800499 hosts=["host64514", "host64515", "host64516"],
500 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800501
502 main.step( "Kill speaker1" )
503 command1 = "ps -e | grep bgp -c"
504 result1 = main.Mininet.node( "root", command1 )
505
506 # The total BGP daemon number in this test environment is 5.
507 if "5" in result1:
508 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
509 else:
510 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
511 main.log.info( result1 )
512
513 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
514 result2 = main.Mininet.node( "root", command2 )
515
516 result3 = main.Mininet.node( "root", command1 )
517
Jon Hall6e9897d2016-02-29 14:41:32 -0800518 utilities.assert_equals( expect=True,
519 actual=( "4" in result3 ),
520 onpass="Kill speaker1 succeeded",
521 onfail="Kill speaker1 failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800522 if ( "4" not in result3 ) :
523 main.log.info( result3 )
524 main.cleanup()
525 main.exit()
526
527 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
528 main.Functions.checkRouteNum( main, 3 )
529 main.Functions.checkM2SintentNum( main, 3 )
530 main.Functions.checkP2PintentNum( main, 18 * 2 )
531
532 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800533 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
534 main.FALSE,
535 kwargs={'isPENDING':False},
536 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800537 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800538 expect=main.TRUE,
539 actual=flowCheck,
540 onpass="Flow status is correct!",
541 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800542
543 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800544 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
545 peers=["pr64514", "pr64515", "pr64516"],
546 expectAllSuccess=False )
pingping-lin26990f02015-11-30 15:48:06 -0800547 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800548 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
549 peers=[pr64514, pr64515, pr64516],
550 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800551 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800552 hosts=["host64514", "host64515", "host64516"],
553 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800554
555
556 def CASE12( self, main ):
557 import time
558 import json
559 main.case( "Bring down leader ONOS node, check: \
560 route number, P2P intent number, M2S intent number, ping test" )
561 main.step( "Find out ONOS leader node" )
562 result = main.ONOScli1.leaders()
563 jsonResult = json.loads( result )
564 leaderIP = ""
565 for entry in jsonResult:
566 if entry["topic"] == "org.onosproject.sdnip":
567 leaderIP = entry["leader"]
568 main.log.info( "leaderIP is: " )
569 main.log.info( leaderIP )
570
Devin Lim58046fa2017-07-05 16:55:00 -0700571 main.step( "Uninstall ONOS/SDN-IP leader node" )
572 for ip in main.ONOSip:
573 if leaderIP == ip:
574 uninstallResult = main.ONOSbench.onosStop( ip )
pingping-lin26990f02015-11-30 15:48:06 -0800575
Jon Hall6e9897d2016-02-29 14:41:32 -0800576 utilities.assert_equals( expect=main.TRUE,
577 actual=uninstallResult,
578 onpass="Uninstall ONOS leader succeeded",
579 onfail="Uninstall ONOS leader failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800580 if uninstallResult != main.TRUE:
581 main.cleanup()
582 main.exit()
583 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
584
Devin Lim58046fa2017-07-05 16:55:00 -0700585 if leaderIP == main.ONOSip[ 0 ]:
Jon Hall6e9897d2016-02-29 14:41:32 -0800586 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
587 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
588 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
pingping-lin26990f02015-11-30 15:48:06 -0800589
590 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800591 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
592 main.FALSE,
593 kwargs={'isPENDING':False},
594 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800595 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800596 expect=main.TRUE,
597 actual=flowCheck,
598 onpass="Flow status is correct!",
599 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800600 else:
601 main.Functions.checkRouteNum( main, 3 )
602 main.Functions.checkM2SintentNum( main, 3 )
603 main.Functions.checkP2PintentNum( main, 18 * 2 )
604
605 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800606 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
607 main.FALSE,
608 kwargs={'isPENDING':False},
609 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800610 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800611 expect=main.TRUE,
612 actual=flowCheck,
613 onpass="Flow status is correct!",
614 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800615
Jon Hall6e9897d2016-02-29 14:41:32 -0800616 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
617 peers=["pr64514", "pr64515", "pr64516"],
618 expectAllSuccess=True )
619 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
620 peers=[pr64514, pr64515, pr64516],
621 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800622 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800623 hosts=["host64514", "host64515", "host64516"],
624 expectAllSuccess=True )