blob: 57420926ffaae4f3b8049d8ea774fa91599ffc78 [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 Hall70b768c2016-04-19 08:38:29 -070079 main.step( "Copying config files" )
80 src = os.path.dirname( main.testFile ) + "/network-cfg.json"
81 dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json"
82 status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" )
83 utilities.assert_equals( expect=main.TRUE,
84 actual=status,
85 onpass="Copy config file succeeded",
86 onfail="Copy config file failed" )
87
Jon Hall6e9897d2016-02-29 14:41:32 -080088 main.step( "Create cell file" )
89 cellAppString = main.params[ 'ENV' ][ 'appString' ]
90 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
91 main.Mininet.ip_address,
92 cellAppString, ipList )
93
pingping-linea32cf82015-10-08 22:37:37 -070094 main.step( "Applying cell variable to environment" )
95 cellResult = main.ONOSbench.setCell( cellName )
Jon Hall6e9897d2016-02-29 14:41:32 -080096 utilities.assert_equals( expect=main.TRUE,
97 actual=cellResult,
98 onpass="Set cell succeeded",
99 onfail="Set cell failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700100
Jon Hall70b768c2016-04-19 08:38:29 -0700101 main.step( "Verify cell connectivity" )
pingping-linea32cf82015-10-08 22:37:37 -0700102 verifyResult = main.ONOSbench.verifyCell()
Jon Hall6e9897d2016-02-29 14:41:32 -0800103 utilities.assert_equals( expect=main.TRUE,
104 actual=verifyResult,
105 onpass="Verify cell succeeded",
106 onfail="Verify cell failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700107
108 branchName = main.ONOSbench.getBranchName()
109 main.log.report( "ONOS is on branch: " + branchName )
110
111 main.log.step( "Uninstalling ONOS" )
112 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) \
113 and main.ONOSbench.onosUninstall( ONOS2Ip ) \
114 and main.ONOSbench.onosUninstall( ONOS3Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -0800115 utilities.assert_equals( expect=main.TRUE,
116 actual=uninstallResult,
117 onpass="Uninstall ONOS from nodes succeeded",
118 onfail="Uninstall ONOS form nodes failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700119
Jon Hall6e9897d2016-02-29 14:41:32 -0800120 main.ONOSbench.getVersion( report=True )
pingping-linea32cf82015-10-08 22:37:37 -0700121
122 main.step( "Creating ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800123 packageResult = main.ONOSbench.onosPackage( opTimeout=500 )
124 utilities.assert_equals( expect=main.TRUE,
125 actual=packageResult,
126 onpass="Package ONOS succeeded",
127 onfail="Package ONOS failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700128
129 main.step( "Installing ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800130 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
131 node=ONOS1Ip )
132 onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
133 node=ONOS2Ip )
134 onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
135 node=ONOS3Ip )
pingping-linea32cf82015-10-08 22:37:37 -0700136 onosInstallResult = onos1InstallResult and onos2InstallResult \
137 and onos3InstallResult
Jon Hall6e9897d2016-02-29 14:41:32 -0800138 utilities.assert_equals( expect=main.TRUE,
139 actual=onosInstallResult,
140 onpass="Install ONOS to nodes succeeded",
141 onfail="Install ONOS to nodes failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700142
143 main.step( "Checking if ONOS is up yet" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800144 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
145 onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
146 onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout=420 )
pingping-linea32cf82015-10-08 22:37:37 -0700147 onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult
Jon Hall6e9897d2016-02-29 14:41:32 -0800148 utilities.assert_equals( expect=main.TRUE,
149 actual=onosUpResult,
150 onpass="ONOS nodes are up",
151 onfail="ONOS nodes are NOT up" )
pingping-linea32cf82015-10-08 22:37:37 -0700152
153 main.step( "Checking if ONOS CLI is ready" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800154 main.CLIs = []
pingping-lina14c7c82015-10-09 15:44:36 -0700155 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800156 commandlineTimeout=100, onosStartTimeout=600 )
157 main.CLIs.append( main.ONOScli1 )
pingping-lina14c7c82015-10-09 15:44:36 -0700158 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800159 commandlineTimeout=100, onosStartTimeout=600 )
160 main.CLIs.append( main.ONOScli2 )
161 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
162 commandlineTimeout=100, onosStartTimeout=600 )
163 main.CLIs.append( main.ONOScli3 )
164 cliResult = cliResult1 and cliResult2 and cliResult3
165 utilities.assert_equals( expect=main.TRUE,
166 actual=cliResult,
167 onpass="ONOS CLIs are ready",
168 onfail="ONOS CLIs are not ready" )
pingping-linea32cf82015-10-08 22:37:37 -0700169
Jon Hall362aa922016-03-31 09:39:26 -0700170 main.step( "Checking if ONOS CLI is ready for issuing commands" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800171 for i in range( 10 ):
172 ready = True
173 for cli in main.CLIs:
174 output = cli.summary()
175 if not output:
176 ready = False
177 if ready:
178 break
179 time.sleep( 30 )
180 utilities.assert_equals( expect=True, actual=ready,
181 onpass="ONOS summary command succeded",
182 onfail="ONOS summary command failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700183
Jon Hall6e9897d2016-02-29 14:41:32 -0800184 if not ready:
pingping-linea32cf82015-10-08 22:37:37 -0700185 main.log.error( "ONOS startup failed!" )
186 main.cleanup()
187 main.exit()
188
pingping-linea32cf82015-10-08 22:37:37 -0700189 def CASE200( self, main ):
190 main.case( "Activate sdn-ip application" )
191 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800192 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700193
Jon Hall362aa922016-03-31 09:39:26 -0700194 main.step( "Get links in the network" )
pingping-lina14c7c82015-10-09 15:44:36 -0700195 summaryResult = main.ONOScli1.summary()
pingping-linea32cf82015-10-08 22:37:37 -0700196 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall362aa922016-03-31 09:39:26 -0700197 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
pingping-linea32cf82015-10-08 22:37:37 -0700198 if linkNum < 100:
Jon Hall362aa922016-03-31 09:39:26 -0700199 main.log.error( "Link number is wrong! Retrying..." )
Jon Hall6e9897d2016-02-29 14:41:32 -0800200 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700201 summaryResult = main.ONOScli1.summary()
202 linkNum = json.loads( summaryResult )[ "links" ]
203 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
204 utilities.assert_equals( expect=100,
205 actual=linkNum,
206 onpass="ONOS correctly discovered all links",
207 onfail="ONOS Failed to discover all links" )
208 if linkNum < 100:
pingping-linea32cf82015-10-08 22:37:37 -0700209 main.cleanup()
210 main.exit()
211
pingping-linea32cf82015-10-08 22:37:37 -0700212 main.step( "Activate sdn-ip application" )
pingping-lina14c7c82015-10-09 15:44:36 -0700213 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800214 utilities.assert_equals( expect=main.TRUE,
215 actual=activeSDNIPresult,
216 onpass="Activate SDN-IP succeeded",
217 onfail="Activate SDN-IP failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700218 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800219 main.log.info( "Activate SDN-IP failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700220 main.cleanup()
221 main.exit()
222
pingping-linea32cf82015-10-08 22:37:37 -0700223
224 def CASE102( self, main ):
225 '''
226 This test case is to load the methods from other Python files, and create
227 tunnels from mininet host to onos nodes.
228 '''
229 import time
230 main.case( "Load methods from other Python file and create tunnels" )
231 # load the methods from other file
232 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
233 main.Functions = imp.load_source( wrapperFile1,
234 main.dependencyPath +
235 wrapperFile1 +
236 ".py" )
237 # Create tunnels
238 main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
239 main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
240 main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
241
242 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
243 and the BGP paths in data plane are ready..." )
244 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
245
246 main.log.info( "Wait Quagga to finish delivery all routes to each \
247 other and to sdn-ip, plus finish installing all intents..." )
248 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700249
250 def CASE1( self, main ):
251 '''
252 ping test from 3 bgp peers to BGP speaker
253 '''
254
Jon Hall362aa922016-03-31 09:39:26 -0700255 main.case( "Ping between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800256 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
257 peers=["peer64514", "peer64515", "peer64516"],
258 expectAllSuccess=True )
259 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
260 peers=[peer64514, peer64515, peer64516],
261 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700262
263 def CASE2( self, main ):
264 '''
265 point-to-point intents test for each BGP peer and BGP speaker pair
266 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800267 import time
pingping-linea32cf82015-10-08 22:37:37 -0700268 main.case( "Check point-to-point intents" )
269 main.log.info( "There are %s BGP peers in total "
270 % main.params[ 'config' ][ 'peerNum' ] )
271 main.step( "Check P2P intents number from ONOS CLI" )
272
Jon Hall6e9897d2016-02-29 14:41:32 -0800273 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700274 bgpIntentsActualNum = \
275 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
276 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
Jon Hall6e9897d2016-02-29 14:41:32 -0800277 if bgpIntentsActualNum != bgpIntentsExpectedNum:
278 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700279 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800280 bgpIntentsActualNum = \
281 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
pingping-linea32cf82015-10-08 22:37:37 -0700282 main.log.info( "bgpIntentsExpected num is:" )
283 main.log.info( bgpIntentsExpectedNum )
284 main.log.info( "bgpIntentsActual num is:" )
285 main.log.info( bgpIntentsActualNum )
Jon Hall362aa922016-03-31 09:39:26 -0700286 utilities.assert_equals( expect=bgpIntentsExpectedNum,
287 actual=bgpIntentsActualNum,
288 onpass="PointToPointIntent Intent Num is correct!",
289 onfail="PointToPointIntent Intent Num is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700290
291 def CASE3( self, main ):
292 '''
293 routes and intents check to all BGP peers
294 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800295 import time
pingping-linea32cf82015-10-08 22:37:37 -0700296 main.case( "Check routes and M2S intents to all BGP peers" )
297
Jon Hall362aa922016-03-31 09:39:26 -0700298 main.step( "Check routes installed" )
pingping-linea32cf82015-10-08 22:37:37 -0700299 allRoutesExpected = []
300 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
301 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
302 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
303
Jon Hall6e9897d2016-02-29 14:41:32 -0800304 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700305 allRoutesActual = \
306 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
307 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
308 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800309 if allRoutesStrActual != allRoutesStrExpected:
310 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
311 allRoutesActual = \
312 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
313 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
pingping-linea32cf82015-10-08 22:37:37 -0700314
pingping-linea32cf82015-10-08 22:37:37 -0700315 main.log.info( "Routes expected:" )
316 main.log.info( allRoutesStrExpected )
317 main.log.info( "Routes get from ONOS CLI:" )
318 main.log.info( allRoutesStrActual )
Jon Hall362aa922016-03-31 09:39:26 -0700319 utilities.assert_equals( expect=allRoutesStrExpected,
320 actual=allRoutesStrActual,
321 onpass="Routes are correct!",
322 onfail="Routes are wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700323
324 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800325 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700326 routeIntentsActualNum = \
327 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
328 routeIntentsExpectedNum = 3
Jon Hall6e9897d2016-02-29 14:41:32 -0800329 if routeIntentsActualNum != routeIntentsExpectedNum:
330 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700331 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800332 routeIntentsActualNum = \
333 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-linea32cf82015-10-08 22:37:37 -0700334
335 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
336 main.log.info( routeIntentsExpectedNum )
337 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
338 main.log.info( routeIntentsActualNum )
Jon Hall362aa922016-03-31 09:39:26 -0700339 utilities.assert_equals( expect=routeIntentsExpectedNum,
340 actual=routeIntentsActualNum,
341 onpass="MultiPointToSinglePoint Intent Num is correct!",
342 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700343
344 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800345 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
346 main.FALSE,
347 kwargs={'isPENDING':False},
348 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700349 utilities.assert_equals( expect=main.TRUE,
350 actual=flowCheck,
351 onpass="Flow status is correct!",
352 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700353
354
355 def CASE4( self, main ):
356 '''
357 Ping test in data plane for each route
358 '''
359 main.case( "Ping test for each route, all hosts behind BGP peers" )
360 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800361 hosts=["host64514", "host64515", "host64516"],
362 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700363
364
365 def CASE5( self, main ):
366 '''
367 Cut links to peers one by one, check routes/intents
368 '''
369 import time
370 main.case( "Bring down links and check routes/intents" )
371 main.step( "Bring down the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800372 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
373 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700374 utilities.assert_equals( expect=main.TRUE,
375 actual=linkResult1,
376 onpass="Bring down link succeeded!",
377 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700378
379 if linkResult1 == main.TRUE:
380 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
381 main.Functions.checkRouteNum( main, 2 )
382 main.Functions.checkM2SintentNum( main, 2 )
383 else:
384 main.log.error( "Bring down link failed!" )
385 main.cleanup()
386 main.exit()
387
388 main.step( "Bring down the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800389 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
390 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700391 utilities.assert_equals( expect=main.TRUE,
392 actual=linkResult2,
393 onpass="Bring down link succeeded!",
394 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700395 if linkResult2 == main.TRUE:
396 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
397 main.Functions.checkRouteNum( main, 1 )
398 main.Functions.checkM2SintentNum( main, 1 )
399 else:
400 main.log.error( "Bring down link failed!" )
401 main.cleanup()
402 main.exit()
403
404 main.step( "Bring down the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800405 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
406 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700407 utilities.assert_equals( expect=main.TRUE,
408 actual=linkResult3,
409 onpass="Bring down link succeeded!",
410 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700411 if linkResult3 == main.TRUE:
412 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
413 main.Functions.checkRouteNum( main, 0 )
414 main.Functions.checkM2SintentNum( main, 0 )
415 else:
416 main.log.error( "Bring down link failed!" )
417 main.cleanup()
418 main.exit()
419
420 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800421 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
422 main.FALSE,
423 kwargs={'isPENDING':False},
424 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700425 utilities.assert_equals( expect=main.TRUE,
426 actual=flowCheck,
427 onpass="Flow status is correct!",
428 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700429
430 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800431 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
432 peers=["peer64514", "peer64515", "peer64516"],
433 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700434 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800435 hosts=["host64514", "host64515", "host64516"],
436 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700437
pingping-linea32cf82015-10-08 22:37:37 -0700438 def CASE6( self, main ):
439 '''
440 Recover links to peers one by one, check routes/intents
441 '''
442 import time
443 main.case( "Bring up links and check routes/intents" )
444 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800445 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
446 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700447 utilities.assert_equals( expect=main.TRUE,
448 actual=linkResult1,
449 onpass="Bring up link succeeded!",
450 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700451 if linkResult1 == main.TRUE:
452 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
453 main.Functions.checkRouteNum( main, 1 )
454 main.Functions.checkM2SintentNum( main, 1 )
455 else:
456 main.log.error( "Bring up link failed!" )
457 main.cleanup()
458 main.exit()
459
460 main.step( "Bring up the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800461 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
462 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700463 utilities.assert_equals( expect=main.TRUE,
464 actual=linkResult2,
465 onpass="Bring up link succeeded!",
466 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700467 if linkResult2 == main.TRUE:
468 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
469 main.Functions.checkRouteNum( main, 2 )
470 main.Functions.checkM2SintentNum( main, 2 )
471 else:
472 main.log.error( "Bring up link failed!" )
473 main.cleanup()
474 main.exit()
475
476 main.step( "Bring up the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800477 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
478 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700479 utilities.assert_equals( expect=main.TRUE,
480 actual=linkResult3,
481 onpass="Bring up link succeeded!",
482 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700483 if linkResult3 == main.TRUE:
484 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
485 main.Functions.checkRouteNum( main, 3 )
486 main.Functions.checkM2SintentNum( main, 3 )
487 else:
488 main.log.error( "Bring up link failed!" )
489 main.cleanup()
490 main.exit()
491
492 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800493 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
494 main.FALSE,
495 kwargs={'isPENDING':False},
496 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700497 utilities.assert_equals( expect=main.TRUE,
498 actual=flowCheck,
499 onpass="Flow status is correct!",
500 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700501
502 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800503 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
504 peers=["peer64514", "peer64515", "peer64516"],
505 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700506 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800507 hosts=["host64514", "host64515", "host64516"],
508 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700509
pingping-linea32cf82015-10-08 22:37:37 -0700510 def CASE7( self, main ):
511 '''
512 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
513 '''
514 import time
515 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
516 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800517 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700518 utilities.assert_equals( expect=main.TRUE, actual=result,
519 onpass="Stopping switch succeeded!",
520 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700521
522 if result == main.TRUE:
523 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
524 main.Functions.checkRouteNum( main, 2 )
525 main.Functions.checkM2SintentNum( main, 2 )
526 main.Functions.checkP2PintentNum( main, 12 * 2 )
527 else:
528 main.log.error( "Stopping switch failed!" )
529 main.cleanup()
530 main.exit()
531
532 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800533 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
534 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
535 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700536
537 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
538 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800539 utilities.assert_equals( expect=True, actual=pingResult1,
540 onpass="Ping test result is correct",
541 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700542
543 if pingResult1 == False:
544 main.cleanup()
545 main.exit()
546
547 main.step( "Check ping between BGP peers and speaker1" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800548 result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" )
549 result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" )
550 result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700551
552 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
553 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800554 utilities.assert_equals( expect=True, actual=pingResult2,
555 onpass="Speaker1 ping peers successful",
556 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700557
558 if pingResult2 == False:
559 main.cleanup()
560 main.exit()
561
562 main.step( "Check ping between BGP peers and speaker2" )
563 # TODO
Jon Hall6e9897d2016-02-29 14:41:32 -0800564 result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 )
565 result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 )
566 result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700567
568 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
569 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800570 utilities.assert_equals( expect=True, actual=pingResult2,
571 onpass="Speaker2 ping peers successful",
572 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700573
574 if pingResult3 == False:
575 main.cleanup()
576 main.exit()
577
578 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800579 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
580 main.FALSE,
581 kwargs={'isPENDING':False},
582 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700583 utilities.assert_equals( expect=main.TRUE,
584 actual=flowCheck,
585 onpass="Flow status is correct!",
586 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700587
588 def CASE8( self, main ):
589 '''
590 Bring up the edge switch (sw32) which was shut down in CASE7,
591 check P-2-P and M-2-S intents, ping test
592 '''
593 import time
594 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
595 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800596 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700597 utilities.assert_equals( expect=main.TRUE,
598 actual=result1,
599 onpass="Starting switch succeeded!",
600 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700601
602 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700603 utilities.assert_equals( expect=main.TRUE,
604 actual=result2,
605 onpass="Connect switch to ONOS succeeded!",
606 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700607
608 if result1 and result2:
609 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
610 main.Functions.checkRouteNum( main, 3 )
611 main.Functions.checkM2SintentNum( main, 3 )
612 main.Functions.checkP2PintentNum( main, 18 * 2 )
613 else:
614 main.log.error( "Starting switch failed!" )
615 main.cleanup()
616 main.exit()
617
618 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800619 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
620 main.FALSE,
621 kwargs={'isPENDING':False},
622 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700623 utilities.assert_equals( expect=main.TRUE,
624 actual=flowCheck,
625 onpass="Flow status is correct!",
626 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700627
628 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800629 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
630 peers=["peer64514", "peer64515", "peer64516"],
631 expectAllSuccess=True )
632 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
633 peers=[peer64514, peer64515, peer64516],
634 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700635 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800636 hosts=["host64514", "host64515", "host64516"],
637 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700638
pingping-linea32cf82015-10-08 22:37:37 -0700639 def CASE9( self, main ):
640 '''
641 Bring down a switch in best path, check:
642 route number, P2P intent number, M2S intent number, ping test
643 '''
644 main.case( "Stop sw11 located in best path, \
645 check route number, P2P intent number, M2S intent number, ping test" )
646
647 main.log.info( "Check the flow number correctness before stopping sw11" )
648 main.Functions.checkFlowNum( main, "sw11", 19 )
649 main.Functions.checkFlowNum( main, "sw1", 3 )
650 main.Functions.checkFlowNum( main, "sw7", 3 )
651 main.log.info( main.Mininet.checkFlows( "sw11" ) )
652 main.log.info( main.Mininet.checkFlows( "sw1" ) )
653 main.log.info( main.Mininet.checkFlows( "sw7" ) )
654
655 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800656 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700657 utilities.assert_equals( expect=main.TRUE, actual=result,
658 onpass="Stopping switch succeeded!",
659 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700660 if result:
661 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
662 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
663 main.Functions.checkRouteNum( main, 3 )
664 main.Functions.checkM2SintentNum( main, 3 )
665 main.Functions.checkP2PintentNum( main, 18 * 2 )
666 else:
667 main.log.error( "Stopping switch failed!" )
668 main.cleanup()
669 main.exit()
670
671 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800672 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
673 main.FALSE,
674 kwargs={'isPENDING':False},
675 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700676 utilities.assert_equals( expect=main.TRUE,
677 actual=flowCheck,
678 onpass="Flow status is correct!",
679 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700680 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800681 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
682 peers=["peer64514", "peer64515", "peer64516"],
683 expectAllSuccess=True )
684 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
685 peers=[peer64514, peer64515, peer64516],
686 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700687 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800688 hosts=["host64514", "host64515", "host64516"],
689 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700690
691
692 def CASE10( self, main ):
693 '''
694 Bring up the switch which was stopped in CASE9, check:
695 route number, P2P intent number, M2S intent number, ping test
696 '''
697 main.case( "Start sw11 which was stopped in CASE9, \
698 check route number, P2P intent number, M2S intent number, ping test" )
699
700 main.log.info( "Check the flow status before starting sw11" )
701 main.Functions.checkFlowNum( main, "sw1", 17 )
702 main.Functions.checkFlowNum( main, "sw7", 5 )
703 main.log.info( main.Mininet.checkFlows( "sw1" ) )
704 main.log.info( main.Mininet.checkFlows( "sw7" ) )
705
706 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800707 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700708 utilities.assert_equals( expect=main.TRUE, actual=result1,
709 onpass="Starting switch succeeded!",
710 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700711 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700712 utilities.assert_equals( expect=main.TRUE, actual=result2,
713 onpass="Connect switch to ONOS succeeded!",
714 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700715 if result1 and result2:
716 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
717 main.Functions.checkRouteNum( main, 3 )
718 main.Functions.checkM2SintentNum( main, 3 )
719 main.Functions.checkP2PintentNum( main, 18 * 2 )
720
721 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
722 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
723 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
724 else:
725 main.log.error( "Starting switch failed!" )
726 main.cleanup()
727 main.exit()
728
729 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800730 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
731 main.FALSE,
732 kwargs={'isPENDING':False},
733 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700734 utilities.assert_equals( expect=main.TRUE,
735 actual=flowCheck,
736 onpass="Flow status is correct!",
737 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700738 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800739 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
740 peers=["peer64514", "peer64515", "peer64516"],
741 expectAllSuccess=True )
742 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
743 peers=[peer64514, peer64515, peer64516],
744 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700745 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800746 hosts=["host64514", "host64515", "host64516"],
747 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700748
749
750 def CASE11(self, main):
751 import time
752 main.case( "Kill speaker1, check:\
753 route number, P2P intent number, M2S intent number, ping test" )
pingping-lina14c7c82015-10-09 15:44:36 -0700754 main.log.info( "Check network status before killing speaker1" )
pingping-linea32cf82015-10-08 22:37:37 -0700755 main.Functions.checkRouteNum( main, 3 )
756 main.Functions.checkM2SintentNum( main, 3 )
757 main.Functions.checkP2PintentNum( main, 18 * 2 )
758 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800759 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
760 main.FALSE,
761 kwargs={'isPENDING':False},
762 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700763 utilities.assert_equals( expect=main.TRUE,
764 actual=flowCheck,
765 onpass="Flow status is correct!",
766 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700767
Jon Hall6e9897d2016-02-29 14:41:32 -0800768 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
769 peers=["peer64514", "peer64515", "peer64516"],
770 expectAllSuccess=True )
771 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
772 peers=[peer64514, peer64515, peer64516],
773 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700774 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800775 hosts=["host64514", "host64515", "host64516"],
776 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700777
778 main.step( "Kill speaker1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700779 command1 = "ps -e | grep bgp -c"
780 result1 = main.Mininet.node( "root", command1 )
781
782 # The total BGP daemon number in this test environment is 5.
783 if "5" in result1:
784 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
785 else:
786 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
787 main.log.info( result1 )
788
789 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
790 result2 = main.Mininet.node( "root", command2 )
791
792 result3 = main.Mininet.node( "root", command1 )
793
Jon Hall6e9897d2016-02-29 14:41:32 -0800794 utilities.assert_equals( expect=True,
795 actual=( "4" in result3 ),
796 onpass="Kill speaker1 succeeded",
797 onfail="Kill speaker1 failed" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700798 if ( "4" not in result3 ) :
799 main.log.info( result3 )
pingping-linea32cf82015-10-08 22:37:37 -0700800 main.cleanup()
801 main.exit()
802
803 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
804 main.Functions.checkRouteNum( main, 3 )
805 main.Functions.checkM2SintentNum( main, 3 )
806 main.Functions.checkP2PintentNum( main, 18 * 2 )
807
808 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800809 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
810 main.FALSE,
811 kwargs={'isPENDING':False},
812 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700813 utilities.assert_equals( expect=main.TRUE,
814 actual=flowCheck,
815 onpass="Flow status is correct!",
816 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700817
818 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800819 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
820 peers=["peer64514", "peer64515", "peer64516"],
821 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700822 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800823 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
824 peers=[peer64514, peer64515, peer64516],
825 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700826 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800827 hosts=["host64514", "host64515", "host64516"],
828 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700829
830
831 def CASE12( self, main ):
832 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700833 import json
pingping-linea32cf82015-10-08 22:37:37 -0700834 main.case( "Bring down leader ONOS node, check: \
835 route number, P2P intent number, M2S intent number, ping test" )
836 main.step( "Find out ONOS leader node" )
pingping-lina14c7c82015-10-09 15:44:36 -0700837 result = main.ONOScli1.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700838 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700839 leaderIP = ""
840 for entry in jsonResult:
841 if entry["topic"] == "org.onosproject.sdnip":
842 leaderIP = entry["leader"]
843 main.log.info( "leaderIP is: " )
844 main.log.info( leaderIP )
845
846 main.step( "Uninstall ONOS/SDN-IP leader node" )
847 if leaderIP == ONOS1Ip:
848 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
849 elif leaderIP == ONOS2Ip:
850 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
851 else:
852 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
853
Jon Hall6e9897d2016-02-29 14:41:32 -0800854 utilities.assert_equals( expect=main.TRUE,
855 actual=uninstallResult,
856 onpass="Uninstall ONOS leader succeeded",
857 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700858 if uninstallResult != main.TRUE:
859 main.cleanup()
860 main.exit()
861 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700862
pingping-lina14c7c82015-10-09 15:44:36 -0700863 if leaderIP == ONOS1Ip:
Jon Hall6e9897d2016-02-29 14:41:32 -0800864 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
865 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
866 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
pingping-lina14c7c82015-10-09 15:44:36 -0700867
868 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800869 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
870 main.FALSE,
871 kwargs={'isPENDING':False},
872 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700873 utilities.assert_equals( expect=main.TRUE,
874 actual=flowCheck,
875 onpass="Flow status is correct!",
876 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700877 else:
878 main.Functions.checkRouteNum( main, 3 )
879 main.Functions.checkM2SintentNum( main, 3 )
880 main.Functions.checkP2PintentNum( main, 18 * 2 )
881
882 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800883 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
884 main.FALSE,
885 kwargs={'isPENDING':False},
886 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700887 utilities.assert_equals( expect=main.TRUE,
888 actual=flowCheck,
889 onpass="Flow status is correct!",
890 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700891
Jon Hall6e9897d2016-02-29 14:41:32 -0800892 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
893 peers=["peer64514", "peer64515", "peer64516"],
894 expectAllSuccess=True )
895 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
896 peers=[peer64514, peer64515, peer64516],
897 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700898 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800899 hosts=["host64514", "host64515", "host64516"],
900 expectAllSuccess=True )