blob: 68ed7598b0ebaee47b35d27513c440e2eed3420c [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
alison62006dd2016-12-15 16:21:28 -080072 global p64514
73 global p64515
74 global p64516
75 p64514 = main.params['config']['p64514']
76 p64515 = main.params['config']['p64515']
77 p64516 = main.params['config']['p64516']
pingping-linea32cf82015-10-08 22:37:37 -070078
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" )
alison62006dd2016-12-15 16:21:28 -0800265 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
266 peers=[ "p64514", "p64515", "p64516" ],
267 expectAllSuccess=True )
268
269 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
270 peers=[ p64514, p64515, p64516 ],
271 expectAllSuccess=True )
272
273 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ],
274 peers=[ "p64519", "p64520" ],
275 expectAllSuccess=True )
276
277 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk4" ],
278 peers=[ "p64517", "p64518" ],
279 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700280
281 def CASE2( self, main ):
282 '''
283 point-to-point intents test for each BGP peer and BGP speaker pair
284 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800285 import time
pingping-linea32cf82015-10-08 22:37:37 -0700286 main.case( "Check point-to-point intents" )
287 main.log.info( "There are %s BGP peers in total "
288 % main.params[ 'config' ][ 'peerNum' ] )
289 main.step( "Check P2P intents number from ONOS CLI" )
290
Jon Hall6e9897d2016-02-29 14:41:32 -0800291 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700292 bgpIntentsActualNum = \
293 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
294 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
Jon Hall6e9897d2016-02-29 14:41:32 -0800295 if bgpIntentsActualNum != bgpIntentsExpectedNum:
296 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700297 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800298 bgpIntentsActualNum = \
299 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
pingping-linea32cf82015-10-08 22:37:37 -0700300 main.log.info( "bgpIntentsExpected num is:" )
301 main.log.info( bgpIntentsExpectedNum )
302 main.log.info( "bgpIntentsActual num is:" )
303 main.log.info( bgpIntentsActualNum )
Jon Hall362aa922016-03-31 09:39:26 -0700304 utilities.assert_equals( expect=bgpIntentsExpectedNum,
305 actual=bgpIntentsActualNum,
306 onpass="PointToPointIntent Intent Num is correct!",
307 onfail="PointToPointIntent Intent Num is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700308
309 def CASE3( self, main ):
310 '''
311 routes and intents check to all BGP peers
312 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800313 import time
pingping-linea32cf82015-10-08 22:37:37 -0700314 main.case( "Check routes and M2S intents to all BGP peers" )
315
Jon Hall362aa922016-03-31 09:39:26 -0700316 main.step( "Check routes installed" )
pingping-linea32cf82015-10-08 22:37:37 -0700317 allRoutesExpected = []
318 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
319 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
320 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
alison62006dd2016-12-15 16:21:28 -0800321 allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" )
322 allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" )
323 allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
324 allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
pingping-linea32cf82015-10-08 22:37:37 -0700325
Jon Hall6e9897d2016-02-29 14:41:32 -0800326 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700327 allRoutesActual = \
328 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
329 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
330 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800331 if allRoutesStrActual != allRoutesStrExpected:
332 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700333 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800334 allRoutesActual = \
335 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
336 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
pingping-linea32cf82015-10-08 22:37:37 -0700337
pingping-linea32cf82015-10-08 22:37:37 -0700338 main.log.info( "Routes expected:" )
339 main.log.info( allRoutesStrExpected )
340 main.log.info( "Routes get from ONOS CLI:" )
341 main.log.info( allRoutesStrActual )
Jon Hall362aa922016-03-31 09:39:26 -0700342 utilities.assert_equals( expect=allRoutesStrExpected,
343 actual=allRoutesStrActual,
344 onpass="Routes are correct!",
345 onfail="Routes are wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700346
347 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800348 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-linea32cf82015-10-08 22:37:37 -0700349 routeIntentsActualNum = \
350 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
alison62006dd2016-12-15 16:21:28 -0800351 routeIntentsExpectedNum = 7
Jon Hall6e9897d2016-02-29 14:41:32 -0800352 if routeIntentsActualNum != routeIntentsExpectedNum:
353 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hall362aa922016-03-31 09:39:26 -0700354 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800355 routeIntentsActualNum = \
356 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-linea32cf82015-10-08 22:37:37 -0700357
358 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
359 main.log.info( routeIntentsExpectedNum )
360 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
361 main.log.info( routeIntentsActualNum )
Jon Hall362aa922016-03-31 09:39:26 -0700362 utilities.assert_equals( expect=routeIntentsExpectedNum,
363 actual=routeIntentsActualNum,
364 onpass="MultiPointToSinglePoint Intent Num is correct!",
365 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700366
367 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800368 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
369 main.FALSE,
370 kwargs={'isPENDING':False},
371 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700372 utilities.assert_equals( expect=main.TRUE,
373 actual=flowCheck,
374 onpass="Flow status is correct!",
375 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700376
377
378 def CASE4( self, main ):
379 '''
380 Ping test in data plane for each route
381 '''
382 main.case( "Ping test for each route, all hosts behind BGP peers" )
383 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800384 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800385 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800386 main.Functions.pingHostToHost(main,
387 hosts=["h64517", "h64518"],
388 expectAllSuccess=True)
389 main.Functions.pingHostToHost(main,
390 hosts=["h64519", "h64520"],
391 expectAllSuccess=True)
pingping-linea32cf82015-10-08 22:37:37 -0700392
393 def CASE5( self, main ):
394 '''
395 Cut links to peers one by one, check routes/intents
396 '''
397 import time
398 main.case( "Bring down links and check routes/intents" )
alison62006dd2016-12-15 16:21:28 -0800399 main.step( "Bring down the link between sw32 and p64514" )
400 linkResult1 = main.Mininet.link( END1="sw32", END2="p64514",
Jon Hall6e9897d2016-02-29 14:41:32 -0800401 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700402 utilities.assert_equals( expect=main.TRUE,
403 actual=linkResult1,
404 onpass="Bring down link succeeded!",
405 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700406
407 if linkResult1 == main.TRUE:
408 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800409 main.Functions.checkRouteNum( main, 6 )
410 main.Functions.checkM2SintentNum( main, 6 )
pingping-linea32cf82015-10-08 22:37:37 -0700411 else:
412 main.log.error( "Bring down link failed!" )
413 main.cleanup()
414 main.exit()
415
alison62006dd2016-12-15 16:21:28 -0800416 main.step( "Bring down the link between sw8 and p64515" )
417 linkResult2 = main.Mininet.link( END1="sw8", END2="p64515",
Jon Hall6e9897d2016-02-29 14:41:32 -0800418 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700419 utilities.assert_equals( expect=main.TRUE,
420 actual=linkResult2,
421 onpass="Bring down link succeeded!",
422 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700423 if linkResult2 == main.TRUE:
424 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800425 main.Functions.checkRouteNum( main, 5 )
426 main.Functions.checkM2SintentNum( main, 5 )
pingping-linea32cf82015-10-08 22:37:37 -0700427 else:
428 main.log.error( "Bring down link failed!" )
429 main.cleanup()
430 main.exit()
431
alison62006dd2016-12-15 16:21:28 -0800432 main.step( "Bring down the link between sw28 and p64516" )
433 linkResult3 = main.Mininet.link( END1="sw28", END2="p64516",
Jon Hall6e9897d2016-02-29 14:41:32 -0800434 OPTION="down" )
Jon Hall362aa922016-03-31 09:39:26 -0700435 utilities.assert_equals( expect=main.TRUE,
436 actual=linkResult3,
437 onpass="Bring down link succeeded!",
438 onfail="Bring down link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700439 if linkResult3 == main.TRUE:
440 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800441 main.Functions.checkRouteNum( main, 4 )
442 main.Functions.checkM2SintentNum( main, 4 )
pingping-linea32cf82015-10-08 22:37:37 -0700443 else:
444 main.log.error( "Bring down link failed!" )
445 main.cleanup()
446 main.exit()
447
448 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800449 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
450 main.FALSE,
451 kwargs={'isPENDING':False},
452 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700453 utilities.assert_equals( expect=main.TRUE,
454 actual=flowCheck,
455 onpass="Flow status is correct!",
456 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700457
458 # Ping test
alison62006dd2016-12-15 16:21:28 -0800459 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
460 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800461 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700462 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800463 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800464 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700465
pingping-linea32cf82015-10-08 22:37:37 -0700466 def CASE6( self, main ):
467 '''
468 Recover links to peers one by one, check routes/intents
469 '''
470 import time
471 main.case( "Bring up links and check routes/intents" )
alison62006dd2016-12-15 16:21:28 -0800472 main.step( "Bring up the link between sw32 and p64514" )
473 linkResult1 = main.Mininet.link( END1="sw32", END2="p64514",
Jon Hall6e9897d2016-02-29 14:41:32 -0800474 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700475 utilities.assert_equals( expect=main.TRUE,
476 actual=linkResult1,
477 onpass="Bring up link succeeded!",
478 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700479 if linkResult1 == main.TRUE:
480 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800481 main.Functions.checkRouteNum( main, 5 )
482 main.Functions.checkM2SintentNum( main, 5 )
pingping-linea32cf82015-10-08 22:37:37 -0700483 else:
484 main.log.error( "Bring up link failed!" )
485 main.cleanup()
486 main.exit()
487
alison62006dd2016-12-15 16:21:28 -0800488 main.step( "Bring up the link between sw8 and p64515" )
489 linkResult2 = main.Mininet.link( END1="sw8", END2="p64515",
Jon Hall6e9897d2016-02-29 14:41:32 -0800490 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700491 utilities.assert_equals( expect=main.TRUE,
492 actual=linkResult2,
493 onpass="Bring up link succeeded!",
494 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700495 if linkResult2 == main.TRUE:
496 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800497 main.Functions.checkRouteNum( main, 6 )
498 main.Functions.checkM2SintentNum( main, 6 )
pingping-linea32cf82015-10-08 22:37:37 -0700499 else:
500 main.log.error( "Bring up link failed!" )
501 main.cleanup()
502 main.exit()
503
alison62006dd2016-12-15 16:21:28 -0800504 main.step( "Bring up the link between sw28 and p64516" )
505 linkResult3 = main.Mininet.link( END1="sw28", END2="p64516",
Jon Hall6e9897d2016-02-29 14:41:32 -0800506 OPTION="up" )
Jon Hall362aa922016-03-31 09:39:26 -0700507 utilities.assert_equals( expect=main.TRUE,
508 actual=linkResult3,
509 onpass="Bring up link succeeded!",
510 onfail="Bring up link failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700511 if linkResult3 == main.TRUE:
512 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800513 main.Functions.checkRouteNum( main, 7 )
514 main.Functions.checkM2SintentNum( main, 7 )
pingping-linea32cf82015-10-08 22:37:37 -0700515 else:
516 main.log.error( "Bring up link failed!" )
517 main.cleanup()
518 main.exit()
519
520 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800521 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
522 main.FALSE,
523 kwargs={'isPENDING':False},
524 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700525 utilities.assert_equals( expect=main.TRUE,
526 actual=flowCheck,
527 onpass="Flow status is correct!",
528 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700529
530 # Ping test
alison62006dd2016-12-15 16:21:28 -0800531 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
532 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800533 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700534 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800535 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800536 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700537
pingping-linea32cf82015-10-08 22:37:37 -0700538 def CASE7( self, main ):
539 '''
540 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
541 '''
542 import time
543 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
544 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800545 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700546 utilities.assert_equals( expect=main.TRUE, actual=result,
547 onpass="Stopping switch succeeded!",
548 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700549
550 if result == main.TRUE:
551 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800552 main.Functions.checkRouteNum( main, 6 )
553 main.Functions.checkM2SintentNum( main, 6 )
554 main.Functions.checkP2PintentNum( main, 48 ) #14 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700555 else:
556 main.log.error( "Stopping switch failed!" )
557 main.cleanup()
558 main.exit()
559
560 main.step( "Check ping between hosts behind BGP peers" )
alison62006dd2016-12-15 16:21:28 -0800561 result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
562 result2 = main.Mininet.pingHost( src="h64515", target="h64516" )
563 result3 = main.Mininet.pingHost( src="h64514", target="h64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700564
565 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
566 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800567 utilities.assert_equals( expect=True, actual=pingResult1,
568 onpass="Ping test result is correct",
569 onfail="Ping test result is wrong" )
pingping-linea32cf82015-10-08 22:37:37 -0700570
571 if pingResult1 == False:
572 main.cleanup()
573 main.exit()
574
alison62006dd2016-12-15 16:21:28 -0800575 main.step( "Check ping between BGP peers and spk1" )
576 result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
577 result5 = main.Mininet.pingHost( src="spk1", target="p64515" )
578 result6 = main.Mininet.pingHost( src="spk1", target="p64516" )
pingping-linea32cf82015-10-08 22:37:37 -0700579
580 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
581 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800582 utilities.assert_equals( expect=True, actual=pingResult2,
583 onpass="Speaker1 ping peers successful",
584 onfail="Speaker1 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700585
586 if pingResult2 == False:
587 main.cleanup()
588 main.exit()
589
alison62006dd2016-12-15 16:21:28 -0800590 main.step( "Check ping between BGP peers and spk2" )
pingping-linea32cf82015-10-08 22:37:37 -0700591 # TODO
alison62006dd2016-12-15 16:21:28 -0800592 result7 = main.Mininet.pingHost( src="spk2", target=p64514 )
593 result8 = main.Mininet.pingHost( src="spk2", target=p64515 )
594 result9 = main.Mininet.pingHost( src="spk2", target=p64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700595
596 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
597 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800598 utilities.assert_equals( expect=True, actual=pingResult2,
599 onpass="Speaker2 ping peers successful",
600 onfail="Speaker2 ping peers NOT successful" )
pingping-linea32cf82015-10-08 22:37:37 -0700601
602 if pingResult3 == False:
603 main.cleanup()
604 main.exit()
605
606 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800607 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
608 main.FALSE,
609 kwargs={'isPENDING':False},
610 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700611 utilities.assert_equals( expect=main.TRUE,
612 actual=flowCheck,
613 onpass="Flow status is correct!",
614 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700615
616 def CASE8( self, main ):
617 '''
618 Bring up the edge switch (sw32) which was shut down in CASE7,
619 check P-2-P and M-2-S intents, ping test
620 '''
621 import time
622 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
623 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800624 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700625 utilities.assert_equals( expect=main.TRUE,
626 actual=result1,
627 onpass="Starting switch succeeded!",
628 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700629
630 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700631 utilities.assert_equals( expect=main.TRUE,
632 actual=result2,
633 onpass="Connect switch to ONOS succeeded!",
634 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700635
636 if result1 and result2:
637 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800638 main.Functions.checkRouteNum( main, 7 )
639 main.Functions.checkM2SintentNum( main, 7 )
640 main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18*2
pingping-linea32cf82015-10-08 22:37:37 -0700641 else:
642 main.log.error( "Starting switch failed!" )
643 main.cleanup()
644 main.exit()
645
646 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800647 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
648 main.FALSE,
649 kwargs={'isPENDING':False},
650 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700651 utilities.assert_equals( expect=main.TRUE,
652 actual=flowCheck,
653 onpass="Flow status is correct!",
654 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700655
656 # Ping test
alison62006dd2016-12-15 16:21:28 -0800657 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
658 peers=["p64514", "p64515", "p64516"],
659 expectAllSuccess=True )
660
661 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
662 peers=[ p64514, p64515, p64516 ],
663 expectAllSuccess=True )
664
pingping-linea32cf82015-10-08 22:37:37 -0700665 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800666 hosts=[ "h64514", "h64515", "h64516" ],
667 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700668
pingping-linea32cf82015-10-08 22:37:37 -0700669 def CASE9( self, main ):
670 '''
671 Bring down a switch in best path, check:
672 route number, P2P intent number, M2S intent number, ping test
673 '''
674 main.case( "Stop sw11 located in best path, \
675 check route number, P2P intent number, M2S intent number, ping test" )
676
677 main.log.info( "Check the flow number correctness before stopping sw11" )
alison62006dd2016-12-15 16:21:28 -0800678 main.Functions.checkFlowNum( main, "sw11", 49 )
679 main.Functions.checkFlowNum( main, "sw1", 7 )
680 main.Functions.checkFlowNum( main, "sw7", 34 )
pingping-linea32cf82015-10-08 22:37:37 -0700681 main.log.info( main.Mininet.checkFlows( "sw11" ) )
682 main.log.info( main.Mininet.checkFlows( "sw1" ) )
683 main.log.info( main.Mininet.checkFlows( "sw7" ) )
684
685 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800686 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Hall362aa922016-03-31 09:39:26 -0700687 utilities.assert_equals( expect=main.TRUE, actual=result,
688 onpass="Stopping switch succeeded!",
689 onfail="Stopping switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700690 if result:
691 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
692 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800693 main.Functions.checkRouteNum( main, 7 )
694 main.Functions.checkM2SintentNum( main, 7 )
695 main.Functions.checkP2PintentNum( main, 30 * 2 ) #18 * 2
pingping-linea32cf82015-10-08 22:37:37 -0700696 else:
697 main.log.error( "Stopping switch failed!" )
698 main.cleanup()
699 main.exit()
700
701 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800702 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
703 main.FALSE,
704 kwargs={'isPENDING':False},
705 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700706 utilities.assert_equals( expect=main.TRUE,
707 actual=flowCheck,
708 onpass="Flow status is correct!",
709 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700710 # Ping test
alison62006dd2016-12-15 16:21:28 -0800711 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
712 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800713 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800714 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
715 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800716 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700717 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800718 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800719 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700720
721
722 def CASE10( self, main ):
723 '''
724 Bring up the switch which was stopped in CASE9, check:
725 route number, P2P intent number, M2S intent number, ping test
726 '''
727 main.case( "Start sw11 which was stopped in CASE9, \
728 check route number, P2P intent number, M2S intent number, ping test" )
729
730 main.log.info( "Check the flow status before starting sw11" )
alison62006dd2016-12-15 16:21:28 -0800731 main.Functions.checkFlowNum( main, "sw1", 36 )
732 main.Functions.checkFlowNum( main, "sw7", 30 )
pingping-linea32cf82015-10-08 22:37:37 -0700733 main.log.info( main.Mininet.checkFlows( "sw1" ) )
734 main.log.info( main.Mininet.checkFlows( "sw7" ) )
735
736 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800737 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Hall362aa922016-03-31 09:39:26 -0700738 utilities.assert_equals( expect=main.TRUE, actual=result1,
739 onpass="Starting switch succeeded!",
740 onfail="Starting switch failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700741 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
Jon Hall362aa922016-03-31 09:39:26 -0700742 utilities.assert_equals( expect=main.TRUE, actual=result2,
743 onpass="Connect switch to ONOS succeeded!",
744 onfail="Connect switch to ONOS failed!" )
pingping-linea32cf82015-10-08 22:37:37 -0700745 if result1 and result2:
746 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800747 main.Functions.checkRouteNum( main, 7 )
748 main.Functions.checkM2SintentNum( main, 7 )
749 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700750
751 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
752 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
753 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
754 else:
755 main.log.error( "Starting switch failed!" )
756 main.cleanup()
757 main.exit()
758
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 # Ping test
alison62006dd2016-12-15 16:21:28 -0800769 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
770 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800771 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800772 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
773 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800774 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700775 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800776 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800777 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700778
779
780 def CASE11(self, main):
781 import time
alison62006dd2016-12-15 16:21:28 -0800782 main.case( "Kill spk1, check:\
pingping-linea32cf82015-10-08 22:37:37 -0700783 route number, P2P intent number, M2S intent number, ping test" )
alison62006dd2016-12-15 16:21:28 -0800784 main.log.info( "Check network status before killing spk1" )
785 main.Functions.checkRouteNum( main, 7 )
786 main.Functions.checkM2SintentNum( main, 7 )
787 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700788 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800789 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
790 main.FALSE,
791 kwargs={'isPENDING':False},
792 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700793 utilities.assert_equals( expect=main.TRUE,
794 actual=flowCheck,
795 onpass="Flow status is correct!",
796 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700797
alison62006dd2016-12-15 16:21:28 -0800798 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
799 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800800 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800801 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
802 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800803 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700804 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800805 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800806 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700807
alison62006dd2016-12-15 16:21:28 -0800808 main.step( "Kill spk1" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700809 command1 = "ps -e | grep bgp -c"
810 result1 = main.Mininet.node( "root", command1 )
811
812 # The total BGP daemon number in this test environment is 5.
813 if "5" in result1:
alison62006dd2016-12-15 16:21:28 -0800814 main.log.debug( "Before kill spk1, 5 BGP daemons - correct" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700815 else:
alison62006dd2016-12-15 16:21:28 -0800816 main.log.warn( "Before kill spk1, number of BGP daemons is wrong" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700817 main.log.info( result1 )
818
819 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
820 result2 = main.Mininet.node( "root", command2 )
821
822 result3 = main.Mininet.node( "root", command1 )
823
Jon Hall6e9897d2016-02-29 14:41:32 -0800824 utilities.assert_equals( expect=True,
825 actual=( "4" in result3 ),
alison62006dd2016-12-15 16:21:28 -0800826 onpass="Kill spk1 succeeded",
827 onfail="Kill spk1 failed" )
pingping-lin145cd0a2015-10-09 17:44:34 -0700828 if ( "4" not in result3 ) :
829 main.log.info( result3 )
pingping-linea32cf82015-10-08 22:37:37 -0700830 main.cleanup()
831 main.exit()
832
833 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alison62006dd2016-12-15 16:21:28 -0800834 main.Functions.checkRouteNum( main, 7 )
835 main.Functions.checkM2SintentNum( main, 7 )
836 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-linea32cf82015-10-08 22:37:37 -0700837
838 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800839 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
840 main.FALSE,
841 kwargs={'isPENDING':False},
842 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700843 utilities.assert_equals( expect=main.TRUE,
844 actual=flowCheck,
845 onpass="Flow status is correct!",
846 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700847
848 '''
alison62006dd2016-12-15 16:21:28 -0800849 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
850 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800851 expectAllSuccess=False )
pingping-linea32cf82015-10-08 22:37:37 -0700852 '''
alison62006dd2016-12-15 16:21:28 -0800853 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
854 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800855 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700856 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800857 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800858 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700859
860
861 def CASE12( self, main ):
862 import time
pingping-lina14c7c82015-10-09 15:44:36 -0700863 import json
pingping-linea32cf82015-10-08 22:37:37 -0700864 main.case( "Bring down leader ONOS node, check: \
865 route number, P2P intent number, M2S intent number, ping test" )
866 main.step( "Find out ONOS leader node" )
pingping-lina14c7c82015-10-09 15:44:36 -0700867 result = main.ONOScli1.leaders()
pingping-lin3f932a72015-10-09 16:44:50 -0700868 jsonResult = json.loads( result )
pingping-lina14c7c82015-10-09 15:44:36 -0700869 leaderIP = ""
870 for entry in jsonResult:
871 if entry["topic"] == "org.onosproject.sdnip":
872 leaderIP = entry["leader"]
873 main.log.info( "leaderIP is: " )
874 main.log.info( leaderIP )
875
876 main.step( "Uninstall ONOS/SDN-IP leader node" )
877 if leaderIP == ONOS1Ip:
878 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
879 elif leaderIP == ONOS2Ip:
880 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
881 else:
882 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
883
Jon Hall6e9897d2016-02-29 14:41:32 -0800884 utilities.assert_equals( expect=main.TRUE,
885 actual=uninstallResult,
886 onpass="Uninstall ONOS leader succeeded",
887 onfail="Uninstall ONOS leader failed" )
pingping-linea32cf82015-10-08 22:37:37 -0700888 if uninstallResult != main.TRUE:
889 main.cleanup()
890 main.exit()
891 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linea32cf82015-10-08 22:37:37 -0700892
pingping-lina14c7c82015-10-09 15:44:36 -0700893 if leaderIP == ONOS1Ip:
alison62006dd2016-12-15 16:21:28 -0800894 main.Functions.checkRouteNum( main, 7, ONOScli="ONOScli2" )
895 main.Functions.checkM2SintentNum( main, 7, ONOScli="ONOScli2" )
896 main.Functions.checkP2PintentNum( main, 30 * 2, ONOScli="ONOScli2" )
pingping-lina14c7c82015-10-09 15:44:36 -0700897
898 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800899 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
900 main.FALSE,
901 kwargs={'isPENDING':False},
902 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700903 utilities.assert_equals( expect=main.TRUE,
904 actual=flowCheck,
905 onpass="Flow status is correct!",
906 onfail="Flow status is wrong!" )
pingping-lina14c7c82015-10-09 15:44:36 -0700907 else:
alison62006dd2016-12-15 16:21:28 -0800908 main.Functions.checkRouteNum( main, 7 )
909 main.Functions.checkM2SintentNum( main, 7 )
910 main.Functions.checkP2PintentNum( main, 30 * 2 )
pingping-lina14c7c82015-10-09 15:44:36 -0700911
912 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800913 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
914 main.FALSE,
915 kwargs={'isPENDING':False},
916 attempts=10 )
Jon Hall362aa922016-03-31 09:39:26 -0700917 utilities.assert_equals( expect=main.TRUE,
918 actual=flowCheck,
919 onpass="Flow status is correct!",
920 onfail="Flow status is wrong!" )
pingping-linea32cf82015-10-08 22:37:37 -0700921
alison62006dd2016-12-15 16:21:28 -0800922 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
923 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800924 expectAllSuccess=True )
alison62006dd2016-12-15 16:21:28 -0800925 main.Functions.pingSpeakerToPeer( main, speakers=["spk2"],
926 peers=[p64514, p64515, p64516],
Jon Hall6e9897d2016-02-29 14:41:32 -0800927 expectAllSuccess=True )
pingping-linea32cf82015-10-08 22:37:37 -0700928 main.Functions.pingHostToHost( main,
alison62006dd2016-12-15 16:21:28 -0800929 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800930 expectAllSuccess=True )