blob: 75933688c151a875f38c55828bc72c5b1a6fc961 [file] [log] [blame]
pingping-linea32cf82015-10-08 22:37:37 -07001# Testing the functionality of SDN-IP with single ONOS instance
2class USECASE_SdnipFunctionCluster:
3
4 def __init__( self ):
5 self.default = ''
6 global branchName
7
8 def CASE100( self, main ):
9 """
10 Start mininet
11 """
12 import imp
Jon Hall362aa922016-03-31 09:39:26 -070013 main.case( "Setup the Mininet testbed" )
pingping-linea32cf82015-10-08 22:37:37 -070014 main.dependencyPath = main.testDir + \
15 main.params[ 'DEPENDENCY' ][ 'path' ]
16 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
17
18 main.step( "Starting Mininet Topology" )
19 topology = main.dependencyPath + main.topology
Jon Hall6e9897d2016-02-29 14:41:32 -080020 topoResult = main.Mininet.startNet( topoFile=topology )
21 utilities.assert_equals( expect=main.TRUE,
22 actual=topoResult,
23 onpass="Successfully loaded topology",
24 onfail="Failed to load topology" )
pingping-linea32cf82015-10-08 22:37:37 -070025 # Exit if topology did not load properly
26 if not topoResult:
27 main.cleanup()
28 main.exit()
29 main.step( "Connect switches to controllers" )
30
31 # connect all switches to controllers
32 swResult = main.TRUE
33 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
34 sw = "sw%s" % ( i )
35 swResult = swResult and main.Mininet.assignSwController( sw,
36 [ONOS1Ip, ONOS2Ip, ONOS3Ip] )
Jon Hall6e9897d2016-02-29 14:41:32 -080037 utilities.assert_equals( expect=main.TRUE,
38 actual=swResult,
39 onpass="Successfully connect all switches to ONOS",
40 onfail="Failed to connect all switches to ONOS" )
pingping-linea32cf82015-10-08 22:37:37 -070041 if not swResult:
42 main.cleanup()
43 main.exit()
44
45
46 def CASE101( self, main ):
47 """
48 Package ONOS and install it
49 Startup sequence:
50 cell <name>
51 onos-verify-cell
52 onos-package
53 onos-install -f
54 onos-wait-for-start
55 """
56 import json
57 import time
58 import os
59 from operator import eq
60
61 main.case( "Setting up ONOS environment" )
62
63 cellName = main.params[ 'ENV' ][ 'cellName' ]
64 global ONOS1Ip
65 global ONOS2Ip
66 global ONOS3Ip
67 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
68 ONOS2Ip = os.getenv( main.params[ 'CTRL' ][ 'ip2' ] )
69 ONOS3Ip = os.getenv( main.params[ 'CTRL' ][ 'ip3' ] )
Jon Hall6e9897d2016-02-29 14:41:32 -080070 ipList = [ ONOS1Ip, ONOS2Ip, ONOS3Ip ]
pingping-linea32cf82015-10-08 22:37:37 -070071
72 global peer64514
73 global peer64515
74 global peer64516
75 peer64514 = main.params['config']['peer64514']
76 peer64515 = main.params['config']['peer64515']
77 peer64516 = main.params['config']['peer64516']
78
Jon Hall6e9897d2016-02-29 14:41:32 -080079 main.step( "Create cell file" )
80 cellAppString = main.params[ 'ENV' ][ 'appString' ]
81 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
82 main.Mininet.ip_address,
83 cellAppString, ipList )
84
pingping-linea32cf82015-10-08 22:37:37 -070085 main.step( "Applying cell variable to environment" )
86 cellResult = main.ONOSbench.setCell( cellName )
Jon Hall6e9897d2016-02-29 14:41:32 -080087 utilities.assert_equals( expect=main.TRUE,
88 actual=cellResult,
89 onpass="Set cell succeeded",
90 onfail="Set cell failed" )
pingping-linea32cf82015-10-08 22:37:37 -070091
92 verifyResult = main.ONOSbench.verifyCell()
Jon Hall6e9897d2016-02-29 14:41:32 -080093 utilities.assert_equals( expect=main.TRUE,
94 actual=verifyResult,
95 onpass="Verify cell succeeded",
96 onfail="Verify cell failed" )
pingping-linea32cf82015-10-08 22:37:37 -070097
98 branchName = main.ONOSbench.getBranchName()
99 main.log.report( "ONOS is on branch: " + branchName )
100
101 main.log.step( "Uninstalling ONOS" )
102 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) \
103 and main.ONOSbench.onosUninstall( ONOS2Ip ) \
104 and main.ONOSbench.onosUninstall( ONOS3Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -0800105 utilities.assert_equals( expect=main.TRUE,
106 actual=uninstallResult,
107 onpass="Uninstall ONOS from nodes succeeded",
108 onfail="Uninstall ONOS form nodes failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700109
Jon Hall6e9897d2016-02-29 14:41:32 -0800110 main.ONOSbench.getVersion( report=True )
pingping-linea32cf82015-10-08 22:37:37 -0700111
112 main.step( "Creating ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800113 packageResult = main.ONOSbench.onosPackage( opTimeout=500 )
114 utilities.assert_equals( expect=main.TRUE,
115 actual=packageResult,
116 onpass="Package ONOS succeeded",
117 onfail="Package ONOS failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700118
119 main.step( "Installing ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800120 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
121 node=ONOS1Ip )
122 onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
123 node=ONOS2Ip )
124 onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
125 node=ONOS3Ip )
pingping-linea32cf82015-10-08 22:37:37 -0700126 onosInstallResult = onos1InstallResult and onos2InstallResult \
127 and onos3InstallResult
Jon Hall6e9897d2016-02-29 14:41:32 -0800128 utilities.assert_equals( expect=main.TRUE,
129 actual=onosInstallResult,
130 onpass="Install ONOS to nodes succeeded",
131 onfail="Install ONOS to nodes failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700132
133 main.step( "Checking if ONOS is up yet" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800134 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
135 onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
136 onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout=420 )
pingping-linea32cf82015-10-08 22:37:37 -0700137 onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult
Jon Hall6e9897d2016-02-29 14:41:32 -0800138 utilities.assert_equals( expect=main.TRUE,
139 actual=onosUpResult,
140 onpass="ONOS nodes are up",
141 onfail="ONOS nodes are NOT up" )
pingping-linea32cf82015-10-08 22:37:37 -0700142
143 main.step( "Checking if ONOS CLI is ready" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800144 main.CLIs = []
pingping-lina14c7c82015-10-09 15:44:36 -0700145 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800146 commandlineTimeout=100, onosStartTimeout=600 )
147 main.CLIs.append( main.ONOScli1 )
pingping-lina14c7c82015-10-09 15:44:36 -0700148 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800149 commandlineTimeout=100, onosStartTimeout=600 )
150 main.CLIs.append( main.ONOScli2 )
151 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
152 commandlineTimeout=100, onosStartTimeout=600 )
153 main.CLIs.append( main.ONOScli3 )
154 cliResult = cliResult1 and cliResult2 and cliResult3
155 utilities.assert_equals( expect=main.TRUE,
156 actual=cliResult,
157 onpass="ONOS CLIs are ready",
158 onfail="ONOS CLIs are not ready" )
pingping-linea32cf82015-10-08 22:37:37 -0700159
Jon Hall362aa922016-03-31 09:39:26 -0700160 main.step( "Checking if ONOS CLI is ready for issuing commands" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800161 for i in range( 10 ):
162 ready = True
163 for cli in main.CLIs:
164 output = cli.summary()
165 if not output:
166 ready = False
167 if ready:
168 break
169 time.sleep( 30 )
170 utilities.assert_equals( expect=True, actual=ready,
171 onpass="ONOS summary command succeded",
172 onfail="ONOS summary command failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700173
Jon Hall6e9897d2016-02-29 14:41:32 -0800174 if not ready:
pingping-linea32cf82015-10-08 22:37:37 -0700175 main.log.error( "ONOS startup failed!" )
176 main.cleanup()
177 main.exit()
178
pingping-linea32cf82015-10-08 22:37:37 -0700179 def CASE200( self, main ):
180 main.case( "Activate sdn-ip application" )
181 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800182 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700183
Jon Hall362aa922016-03-31 09:39:26 -0700184 main.step( "Get links in the network" )
pingping-lina14c7c82015-10-09 15:44:36 -0700185 summaryResult = main.ONOScli1.summary()
pingping-linea32cf82015-10-08 22:37:37 -0700186 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall362aa922016-03-31 09:39:26 -0700187 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
pingping-linea32cf82015-10-08 22:37:37 -0700188 if linkNum < 100:
Jon Hall362aa922016-03-31 09:39:26 -0700189 main.log.error( "Link number is wrong! Retrying..." )
Jon Hall6e9897d2016-02-29 14:41:32 -0800190 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700191 summaryResult = main.ONOScli1.summary()
192 linkNum = json.loads( summaryResult )[ "links" ]
193 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
194 utilities.assert_equals( expect=100,
195 actual=linkNum,
196 onpass="ONOS correctly discovered all links",
197 onfail="ONOS Failed to discover all links" )
198 if linkNum < 100:
pingping-linea32cf82015-10-08 22:37:37 -0700199 main.cleanup()
200 main.exit()
201
pingping-linea32cf82015-10-08 22:37:37 -0700202 main.step( "Activate sdn-ip application" )
pingping-lina14c7c82015-10-09 15:44:36 -0700203 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800204 utilities.assert_equals( expect=main.TRUE,
205 actual=activeSDNIPresult,
206 onpass="Activate SDN-IP succeeded",
207 onfail="Activate SDN-IP failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700208 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800209 main.log.info( "Activate SDN-IP failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700210 main.cleanup()
211 main.exit()
212
pingping-linea32cf82015-10-08 22:37:37 -0700213
214 def CASE102( self, main ):
215 '''
216 This test case is to load the methods from other Python files, and create
217 tunnels from mininet host to onos nodes.
218 '''
219 import time
220 main.case( "Load methods from other Python file and create tunnels" )
221 # load the methods from other file
222 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
223 main.Functions = imp.load_source( wrapperFile1,
224 main.dependencyPath +
225 wrapperFile1 +
226 ".py" )
227 # Create tunnels
228 main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
229 main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
230 main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
231
232 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
233 and the BGP paths in data plane are ready..." )
234 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
235
236 main.log.info( "Wait Quagga to finish delivery all routes to each \
237 other and to sdn-ip, plus finish installing all intents..." )
238 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700239
240 def CASE1( self, main ):
241 '''
242 ping test from 3 bgp peers to BGP speaker
243 '''
244
Jon Hall362aa922016-03-31 09:39:26 -0700245 main.case( "Ping between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800246 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
247 peers=["peer64514", "peer64515", "peer64516"],
248 expectAllSuccess=True )
249 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
250 peers=[peer64514, peer64515, peer64516],
251 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700252
253 def CASE2( self, main ):
254 '''
255 point-to-point intents test for each BGP peer and BGP speaker pair
256 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800257 import time
pingping-linea32cf82015-10-08 22:37:37 -0700258 main.case( "Check point-to-point intents" )
259 main.log.info( "There are %s BGP peers in total "
260 % main.params[ 'config' ][ 'peerNum' ] )
261 main.step( "Check P2P intents number from ONOS CLI" )
262
Jon Hall6e9897d2016-02-29 14:41:32 -0800263 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700264 bgpIntentsActualNum = \
265 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
266 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
Jon Hall6e9897d2016-02-29 14:41:32 -0800267 if bgpIntentsActualNum != bgpIntentsExpectedNum:
268 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700269 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800270 bgpIntentsActualNum = \
271 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
pingping-linea32cf82015-10-08 22:37:37 -0700272 main.log.info( "bgpIntentsExpected num is:" )
273 main.log.info( bgpIntentsExpectedNum )
274 main.log.info( "bgpIntentsActual num is:" )
275 main.log.info( bgpIntentsActualNum )
Jon Hall362aa922016-03-31 09:39:26 -0700276 utilities.assert_equals( expect=bgpIntentsExpectedNum,
277 actual=bgpIntentsActualNum,
278 onpass="PointToPointIntent Intent Num is correct!",
279 onfail="PointToPointIntent Intent Num is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700280
281 def CASE3( self, main ):
282 '''
283 routes and intents check to all BGP peers
284 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800285 import time
pingping-linea32cf82015-10-08 22:37:37 -0700286 main.case( "Check routes and M2S intents to all BGP peers" )
287
Jon Hall362aa922016-03-31 09:39:26 -0700288 main.step( "Check routes installed" )
pingping-linea32cf82015-10-08 22:37:37 -0700289 allRoutesExpected = []
290 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
291 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
292 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
293
Jon Hall6e9897d2016-02-29 14:41:32 -0800294 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700295 allRoutesActual = \
296 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
297 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
298 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800299 if allRoutesStrActual != allRoutesStrExpected:
300 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
301 allRoutesActual = \
302 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
303 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
pingping-linea32cf82015-10-08 22:37:37 -0700304
pingping-linea32cf82015-10-08 22:37:37 -0700305 main.log.info( "Routes expected:" )
306 main.log.info( allRoutesStrExpected )
307 main.log.info( "Routes get from ONOS CLI:" )
308 main.log.info( allRoutesStrActual )
Jon Hall362aa922016-03-31 09:39:26 -0700309 utilities.assert_equals( expect=allRoutesStrExpected,
310 actual=allRoutesStrActual,
311 onpass="Routes are correct!",
312 onfail="Routes are wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700313
314 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800315 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700316 routeIntentsActualNum = \
317 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
318 routeIntentsExpectedNum = 3
Jon Hall6e9897d2016-02-29 14:41:32 -0800319 if routeIntentsActualNum != routeIntentsExpectedNum:
320 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700321 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800322 routeIntentsActualNum = \
323 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-linea32cf82015-10-08 22:37:37 -0700324
325 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
326 main.log.info( routeIntentsExpectedNum )
327 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
328 main.log.info( routeIntentsActualNum )
Jon Hall362aa922016-03-31 09:39:26 -0700329 utilities.assert_equals( expect=routeIntentsExpectedNum,
330 actual=routeIntentsActualNum,
331 onpass="MultiPointToSinglePoint Intent Num is correct!",
332 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700333
334 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800335 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
336 main.FALSE,
337 kwargs={'isPENDING':False},
338 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700339 utilities.assert_equals( expect=main.TRUE,
340 actual=flowCheck,
341 onpass="Flow status is correct!",
342 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700343
344
345 def CASE4( self, main ):
346 '''
347 Ping test in data plane for each route
348 '''
349 main.case( "Ping test for each route, all hosts behind BGP peers" )
350 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800351 hosts=["host64514", "host64515", "host64516"],
352 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700353
354
355 def CASE5( self, main ):
356 '''
357 Cut links to peers one by one, check routes/intents
358 '''
359 import time
360 main.case( "Bring down links and check routes/intents" )
361 main.step( "Bring down the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800362 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
363 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700364 utilities.assert_equals( expect=main.TRUE,
365 actual=linkResult1,
366 onpass="Bring down link succeeded!",
367 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700368
369 if linkResult1 == main.TRUE:
370 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
371 main.Functions.checkRouteNum( main, 2 )
372 main.Functions.checkM2SintentNum( main, 2 )
373 else:
374 main.log.error( "Bring down link failed!" )
375 main.cleanup()
376 main.exit()
377
378 main.step( "Bring down the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800379 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
380 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700381 utilities.assert_equals( expect=main.TRUE,
382 actual=linkResult2,
383 onpass="Bring down link succeeded!",
384 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700385 if linkResult2 == main.TRUE:
386 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
387 main.Functions.checkRouteNum( main, 1 )
388 main.Functions.checkM2SintentNum( main, 1 )
389 else:
390 main.log.error( "Bring down link failed!" )
391 main.cleanup()
392 main.exit()
393
394 main.step( "Bring down the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800395 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
396 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700397 utilities.assert_equals( expect=main.TRUE,
398 actual=linkResult3,
399 onpass="Bring down link succeeded!",
400 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700401 if linkResult3 == main.TRUE:
402 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
403 main.Functions.checkRouteNum( main, 0 )
404 main.Functions.checkM2SintentNum( main, 0 )
405 else:
406 main.log.error( "Bring down link failed!" )
407 main.cleanup()
408 main.exit()
409
410 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800411 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
412 main.FALSE,
413 kwargs={'isPENDING':False},
414 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700415 utilities.assert_equals( expect=main.TRUE,
416 actual=flowCheck,
417 onpass="Flow status is correct!",
418 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700419
420 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800421 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
422 peers=["peer64514", "peer64515", "peer64516"],
423 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700424 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800425 hosts=["host64514", "host64515", "host64516"],
426 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700427
pingping-linea32cf82015-10-08 22:37:37 -0700428 def CASE6( self, main ):
429 '''
430 Recover links to peers one by one, check routes/intents
431 '''
432 import time
433 main.case( "Bring up links and check routes/intents" )
434 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800435 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
436 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700437 utilities.assert_equals( expect=main.TRUE,
438 actual=linkResult1,
439 onpass="Bring up link succeeded!",
440 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700441 if linkResult1 == main.TRUE:
442 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
443 main.Functions.checkRouteNum( main, 1 )
444 main.Functions.checkM2SintentNum( main, 1 )
445 else:
446 main.log.error( "Bring up link failed!" )
447 main.cleanup()
448 main.exit()
449
450 main.step( "Bring up the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800451 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
452 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700453 utilities.assert_equals( expect=main.TRUE,
454 actual=linkResult2,
455 onpass="Bring up link succeeded!",
456 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700457 if linkResult2 == main.TRUE:
458 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
459 main.Functions.checkRouteNum( main, 2 )
460 main.Functions.checkM2SintentNum( main, 2 )
461 else:
462 main.log.error( "Bring up link failed!" )
463 main.cleanup()
464 main.exit()
465
466 main.step( "Bring up the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800467 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
468 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700469 utilities.assert_equals( expect=main.TRUE,
470 actual=linkResult3,
471 onpass="Bring up link succeeded!",
472 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700473 if linkResult3 == main.TRUE:
474 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
475 main.Functions.checkRouteNum( main, 3 )
476 main.Functions.checkM2SintentNum( main, 3 )
477 else:
478 main.log.error( "Bring up link failed!" )
479 main.cleanup()
480 main.exit()
481
482 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800483 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
484 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
492 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800493 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
494 peers=["peer64514", "peer64515", "peer64516"],
495 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700496 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800497 hosts=["host64514", "host64515", "host64516"],
498 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700499
pingping-linea32cf82015-10-08 22:37:37 -0700500 def CASE7( self, main ):
501 '''
502 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
503 '''
504 import time
505 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
506 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800507 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700508 utilities.assert_equals( expect=main.TRUE, actual=result,
509 onpass="Stopping switch succeeded!",
510 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700511
512 if result == main.TRUE:
513 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
514 main.Functions.checkRouteNum( main, 2 )
515 main.Functions.checkM2SintentNum( main, 2 )
516 main.Functions.checkP2PintentNum( main, 12 * 2 )
517 else:
518 main.log.error( "Stopping switch failed!" )
519 main.cleanup()
520 main.exit()
521
522 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800523 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
524 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
525 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700526
527 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
528 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800529 utilities.assert_equals( expect=True, actual=pingResult1,
530 onpass="Ping test result is correct",
531 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700532
533 if pingResult1 == False:
534 main.cleanup()
535 main.exit()
536
537 main.step( "Check ping between BGP peers and speaker1" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800538 result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" )
539 result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" )
540 result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700541
542 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
543 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800544 utilities.assert_equals( expect=True, actual=pingResult2,
545 onpass="Speaker1 ping peers successful",
546 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700547
548 if pingResult2 == False:
549 main.cleanup()
550 main.exit()
551
552 main.step( "Check ping between BGP peers and speaker2" )
553 # TODO
Jon Hall6e9897d2016-02-29 14:41:32 -0800554 result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 )
555 result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 )
556 result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700557
558 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
559 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800560 utilities.assert_equals( expect=True, actual=pingResult2,
561 onpass="Speaker2 ping peers successful",
562 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700563
564 if pingResult3 == False:
565 main.cleanup()
566 main.exit()
567
568 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800569 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
570 main.FALSE,
571 kwargs={'isPENDING':False},
572 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700573 utilities.assert_equals( expect=main.TRUE,
574 actual=flowCheck,
575 onpass="Flow status is correct!",
576 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700577
578 def CASE8( self, main ):
579 '''
580 Bring up the edge switch (sw32) which was shut down in CASE7,
581 check P-2-P and M-2-S intents, ping test
582 '''
583 import time
584 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
585 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800586 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700587 utilities.assert_equals( expect=main.TRUE,
588 actual=result1,
589 onpass="Starting switch succeeded!",
590 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700591
592 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700593 utilities.assert_equals( expect=main.TRUE,
594 actual=result2,
595 onpass="Connect switch to ONOS succeeded!",
596 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700597
598 if result1 and result2:
599 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
600 main.Functions.checkRouteNum( main, 3 )
601 main.Functions.checkM2SintentNum( main, 3 )
602 main.Functions.checkP2PintentNum( main, 18 * 2 )
603 else:
604 main.log.error( "Starting switch failed!" )
605 main.cleanup()
606 main.exit()
607
608 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800609 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
610 main.FALSE,
611 kwargs={'isPENDING':False},
612 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700613 utilities.assert_equals( expect=main.TRUE,
614 actual=flowCheck,
615 onpass="Flow status is correct!",
616 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700617
618 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800619 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
620 peers=["peer64514", "peer64515", "peer64516"],
621 expectAllSuccess=True )
622 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
623 peers=[peer64514, peer64515, peer64516],
624 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700625 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800626 hosts=["host64514", "host64515", "host64516"],
627 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700628
pingping-linea32cf82015-10-08 22:37:37 -0700629 def CASE9( self, main ):
630 '''
631 Bring down a switch in best path, check:
632 route number, P2P intent number, M2S intent number, ping test
633 '''
634 main.case( "Stop sw11 located in best path, \
635 check route number, P2P intent number, M2S intent number, ping test" )
636
637 main.log.info( "Check the flow number correctness before stopping sw11" )
638 main.Functions.checkFlowNum( main, "sw11", 19 )
639 main.Functions.checkFlowNum( main, "sw1", 3 )
640 main.Functions.checkFlowNum( main, "sw7", 3 )
641 main.log.info( main.Mininet.checkFlows( "sw11" ) )
642 main.log.info( main.Mininet.checkFlows( "sw1" ) )
643 main.log.info( main.Mininet.checkFlows( "sw7" ) )
644
645 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800646 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700647 utilities.assert_equals( expect=main.TRUE, actual=result,
648 onpass="Stopping switch succeeded!",
649 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700650 if result:
651 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
652 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
653 main.Functions.checkRouteNum( main, 3 )
654 main.Functions.checkM2SintentNum( main, 3 )
655 main.Functions.checkP2PintentNum( main, 18 * 2 )
656 else:
657 main.log.error( "Stopping switch failed!" )
658 main.cleanup()
659 main.exit()
660
661 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800662 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
663 main.FALSE,
664 kwargs={'isPENDING':False},
665 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700666 utilities.assert_equals( expect=main.TRUE,
667 actual=flowCheck,
668 onpass="Flow status is correct!",
669 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700670 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800671 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
672 peers=["peer64514", "peer64515", "peer64516"],
673 expectAllSuccess=True )
674 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
675 peers=[peer64514, peer64515, peer64516],
676 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700677 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800678 hosts=["host64514", "host64515", "host64516"],
679 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700680
681
682 def CASE10( self, main ):
683 '''
684 Bring up the switch which was stopped in CASE9, check:
685 route number, P2P intent number, M2S intent number, ping test
686 '''
687 main.case( "Start sw11 which was stopped in CASE9, \
688 check route number, P2P intent number, M2S intent number, ping test" )
689
690 main.log.info( "Check the flow status before starting sw11" )
691 main.Functions.checkFlowNum( main, "sw1", 17 )
692 main.Functions.checkFlowNum( main, "sw7", 5 )
693 main.log.info( main.Mininet.checkFlows( "sw1" ) )
694 main.log.info( main.Mininet.checkFlows( "sw7" ) )
695
696 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800697 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700698 utilities.assert_equals( expect=main.TRUE, actual=result1,
699 onpass="Starting switch succeeded!",
700 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700701 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700702 utilities.assert_equals( expect=main.TRUE, actual=result2,
703 onpass="Connect switch to ONOS succeeded!",
704 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700705 if result1 and result2:
706 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
707 main.Functions.checkRouteNum( main, 3 )
708 main.Functions.checkM2SintentNum( main, 3 )
709 main.Functions.checkP2PintentNum( main, 18 * 2 )
710
711 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
712 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
713 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
714 else:
715 main.log.error( "Starting switch failed!" )
716 main.cleanup()
717 main.exit()
718
719 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800720 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
721 main.FALSE,
722 kwargs={'isPENDING':False},
723 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700724 utilities.assert_equals( expect=main.TRUE,
725 actual=flowCheck,
726 onpass="Flow status is correct!",
727 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700728 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800729 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
730 peers=["peer64514", "peer64515", "peer64516"],
731 expectAllSuccess=True )
732 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
733 peers=[peer64514, peer64515, peer64516],
734 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700735 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800736 hosts=["host64514", "host64515", "host64516"],
737 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700738
739
740 def CASE11(self, main):
741 import time
742 main.case( "Kill speaker1, check:\
743 route number, P2P intent number, M2S intent number, ping test" )
pingping-lina14c7c82015-10-09 15:44:36 -0700744 main.log.info( "Check network status before killing speaker1" )
pingping-linea32cf82015-10-08 22:37:37 -0700745 main.Functions.checkRouteNum( main, 3 )
746 main.Functions.checkM2SintentNum( main, 3 )
747 main.Functions.checkP2PintentNum( main, 18 * 2 )
748 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800749 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
750 main.FALSE,
751 kwargs={'isPENDING':False},
752 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700753 utilities.assert_equals( expect=main.TRUE,
754 actual=flowCheck,
755 onpass="Flow status is correct!",
756 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700757
Jon Hall6e9897d2016-02-29 14:41:32 -0800758 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
759 peers=["peer64514", "peer64515", "peer64516"],
760 expectAllSuccess=True )
761 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
762 peers=[peer64514, peer64515, peer64516],
763 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700764 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800765 hosts=["host64514", "host64515", "host64516"],
766 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700767
768 main.step( "Kill speaker1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700769 command1 = "ps -e | grep bgp -c"
770 result1 = main.Mininet.node( "root", command1 )
771
772 # The total BGP daemon number in this test environment is 5.
773 if "5" in result1:
774 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
775 else:
776 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
777 main.log.info( result1 )
778
779 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
780 result2 = main.Mininet.node( "root", command2 )
781
782 result3 = main.Mininet.node( "root", command1 )
783
Jon Hall6e9897d2016-02-29 14:41:32 -0800784 utilities.assert_equals( expect=True,
785 actual=( "4" in result3 ),
786 onpass="Kill speaker1 succeeded",
787 onfail="Kill speaker1 failed" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700788 if ( "4" not in result3 ) :
789 main.log.info( result3 )
pingping-linea32cf82015-10-08 22:37:37 -0700790 main.cleanup()
791 main.exit()
792
793 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
794 main.Functions.checkRouteNum( main, 3 )
795 main.Functions.checkM2SintentNum( main, 3 )
796 main.Functions.checkP2PintentNum( main, 18 * 2 )
797
798 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800799 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
800 main.FALSE,
801 kwargs={'isPENDING':False},
802 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700803 utilities.assert_equals( expect=main.TRUE,
804 actual=flowCheck,
805 onpass="Flow status is correct!",
806 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700807
808 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800809 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
810 peers=["peer64514", "peer64515", "peer64516"],
811 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700812 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800813 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
814 peers=[peer64514, peer64515, peer64516],
815 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700816 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800817 hosts=["host64514", "host64515", "host64516"],
818 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700819
820
821 def CASE12( self, main ):
822 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700823 import json
pingping-linea32cf82015-10-08 22:37:37 -0700824 main.case( "Bring down leader ONOS node, check: \
825 route number, P2P intent number, M2S intent number, ping test" )
826 main.step( "Find out ONOS leader node" )
pingping-lina14c7c82015-10-09 15:44:36 -0700827 result = main.ONOScli1.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700828 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700829 leaderIP = ""
830 for entry in jsonResult:
831 if entry["topic"] == "org.onosproject.sdnip":
832 leaderIP = entry["leader"]
833 main.log.info( "leaderIP is: " )
834 main.log.info( leaderIP )
835
836 main.step( "Uninstall ONOS/SDN-IP leader node" )
837 if leaderIP == ONOS1Ip:
838 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
839 elif leaderIP == ONOS2Ip:
840 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
841 else:
842 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
843
Jon Hall6e9897d2016-02-29 14:41:32 -0800844 utilities.assert_equals( expect=main.TRUE,
845 actual=uninstallResult,
846 onpass="Uninstall ONOS leader succeeded",
847 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700848 if uninstallResult != main.TRUE:
849 main.cleanup()
850 main.exit()
851 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700852
pingping-lina14c7c82015-10-09 15:44:36 -0700853 if leaderIP == ONOS1Ip:
Jon Hall6e9897d2016-02-29 14:41:32 -0800854 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
855 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
856 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
pingping-lina14c7c82015-10-09 15:44:36 -0700857
858 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800859 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
860 main.FALSE,
861 kwargs={'isPENDING':False},
862 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700863 utilities.assert_equals( expect=main.TRUE,
864 actual=flowCheck,
865 onpass="Flow status is correct!",
866 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700867 else:
868 main.Functions.checkRouteNum( main, 3 )
869 main.Functions.checkM2SintentNum( main, 3 )
870 main.Functions.checkP2PintentNum( main, 18 * 2 )
871
872 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800873 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
874 main.FALSE,
875 kwargs={'isPENDING':False},
876 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700877 utilities.assert_equals( expect=main.TRUE,
878 actual=flowCheck,
879 onpass="Flow status is correct!",
880 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700881
Jon Hall6e9897d2016-02-29 14:41:32 -0800882 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
883 peers=["peer64514", "peer64515", "peer64516"],
884 expectAllSuccess=True )
885 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
886 peers=[peer64514, peer64515, peer64516],
887 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700888 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800889 hosts=["host64514", "host64515", "host64516"],
890 expectAllSuccess=True )