blob: a1fb40557e29857c05dd1faed54056fd20e6da85 [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
Jon Hall362aa922016-03-31 09:39:26 -070013 main.case( "Setup the Mininet testbed" )
pingping-linea32cf82015-10-08 22:37:37 -070014 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-linea32cf82015-10-08 22:37:37 -070025 # 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 )
Devin Lim58046fa2017-07-05 16:55:00 -070035 swResult = swResult and main.Mininet.assignSwController( sw, main.ONOSip )
Jon Hall6e9897d2016-02-29 14:41:32 -080036 utilities.assert_equals( expect=main.TRUE,
37 actual=swResult,
38 onpass="Successfully connect all switches to ONOS",
39 onfail="Failed to connect all switches to ONOS" )
pingping-linea32cf82015-10-08 22:37:37 -070040 if not swResult:
41 main.cleanup()
42 main.exit()
43
44
45 def CASE101( self, main ):
46 """
47 Package ONOS and install it
48 Startup sequence:
49 cell <name>
50 onos-verify-cell
51 onos-package
52 onos-install -f
53 onos-wait-for-start
54 """
55 import json
56 import time
57 import os
58 from operator import eq
alison62006dd2016-12-15 16:21:28 -080059 global p64514
60 global p64515
61 global p64516
Devin Lim58046fa2017-07-05 16:55:00 -070062 p64514 = main.params[ 'config' ][ 'p64514' ]
63 p64515 = main.params[ 'config' ][ 'p64515' ]
64 p64516 = main.params[ 'config' ][ 'p64516' ]
pingping-linea32cf82015-10-08 22:37:37 -070065
Devin Lim58046fa2017-07-05 16:55:00 -070066 try:
67 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
68 except ImportError:
69 main.log.error( "sdnBase not found. exiting the test" )
pingping-linea32cf82015-10-08 22:37:37 -070070 main.exit()
Devin Lim58046fa2017-07-05 16:55:00 -070071 try:
72 main.sdnBase
73 except ( NameError, AttributeError ):
74 main.sdnBase = SdnBase()
75
76 main.sdnBase.initSetup()
pingping-linea32cf82015-10-08 22:37:37 -070077
pingping-linea32cf82015-10-08 22:37:37 -070078 def CASE200( self, main ):
79 main.case( "Activate sdn-ip application" )
80 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -080081 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-linea32cf82015-10-08 22:37:37 -070082
Jon Hall362aa922016-03-31 09:39:26 -070083 main.step( "Get links in the network" )
pingping-lina14c7c82015-10-09 15:44:36 -070084 summaryResult = main.ONOScli1.summary()
pingping-linea32cf82015-10-08 22:37:37 -070085 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall362aa922016-03-31 09:39:26 -070086 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
pingping-linea32cf82015-10-08 22:37:37 -070087 if linkNum < 100:
Jon Hall362aa922016-03-31 09:39:26 -070088 main.log.error( "Link number is wrong! Retrying..." )
Jon Hall6e9897d2016-02-29 14:41:32 -080089 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -070090 summaryResult = main.ONOScli1.summary()
91 linkNum = json.loads( summaryResult )[ "links" ]
92 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
93 utilities.assert_equals( expect=100,
94 actual=linkNum,
95 onpass="ONOS correctly discovered all links",
96 onfail="ONOS Failed to discover all links" )
97 if linkNum < 100:
pingping-linea32cf82015-10-08 22:37:37 -070098 main.cleanup()
99 main.exit()
100
pingping-linea32cf82015-10-08 22:37:37 -0700101 main.step( "Activate sdn-ip application" )
pingping-lina14c7c82015-10-09 15:44:36 -0700102 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800103 utilities.assert_equals( expect=main.TRUE,
104 actual=activeSDNIPresult,
105 onpass="Activate SDN-IP succeeded",
106 onfail="Activate SDN-IP failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700107 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800108 main.log.info( "Activate SDN-IP failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700109 main.cleanup()
110 main.exit()
111
pingping-linea32cf82015-10-08 22:37:37 -0700112 def CASE102( self, main ):
113 '''
114 This test case is to load the methods from other Python files, and create
115 tunnels from mininet host to onos nodes.
116 '''
117 import time
118 main.case( "Load methods from other Python file and create tunnels" )
119 # load the methods from other file
120 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
121 main.Functions = imp.load_source( wrapperFile1,
122 main.dependencyPath +
123 wrapperFile1 +
124 ".py" )
125 # Create tunnels
Devin Lim58046fa2017-07-05 16:55:00 -0700126 for i in range ( len( main.ONOSip ) ):
127 main.Functions.setupTunnel( main, '1.1.1.' + str( ( i + 1 ) * 2 ), 2000, main.ONOSip[ i ], 2000 )
pingping-linea32cf82015-10-08 22:37:37 -0700128
129 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
130 and the BGP paths in data plane are ready..." )
131 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
132
133 main.log.info( "Wait Quagga to finish delivery all routes to each \
134 other and to sdn-ip, plus finish installing all intents..." )
135 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700136
137 def CASE1( self, main ):
138 '''
139 ping test from 3 bgp peers to BGP speaker
140 '''
141
Jon Hall362aa922016-03-31 09:39:26 -0700142 main.case( "Ping between BGP peers and speakers" )
alison62006dd2016-12-15 16:21:28 -0800143 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
144 peers=[ "p64514", "p64515", "p64516" ],
145 expectAllSuccess=True )
146
147 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
148 peers=[ p64514, p64515, p64516 ],
149 expectAllSuccess=True )
150
151 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ],
152 peers=[ "p64519", "p64520" ],
153 expectAllSuccess=True )
154
155 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk4" ],
156 peers=[ "p64517", "p64518" ],
157 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700158
159 def CASE2( self, main ):
160 '''
161 point-to-point intents test for each BGP peer and BGP speaker pair
162 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700163 main.sdnBase.pToPIntentTest( 12 )
pingping-linea32cf82015-10-08 22:37:37 -0700164
165 def CASE3( self, main ):
166 '''
167 routes and intents check to all BGP peers
168 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800169 import time
pingping-linea32cf82015-10-08 22:37:37 -0700170 main.case( "Check routes and M2S intents to all BGP peers" )
171
Jon Hall362aa922016-03-31 09:39:26 -0700172 main.step( "Check routes installed" )
pingping-linea32cf82015-10-08 22:37:37 -0700173 allRoutesExpected = []
174 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
175 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
176 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
alison62006dd2016-12-15 16:21:28 -0800177 allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" )
178 allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" )
179 allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
180 allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
pingping-linea32cf82015-10-08 22:37:37 -0700181
Devin Lim58046fa2017-07-05 16:55:00 -0700182 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
pingping-linea32cf82015-10-08 22:37:37 -0700183
184
185 def CASE4( self, main ):
186 '''
187 Ping test in data plane for each route
188 '''
189 main.case( "Ping test for each route, all hosts behind BGP peers" )
190 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800191 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800192 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800193 main.Functions.pingHostToHost(main,
194 hosts=["h64517", "h64518"],
195 expectAllSuccess=True)
Devin Lim58046fa2017-07-05 16:55:00 -0700196 main.Functions.pingHostToHost( main,
197 hosts=[ "h64519", "h64520" ],
198 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700199
200 def CASE5( self, main ):
201 '''
202 Cut links to peers one by one, check routes/intents
203 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700204 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
205 6, 6, 5, 5, 4, 4,
206 "spk1", [ "h64514", "h64515", "h64516" ],
207 "down" )
pingping-linea32cf82015-10-08 22:37:37 -0700208
pingping-linea32cf82015-10-08 22:37:37 -0700209 def CASE6( self, main ):
210 '''
211 Recover links to peers one by one, check routes/intents
212 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700213 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
214 5, 5, 6, 6, 7, 7,
215 "spk1", [ "h64514", "h64515", "h64516" ],
216 "up" )
pingping-linea32cf82015-10-08 22:37:37 -0700217
pingping-linea32cf82015-10-08 22:37:37 -0700218 def CASE7( self, main ):
219 '''
220 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
221 '''
222 import time
223 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
224 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800225 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700226 utilities.assert_equals( expect=main.TRUE, actual=result,
227 onpass="Stopping switch succeeded!",
228 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700229
230 if result == main.TRUE:
231 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800232 main.Functions.checkRouteNum( main, 6 )
233 main.Functions.checkM2SintentNum( main, 6 )
234 main.Functions.checkP2PintentNum( main, 48 ) #14 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700235 else:
236 main.log.error( "Stopping switch failed!" )
237 main.cleanup()
238 main.exit()
239
240 main.step( "Check ping between hosts behind BGP peers" )
alison62006dd2016-12-15 16:21:28 -0800241 result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
242 result2 = main.Mininet.pingHost( src="h64515", target="h64516" )
243 result3 = main.Mininet.pingHost( src="h64514", target="h64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700244
245 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
246 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800247 utilities.assert_equals( expect=True, actual=pingResult1,
248 onpass="Ping test result is correct",
249 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700250
251 if pingResult1 == False:
252 main.cleanup()
253 main.exit()
254
alison62006dd2016-12-15 16:21:28 -0800255 main.step( "Check ping between BGP peers and spk1" )
256 result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
257 result5 = main.Mininet.pingHost( src="spk1", target="p64515" )
258 result6 = main.Mininet.pingHost( src="spk1", target="p64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700259
260 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
261 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800262 utilities.assert_equals( expect=True, actual=pingResult2,
263 onpass="Speaker1 ping peers successful",
264 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700265
266 if pingResult2 == False:
267 main.cleanup()
268 main.exit()
269
alison62006dd2016-12-15 16:21:28 -0800270 main.step( "Check ping between BGP peers and spk2" )
pingping-linea32cf82015-10-08 22:37:37 -0700271 # TODO
alison62006dd2016-12-15 16:21:28 -0800272 result7 = main.Mininet.pingHost( src="spk2", target=p64514 )
273 result8 = main.Mininet.pingHost( src="spk2", target=p64515 )
274 result9 = main.Mininet.pingHost( src="spk2", target=p64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700275
276 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
277 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800278 utilities.assert_equals( expect=True, actual=pingResult2,
279 onpass="Speaker2 ping peers successful",
280 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700281
282 if pingResult3 == False:
283 main.cleanup()
284 main.exit()
285
286 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800287 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
288 main.FALSE,
289 kwargs={'isPENDING':False},
290 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700291 utilities.assert_equals( expect=main.TRUE,
292 actual=flowCheck,
293 onpass="Flow status is correct!",
294 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700295
296 def CASE8( self, main ):
297 '''
298 Bring up the edge switch (sw32) which was shut down in CASE7,
299 check P-2-P and M-2-S intents, ping test
300 '''
301 import time
302 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
303 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800304 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700305 utilities.assert_equals( expect=main.TRUE,
306 actual=result1,
307 onpass="Starting switch succeeded!",
308 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700309
Devin Lim58046fa2017-07-05 16:55:00 -0700310 result2 = main.Mininet.assignSwController( "sw32", main.ONOSip[ 0 ] )
Jon Hall362aa922016-03-31 09:39:26 -0700311 utilities.assert_equals( expect=main.TRUE,
312 actual=result2,
313 onpass="Connect switch to ONOS succeeded!",
314 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700315
316 if result1 and result2:
317 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800318 main.Functions.checkRouteNum( main, 7 )
319 main.Functions.checkM2SintentNum( main, 7 )
320 main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18*2
pingping-linea32cf82015-10-08 22:37:37 -0700321 else:
322 main.log.error( "Starting switch failed!" )
323 main.cleanup()
324 main.exit()
325
326 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800327 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
328 main.FALSE,
329 kwargs={'isPENDING':False},
330 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700331 utilities.assert_equals( expect=main.TRUE,
332 actual=flowCheck,
333 onpass="Flow status is correct!",
334 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700335
336 # Ping test
alison62006dd2016-12-15 16:21:28 -0800337 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
338 peers=["p64514", "p64515", "p64516"],
339 expectAllSuccess=True )
340
341 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
342 peers=[ p64514, p64515, p64516 ],
343 expectAllSuccess=True )
344
pingping-linea32cf82015-10-08 22:37:37 -0700345 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800346 hosts=[ "h64514", "h64515", "h64516" ],
347 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700348
pingping-linea32cf82015-10-08 22:37:37 -0700349 def CASE9( self, main ):
350 '''
351 Bring down a switch in best path, check:
352 route number, P2P intent number, M2S intent number, ping test
353 '''
354 main.case( "Stop sw11 located in best path, \
355 check route number, P2P intent number, M2S intent number, ping test" )
356
357 main.log.info( "Check the flow number correctness before stopping sw11" )
alison62006dd2016-12-15 16:21:28 -0800358 main.Functions.checkFlowNum( main, "sw11", 49 )
359 main.Functions.checkFlowNum( main, "sw1", 7 )
360 main.Functions.checkFlowNum( main, "sw7", 34 )
pingping-linea32cf82015-10-08 22:37:37 -0700361 main.log.info( main.Mininet.checkFlows( "sw11" ) )
362 main.log.info( main.Mininet.checkFlows( "sw1" ) )
363 main.log.info( main.Mininet.checkFlows( "sw7" ) )
364
365 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800366 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700367 utilities.assert_equals( expect=main.TRUE, actual=result,
368 onpass="Stopping switch succeeded!",
369 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700370 if result:
371 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
372 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800373 main.Functions.checkRouteNum( main, 7 )
374 main.Functions.checkM2SintentNum( main, 7 )
375 main.Functions.checkP2PintentNum( main, 30 * 2 ) #18 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700376 else:
377 main.log.error( "Stopping switch failed!" )
378 main.cleanup()
379 main.exit()
380
381 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800382 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
383 main.FALSE,
384 kwargs={'isPENDING':False},
385 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700386 utilities.assert_equals( expect=main.TRUE,
387 actual=flowCheck,
388 onpass="Flow status is correct!",
389 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700390 # Ping test
alison62006dd2016-12-15 16:21:28 -0800391 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
392 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800393 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800394 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
395 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800396 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700397 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800398 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800399 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700400
401
402 def CASE10( self, main ):
403 '''
404 Bring up the switch which was stopped in CASE9, check:
405 route number, P2P intent number, M2S intent number, ping test
406 '''
407 main.case( "Start sw11 which was stopped in CASE9, \
408 check route number, P2P intent number, M2S intent number, ping test" )
409
410 main.log.info( "Check the flow status before starting sw11" )
alison62006dd2016-12-15 16:21:28 -0800411 main.Functions.checkFlowNum( main, "sw1", 36 )
412 main.Functions.checkFlowNum( main, "sw7", 30 )
pingping-linea32cf82015-10-08 22:37:37 -0700413 main.log.info( main.Mininet.checkFlows( "sw1" ) )
414 main.log.info( main.Mininet.checkFlows( "sw7" ) )
415
416 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800417 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700418 utilities.assert_equals( expect=main.TRUE, actual=result1,
419 onpass="Starting switch succeeded!",
420 onfail="Starting switch failed!" )
Devin Lim58046fa2017-07-05 16:55:00 -0700421 result2 = main.Mininet.assignSwController( "sw11", main.ONOSip[ 0 ] )
Jon Hall362aa922016-03-31 09:39:26 -0700422 utilities.assert_equals( expect=main.TRUE, actual=result2,
423 onpass="Connect switch to ONOS succeeded!",
424 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700425 if result1 and result2:
426 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800427 main.Functions.checkRouteNum( main, 7 )
428 main.Functions.checkM2SintentNum( main, 7 )
429 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700430
431 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
432 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
433 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
434 else:
435 main.log.error( "Starting switch failed!" )
436 main.cleanup()
437 main.exit()
438
439 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800440 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
441 main.FALSE,
442 kwargs={'isPENDING':False},
443 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700444 utilities.assert_equals( expect=main.TRUE,
445 actual=flowCheck,
446 onpass="Flow status is correct!",
447 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700448 # Ping test
alison62006dd2016-12-15 16:21:28 -0800449 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
450 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800451 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800452 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
453 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800454 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700455 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800456 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800457 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700458
459
460 def CASE11(self, main):
461 import time
alison62006dd2016-12-15 16:21:28 -0800462 main.case( "Kill spk1, check:\
pingping-linea32cf82015-10-08 22:37:37 -0700463 route number, P2P intent number, M2S intent number, ping test" )
alison62006dd2016-12-15 16:21:28 -0800464 main.log.info( "Check network status before killing spk1" )
465 main.Functions.checkRouteNum( main, 7 )
466 main.Functions.checkM2SintentNum( main, 7 )
467 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700468 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800469 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
470 main.FALSE,
471 kwargs={'isPENDING':False},
472 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700473 utilities.assert_equals( expect=main.TRUE,
474 actual=flowCheck,
475 onpass="Flow status is correct!",
476 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700477
alison62006dd2016-12-15 16:21:28 -0800478 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
479 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800480 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800481 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
482 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800483 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700484 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800485 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800486 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700487
alison62006dd2016-12-15 16:21:28 -0800488 main.step( "Kill spk1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700489 command1 = "ps -e | grep bgp -c"
490 result1 = main.Mininet.node( "root", command1 )
491
492 # The total BGP daemon number in this test environment is 5.
493 if "5" in result1:
alison62006dd2016-12-15 16:21:28 -0800494 main.log.debug( "Before kill spk1, 5 BGP daemons - correct" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700495 else:
alison62006dd2016-12-15 16:21:28 -0800496 main.log.warn( "Before kill spk1, number of BGP daemons is wrong" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700497 main.log.info( result1 )
498
499 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
500 result2 = main.Mininet.node( "root", command2 )
501
502 result3 = main.Mininet.node( "root", command1 )
503
Jon Hall6e9897d2016-02-29 14:41:32 -0800504 utilities.assert_equals( expect=True,
505 actual=( "4" in result3 ),
alison62006dd2016-12-15 16:21:28 -0800506 onpass="Kill spk1 succeeded",
507 onfail="Kill spk1 failed" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700508 if ( "4" not in result3 ) :
509 main.log.info( result3 )
pingping-linea32cf82015-10-08 22:37:37 -0700510 main.cleanup()
511 main.exit()
512
513 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800514 main.Functions.checkRouteNum( main, 7 )
515 main.Functions.checkM2SintentNum( main, 7 )
516 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700517
518 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800519 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
520 main.FALSE,
521 kwargs={'isPENDING':False},
522 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700523 utilities.assert_equals( expect=main.TRUE,
524 actual=flowCheck,
525 onpass="Flow status is correct!",
526 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700527
528 '''
alison62006dd2016-12-15 16:21:28 -0800529 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
530 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800531 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700532 '''
alison62006dd2016-12-15 16:21:28 -0800533 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
534 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800535 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700536 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800537 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800538 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700539
540
541 def CASE12( self, main ):
542 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700543 import json
pingping-linea32cf82015-10-08 22:37:37 -0700544 main.case( "Bring down leader ONOS node, check: \
545 route number, P2P intent number, M2S intent number, ping test" )
546 main.step( "Find out ONOS leader node" )
pingping-lina14c7c82015-10-09 15:44:36 -0700547 result = main.ONOScli1.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700548 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700549 leaderIP = ""
550 for entry in jsonResult:
551 if entry["topic"] == "org.onosproject.sdnip":
552 leaderIP = entry["leader"]
553 main.log.info( "leaderIP is: " )
554 main.log.info( leaderIP )
555
556 main.step( "Uninstall ONOS/SDN-IP leader node" )
Devin Lim58046fa2017-07-05 16:55:00 -0700557 for ip in main.ONOSip:
558 if leaderIP == ip:
559 uninstallResult = main.ONOSbench.onosStop( ip )
pingping-lina14c7c82015-10-09 15:44:36 -0700560
Jon Hall6e9897d2016-02-29 14:41:32 -0800561 utilities.assert_equals( expect=main.TRUE,
562 actual=uninstallResult,
563 onpass="Uninstall ONOS leader succeeded",
564 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700565 if uninstallResult != main.TRUE:
566 main.cleanup()
567 main.exit()
568 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700569
Devin Lim58046fa2017-07-05 16:55:00 -0700570 if leaderIP == main.ONOSip[ 0 ]:
alison62006dd2016-12-15 16:21:28 -0800571 main.Functions.checkRouteNum( main, 7, ONOScli="ONOScli2" )
572 main.Functions.checkM2SintentNum( main, 7, ONOScli="ONOScli2" )
573 main.Functions.checkP2PintentNum( main, 30 * 2, ONOScli="ONOScli2" )
pingping-lina14c7c82015-10-09 15:44:36 -0700574
575 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800576 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
577 main.FALSE,
578 kwargs={'isPENDING':False},
579 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700580 utilities.assert_equals( expect=main.TRUE,
581 actual=flowCheck,
582 onpass="Flow status is correct!",
583 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700584 else:
alison62006dd2016-12-15 16:21:28 -0800585 main.Functions.checkRouteNum( main, 7 )
586 main.Functions.checkM2SintentNum( main, 7 )
587 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-lina14c7c82015-10-09 15:44:36 -0700588
589 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800590 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
591 main.FALSE,
592 kwargs={'isPENDING':False},
593 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700594 utilities.assert_equals( expect=main.TRUE,
595 actual=flowCheck,
596 onpass="Flow status is correct!",
597 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700598
alison62006dd2016-12-15 16:21:28 -0800599 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
600 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800601 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800602 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
603 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800604 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700605 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800606 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800607 expectAllSuccess=True )