blob: bb8acb839214c170c06f45dd100119bdbf156d3d [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
Jon Hall6509dbf2016-06-21 17:01:17 -0700111 main.step( "Uninstalling ONOS" )
pingping-linea32cf82015-10-08 22:37:37 -0700112 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'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700311 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800312 allRoutesActual = \
313 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
314 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
pingping-linea32cf82015-10-08 22:37:37 -0700315
pingping-linea32cf82015-10-08 22:37:37 -0700316 main.log.info( "Routes expected:" )
317 main.log.info( allRoutesStrExpected )
318 main.log.info( "Routes get from ONOS CLI:" )
319 main.log.info( allRoutesStrActual )
Jon Hall362aa922016-03-31 09:39:26 -0700320 utilities.assert_equals( expect=allRoutesStrExpected,
321 actual=allRoutesStrActual,
322 onpass="Routes are correct!",
323 onfail="Routes are wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700324
325 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800326 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700327 routeIntentsActualNum = \
328 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
329 routeIntentsExpectedNum = 3
Jon Hall6e9897d2016-02-29 14:41:32 -0800330 if routeIntentsActualNum != routeIntentsExpectedNum:
331 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700332 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800333 routeIntentsActualNum = \
334 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-linea32cf82015-10-08 22:37:37 -0700335
336 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
337 main.log.info( routeIntentsExpectedNum )
338 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
339 main.log.info( routeIntentsActualNum )
Jon Hall362aa922016-03-31 09:39:26 -0700340 utilities.assert_equals( expect=routeIntentsExpectedNum,
341 actual=routeIntentsActualNum,
342 onpass="MultiPointToSinglePoint Intent Num is correct!",
343 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700344
345 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800346 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
347 main.FALSE,
348 kwargs={'isPENDING':False},
349 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700350 utilities.assert_equals( expect=main.TRUE,
351 actual=flowCheck,
352 onpass="Flow status is correct!",
353 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700354
355
356 def CASE4( self, main ):
357 '''
358 Ping test in data plane for each route
359 '''
360 main.case( "Ping test for each route, all hosts behind BGP peers" )
361 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800362 hosts=["host64514", "host64515", "host64516"],
363 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700364
365
366 def CASE5( self, main ):
367 '''
368 Cut links to peers one by one, check routes/intents
369 '''
370 import time
371 main.case( "Bring down links and check routes/intents" )
372 main.step( "Bring down the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800373 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
374 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700375 utilities.assert_equals( expect=main.TRUE,
376 actual=linkResult1,
377 onpass="Bring down link succeeded!",
378 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700379
380 if linkResult1 == main.TRUE:
381 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
382 main.Functions.checkRouteNum( main, 2 )
383 main.Functions.checkM2SintentNum( main, 2 )
384 else:
385 main.log.error( "Bring down link failed!" )
386 main.cleanup()
387 main.exit()
388
389 main.step( "Bring down the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800390 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
391 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700392 utilities.assert_equals( expect=main.TRUE,
393 actual=linkResult2,
394 onpass="Bring down link succeeded!",
395 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700396 if linkResult2 == main.TRUE:
397 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
398 main.Functions.checkRouteNum( main, 1 )
399 main.Functions.checkM2SintentNum( main, 1 )
400 else:
401 main.log.error( "Bring down link failed!" )
402 main.cleanup()
403 main.exit()
404
405 main.step( "Bring down the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800406 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
407 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700408 utilities.assert_equals( expect=main.TRUE,
409 actual=linkResult3,
410 onpass="Bring down link succeeded!",
411 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700412 if linkResult3 == main.TRUE:
413 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
414 main.Functions.checkRouteNum( main, 0 )
415 main.Functions.checkM2SintentNum( main, 0 )
416 else:
417 main.log.error( "Bring down link failed!" )
418 main.cleanup()
419 main.exit()
420
421 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800422 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
423 main.FALSE,
424 kwargs={'isPENDING':False},
425 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700426 utilities.assert_equals( expect=main.TRUE,
427 actual=flowCheck,
428 onpass="Flow status is correct!",
429 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700430
431 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800432 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
433 peers=["peer64514", "peer64515", "peer64516"],
434 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700435 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800436 hosts=["host64514", "host64515", "host64516"],
437 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700438
pingping-linea32cf82015-10-08 22:37:37 -0700439 def CASE6( self, main ):
440 '''
441 Recover links to peers one by one, check routes/intents
442 '''
443 import time
444 main.case( "Bring up links and check routes/intents" )
445 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800446 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
447 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700448 utilities.assert_equals( expect=main.TRUE,
449 actual=linkResult1,
450 onpass="Bring up link succeeded!",
451 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700452 if linkResult1 == main.TRUE:
453 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
454 main.Functions.checkRouteNum( main, 1 )
455 main.Functions.checkM2SintentNum( main, 1 )
456 else:
457 main.log.error( "Bring up link failed!" )
458 main.cleanup()
459 main.exit()
460
461 main.step( "Bring up the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800462 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
463 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700464 utilities.assert_equals( expect=main.TRUE,
465 actual=linkResult2,
466 onpass="Bring up link succeeded!",
467 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700468 if linkResult2 == main.TRUE:
469 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
470 main.Functions.checkRouteNum( main, 2 )
471 main.Functions.checkM2SintentNum( main, 2 )
472 else:
473 main.log.error( "Bring up link failed!" )
474 main.cleanup()
475 main.exit()
476
477 main.step( "Bring up the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800478 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
479 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700480 utilities.assert_equals( expect=main.TRUE,
481 actual=linkResult3,
482 onpass="Bring up link succeeded!",
483 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700484 if linkResult3 == main.TRUE:
485 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
486 main.Functions.checkRouteNum( main, 3 )
487 main.Functions.checkM2SintentNum( main, 3 )
488 else:
489 main.log.error( "Bring up link failed!" )
490 main.cleanup()
491 main.exit()
492
493 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800494 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
495 main.FALSE,
496 kwargs={'isPENDING':False},
497 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700498 utilities.assert_equals( expect=main.TRUE,
499 actual=flowCheck,
500 onpass="Flow status is correct!",
501 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700502
503 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800504 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
505 peers=["peer64514", "peer64515", "peer64516"],
506 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700507 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800508 hosts=["host64514", "host64515", "host64516"],
509 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700510
pingping-linea32cf82015-10-08 22:37:37 -0700511 def CASE7( self, main ):
512 '''
513 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
514 '''
515 import time
516 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
517 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800518 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700519 utilities.assert_equals( expect=main.TRUE, actual=result,
520 onpass="Stopping switch succeeded!",
521 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700522
523 if result == main.TRUE:
524 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
525 main.Functions.checkRouteNum( main, 2 )
526 main.Functions.checkM2SintentNum( main, 2 )
527 main.Functions.checkP2PintentNum( main, 12 * 2 )
528 else:
529 main.log.error( "Stopping switch failed!" )
530 main.cleanup()
531 main.exit()
532
533 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800534 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
535 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
536 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700537
538 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
539 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800540 utilities.assert_equals( expect=True, actual=pingResult1,
541 onpass="Ping test result is correct",
542 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700543
544 if pingResult1 == False:
545 main.cleanup()
546 main.exit()
547
548 main.step( "Check ping between BGP peers and speaker1" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800549 result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" )
550 result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" )
551 result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700552
553 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
554 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800555 utilities.assert_equals( expect=True, actual=pingResult2,
556 onpass="Speaker1 ping peers successful",
557 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700558
559 if pingResult2 == False:
560 main.cleanup()
561 main.exit()
562
563 main.step( "Check ping between BGP peers and speaker2" )
564 # TODO
Jon Hall6e9897d2016-02-29 14:41:32 -0800565 result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 )
566 result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 )
567 result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700568
569 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
570 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800571 utilities.assert_equals( expect=True, actual=pingResult2,
572 onpass="Speaker2 ping peers successful",
573 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700574
575 if pingResult3 == False:
576 main.cleanup()
577 main.exit()
578
579 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800580 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
581 main.FALSE,
582 kwargs={'isPENDING':False},
583 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700584 utilities.assert_equals( expect=main.TRUE,
585 actual=flowCheck,
586 onpass="Flow status is correct!",
587 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700588
589 def CASE8( self, main ):
590 '''
591 Bring up the edge switch (sw32) which was shut down in CASE7,
592 check P-2-P and M-2-S intents, ping test
593 '''
594 import time
595 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
596 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800597 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700598 utilities.assert_equals( expect=main.TRUE,
599 actual=result1,
600 onpass="Starting switch succeeded!",
601 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700602
603 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700604 utilities.assert_equals( expect=main.TRUE,
605 actual=result2,
606 onpass="Connect switch to ONOS succeeded!",
607 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700608
609 if result1 and result2:
610 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
611 main.Functions.checkRouteNum( main, 3 )
612 main.Functions.checkM2SintentNum( main, 3 )
613 main.Functions.checkP2PintentNum( main, 18 * 2 )
614 else:
615 main.log.error( "Starting switch failed!" )
616 main.cleanup()
617 main.exit()
618
619 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800620 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
621 main.FALSE,
622 kwargs={'isPENDING':False},
623 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700624 utilities.assert_equals( expect=main.TRUE,
625 actual=flowCheck,
626 onpass="Flow status is correct!",
627 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700628
629 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800630 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
631 peers=["peer64514", "peer64515", "peer64516"],
632 expectAllSuccess=True )
633 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
634 peers=[peer64514, peer64515, peer64516],
635 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700636 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800637 hosts=["host64514", "host64515", "host64516"],
638 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700639
pingping-linea32cf82015-10-08 22:37:37 -0700640 def CASE9( self, main ):
641 '''
642 Bring down a switch in best path, check:
643 route number, P2P intent number, M2S intent number, ping test
644 '''
645 main.case( "Stop sw11 located in best path, \
646 check route number, P2P intent number, M2S intent number, ping test" )
647
648 main.log.info( "Check the flow number correctness before stopping sw11" )
649 main.Functions.checkFlowNum( main, "sw11", 19 )
650 main.Functions.checkFlowNum( main, "sw1", 3 )
651 main.Functions.checkFlowNum( main, "sw7", 3 )
652 main.log.info( main.Mininet.checkFlows( "sw11" ) )
653 main.log.info( main.Mininet.checkFlows( "sw1" ) )
654 main.log.info( main.Mininet.checkFlows( "sw7" ) )
655
656 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800657 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700658 utilities.assert_equals( expect=main.TRUE, actual=result,
659 onpass="Stopping switch succeeded!",
660 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700661 if result:
662 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
663 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
664 main.Functions.checkRouteNum( main, 3 )
665 main.Functions.checkM2SintentNum( main, 3 )
666 main.Functions.checkP2PintentNum( main, 18 * 2 )
667 else:
668 main.log.error( "Stopping switch failed!" )
669 main.cleanup()
670 main.exit()
671
672 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800673 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
674 main.FALSE,
675 kwargs={'isPENDING':False},
676 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700677 utilities.assert_equals( expect=main.TRUE,
678 actual=flowCheck,
679 onpass="Flow status is correct!",
680 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700681 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800682 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
683 peers=["peer64514", "peer64515", "peer64516"],
684 expectAllSuccess=True )
685 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
686 peers=[peer64514, peer64515, peer64516],
687 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700688 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800689 hosts=["host64514", "host64515", "host64516"],
690 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700691
692
693 def CASE10( self, main ):
694 '''
695 Bring up the switch which was stopped in CASE9, check:
696 route number, P2P intent number, M2S intent number, ping test
697 '''
698 main.case( "Start sw11 which was stopped in CASE9, \
699 check route number, P2P intent number, M2S intent number, ping test" )
700
701 main.log.info( "Check the flow status before starting sw11" )
702 main.Functions.checkFlowNum( main, "sw1", 17 )
703 main.Functions.checkFlowNum( main, "sw7", 5 )
704 main.log.info( main.Mininet.checkFlows( "sw1" ) )
705 main.log.info( main.Mininet.checkFlows( "sw7" ) )
706
707 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800708 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700709 utilities.assert_equals( expect=main.TRUE, actual=result1,
710 onpass="Starting switch succeeded!",
711 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700712 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700713 utilities.assert_equals( expect=main.TRUE, actual=result2,
714 onpass="Connect switch to ONOS succeeded!",
715 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700716 if result1 and result2:
717 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
718 main.Functions.checkRouteNum( main, 3 )
719 main.Functions.checkM2SintentNum( main, 3 )
720 main.Functions.checkP2PintentNum( main, 18 * 2 )
721
722 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
723 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
724 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
725 else:
726 main.log.error( "Starting switch failed!" )
727 main.cleanup()
728 main.exit()
729
730 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800731 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
732 main.FALSE,
733 kwargs={'isPENDING':False},
734 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700735 utilities.assert_equals( expect=main.TRUE,
736 actual=flowCheck,
737 onpass="Flow status is correct!",
738 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700739 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800740 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
741 peers=["peer64514", "peer64515", "peer64516"],
742 expectAllSuccess=True )
743 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
744 peers=[peer64514, peer64515, peer64516],
745 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700746 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800747 hosts=["host64514", "host64515", "host64516"],
748 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700749
750
751 def CASE11(self, main):
752 import time
753 main.case( "Kill speaker1, check:\
754 route number, P2P intent number, M2S intent number, ping test" )
pingping-lina14c7c82015-10-09 15:44:36 -0700755 main.log.info( "Check network status before killing speaker1" )
pingping-linea32cf82015-10-08 22:37:37 -0700756 main.Functions.checkRouteNum( main, 3 )
757 main.Functions.checkM2SintentNum( main, 3 )
758 main.Functions.checkP2PintentNum( main, 18 * 2 )
759 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800760 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
761 main.FALSE,
762 kwargs={'isPENDING':False},
763 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700764 utilities.assert_equals( expect=main.TRUE,
765 actual=flowCheck,
766 onpass="Flow status is correct!",
767 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700768
Jon Hall6e9897d2016-02-29 14:41:32 -0800769 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
770 peers=["peer64514", "peer64515", "peer64516"],
771 expectAllSuccess=True )
772 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
773 peers=[peer64514, peer64515, peer64516],
774 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700775 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800776 hosts=["host64514", "host64515", "host64516"],
777 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700778
779 main.step( "Kill speaker1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700780 command1 = "ps -e | grep bgp -c"
781 result1 = main.Mininet.node( "root", command1 )
782
783 # The total BGP daemon number in this test environment is 5.
784 if "5" in result1:
785 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
786 else:
787 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
788 main.log.info( result1 )
789
790 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
791 result2 = main.Mininet.node( "root", command2 )
792
793 result3 = main.Mininet.node( "root", command1 )
794
Jon Hall6e9897d2016-02-29 14:41:32 -0800795 utilities.assert_equals( expect=True,
796 actual=( "4" in result3 ),
797 onpass="Kill speaker1 succeeded",
798 onfail="Kill speaker1 failed" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700799 if ( "4" not in result3 ) :
800 main.log.info( result3 )
pingping-linea32cf82015-10-08 22:37:37 -0700801 main.cleanup()
802 main.exit()
803
804 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
805 main.Functions.checkRouteNum( main, 3 )
806 main.Functions.checkM2SintentNum( main, 3 )
807 main.Functions.checkP2PintentNum( main, 18 * 2 )
808
809 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800810 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
811 main.FALSE,
812 kwargs={'isPENDING':False},
813 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700814 utilities.assert_equals( expect=main.TRUE,
815 actual=flowCheck,
816 onpass="Flow status is correct!",
817 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700818
819 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800820 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
821 peers=["peer64514", "peer64515", "peer64516"],
822 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700823 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800824 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
825 peers=[peer64514, peer64515, peer64516],
826 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700827 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800828 hosts=["host64514", "host64515", "host64516"],
829 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700830
831
832 def CASE12( self, main ):
833 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700834 import json
pingping-linea32cf82015-10-08 22:37:37 -0700835 main.case( "Bring down leader ONOS node, check: \
836 route number, P2P intent number, M2S intent number, ping test" )
837 main.step( "Find out ONOS leader node" )
pingping-lina14c7c82015-10-09 15:44:36 -0700838 result = main.ONOScli1.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700839 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700840 leaderIP = ""
841 for entry in jsonResult:
842 if entry["topic"] == "org.onosproject.sdnip":
843 leaderIP = entry["leader"]
844 main.log.info( "leaderIP is: " )
845 main.log.info( leaderIP )
846
847 main.step( "Uninstall ONOS/SDN-IP leader node" )
848 if leaderIP == ONOS1Ip:
849 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
850 elif leaderIP == ONOS2Ip:
851 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
852 else:
853 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
854
Jon Hall6e9897d2016-02-29 14:41:32 -0800855 utilities.assert_equals( expect=main.TRUE,
856 actual=uninstallResult,
857 onpass="Uninstall ONOS leader succeeded",
858 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700859 if uninstallResult != main.TRUE:
860 main.cleanup()
861 main.exit()
862 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700863
pingping-lina14c7c82015-10-09 15:44:36 -0700864 if leaderIP == ONOS1Ip:
Jon Hall6e9897d2016-02-29 14:41:32 -0800865 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
866 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
867 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
pingping-lina14c7c82015-10-09 15:44:36 -0700868
869 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800870 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
871 main.FALSE,
872 kwargs={'isPENDING':False},
873 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700874 utilities.assert_equals( expect=main.TRUE,
875 actual=flowCheck,
876 onpass="Flow status is correct!",
877 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700878 else:
879 main.Functions.checkRouteNum( main, 3 )
880 main.Functions.checkM2SintentNum( main, 3 )
881 main.Functions.checkP2PintentNum( main, 18 * 2 )
882
883 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800884 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
885 main.FALSE,
886 kwargs={'isPENDING':False},
887 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700888 utilities.assert_equals( expect=main.TRUE,
889 actual=flowCheck,
890 onpass="Flow status is correct!",
891 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700892
Jon Hall6e9897d2016-02-29 14:41:32 -0800893 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
894 peers=["peer64514", "peer64515", "peer64516"],
895 expectAllSuccess=True )
896 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
897 peers=[peer64514, peer64515, peer64516],
898 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700899 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800900 hosts=["host64514", "host64515", "host64516"],
901 expectAllSuccess=True )