blob: 63940cbcf65271964c5e5202cbc32a49d02d1241 [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 Lim142b5342017-07-20 15:22:39 -070056 swResult = swResult and \
57 main.Mininet.assignSwController( sw, main.Cluster.getIps() )
Jon Hall6e9897d2016-02-29 14:41:32 -080058 utilities.assert_equals( expect=main.TRUE,
59 actual=swResult,
60 onpass="Successfully connect all switches to ONOS",
61 onfail="Failed to connect all switches to ONOS" )
pingping-linea32cf82015-10-08 22:37:37 -070062 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
alison62006dd2016-12-15 16:21:28 -080081 global p64514
82 global p64515
83 global p64516
Devin Lim58046fa2017-07-05 16:55:00 -070084 p64514 = main.params[ 'config' ][ 'p64514' ]
85 p64515 = main.params[ 'config' ][ 'p64515' ]
86 p64516 = main.params[ 'config' ][ 'p64516' ]
pingping-linea32cf82015-10-08 22:37:37 -070087
Devin Lim58046fa2017-07-05 16:55:00 -070088 try:
89 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
90 except ImportError:
91 main.log.error( "sdnBase not found. exiting the test" )
pingping-linea32cf82015-10-08 22:37:37 -070092 main.exit()
Devin Lim58046fa2017-07-05 16:55:00 -070093 try:
94 main.sdnBase
95 except ( NameError, AttributeError ):
96 main.sdnBase = SdnBase()
97
98 main.sdnBase.initSetup()
pingping-linea32cf82015-10-08 22:37:37 -070099
pingping-linea32cf82015-10-08 22:37:37 -0700100 def CASE200( self, main ):
101 main.case( "Activate sdn-ip application" )
102 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800103 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700104
Jon Hall362aa922016-03-31 09:39:26 -0700105 main.step( "Get links in the network" )
Devin Lim142b5342017-07-20 15:22:39 -0700106 summaryResult = main.Cluster.active( 0 ).CLI.summary()
pingping-linea32cf82015-10-08 22:37:37 -0700107 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall362aa922016-03-31 09:39:26 -0700108 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
pingping-linea32cf82015-10-08 22:37:37 -0700109 if linkNum < 100:
Jon Hall362aa922016-03-31 09:39:26 -0700110 main.log.error( "Link number is wrong! Retrying..." )
Jon Hall6e9897d2016-02-29 14:41:32 -0800111 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Devin Lim142b5342017-07-20 15:22:39 -0700112 summaryResult = main.Cluster.active( 0 ).CLI.summary()
Jon Hall362aa922016-03-31 09:39:26 -0700113 linkNum = json.loads( summaryResult )[ "links" ]
114 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
115 utilities.assert_equals( expect=100,
116 actual=linkNum,
117 onpass="ONOS correctly discovered all links",
118 onfail="ONOS Failed to discover all links" )
119 if linkNum < 100:
pingping-linea32cf82015-10-08 22:37:37 -0700120 main.cleanup()
121 main.exit()
122
pingping-linea32cf82015-10-08 22:37:37 -0700123 main.step( "Activate sdn-ip application" )
Devin Lim142b5342017-07-20 15:22:39 -0700124 activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800125 utilities.assert_equals( expect=main.TRUE,
126 actual=activeSDNIPresult,
127 onpass="Activate SDN-IP succeeded",
128 onfail="Activate SDN-IP failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700129 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800130 main.log.info( "Activate SDN-IP failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700131 main.cleanup()
132 main.exit()
133
pingping-linea32cf82015-10-08 22:37:37 -0700134 def CASE102( self, main ):
135 '''
136 This test case is to load the methods from other Python files, and create
137 tunnels from mininet host to onos nodes.
138 '''
139 import time
140 main.case( "Load methods from other Python file and create tunnels" )
141 # load the methods from other file
142 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
143 main.Functions = imp.load_source( wrapperFile1,
144 main.dependencyPath +
145 wrapperFile1 +
146 ".py" )
147 # Create tunnels
Devin Lim142b5342017-07-20 15:22:39 -0700148 for i in range ( main.Cluster.numCtrls ):
149 main.Functions.setupTunnel( main,
150 '1.1.1.' + str( ( i + 1 ) * 2 ),
151 2000,
152 main.Cluster.active( i ).ipAddress, 2000 )
pingping-linea32cf82015-10-08 22:37:37 -0700153
154 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
155 and the BGP paths in data plane are ready..." )
156 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
157
158 main.log.info( "Wait Quagga to finish delivery all routes to each \
159 other and to sdn-ip, plus finish installing all intents..." )
160 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700161
162 def CASE1( self, main ):
163 '''
164 ping test from 3 bgp peers to BGP speaker
165 '''
166
Jon Hall362aa922016-03-31 09:39:26 -0700167 main.case( "Ping between BGP peers and speakers" )
alison62006dd2016-12-15 16:21:28 -0800168 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
169 peers=[ "p64514", "p64515", "p64516" ],
170 expectAllSuccess=True )
171
172 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
173 peers=[ p64514, p64515, p64516 ],
174 expectAllSuccess=True )
175
176 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ],
177 peers=[ "p64519", "p64520" ],
178 expectAllSuccess=True )
179
180 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk4" ],
181 peers=[ "p64517", "p64518" ],
182 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700183
184 def CASE2( self, main ):
185 '''
186 point-to-point intents test for each BGP peer and BGP speaker pair
187 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700188 main.sdnBase.pToPIntentTest( 12 )
pingping-linea32cf82015-10-08 22:37:37 -0700189
190 def CASE3( self, main ):
191 '''
192 routes and intents check to all BGP peers
193 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800194 import time
pingping-linea32cf82015-10-08 22:37:37 -0700195 main.case( "Check routes and M2S intents to all BGP peers" )
196
Jon Hall362aa922016-03-31 09:39:26 -0700197 main.step( "Check routes installed" )
pingping-linea32cf82015-10-08 22:37:37 -0700198 allRoutesExpected = []
199 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
200 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
201 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
alison62006dd2016-12-15 16:21:28 -0800202 allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" )
203 allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" )
204 allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
205 allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
pingping-linea32cf82015-10-08 22:37:37 -0700206
Devin Lim58046fa2017-07-05 16:55:00 -0700207 main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
pingping-linea32cf82015-10-08 22:37:37 -0700208
209
210 def CASE4( self, main ):
211 '''
212 Ping test in data plane for each route
213 '''
214 main.case( "Ping test for each route, all hosts behind BGP peers" )
215 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800216 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800217 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800218 main.Functions.pingHostToHost(main,
219 hosts=["h64517", "h64518"],
220 expectAllSuccess=True)
Devin Lim58046fa2017-07-05 16:55:00 -0700221 main.Functions.pingHostToHost( main,
222 hosts=[ "h64519", "h64520" ],
223 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700224
225 def CASE5( self, main ):
226 '''
227 Cut links to peers one by one, check routes/intents
228 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700229 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
230 6, 6, 5, 5, 4, 4,
231 "spk1", [ "h64514", "h64515", "h64516" ],
232 "down" )
pingping-linea32cf82015-10-08 22:37:37 -0700233
pingping-linea32cf82015-10-08 22:37:37 -0700234 def CASE6( self, main ):
235 '''
236 Recover links to peers one by one, check routes/intents
237 '''
Devin Lim58046fa2017-07-05 16:55:00 -0700238 main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
239 5, 5, 6, 6, 7, 7,
240 "spk1", [ "h64514", "h64515", "h64516" ],
241 "up" )
pingping-linea32cf82015-10-08 22:37:37 -0700242
pingping-linea32cf82015-10-08 22:37:37 -0700243 def CASE7( self, main ):
244 '''
245 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
246 '''
247 import time
248 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
249 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800250 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700251 utilities.assert_equals( expect=main.TRUE, actual=result,
252 onpass="Stopping switch succeeded!",
253 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700254
255 if result == main.TRUE:
256 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800257 main.Functions.checkRouteNum( main, 6 )
258 main.Functions.checkM2SintentNum( main, 6 )
259 main.Functions.checkP2PintentNum( main, 48 ) #14 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700260 else:
261 main.log.error( "Stopping switch failed!" )
262 main.cleanup()
263 main.exit()
264
265 main.step( "Check ping between hosts behind BGP peers" )
alison62006dd2016-12-15 16:21:28 -0800266 result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
267 result2 = main.Mininet.pingHost( src="h64515", target="h64516" )
268 result3 = main.Mininet.pingHost( src="h64514", target="h64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700269
270 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
271 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800272 utilities.assert_equals( expect=True, actual=pingResult1,
273 onpass="Ping test result is correct",
274 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700275
276 if pingResult1 == False:
277 main.cleanup()
278 main.exit()
279
alison62006dd2016-12-15 16:21:28 -0800280 main.step( "Check ping between BGP peers and spk1" )
281 result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
282 result5 = main.Mininet.pingHost( src="spk1", target="p64515" )
283 result6 = main.Mininet.pingHost( src="spk1", target="p64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700284
285 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
286 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800287 utilities.assert_equals( expect=True, actual=pingResult2,
288 onpass="Speaker1 ping peers successful",
289 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700290
291 if pingResult2 == False:
292 main.cleanup()
293 main.exit()
294
alison62006dd2016-12-15 16:21:28 -0800295 main.step( "Check ping between BGP peers and spk2" )
pingping-linea32cf82015-10-08 22:37:37 -0700296 # TODO
alison62006dd2016-12-15 16:21:28 -0800297 result7 = main.Mininet.pingHost( src="spk2", target=p64514 )
298 result8 = main.Mininet.pingHost( src="spk2", target=p64515 )
299 result9 = main.Mininet.pingHost( src="spk2", target=p64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700300
301 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
302 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800303 utilities.assert_equals( expect=True, actual=pingResult2,
304 onpass="Speaker2 ping peers successful",
305 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700306
307 if pingResult3 == False:
308 main.cleanup()
309 main.exit()
310
311 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700312 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800313 main.FALSE,
314 kwargs={'isPENDING':False},
315 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700316 utilities.assert_equals( expect=main.TRUE,
317 actual=flowCheck,
318 onpass="Flow status is correct!",
319 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700320
321 def CASE8( self, main ):
322 '''
323 Bring up the edge switch (sw32) which was shut down in CASE7,
324 check P-2-P and M-2-S intents, ping test
325 '''
326 import time
327 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
328 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800329 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700330 utilities.assert_equals( expect=main.TRUE,
331 actual=result1,
332 onpass="Starting switch succeeded!",
333 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700334
Devin Lim142b5342017-07-20 15:22:39 -0700335 result2 = main.Mininet.assignSwController( "sw32", main.Cluster.active( 0 ).ipAddress )
Jon Hall362aa922016-03-31 09:39:26 -0700336 utilities.assert_equals( expect=main.TRUE,
337 actual=result2,
338 onpass="Connect switch to ONOS succeeded!",
339 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700340
341 if result1 and result2:
342 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800343 main.Functions.checkRouteNum( main, 7 )
344 main.Functions.checkM2SintentNum( main, 7 )
345 main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18*2
pingping-linea32cf82015-10-08 22:37:37 -0700346 else:
347 main.log.error( "Starting switch failed!" )
348 main.cleanup()
349 main.exit()
350
351 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700352 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800353 main.FALSE,
354 kwargs={'isPENDING':False},
355 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700356 utilities.assert_equals( expect=main.TRUE,
357 actual=flowCheck,
358 onpass="Flow status is correct!",
359 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700360
361 # Ping test
alison62006dd2016-12-15 16:21:28 -0800362 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
363 peers=["p64514", "p64515", "p64516"],
364 expectAllSuccess=True )
365
366 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
367 peers=[ p64514, p64515, p64516 ],
368 expectAllSuccess=True )
369
pingping-linea32cf82015-10-08 22:37:37 -0700370 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800371 hosts=[ "h64514", "h64515", "h64516" ],
372 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700373
pingping-linea32cf82015-10-08 22:37:37 -0700374 def CASE9( self, main ):
375 '''
376 Bring down a switch in best path, check:
377 route number, P2P intent number, M2S intent number, ping test
378 '''
379 main.case( "Stop sw11 located in best path, \
380 check route number, P2P intent number, M2S intent number, ping test" )
381
382 main.log.info( "Check the flow number correctness before stopping sw11" )
alison62006dd2016-12-15 16:21:28 -0800383 main.Functions.checkFlowNum( main, "sw11", 49 )
384 main.Functions.checkFlowNum( main, "sw1", 7 )
385 main.Functions.checkFlowNum( main, "sw7", 34 )
pingping-linea32cf82015-10-08 22:37:37 -0700386 main.log.info( main.Mininet.checkFlows( "sw11" ) )
387 main.log.info( main.Mininet.checkFlows( "sw1" ) )
388 main.log.info( main.Mininet.checkFlows( "sw7" ) )
389
390 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800391 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700392 utilities.assert_equals( expect=main.TRUE, actual=result,
393 onpass="Stopping switch succeeded!",
394 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700395 if result:
396 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
397 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800398 main.Functions.checkRouteNum( main, 7 )
399 main.Functions.checkM2SintentNum( main, 7 )
400 main.Functions.checkP2PintentNum( main, 30 * 2 ) #18 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700401 else:
402 main.log.error( "Stopping switch failed!" )
403 main.cleanup()
404 main.exit()
405
406 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700407 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800408 main.FALSE,
409 kwargs={'isPENDING':False},
410 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700411 utilities.assert_equals( expect=main.TRUE,
412 actual=flowCheck,
413 onpass="Flow status is correct!",
414 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700415 # Ping test
alison62006dd2016-12-15 16:21:28 -0800416 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
417 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800418 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800419 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
420 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800421 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700422 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800423 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800424 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700425
426
427 def CASE10( self, main ):
428 '''
429 Bring up the switch which was stopped in CASE9, check:
430 route number, P2P intent number, M2S intent number, ping test
431 '''
432 main.case( "Start sw11 which was stopped in CASE9, \
433 check route number, P2P intent number, M2S intent number, ping test" )
434
435 main.log.info( "Check the flow status before starting sw11" )
alison62006dd2016-12-15 16:21:28 -0800436 main.Functions.checkFlowNum( main, "sw1", 36 )
437 main.Functions.checkFlowNum( main, "sw7", 30 )
pingping-linea32cf82015-10-08 22:37:37 -0700438 main.log.info( main.Mininet.checkFlows( "sw1" ) )
439 main.log.info( main.Mininet.checkFlows( "sw7" ) )
440
441 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800442 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700443 utilities.assert_equals( expect=main.TRUE, actual=result1,
444 onpass="Starting switch succeeded!",
445 onfail="Starting switch failed!" )
Devin Lim142b5342017-07-20 15:22:39 -0700446 result2 = main.Mininet.assignSwController( "sw11", main.Cluster.active( 0 ).ipAddress )
Jon Hall362aa922016-03-31 09:39:26 -0700447 utilities.assert_equals( expect=main.TRUE, actual=result2,
448 onpass="Connect switch to ONOS succeeded!",
449 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700450 if result1 and result2:
451 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800452 main.Functions.checkRouteNum( main, 7 )
453 main.Functions.checkM2SintentNum( main, 7 )
454 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700455
456 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
457 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
458 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
459 else:
460 main.log.error( "Starting switch failed!" )
461 main.cleanup()
462 main.exit()
463
464 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700465 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800466 main.FALSE,
467 kwargs={'isPENDING':False},
468 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700469 utilities.assert_equals( expect=main.TRUE,
470 actual=flowCheck,
471 onpass="Flow status is correct!",
472 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700473 # Ping test
alison62006dd2016-12-15 16:21:28 -0800474 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
475 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800476 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800477 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
478 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800479 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700480 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800481 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800482 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700483
484
485 def CASE11(self, main):
486 import time
alison62006dd2016-12-15 16:21:28 -0800487 main.case( "Kill spk1, check:\
pingping-linea32cf82015-10-08 22:37:37 -0700488 route number, P2P intent number, M2S intent number, ping test" )
alison62006dd2016-12-15 16:21:28 -0800489 main.log.info( "Check network status before killing spk1" )
490 main.Functions.checkRouteNum( main, 7 )
491 main.Functions.checkM2SintentNum( main, 7 )
492 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700493 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700494 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800495 main.FALSE,
496 kwargs={'isPENDING':False},
497 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700498 utilities.assert_equals( expect=main.TRUE,
499 actual=flowCheck,
500 onpass="Flow status is correct!",
501 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700502
alison62006dd2016-12-15 16:21:28 -0800503 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
504 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800505 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800506 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
507 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800508 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700509 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800510 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800511 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700512
alison62006dd2016-12-15 16:21:28 -0800513 main.step( "Kill spk1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700514 command1 = "ps -e | grep bgp -c"
515 result1 = main.Mininet.node( "root", command1 )
516
517 # The total BGP daemon number in this test environment is 5.
518 if "5" in result1:
alison62006dd2016-12-15 16:21:28 -0800519 main.log.debug( "Before kill spk1, 5 BGP daemons - correct" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700520 else:
alison62006dd2016-12-15 16:21:28 -0800521 main.log.warn( "Before kill spk1, number of BGP daemons is wrong" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700522 main.log.info( result1 )
523
524 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
525 result2 = main.Mininet.node( "root", command2 )
526
527 result3 = main.Mininet.node( "root", command1 )
528
Jon Hall6e9897d2016-02-29 14:41:32 -0800529 utilities.assert_equals( expect=True,
530 actual=( "4" in result3 ),
alison62006dd2016-12-15 16:21:28 -0800531 onpass="Kill spk1 succeeded",
532 onfail="Kill spk1 failed" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700533 if ( "4" not in result3 ) :
534 main.log.info( result3 )
pingping-linea32cf82015-10-08 22:37:37 -0700535 main.cleanup()
536 main.exit()
537
538 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800539 main.Functions.checkRouteNum( main, 7 )
540 main.Functions.checkM2SintentNum( main, 7 )
541 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700542
543 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700544 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800545 main.FALSE,
546 kwargs={'isPENDING':False},
547 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700548 utilities.assert_equals( expect=main.TRUE,
549 actual=flowCheck,
550 onpass="Flow status is correct!",
551 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700552
553 '''
alison62006dd2016-12-15 16:21:28 -0800554 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
555 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800556 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700557 '''
alison62006dd2016-12-15 16:21:28 -0800558 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
559 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800560 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700561 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800562 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800563 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700564
565
566 def CASE12( self, main ):
567 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700568 import json
pingping-linea32cf82015-10-08 22:37:37 -0700569 main.case( "Bring down leader ONOS node, check: \
570 route number, P2P intent number, M2S intent number, ping test" )
571 main.step( "Find out ONOS leader node" )
Devin Lim142b5342017-07-20 15:22:39 -0700572 result = main.Cluster.active( 0 ).CLI.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700573 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700574 leaderIP = ""
575 for entry in jsonResult:
576 if entry["topic"] == "org.onosproject.sdnip":
577 leaderIP = entry["leader"]
578 main.log.info( "leaderIP is: " )
579 main.log.info( leaderIP )
580
581 main.step( "Uninstall ONOS/SDN-IP leader node" )
Devin Lim142b5342017-07-20 15:22:39 -0700582 for ip in main.Cluster.getIps():
Devin Lim58046fa2017-07-05 16:55:00 -0700583 if leaderIP == ip:
584 uninstallResult = main.ONOSbench.onosStop( ip )
pingping-lina14c7c82015-10-09 15:44:36 -0700585
Jon Hall6e9897d2016-02-29 14:41:32 -0800586 utilities.assert_equals( expect=main.TRUE,
587 actual=uninstallResult,
588 onpass="Uninstall ONOS leader succeeded",
589 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700590 if uninstallResult != main.TRUE:
591 main.cleanup()
592 main.exit()
593 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700594
Devin Lim142b5342017-07-20 15:22:39 -0700595 if leaderIP == main.Cluster.active( 0 ).ipAddress:
596 main.Functions.checkRouteNum( main, 7, node=2 )
597 main.Functions.checkM2SintentNum( main, 7, node=2 )
598 main.Functions.checkP2PintentNum( main, 30 * 2, node=2 )
pingping-lina14c7c82015-10-09 15:44:36 -0700599
600 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700601 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800602 main.FALSE,
603 kwargs={'isPENDING':False},
604 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700605 utilities.assert_equals( expect=main.TRUE,
606 actual=flowCheck,
607 onpass="Flow status is correct!",
608 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700609 else:
alison62006dd2016-12-15 16:21:28 -0800610 main.Functions.checkRouteNum( main, 7 )
611 main.Functions.checkM2SintentNum( main, 7 )
612 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-lina14c7c82015-10-09 15:44:36 -0700613
614 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700615 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800616 main.FALSE,
617 kwargs={'isPENDING':False},
618 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700619 utilities.assert_equals( expect=main.TRUE,
620 actual=flowCheck,
621 onpass="Flow status is correct!",
622 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700623
alison62006dd2016-12-15 16:21:28 -0800624 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
625 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800626 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800627 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
628 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800629 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700630 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800631 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800632 expectAllSuccess=True )