blob: 48909f287cd8b67b9a29f6b73731f8970aa46ab5 [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 Hallbd60ea02016-08-23 10:03:59 -0700123 packageResult = main.ONOSbench.buckBuild()
Jon Hall6e9897d2016-02-29 14:41:32 -0800124 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
You Wangf5de25b2017-01-06 15:13:01 -0800143 main.step( "Set up ONOS secure SSH" )
144 secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
145 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS2Ip )
146 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS3Ip )
147 utilities.assert_equals( expect=main.TRUE,
148 actual=secureSshResult,
149 onpass="Set up ONOS secure SSH succeeded",
150 onfail="Set up ONOS secure SSH failed " )
151
pingping-linea32cf82015-10-08 22:37:37 -0700152 main.step( "Checking if ONOS is up yet" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800153 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
154 onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
155 onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout=420 )
pingping-linea32cf82015-10-08 22:37:37 -0700156 onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult
Jon Hall6e9897d2016-02-29 14:41:32 -0800157 utilities.assert_equals( expect=main.TRUE,
158 actual=onosUpResult,
159 onpass="ONOS nodes are up",
160 onfail="ONOS nodes are NOT up" )
pingping-linea32cf82015-10-08 22:37:37 -0700161
162 main.step( "Checking if ONOS CLI is ready" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800163 main.CLIs = []
pingping-lina14c7c82015-10-09 15:44:36 -0700164 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800165 commandlineTimeout=100, onosStartTimeout=600 )
166 main.CLIs.append( main.ONOScli1 )
pingping-lina14c7c82015-10-09 15:44:36 -0700167 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800168 commandlineTimeout=100, onosStartTimeout=600 )
169 main.CLIs.append( main.ONOScli2 )
170 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
171 commandlineTimeout=100, onosStartTimeout=600 )
172 main.CLIs.append( main.ONOScli3 )
173 cliResult = cliResult1 and cliResult2 and cliResult3
174 utilities.assert_equals( expect=main.TRUE,
175 actual=cliResult,
176 onpass="ONOS CLIs are ready",
177 onfail="ONOS CLIs are not ready" )
pingping-linea32cf82015-10-08 22:37:37 -0700178
Jon Hall362aa922016-03-31 09:39:26 -0700179 main.step( "Checking if ONOS CLI is ready for issuing commands" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800180 for i in range( 10 ):
181 ready = True
182 for cli in main.CLIs:
183 output = cli.summary()
184 if not output:
185 ready = False
186 if ready:
187 break
188 time.sleep( 30 )
189 utilities.assert_equals( expect=True, actual=ready,
190 onpass="ONOS summary command succeded",
191 onfail="ONOS summary command failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700192
Jon Hall6e9897d2016-02-29 14:41:32 -0800193 if not ready:
pingping-linea32cf82015-10-08 22:37:37 -0700194 main.log.error( "ONOS startup failed!" )
195 main.cleanup()
196 main.exit()
197
pingping-linea32cf82015-10-08 22:37:37 -0700198 def CASE200( self, main ):
199 main.case( "Activate sdn-ip application" )
200 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800201 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700202
Jon Hall362aa922016-03-31 09:39:26 -0700203 main.step( "Get links in the network" )
pingping-lina14c7c82015-10-09 15:44:36 -0700204 summaryResult = main.ONOScli1.summary()
pingping-linea32cf82015-10-08 22:37:37 -0700205 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall362aa922016-03-31 09:39:26 -0700206 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
pingping-linea32cf82015-10-08 22:37:37 -0700207 if linkNum < 100:
Jon Hall362aa922016-03-31 09:39:26 -0700208 main.log.error( "Link number is wrong! Retrying..." )
Jon Hall6e9897d2016-02-29 14:41:32 -0800209 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700210 summaryResult = main.ONOScli1.summary()
211 linkNum = json.loads( summaryResult )[ "links" ]
212 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
213 utilities.assert_equals( expect=100,
214 actual=linkNum,
215 onpass="ONOS correctly discovered all links",
216 onfail="ONOS Failed to discover all links" )
217 if linkNum < 100:
pingping-linea32cf82015-10-08 22:37:37 -0700218 main.cleanup()
219 main.exit()
220
pingping-linea32cf82015-10-08 22:37:37 -0700221 main.step( "Activate sdn-ip application" )
pingping-lina14c7c82015-10-09 15:44:36 -0700222 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800223 utilities.assert_equals( expect=main.TRUE,
224 actual=activeSDNIPresult,
225 onpass="Activate SDN-IP succeeded",
226 onfail="Activate SDN-IP failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700227 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800228 main.log.info( "Activate SDN-IP failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700229 main.cleanup()
230 main.exit()
231
pingping-linea32cf82015-10-08 22:37:37 -0700232
233 def CASE102( self, main ):
234 '''
235 This test case is to load the methods from other Python files, and create
236 tunnels from mininet host to onos nodes.
237 '''
238 import time
239 main.case( "Load methods from other Python file and create tunnels" )
240 # load the methods from other file
241 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
242 main.Functions = imp.load_source( wrapperFile1,
243 main.dependencyPath +
244 wrapperFile1 +
245 ".py" )
246 # Create tunnels
247 main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
248 main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
249 main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
250
251 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
252 and the BGP paths in data plane are ready..." )
253 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
254
255 main.log.info( "Wait Quagga to finish delivery all routes to each \
256 other and to sdn-ip, plus finish installing all intents..." )
257 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700258
259 def CASE1( self, main ):
260 '''
261 ping test from 3 bgp peers to BGP speaker
262 '''
263
Jon Hall362aa922016-03-31 09:39:26 -0700264 main.case( "Ping between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800265 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
266 peers=["peer64514", "peer64515", "peer64516"],
267 expectAllSuccess=True )
268 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
269 peers=[peer64514, peer64515, peer64516],
270 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700271
272 def CASE2( self, main ):
273 '''
274 point-to-point intents test for each BGP peer and BGP speaker pair
275 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800276 import time
pingping-linea32cf82015-10-08 22:37:37 -0700277 main.case( "Check point-to-point intents" )
278 main.log.info( "There are %s BGP peers in total "
279 % main.params[ 'config' ][ 'peerNum' ] )
280 main.step( "Check P2P intents number from ONOS CLI" )
281
Jon Hall6e9897d2016-02-29 14:41:32 -0800282 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700283 bgpIntentsActualNum = \
284 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
285 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
Jon Hall6e9897d2016-02-29 14:41:32 -0800286 if bgpIntentsActualNum != bgpIntentsExpectedNum:
287 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700288 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800289 bgpIntentsActualNum = \
290 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
pingping-linea32cf82015-10-08 22:37:37 -0700291 main.log.info( "bgpIntentsExpected num is:" )
292 main.log.info( bgpIntentsExpectedNum )
293 main.log.info( "bgpIntentsActual num is:" )
294 main.log.info( bgpIntentsActualNum )
Jon Hall362aa922016-03-31 09:39:26 -0700295 utilities.assert_equals( expect=bgpIntentsExpectedNum,
296 actual=bgpIntentsActualNum,
297 onpass="PointToPointIntent Intent Num is correct!",
298 onfail="PointToPointIntent Intent Num is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700299
300 def CASE3( self, main ):
301 '''
302 routes and intents check to all BGP peers
303 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800304 import time
pingping-linea32cf82015-10-08 22:37:37 -0700305 main.case( "Check routes and M2S intents to all BGP peers" )
306
Jon Hall362aa922016-03-31 09:39:26 -0700307 main.step( "Check routes installed" )
pingping-linea32cf82015-10-08 22:37:37 -0700308 allRoutesExpected = []
309 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
310 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
311 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
312
Jon Hall6e9897d2016-02-29 14:41:32 -0800313 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700314 allRoutesActual = \
315 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
316 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
317 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800318 if allRoutesStrActual != allRoutesStrExpected:
319 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700320 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800321 allRoutesActual = \
322 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
323 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
pingping-linea32cf82015-10-08 22:37:37 -0700324
pingping-linea32cf82015-10-08 22:37:37 -0700325 main.log.info( "Routes expected:" )
326 main.log.info( allRoutesStrExpected )
327 main.log.info( "Routes get from ONOS CLI:" )
328 main.log.info( allRoutesStrActual )
Jon Hall362aa922016-03-31 09:39:26 -0700329 utilities.assert_equals( expect=allRoutesStrExpected,
330 actual=allRoutesStrActual,
331 onpass="Routes are correct!",
332 onfail="Routes are wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700333
334 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800335 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700336 routeIntentsActualNum = \
337 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
338 routeIntentsExpectedNum = 3
Jon Hall6e9897d2016-02-29 14:41:32 -0800339 if routeIntentsActualNum != routeIntentsExpectedNum:
340 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700341 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800342 routeIntentsActualNum = \
343 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-linea32cf82015-10-08 22:37:37 -0700344
345 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
346 main.log.info( routeIntentsExpectedNum )
347 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
348 main.log.info( routeIntentsActualNum )
Jon Hall362aa922016-03-31 09:39:26 -0700349 utilities.assert_equals( expect=routeIntentsExpectedNum,
350 actual=routeIntentsActualNum,
351 onpass="MultiPointToSinglePoint Intent Num is correct!",
352 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700353
354 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800355 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
356 main.FALSE,
357 kwargs={'isPENDING':False},
358 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700359 utilities.assert_equals( expect=main.TRUE,
360 actual=flowCheck,
361 onpass="Flow status is correct!",
362 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700363
364
365 def CASE4( self, main ):
366 '''
367 Ping test in data plane for each route
368 '''
369 main.case( "Ping test for each route, all hosts behind BGP peers" )
370 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800371 hosts=["host64514", "host64515", "host64516"],
372 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700373
374
375 def CASE5( self, main ):
376 '''
377 Cut links to peers one by one, check routes/intents
378 '''
379 import time
380 main.case( "Bring down links and check routes/intents" )
381 main.step( "Bring down the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800382 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
383 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700384 utilities.assert_equals( expect=main.TRUE,
385 actual=linkResult1,
386 onpass="Bring down link succeeded!",
387 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700388
389 if linkResult1 == main.TRUE:
390 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
391 main.Functions.checkRouteNum( main, 2 )
392 main.Functions.checkM2SintentNum( main, 2 )
393 else:
394 main.log.error( "Bring down link failed!" )
395 main.cleanup()
396 main.exit()
397
398 main.step( "Bring down the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800399 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
400 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700401 utilities.assert_equals( expect=main.TRUE,
402 actual=linkResult2,
403 onpass="Bring down link succeeded!",
404 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700405 if linkResult2 == main.TRUE:
406 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
407 main.Functions.checkRouteNum( main, 1 )
408 main.Functions.checkM2SintentNum( main, 1 )
409 else:
410 main.log.error( "Bring down link failed!" )
411 main.cleanup()
412 main.exit()
413
414 main.step( "Bring down the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800415 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
416 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700417 utilities.assert_equals( expect=main.TRUE,
418 actual=linkResult3,
419 onpass="Bring down link succeeded!",
420 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700421 if linkResult3 == main.TRUE:
422 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
423 main.Functions.checkRouteNum( main, 0 )
424 main.Functions.checkM2SintentNum( main, 0 )
425 else:
426 main.log.error( "Bring down link failed!" )
427 main.cleanup()
428 main.exit()
429
430 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800431 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
432 main.FALSE,
433 kwargs={'isPENDING':False},
434 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700435 utilities.assert_equals( expect=main.TRUE,
436 actual=flowCheck,
437 onpass="Flow status is correct!",
438 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700439
440 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800441 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
442 peers=["peer64514", "peer64515", "peer64516"],
443 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700444 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800445 hosts=["host64514", "host64515", "host64516"],
446 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700447
pingping-linea32cf82015-10-08 22:37:37 -0700448 def CASE6( self, main ):
449 '''
450 Recover links to peers one by one, check routes/intents
451 '''
452 import time
453 main.case( "Bring up links and check routes/intents" )
454 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800455 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
456 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700457 utilities.assert_equals( expect=main.TRUE,
458 actual=linkResult1,
459 onpass="Bring up link succeeded!",
460 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700461 if linkResult1 == main.TRUE:
462 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
463 main.Functions.checkRouteNum( main, 1 )
464 main.Functions.checkM2SintentNum( main, 1 )
465 else:
466 main.log.error( "Bring up link failed!" )
467 main.cleanup()
468 main.exit()
469
470 main.step( "Bring up the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800471 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
472 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700473 utilities.assert_equals( expect=main.TRUE,
474 actual=linkResult2,
475 onpass="Bring up link succeeded!",
476 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700477 if linkResult2 == main.TRUE:
478 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
479 main.Functions.checkRouteNum( main, 2 )
480 main.Functions.checkM2SintentNum( main, 2 )
481 else:
482 main.log.error( "Bring up link failed!" )
483 main.cleanup()
484 main.exit()
485
486 main.step( "Bring up the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800487 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
488 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700489 utilities.assert_equals( expect=main.TRUE,
490 actual=linkResult3,
491 onpass="Bring up link succeeded!",
492 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700493 if linkResult3 == main.TRUE:
494 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
495 main.Functions.checkRouteNum( main, 3 )
496 main.Functions.checkM2SintentNum( main, 3 )
497 else:
498 main.log.error( "Bring up link failed!" )
499 main.cleanup()
500 main.exit()
501
502 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800503 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
504 main.FALSE,
505 kwargs={'isPENDING':False},
506 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700507 utilities.assert_equals( expect=main.TRUE,
508 actual=flowCheck,
509 onpass="Flow status is correct!",
510 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700511
512 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800513 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
514 peers=["peer64514", "peer64515", "peer64516"],
515 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700516 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800517 hosts=["host64514", "host64515", "host64516"],
518 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700519
pingping-linea32cf82015-10-08 22:37:37 -0700520 def CASE7( self, main ):
521 '''
522 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
523 '''
524 import time
525 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
526 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800527 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700528 utilities.assert_equals( expect=main.TRUE, actual=result,
529 onpass="Stopping switch succeeded!",
530 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700531
532 if result == main.TRUE:
533 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
534 main.Functions.checkRouteNum( main, 2 )
535 main.Functions.checkM2SintentNum( main, 2 )
536 main.Functions.checkP2PintentNum( main, 12 * 2 )
537 else:
538 main.log.error( "Stopping switch failed!" )
539 main.cleanup()
540 main.exit()
541
542 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800543 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
544 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
545 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700546
547 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
548 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800549 utilities.assert_equals( expect=True, actual=pingResult1,
550 onpass="Ping test result is correct",
551 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700552
553 if pingResult1 == False:
554 main.cleanup()
555 main.exit()
556
557 main.step( "Check ping between BGP peers and speaker1" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800558 result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" )
559 result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" )
560 result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700561
562 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
563 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800564 utilities.assert_equals( expect=True, actual=pingResult2,
565 onpass="Speaker1 ping peers successful",
566 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700567
568 if pingResult2 == False:
569 main.cleanup()
570 main.exit()
571
572 main.step( "Check ping between BGP peers and speaker2" )
573 # TODO
Jon Hall6e9897d2016-02-29 14:41:32 -0800574 result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 )
575 result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 )
576 result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700577
578 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
579 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800580 utilities.assert_equals( expect=True, actual=pingResult2,
581 onpass="Speaker2 ping peers successful",
582 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700583
584 if pingResult3 == False:
585 main.cleanup()
586 main.exit()
587
588 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800589 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
590 main.FALSE,
591 kwargs={'isPENDING':False},
592 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700593 utilities.assert_equals( expect=main.TRUE,
594 actual=flowCheck,
595 onpass="Flow status is correct!",
596 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700597
598 def CASE8( self, main ):
599 '''
600 Bring up the edge switch (sw32) which was shut down in CASE7,
601 check P-2-P and M-2-S intents, ping test
602 '''
603 import time
604 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
605 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800606 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700607 utilities.assert_equals( expect=main.TRUE,
608 actual=result1,
609 onpass="Starting switch succeeded!",
610 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700611
612 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700613 utilities.assert_equals( expect=main.TRUE,
614 actual=result2,
615 onpass="Connect switch to ONOS succeeded!",
616 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700617
618 if result1 and result2:
619 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
620 main.Functions.checkRouteNum( main, 3 )
621 main.Functions.checkM2SintentNum( main, 3 )
622 main.Functions.checkP2PintentNum( main, 18 * 2 )
623 else:
624 main.log.error( "Starting switch failed!" )
625 main.cleanup()
626 main.exit()
627
628 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800629 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
630 main.FALSE,
631 kwargs={'isPENDING':False},
632 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700633 utilities.assert_equals( expect=main.TRUE,
634 actual=flowCheck,
635 onpass="Flow status is correct!",
636 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700637
638 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800639 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
640 peers=["peer64514", "peer64515", "peer64516"],
641 expectAllSuccess=True )
642 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
643 peers=[peer64514, peer64515, peer64516],
644 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700645 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800646 hosts=["host64514", "host64515", "host64516"],
647 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700648
pingping-linea32cf82015-10-08 22:37:37 -0700649 def CASE9( self, main ):
650 '''
651 Bring down a switch in best path, check:
652 route number, P2P intent number, M2S intent number, ping test
653 '''
654 main.case( "Stop sw11 located in best path, \
655 check route number, P2P intent number, M2S intent number, ping test" )
656
657 main.log.info( "Check the flow number correctness before stopping sw11" )
658 main.Functions.checkFlowNum( main, "sw11", 19 )
659 main.Functions.checkFlowNum( main, "sw1", 3 )
660 main.Functions.checkFlowNum( main, "sw7", 3 )
661 main.log.info( main.Mininet.checkFlows( "sw11" ) )
662 main.log.info( main.Mininet.checkFlows( "sw1" ) )
663 main.log.info( main.Mininet.checkFlows( "sw7" ) )
664
665 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800666 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700667 utilities.assert_equals( expect=main.TRUE, actual=result,
668 onpass="Stopping switch succeeded!",
669 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700670 if result:
671 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
672 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
673 main.Functions.checkRouteNum( main, 3 )
674 main.Functions.checkM2SintentNum( main, 3 )
675 main.Functions.checkP2PintentNum( main, 18 * 2 )
676 else:
677 main.log.error( "Stopping switch failed!" )
678 main.cleanup()
679 main.exit()
680
681 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800682 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
683 main.FALSE,
684 kwargs={'isPENDING':False},
685 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700686 utilities.assert_equals( expect=main.TRUE,
687 actual=flowCheck,
688 onpass="Flow status is correct!",
689 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700690 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800691 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
692 peers=["peer64514", "peer64515", "peer64516"],
693 expectAllSuccess=True )
694 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
695 peers=[peer64514, peer64515, peer64516],
696 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700697 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800698 hosts=["host64514", "host64515", "host64516"],
699 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700700
701
702 def CASE10( self, main ):
703 '''
704 Bring up the switch which was stopped in CASE9, check:
705 route number, P2P intent number, M2S intent number, ping test
706 '''
707 main.case( "Start sw11 which was stopped in CASE9, \
708 check route number, P2P intent number, M2S intent number, ping test" )
709
710 main.log.info( "Check the flow status before starting sw11" )
711 main.Functions.checkFlowNum( main, "sw1", 17 )
712 main.Functions.checkFlowNum( main, "sw7", 5 )
713 main.log.info( main.Mininet.checkFlows( "sw1" ) )
714 main.log.info( main.Mininet.checkFlows( "sw7" ) )
715
716 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800717 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700718 utilities.assert_equals( expect=main.TRUE, actual=result1,
719 onpass="Starting switch succeeded!",
720 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700721 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700722 utilities.assert_equals( expect=main.TRUE, actual=result2,
723 onpass="Connect switch to ONOS succeeded!",
724 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700725 if result1 and result2:
726 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
727 main.Functions.checkRouteNum( main, 3 )
728 main.Functions.checkM2SintentNum( main, 3 )
729 main.Functions.checkP2PintentNum( main, 18 * 2 )
730
731 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
732 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
733 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
734 else:
735 main.log.error( "Starting switch failed!" )
736 main.cleanup()
737 main.exit()
738
739 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800740 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
741 main.FALSE,
742 kwargs={'isPENDING':False},
743 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700744 utilities.assert_equals( expect=main.TRUE,
745 actual=flowCheck,
746 onpass="Flow status is correct!",
747 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700748 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800749 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
750 peers=["peer64514", "peer64515", "peer64516"],
751 expectAllSuccess=True )
752 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
753 peers=[peer64514, peer64515, peer64516],
754 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700755 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800756 hosts=["host64514", "host64515", "host64516"],
757 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700758
759
760 def CASE11(self, main):
761 import time
762 main.case( "Kill speaker1, check:\
763 route number, P2P intent number, M2S intent number, ping test" )
pingping-lina14c7c82015-10-09 15:44:36 -0700764 main.log.info( "Check network status before killing speaker1" )
pingping-linea32cf82015-10-08 22:37:37 -0700765 main.Functions.checkRouteNum( main, 3 )
766 main.Functions.checkM2SintentNum( main, 3 )
767 main.Functions.checkP2PintentNum( main, 18 * 2 )
768 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800769 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
770 main.FALSE,
771 kwargs={'isPENDING':False},
772 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700773 utilities.assert_equals( expect=main.TRUE,
774 actual=flowCheck,
775 onpass="Flow status is correct!",
776 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700777
Jon Hall6e9897d2016-02-29 14:41:32 -0800778 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
779 peers=["peer64514", "peer64515", "peer64516"],
780 expectAllSuccess=True )
781 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
782 peers=[peer64514, peer64515, peer64516],
783 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700784 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800785 hosts=["host64514", "host64515", "host64516"],
786 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700787
788 main.step( "Kill speaker1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700789 command1 = "ps -e | grep bgp -c"
790 result1 = main.Mininet.node( "root", command1 )
791
792 # The total BGP daemon number in this test environment is 5.
793 if "5" in result1:
794 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
795 else:
796 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
797 main.log.info( result1 )
798
799 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
800 result2 = main.Mininet.node( "root", command2 )
801
802 result3 = main.Mininet.node( "root", command1 )
803
Jon Hall6e9897d2016-02-29 14:41:32 -0800804 utilities.assert_equals( expect=True,
805 actual=( "4" in result3 ),
806 onpass="Kill speaker1 succeeded",
807 onfail="Kill speaker1 failed" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700808 if ( "4" not in result3 ) :
809 main.log.info( result3 )
pingping-linea32cf82015-10-08 22:37:37 -0700810 main.cleanup()
811 main.exit()
812
813 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
814 main.Functions.checkRouteNum( main, 3 )
815 main.Functions.checkM2SintentNum( main, 3 )
816 main.Functions.checkP2PintentNum( main, 18 * 2 )
817
818 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800819 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
820 main.FALSE,
821 kwargs={'isPENDING':False},
822 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700823 utilities.assert_equals( expect=main.TRUE,
824 actual=flowCheck,
825 onpass="Flow status is correct!",
826 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700827
828 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800829 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
830 peers=["peer64514", "peer64515", "peer64516"],
831 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700832 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800833 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
834 peers=[peer64514, peer64515, peer64516],
835 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700836 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800837 hosts=["host64514", "host64515", "host64516"],
838 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700839
840
841 def CASE12( self, main ):
842 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700843 import json
pingping-linea32cf82015-10-08 22:37:37 -0700844 main.case( "Bring down leader ONOS node, check: \
845 route number, P2P intent number, M2S intent number, ping test" )
846 main.step( "Find out ONOS leader node" )
pingping-lina14c7c82015-10-09 15:44:36 -0700847 result = main.ONOScli1.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700848 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700849 leaderIP = ""
850 for entry in jsonResult:
851 if entry["topic"] == "org.onosproject.sdnip":
852 leaderIP = entry["leader"]
853 main.log.info( "leaderIP is: " )
854 main.log.info( leaderIP )
855
856 main.step( "Uninstall ONOS/SDN-IP leader node" )
857 if leaderIP == ONOS1Ip:
858 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
859 elif leaderIP == ONOS2Ip:
860 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
861 else:
862 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
863
Jon Hall6e9897d2016-02-29 14:41:32 -0800864 utilities.assert_equals( expect=main.TRUE,
865 actual=uninstallResult,
866 onpass="Uninstall ONOS leader succeeded",
867 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700868 if uninstallResult != main.TRUE:
869 main.cleanup()
870 main.exit()
871 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700872
pingping-lina14c7c82015-10-09 15:44:36 -0700873 if leaderIP == ONOS1Ip:
Jon Hall6e9897d2016-02-29 14:41:32 -0800874 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
875 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
876 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
pingping-lina14c7c82015-10-09 15:44:36 -0700877
878 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800879 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
880 main.FALSE,
881 kwargs={'isPENDING':False},
882 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700883 utilities.assert_equals( expect=main.TRUE,
884 actual=flowCheck,
885 onpass="Flow status is correct!",
886 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700887 else:
888 main.Functions.checkRouteNum( main, 3 )
889 main.Functions.checkM2SintentNum( main, 3 )
890 main.Functions.checkP2PintentNum( main, 18 * 2 )
891
892 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800893 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
894 main.FALSE,
895 kwargs={'isPENDING':False},
896 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700897 utilities.assert_equals( expect=main.TRUE,
898 actual=flowCheck,
899 onpass="Flow status is correct!",
900 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700901
Jon Hall6e9897d2016-02-29 14:41:32 -0800902 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
903 peers=["peer64514", "peer64515", "peer64516"],
904 expectAllSuccess=True )
905 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
906 peers=[peer64514, peer64515, peer64516],
907 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700908 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800909 hosts=["host64514", "host64515", "host64516"],
910 expectAllSuccess=True )