blob: d058a85c0f41800b2495377fabc732341757d061 [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:
Devin Lim44075962017-08-11 10:56:37 -070048 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -070049 main.step( "Connect switches to controllers" )
50
51 # connect all switches to controllers
52 swResult = main.TRUE
53 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
54 sw = "sw%s" % ( i )
Devin Lim142b5342017-07-20 15:22:39 -070055 swResult = swResult and \
56 main.Mininet.assignSwController( sw, main.Cluster.getIps() )
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:
Devin Lim44075962017-08-11 10:56:37 -070062 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -070063
64
65 def CASE101( self, main ):
66 """
67 Package ONOS and install it
68 Startup sequence:
69 cell <name>
70 onos-verify-cell
71 onos-package
72 onos-install -f
73 onos-wait-for-start
74 """
75 import json
76 import time
77 import os
78 from operator import eq
alison62006dd2016-12-15 16:21:28 -080079 global p64514
80 global p64515
81 global p64516
Devin Lim58046fa2017-07-05 16:55:00 -070082 p64514 = main.params[ 'config' ][ 'p64514' ]
83 p64515 = main.params[ 'config' ][ 'p64515' ]
84 p64516 = main.params[ 'config' ][ 'p64516' ]
pingping-linea32cf82015-10-08 22:37:37 -070085
Devin Lim58046fa2017-07-05 16:55:00 -070086 try:
87 from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
88 except ImportError:
89 main.log.error( "sdnBase not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070090 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070091 try:
92 main.sdnBase
93 except ( NameError, AttributeError ):
94 main.sdnBase = SdnBase()
95
96 main.sdnBase.initSetup()
pingping-linea32cf82015-10-08 22:37:37 -070097
pingping-linea32cf82015-10-08 22:37:37 -070098 def CASE200( self, main ):
99 main.case( "Activate sdn-ip application" )
100 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800101 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700102
Jon Hall362aa922016-03-31 09:39:26 -0700103 main.step( "Get links in the network" )
Devin Lim142b5342017-07-20 15:22:39 -0700104 summaryResult = main.Cluster.active( 0 ).CLI.summary()
pingping-linea32cf82015-10-08 22:37:37 -0700105 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall362aa922016-03-31 09:39:26 -0700106 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
pingping-linea32cf82015-10-08 22:37:37 -0700107 if linkNum < 100:
Jon Hall362aa922016-03-31 09:39:26 -0700108 main.log.error( "Link number is wrong! Retrying..." )
Jon Hall6e9897d2016-02-29 14:41:32 -0800109 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Devin Lim142b5342017-07-20 15:22:39 -0700110 summaryResult = main.Cluster.active( 0 ).CLI.summary()
Jon Hall362aa922016-03-31 09:39:26 -0700111 linkNum = json.loads( summaryResult )[ "links" ]
112 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
113 utilities.assert_equals( expect=100,
114 actual=linkNum,
115 onpass="ONOS correctly discovered all links",
116 onfail="ONOS Failed to discover all links" )
117 if linkNum < 100:
Devin Lim44075962017-08-11 10:56:37 -0700118 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700119
pingping-linea32cf82015-10-08 22:37:37 -0700120 main.step( "Activate sdn-ip application" )
Devin Lim142b5342017-07-20 15:22:39 -0700121 activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800122 utilities.assert_equals( expect=main.TRUE,
123 actual=activeSDNIPresult,
124 onpass="Activate SDN-IP succeeded",
125 onfail="Activate SDN-IP failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700126 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800127 main.log.info( "Activate SDN-IP failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700128 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700129
pingping-linea32cf82015-10-08 22:37:37 -0700130 def CASE102( self, main ):
131 '''
132 This test case is to load the methods from other Python files, and create
133 tunnels from mininet host to onos nodes.
134 '''
135 import time
136 main.case( "Load methods from other Python file and create tunnels" )
137 # load the methods from other file
138 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
139 main.Functions = imp.load_source( wrapperFile1,
140 main.dependencyPath +
141 wrapperFile1 +
142 ".py" )
143 # Create tunnels
Devin Lim142b5342017-07-20 15:22:39 -0700144 for i in range ( main.Cluster.numCtrls ):
145 main.Functions.setupTunnel( main,
146 '1.1.1.' + str( ( i + 1 ) * 2 ),
147 2000,
148 main.Cluster.active( i ).ipAddress, 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!" )
Devin Lim44075962017-08-11 10:56:37 -0700258 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700259
260 main.step( "Check ping between hosts behind BGP peers" )
alison62006dd2016-12-15 16:21:28 -0800261 result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
262 result2 = main.Mininet.pingHost( src="h64515", target="h64516" )
263 result3 = main.Mininet.pingHost( src="h64514", target="h64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700264
265 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
266 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800267 utilities.assert_equals( expect=True, actual=pingResult1,
268 onpass="Ping test result is correct",
269 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700270
271 if pingResult1 == False:
Devin Lim44075962017-08-11 10:56:37 -0700272 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700273
alison62006dd2016-12-15 16:21:28 -0800274 main.step( "Check ping between BGP peers and spk1" )
275 result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
276 result5 = main.Mininet.pingHost( src="spk1", target="p64515" )
277 result6 = main.Mininet.pingHost( src="spk1", target="p64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700278
279 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
280 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800281 utilities.assert_equals( expect=True, actual=pingResult2,
282 onpass="Speaker1 ping peers successful",
283 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700284
285 if pingResult2 == False:
Devin Lim44075962017-08-11 10:56:37 -0700286 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700287
alison62006dd2016-12-15 16:21:28 -0800288 main.step( "Check ping between BGP peers and spk2" )
pingping-linea32cf82015-10-08 22:37:37 -0700289 # TODO
alison62006dd2016-12-15 16:21:28 -0800290 result7 = main.Mininet.pingHost( src="spk2", target=p64514 )
291 result8 = main.Mininet.pingHost( src="spk2", target=p64515 )
292 result9 = main.Mininet.pingHost( src="spk2", target=p64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700293
294 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
295 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800296 utilities.assert_equals( expect=True, actual=pingResult2,
297 onpass="Speaker2 ping peers successful",
298 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700299
300 if pingResult3 == False:
Devin Lim44075962017-08-11 10:56:37 -0700301 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700302
303 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700304 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800305 main.FALSE,
306 kwargs={'isPENDING':False},
307 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700308 utilities.assert_equals( expect=main.TRUE,
309 actual=flowCheck,
310 onpass="Flow status is correct!",
311 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700312
313 def CASE8( self, main ):
314 '''
315 Bring up the edge switch (sw32) which was shut down in CASE7,
316 check P-2-P and M-2-S intents, ping test
317 '''
318 import time
319 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
320 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800321 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700322 utilities.assert_equals( expect=main.TRUE,
323 actual=result1,
324 onpass="Starting switch succeeded!",
325 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700326
Devin Lim142b5342017-07-20 15:22:39 -0700327 result2 = main.Mininet.assignSwController( "sw32", main.Cluster.active( 0 ).ipAddress )
Jon Hall362aa922016-03-31 09:39:26 -0700328 utilities.assert_equals( expect=main.TRUE,
329 actual=result2,
330 onpass="Connect switch to ONOS succeeded!",
331 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700332
333 if result1 and result2:
334 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800335 main.Functions.checkRouteNum( main, 7 )
336 main.Functions.checkM2SintentNum( main, 7 )
337 main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18*2
pingping-linea32cf82015-10-08 22:37:37 -0700338 else:
339 main.log.error( "Starting switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700340 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700341
342 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700343 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800344 main.FALSE,
345 kwargs={'isPENDING':False},
346 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700347 utilities.assert_equals( expect=main.TRUE,
348 actual=flowCheck,
349 onpass="Flow status is correct!",
350 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700351
352 # Ping test
alison62006dd2016-12-15 16:21:28 -0800353 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
354 peers=["p64514", "p64515", "p64516"],
355 expectAllSuccess=True )
356
357 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
358 peers=[ p64514, p64515, p64516 ],
359 expectAllSuccess=True )
360
pingping-linea32cf82015-10-08 22:37:37 -0700361 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800362 hosts=[ "h64514", "h64515", "h64516" ],
363 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700364
pingping-linea32cf82015-10-08 22:37:37 -0700365 def CASE9( self, main ):
366 '''
367 Bring down a switch in best path, check:
368 route number, P2P intent number, M2S intent number, ping test
369 '''
370 main.case( "Stop sw11 located in best path, \
371 check route number, P2P intent number, M2S intent number, ping test" )
372
373 main.log.info( "Check the flow number correctness before stopping sw11" )
alison62006dd2016-12-15 16:21:28 -0800374 main.Functions.checkFlowNum( main, "sw11", 49 )
375 main.Functions.checkFlowNum( main, "sw1", 7 )
376 main.Functions.checkFlowNum( main, "sw7", 34 )
pingping-linea32cf82015-10-08 22:37:37 -0700377 main.log.info( main.Mininet.checkFlows( "sw11" ) )
378 main.log.info( main.Mininet.checkFlows( "sw1" ) )
379 main.log.info( main.Mininet.checkFlows( "sw7" ) )
380
381 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800382 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700383 utilities.assert_equals( expect=main.TRUE, actual=result,
384 onpass="Stopping switch succeeded!",
385 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700386 if result:
387 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
388 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800389 main.Functions.checkRouteNum( main, 7 )
390 main.Functions.checkM2SintentNum( main, 7 )
391 main.Functions.checkP2PintentNum( main, 30 * 2 ) #18 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700392 else:
393 main.log.error( "Stopping switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700394 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700395
396 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700397 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800398 main.FALSE,
399 kwargs={'isPENDING':False},
400 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700401 utilities.assert_equals( expect=main.TRUE,
402 actual=flowCheck,
403 onpass="Flow status is correct!",
404 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700405 # Ping test
alison62006dd2016-12-15 16:21:28 -0800406 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
407 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800408 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800409 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
410 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800411 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700412 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800413 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800414 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700415
416
417 def CASE10( self, main ):
418 '''
419 Bring up the switch which was stopped in CASE9, check:
420 route number, P2P intent number, M2S intent number, ping test
421 '''
422 main.case( "Start sw11 which was stopped in CASE9, \
423 check route number, P2P intent number, M2S intent number, ping test" )
424
425 main.log.info( "Check the flow status before starting sw11" )
alison62006dd2016-12-15 16:21:28 -0800426 main.Functions.checkFlowNum( main, "sw1", 36 )
427 main.Functions.checkFlowNum( main, "sw7", 30 )
pingping-linea32cf82015-10-08 22:37:37 -0700428 main.log.info( main.Mininet.checkFlows( "sw1" ) )
429 main.log.info( main.Mininet.checkFlows( "sw7" ) )
430
431 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800432 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700433 utilities.assert_equals( expect=main.TRUE, actual=result1,
434 onpass="Starting switch succeeded!",
435 onfail="Starting switch failed!" )
Devin Lim142b5342017-07-20 15:22:39 -0700436 result2 = main.Mininet.assignSwController( "sw11", main.Cluster.active( 0 ).ipAddress )
Jon Hall362aa922016-03-31 09:39:26 -0700437 utilities.assert_equals( expect=main.TRUE, actual=result2,
438 onpass="Connect switch to ONOS succeeded!",
439 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700440 if result1 and result2:
441 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800442 main.Functions.checkRouteNum( main, 7 )
443 main.Functions.checkM2SintentNum( main, 7 )
444 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700445
446 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
447 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
448 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
449 else:
450 main.log.error( "Starting switch failed!" )
Devin Lim44075962017-08-11 10:56:37 -0700451 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700452
453 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700454 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800455 main.FALSE,
456 kwargs={'isPENDING':False},
457 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700458 utilities.assert_equals( expect=main.TRUE,
459 actual=flowCheck,
460 onpass="Flow status is correct!",
461 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700462 # Ping test
alison62006dd2016-12-15 16:21:28 -0800463 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
464 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800465 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800466 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
467 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800468 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700469 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800470 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800471 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700472
473
474 def CASE11(self, main):
475 import time
alison62006dd2016-12-15 16:21:28 -0800476 main.case( "Kill spk1, check:\
pingping-linea32cf82015-10-08 22:37:37 -0700477 route number, P2P intent number, M2S intent number, ping test" )
alison62006dd2016-12-15 16:21:28 -0800478 main.log.info( "Check network status before killing spk1" )
479 main.Functions.checkRouteNum( main, 7 )
480 main.Functions.checkM2SintentNum( main, 7 )
481 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700482 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700483 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800484 main.FALSE,
485 kwargs={'isPENDING':False},
486 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700487 utilities.assert_equals( expect=main.TRUE,
488 actual=flowCheck,
489 onpass="Flow status is correct!",
490 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700491
alison62006dd2016-12-15 16:21:28 -0800492 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
493 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800494 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800495 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
496 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800497 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700498 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800499 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800500 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700501
alison62006dd2016-12-15 16:21:28 -0800502 main.step( "Kill spk1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700503 command1 = "ps -e | grep bgp -c"
504 result1 = main.Mininet.node( "root", command1 )
505
506 # The total BGP daemon number in this test environment is 5.
507 if "5" in result1:
alison62006dd2016-12-15 16:21:28 -0800508 main.log.debug( "Before kill spk1, 5 BGP daemons - correct" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700509 else:
alison62006dd2016-12-15 16:21:28 -0800510 main.log.warn( "Before kill spk1, number of BGP daemons is wrong" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700511 main.log.info( result1 )
512
513 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
514 result2 = main.Mininet.node( "root", command2 )
515
516 result3 = main.Mininet.node( "root", command1 )
517
Jon Hall6e9897d2016-02-29 14:41:32 -0800518 utilities.assert_equals( expect=True,
519 actual=( "4" in result3 ),
alison62006dd2016-12-15 16:21:28 -0800520 onpass="Kill spk1 succeeded",
521 onfail="Kill spk1 failed" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700522 if ( "4" not in result3 ) :
523 main.log.info( result3 )
Devin Lim44075962017-08-11 10:56:37 -0700524 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700525
526 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800527 main.Functions.checkRouteNum( main, 7 )
528 main.Functions.checkM2SintentNum( main, 7 )
529 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700530
531 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700532 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800533 main.FALSE,
534 kwargs={'isPENDING':False},
535 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700536 utilities.assert_equals( expect=main.TRUE,
537 actual=flowCheck,
538 onpass="Flow status is correct!",
539 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700540
541 '''
alison62006dd2016-12-15 16:21:28 -0800542 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
543 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800544 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700545 '''
alison62006dd2016-12-15 16:21:28 -0800546 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
547 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800548 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700549 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800550 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800551 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700552
553
554 def CASE12( self, main ):
555 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700556 import json
pingping-linea32cf82015-10-08 22:37:37 -0700557 main.case( "Bring down leader ONOS node, check: \
558 route number, P2P intent number, M2S intent number, ping test" )
559 main.step( "Find out ONOS leader node" )
Devin Lim142b5342017-07-20 15:22:39 -0700560 result = main.Cluster.active( 0 ).CLI.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700561 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700562 leaderIP = ""
563 for entry in jsonResult:
564 if entry["topic"] == "org.onosproject.sdnip":
565 leaderIP = entry["leader"]
566 main.log.info( "leaderIP is: " )
567 main.log.info( leaderIP )
568
569 main.step( "Uninstall ONOS/SDN-IP leader node" )
Devin Lim142b5342017-07-20 15:22:39 -0700570 for ip in main.Cluster.getIps():
Devin Lim58046fa2017-07-05 16:55:00 -0700571 if leaderIP == ip:
572 uninstallResult = main.ONOSbench.onosStop( ip )
pingping-lina14c7c82015-10-09 15:44:36 -0700573
Jon Hall6e9897d2016-02-29 14:41:32 -0800574 utilities.assert_equals( expect=main.TRUE,
575 actual=uninstallResult,
576 onpass="Uninstall ONOS leader succeeded",
577 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700578 if uninstallResult != main.TRUE:
Devin Lim44075962017-08-11 10:56:37 -0700579 main.cleanAndExit()
pingping-linea32cf82015-10-08 22:37:37 -0700580 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700581
Devin Lim142b5342017-07-20 15:22:39 -0700582 if leaderIP == main.Cluster.active( 0 ).ipAddress:
583 main.Functions.checkRouteNum( main, 7, node=2 )
584 main.Functions.checkM2SintentNum( main, 7, node=2 )
585 main.Functions.checkP2PintentNum( main, 30 * 2, node=2 )
pingping-lina14c7c82015-10-09 15:44:36 -0700586
587 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700588 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800589 main.FALSE,
590 kwargs={'isPENDING':False},
591 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700592 utilities.assert_equals( expect=main.TRUE,
593 actual=flowCheck,
594 onpass="Flow status is correct!",
595 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700596 else:
alison62006dd2016-12-15 16:21:28 -0800597 main.Functions.checkRouteNum( main, 7 )
598 main.Functions.checkM2SintentNum( main, 7 )
599 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-lina14c7c82015-10-09 15:44:36 -0700600
601 main.step( "Check whether all flow status are ADDED" )
Devin Lim142b5342017-07-20 15:22:39 -0700602 flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800603 main.FALSE,
604 kwargs={'isPENDING':False},
605 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700606 utilities.assert_equals( expect=main.TRUE,
607 actual=flowCheck,
608 onpass="Flow status is correct!",
609 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700610
alison62006dd2016-12-15 16:21:28 -0800611 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
612 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800613 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800614 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
615 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800616 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700617 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800618 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800619 expectAllSuccess=True )