blob: 83dbcb776c7aba81492d2dbb446b9a41234ed17e [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-linea32cf82015-10-08 22:37:37 -070022# Testing the functionality of SDN-IP with single ONOS instance
23class USECASE_SdnipFunctionCluster:
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 Hall362aa922016-03-31 09:39:26 -070034 main.case( "Setup the Mininet testbed" )
pingping-linea32cf82015-10-08 22:37:37 -070035 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-linea32cf82015-10-08 22:37:37 -070046 # Exit if topology did not load properly
47 if not topoResult:
48 main.cleanup()
49 main.exit()
50 main.step( "Connect switches to controllers" )
51
52 # connect all switches to controllers
53 swResult = main.TRUE
54 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
55 sw = "sw%s" % ( i )
Devin Lim58046fa2017-07-05 16:55:00 -070056 swResult = swResult and main.Mininet.assignSwController( sw, main.ONOSip )
Jon Hall6e9897d2016-02-29 14:41:32 -080057 utilities.assert_equals( expect=main.TRUE,
58 actual=swResult,
59 onpass="Successfully connect all switches to ONOS",
60 onfail="Failed to connect all switches to ONOS" )
pingping-linea32cf82015-10-08 22:37:37 -070061 if not swResult:
62 main.cleanup()
63 main.exit()
64
65
66 def CASE101( self, main ):
67 """
68 Package ONOS and install it
69 Startup sequence:
70 cell <name>
71 onos-verify-cell
72 onos-package
73 onos-install -f
74 onos-wait-for-start
75 """
76 import json
77 import time
78 import os
79 from operator import eq
alison62006dd2016-12-15 16:21:28 -080080 global p64514
81 global p64515
82 global p64516
Devin Lim58046fa2017-07-05 16:55:00 -070083 p64514 = main.params[ 'config' ][ 'p64514' ]
84 p64515 = main.params[ 'config' ][ 'p64515' ]
85 p64516 = main.params[ 'config' ][ 'p64516' ]
pingping-linea32cf82015-10-08 22:37:37 -070086
Devin Lim58046fa2017-07-05 16:55:00 -070087 try:
88 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
89 except ImportError:
90 main.log.error( "sdnBase not found. exiting the test" )
pingping-linea32cf82015-10-08 22:37:37 -070091 main.exit()
Devin Lim58046fa2017-07-05 16:55:00 -070092 try:
93 main.sdnBase
94 except ( NameError, AttributeError ):
95 main.sdnBase = SdnBase()
96
97 main.sdnBase.initSetup()
pingping-linea32cf82015-10-08 22:37:37 -070098
pingping-linea32cf82015-10-08 22:37:37 -070099 def CASE200( self, main ):
100 main.case( "Activate sdn-ip application" )
101 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800102 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700103
Jon Hall362aa922016-03-31 09:39:26 -0700104 main.step( "Get links in the network" )
pingping-lina14c7c82015-10-09 15:44:36 -0700105 summaryResult = main.ONOScli1.summary()
pingping-linea32cf82015-10-08 22:37:37 -0700106 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall362aa922016-03-31 09:39:26 -0700107 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
pingping-linea32cf82015-10-08 22:37:37 -0700108 if linkNum < 100:
Jon Hall362aa922016-03-31 09:39:26 -0700109 main.log.error( "Link number is wrong! Retrying..." )
Jon Hall6e9897d2016-02-29 14:41:32 -0800110 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700111 summaryResult = main.ONOScli1.summary()
112 linkNum = json.loads( summaryResult )[ "links" ]
113 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
114 utilities.assert_equals( expect=100,
115 actual=linkNum,
116 onpass="ONOS correctly discovered all links",
117 onfail="ONOS Failed to discover all links" )
118 if linkNum < 100:
pingping-linea32cf82015-10-08 22:37:37 -0700119 main.cleanup()
120 main.exit()
121
pingping-linea32cf82015-10-08 22:37:37 -0700122 main.step( "Activate sdn-ip application" )
pingping-lina14c7c82015-10-09 15:44:36 -0700123 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800124 utilities.assert_equals( expect=main.TRUE,
125 actual=activeSDNIPresult,
126 onpass="Activate SDN-IP succeeded",
127 onfail="Activate SDN-IP failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700128 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800129 main.log.info( "Activate SDN-IP failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700130 main.cleanup()
131 main.exit()
132
pingping-linea32cf82015-10-08 22:37:37 -0700133 def CASE102( self, main ):
134 '''
135 This test case is to load the methods from other Python files, and create
136 tunnels from mininet host to onos nodes.
137 '''
138 import time
139 main.case( "Load methods from other Python file and create tunnels" )
140 # load the methods from other file
141 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
142 main.Functions = imp.load_source( wrapperFile1,
143 main.dependencyPath +
144 wrapperFile1 +
145 ".py" )
146 # Create tunnels
Devin Lim58046fa2017-07-05 16:55:00 -0700147 for i in range ( len( main.ONOSip ) ):
148 main.Functions.setupTunnel( main, '1.1.1.' + str( ( i + 1 ) * 2 ), 2000, main.ONOSip[ i ], 2000 )
pingping-linea32cf82015-10-08 22:37:37 -0700149
150 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
151 and the BGP paths in data plane are ready..." )
152 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
153
154 main.log.info( "Wait Quagga to finish delivery all routes to each \
155 other and to sdn-ip, plus finish installing all intents..." )
156 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700157
158 def CASE1( self, main ):
159 '''
160 ping test from 3 bgp peers to BGP speaker
161 '''
162
Jon Hall362aa922016-03-31 09:39:26 -0700163 main.case( "Ping between BGP peers and speakers" )
alison62006dd2016-12-15 16:21:28 -0800164 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
165 peers=[ "p64514", "p64515", "p64516" ],
166 expectAllSuccess=True )
167
168 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
169 peers=[ p64514, p64515, p64516 ],
170 expectAllSuccess=True )
171
172 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ],
173 peers=[ "p64519", "p64520" ],
174 expectAllSuccess=True )
175
176 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk4" ],
177 peers=[ "p64517", "p64518" ],
178 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700179
180 def CASE2( self, main ):
181 '''
182 point-to-point intents test for each BGP peer and BGP speaker pair
183 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700184 main.sdnBase.pToPIntentTest( 12 )
pingping-linea32cf82015-10-08 22:37:37 -0700185
186 def CASE3( self, main ):
187 '''
188 routes and intents check to all BGP peers
189 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800190 import time
pingping-linea32cf82015-10-08 22:37:37 -0700191 main.case( "Check routes and M2S intents to all BGP peers" )
192
Jon Hall362aa922016-03-31 09:39:26 -0700193 main.step( "Check routes installed" )
pingping-linea32cf82015-10-08 22:37:37 -0700194 allRoutesExpected = []
195 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
196 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
197 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
alison62006dd2016-12-15 16:21:28 -0800198 allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" )
199 allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" )
200 allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
201 allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
pingping-linea32cf82015-10-08 22:37:37 -0700202
Devin Lim58046fa2017-07-05 16:55:00 -0700203 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
pingping-linea32cf82015-10-08 22:37:37 -0700204
205
206 def CASE4( self, main ):
207 '''
208 Ping test in data plane for each route
209 '''
210 main.case( "Ping test for each route, all hosts behind BGP peers" )
211 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800212 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800213 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800214 main.Functions.pingHostToHost(main,
215 hosts=["h64517", "h64518"],
216 expectAllSuccess=True)
Devin Lim58046fa2017-07-05 16:55:00 -0700217 main.Functions.pingHostToHost( main,
218 hosts=[ "h64519", "h64520" ],
219 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700220
221 def CASE5( self, main ):
222 '''
223 Cut links to peers one by one, check routes/intents
224 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700225 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
226 6, 6, 5, 5, 4, 4,
227 "spk1", [ "h64514", "h64515", "h64516" ],
228 "down" )
pingping-linea32cf82015-10-08 22:37:37 -0700229
pingping-linea32cf82015-10-08 22:37:37 -0700230 def CASE6( self, main ):
231 '''
232 Recover links to peers one by one, check routes/intents
233 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700234 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
235 5, 5, 6, 6, 7, 7,
236 "spk1", [ "h64514", "h64515", "h64516" ],
237 "up" )
pingping-linea32cf82015-10-08 22:37:37 -0700238
pingping-linea32cf82015-10-08 22:37:37 -0700239 def CASE7( self, main ):
240 '''
241 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
242 '''
243 import time
244 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
245 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800246 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700247 utilities.assert_equals( expect=main.TRUE, actual=result,
248 onpass="Stopping switch succeeded!",
249 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700250
251 if result == main.TRUE:
252 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800253 main.Functions.checkRouteNum( main, 6 )
254 main.Functions.checkM2SintentNum( main, 6 )
255 main.Functions.checkP2PintentNum( main, 48 ) #14 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700256 else:
257 main.log.error( "Stopping switch failed!" )
258 main.cleanup()
259 main.exit()
260
261 main.step( "Check ping between hosts behind BGP peers" )
alison62006dd2016-12-15 16:21:28 -0800262 result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
263 result2 = main.Mininet.pingHost( src="h64515", target="h64516" )
264 result3 = main.Mininet.pingHost( src="h64514", target="h64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700265
266 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
267 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800268 utilities.assert_equals( expect=True, actual=pingResult1,
269 onpass="Ping test result is correct",
270 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700271
272 if pingResult1 == False:
273 main.cleanup()
274 main.exit()
275
alison62006dd2016-12-15 16:21:28 -0800276 main.step( "Check ping between BGP peers and spk1" )
277 result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
278 result5 = main.Mininet.pingHost( src="spk1", target="p64515" )
279 result6 = main.Mininet.pingHost( src="spk1", target="p64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700280
281 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
282 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800283 utilities.assert_equals( expect=True, actual=pingResult2,
284 onpass="Speaker1 ping peers successful",
285 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700286
287 if pingResult2 == False:
288 main.cleanup()
289 main.exit()
290
alison62006dd2016-12-15 16:21:28 -0800291 main.step( "Check ping between BGP peers and spk2" )
pingping-linea32cf82015-10-08 22:37:37 -0700292 # TODO
alison62006dd2016-12-15 16:21:28 -0800293 result7 = main.Mininet.pingHost( src="spk2", target=p64514 )
294 result8 = main.Mininet.pingHost( src="spk2", target=p64515 )
295 result9 = main.Mininet.pingHost( src="spk2", target=p64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700296
297 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
298 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800299 utilities.assert_equals( expect=True, actual=pingResult2,
300 onpass="Speaker2 ping peers successful",
301 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700302
303 if pingResult3 == False:
304 main.cleanup()
305 main.exit()
306
307 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800308 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
309 main.FALSE,
310 kwargs={'isPENDING':False},
311 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700312 utilities.assert_equals( expect=main.TRUE,
313 actual=flowCheck,
314 onpass="Flow status is correct!",
315 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700316
317 def CASE8( self, main ):
318 '''
319 Bring up the edge switch (sw32) which was shut down in CASE7,
320 check P-2-P and M-2-S intents, ping test
321 '''
322 import time
323 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
324 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800325 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700326 utilities.assert_equals( expect=main.TRUE,
327 actual=result1,
328 onpass="Starting switch succeeded!",
329 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700330
Devin Lim58046fa2017-07-05 16:55:00 -0700331 result2 = main.Mininet.assignSwController( "sw32", main.ONOSip[ 0 ] )
Jon Hall362aa922016-03-31 09:39:26 -0700332 utilities.assert_equals( expect=main.TRUE,
333 actual=result2,
334 onpass="Connect switch to ONOS succeeded!",
335 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700336
337 if result1 and result2:
338 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800339 main.Functions.checkRouteNum( main, 7 )
340 main.Functions.checkM2SintentNum( main, 7 )
341 main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18*2
pingping-linea32cf82015-10-08 22:37:37 -0700342 else:
343 main.log.error( "Starting switch failed!" )
344 main.cleanup()
345 main.exit()
346
347 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800348 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
349 main.FALSE,
350 kwargs={'isPENDING':False},
351 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700352 utilities.assert_equals( expect=main.TRUE,
353 actual=flowCheck,
354 onpass="Flow status is correct!",
355 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700356
357 # Ping test
alison62006dd2016-12-15 16:21:28 -0800358 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
359 peers=["p64514", "p64515", "p64516"],
360 expectAllSuccess=True )
361
362 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
363 peers=[ p64514, p64515, p64516 ],
364 expectAllSuccess=True )
365
pingping-linea32cf82015-10-08 22:37:37 -0700366 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800367 hosts=[ "h64514", "h64515", "h64516" ],
368 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700369
pingping-linea32cf82015-10-08 22:37:37 -0700370 def CASE9( self, main ):
371 '''
372 Bring down a switch in best path, check:
373 route number, P2P intent number, M2S intent number, ping test
374 '''
375 main.case( "Stop sw11 located in best path, \
376 check route number, P2P intent number, M2S intent number, ping test" )
377
378 main.log.info( "Check the flow number correctness before stopping sw11" )
alison62006dd2016-12-15 16:21:28 -0800379 main.Functions.checkFlowNum( main, "sw11", 49 )
380 main.Functions.checkFlowNum( main, "sw1", 7 )
381 main.Functions.checkFlowNum( main, "sw7", 34 )
pingping-linea32cf82015-10-08 22:37:37 -0700382 main.log.info( main.Mininet.checkFlows( "sw11" ) )
383 main.log.info( main.Mininet.checkFlows( "sw1" ) )
384 main.log.info( main.Mininet.checkFlows( "sw7" ) )
385
386 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800387 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700388 utilities.assert_equals( expect=main.TRUE, actual=result,
389 onpass="Stopping switch succeeded!",
390 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700391 if result:
392 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
393 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800394 main.Functions.checkRouteNum( main, 7 )
395 main.Functions.checkM2SintentNum( main, 7 )
396 main.Functions.checkP2PintentNum( main, 30 * 2 ) #18 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700397 else:
398 main.log.error( "Stopping switch failed!" )
399 main.cleanup()
400 main.exit()
401
402 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800403 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
404 main.FALSE,
405 kwargs={'isPENDING':False},
406 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700407 utilities.assert_equals( expect=main.TRUE,
408 actual=flowCheck,
409 onpass="Flow status is correct!",
410 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700411 # Ping test
alison62006dd2016-12-15 16:21:28 -0800412 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
413 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800414 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800415 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
416 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800417 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700418 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800419 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800420 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700421
422
423 def CASE10( self, main ):
424 '''
425 Bring up the switch which was stopped in CASE9, check:
426 route number, P2P intent number, M2S intent number, ping test
427 '''
428 main.case( "Start sw11 which was stopped in CASE9, \
429 check route number, P2P intent number, M2S intent number, ping test" )
430
431 main.log.info( "Check the flow status before starting sw11" )
alison62006dd2016-12-15 16:21:28 -0800432 main.Functions.checkFlowNum( main, "sw1", 36 )
433 main.Functions.checkFlowNum( main, "sw7", 30 )
pingping-linea32cf82015-10-08 22:37:37 -0700434 main.log.info( main.Mininet.checkFlows( "sw1" ) )
435 main.log.info( main.Mininet.checkFlows( "sw7" ) )
436
437 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800438 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700439 utilities.assert_equals( expect=main.TRUE, actual=result1,
440 onpass="Starting switch succeeded!",
441 onfail="Starting switch failed!" )
Devin Lim58046fa2017-07-05 16:55:00 -0700442 result2 = main.Mininet.assignSwController( "sw11", main.ONOSip[ 0 ] )
Jon Hall362aa922016-03-31 09:39:26 -0700443 utilities.assert_equals( expect=main.TRUE, actual=result2,
444 onpass="Connect switch to ONOS succeeded!",
445 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700446 if result1 and result2:
447 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800448 main.Functions.checkRouteNum( main, 7 )
449 main.Functions.checkM2SintentNum( main, 7 )
450 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700451
452 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
453 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
454 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
455 else:
456 main.log.error( "Starting switch failed!" )
457 main.cleanup()
458 main.exit()
459
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 )
Jon Hall362aa922016-03-31 09:39:26 -0700465 utilities.assert_equals( expect=main.TRUE,
466 actual=flowCheck,
467 onpass="Flow status is correct!",
468 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700469 # Ping test
alison62006dd2016-12-15 16:21:28 -0800470 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
471 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800472 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800473 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
474 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800475 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700476 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800477 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800478 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700479
480
481 def CASE11(self, main):
482 import time
alison62006dd2016-12-15 16:21:28 -0800483 main.case( "Kill spk1, check:\
pingping-linea32cf82015-10-08 22:37:37 -0700484 route number, P2P intent number, M2S intent number, ping test" )
alison62006dd2016-12-15 16:21:28 -0800485 main.log.info( "Check network status before killing spk1" )
486 main.Functions.checkRouteNum( main, 7 )
487 main.Functions.checkM2SintentNum( main, 7 )
488 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700489 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800490 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
491 main.FALSE,
492 kwargs={'isPENDING':False},
493 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700494 utilities.assert_equals( expect=main.TRUE,
495 actual=flowCheck,
496 onpass="Flow status is correct!",
497 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700498
alison62006dd2016-12-15 16:21:28 -0800499 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
500 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800501 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800502 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
503 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800504 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700505 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800506 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800507 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700508
alison62006dd2016-12-15 16:21:28 -0800509 main.step( "Kill spk1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700510 command1 = "ps -e | grep bgp -c"
511 result1 = main.Mininet.node( "root", command1 )
512
513 # The total BGP daemon number in this test environment is 5.
514 if "5" in result1:
alison62006dd2016-12-15 16:21:28 -0800515 main.log.debug( "Before kill spk1, 5 BGP daemons - correct" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700516 else:
alison62006dd2016-12-15 16:21:28 -0800517 main.log.warn( "Before kill spk1, number of BGP daemons is wrong" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700518 main.log.info( result1 )
519
520 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
521 result2 = main.Mininet.node( "root", command2 )
522
523 result3 = main.Mininet.node( "root", command1 )
524
Jon Hall6e9897d2016-02-29 14:41:32 -0800525 utilities.assert_equals( expect=True,
526 actual=( "4" in result3 ),
alison62006dd2016-12-15 16:21:28 -0800527 onpass="Kill spk1 succeeded",
528 onfail="Kill spk1 failed" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700529 if ( "4" not in result3 ) :
530 main.log.info( result3 )
pingping-linea32cf82015-10-08 22:37:37 -0700531 main.cleanup()
532 main.exit()
533
534 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800535 main.Functions.checkRouteNum( main, 7 )
536 main.Functions.checkM2SintentNum( main, 7 )
537 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700538
539 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800540 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
541 main.FALSE,
542 kwargs={'isPENDING':False},
543 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700544 utilities.assert_equals( expect=main.TRUE,
545 actual=flowCheck,
546 onpass="Flow status is correct!",
547 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700548
549 '''
alison62006dd2016-12-15 16:21:28 -0800550 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
551 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800552 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700553 '''
alison62006dd2016-12-15 16:21:28 -0800554 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
555 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800556 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700557 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800558 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800559 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700560
561
562 def CASE12( self, main ):
563 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700564 import json
pingping-linea32cf82015-10-08 22:37:37 -0700565 main.case( "Bring down leader ONOS node, check: \
566 route number, P2P intent number, M2S intent number, ping test" )
567 main.step( "Find out ONOS leader node" )
pingping-lina14c7c82015-10-09 15:44:36 -0700568 result = main.ONOScli1.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700569 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700570 leaderIP = ""
571 for entry in jsonResult:
572 if entry["topic"] == "org.onosproject.sdnip":
573 leaderIP = entry["leader"]
574 main.log.info( "leaderIP is: " )
575 main.log.info( leaderIP )
576
577 main.step( "Uninstall ONOS/SDN-IP leader node" )
Devin Lim58046fa2017-07-05 16:55:00 -0700578 for ip in main.ONOSip:
579 if leaderIP == ip:
580 uninstallResult = main.ONOSbench.onosStop( ip )
pingping-lina14c7c82015-10-09 15:44:36 -0700581
Jon Hall6e9897d2016-02-29 14:41:32 -0800582 utilities.assert_equals( expect=main.TRUE,
583 actual=uninstallResult,
584 onpass="Uninstall ONOS leader succeeded",
585 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700586 if uninstallResult != main.TRUE:
587 main.cleanup()
588 main.exit()
589 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700590
Devin Lim58046fa2017-07-05 16:55:00 -0700591 if leaderIP == main.ONOSip[ 0 ]:
alison62006dd2016-12-15 16:21:28 -0800592 main.Functions.checkRouteNum( main, 7, ONOScli="ONOScli2" )
593 main.Functions.checkM2SintentNum( main, 7, ONOScli="ONOScli2" )
594 main.Functions.checkP2PintentNum( main, 30 * 2, ONOScli="ONOScli2" )
pingping-lina14c7c82015-10-09 15:44:36 -0700595
596 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800597 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
598 main.FALSE,
599 kwargs={'isPENDING':False},
600 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700601 utilities.assert_equals( expect=main.TRUE,
602 actual=flowCheck,
603 onpass="Flow status is correct!",
604 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700605 else:
alison62006dd2016-12-15 16:21:28 -0800606 main.Functions.checkRouteNum( main, 7 )
607 main.Functions.checkM2SintentNum( main, 7 )
608 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-lina14c7c82015-10-09 15:44:36 -0700609
610 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800611 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
612 main.FALSE,
613 kwargs={'isPENDING':False},
614 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700615 utilities.assert_equals( expect=main.TRUE,
616 actual=flowCheck,
617 onpass="Flow status is correct!",
618 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700619
alison62006dd2016-12-15 16:21:28 -0800620 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
621 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800622 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800623 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
624 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800625 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700626 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800627 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800628 expectAllSuccess=True )