blob: 8ca65a62cbc99e893e490b35c46a4baae6b46ae3 [file] [log] [blame]
pingping-lin26990f02015-11-30 15:48:06 -08001# Testing the functionality of SDN-IP with single ONOS instance
2class USECASE_SdnipFunctionCluster_fsfw:
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 Hall70b768c2016-04-19 08:38:29 -070013 main.case( "Setup the Mininet testbed" )
pingping-lin26990f02015-11-30 15:48:06 -080014 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-lin26990f02015-11-30 15:48:06 -080025 # Exit if topology did not load properly
26 if not topoResult:
27 main.cleanup()
28 main.exit()
pingping-lin14776632015-12-16 12:05:30 -080029 main.step( "Connect switches to FSFW" )
pingping-lin26990f02015-11-30 15:48:06 -080030
pingping-lin26990f02015-11-30 15:48:06 -080031 swResult = main.TRUE
32 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
33 sw = "sw%s" % ( i )
pingping-lin14776632015-12-16 12:05:30 -080034 swResult = swResult and main.Mininet.assignSwController( sw, fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -080035 port=fsfwPort )
pingping-lin26990f02015-11-30 15:48:06 -080036
Jon Hall6e9897d2016-02-29 14:41:32 -080037 utilities.assert_equals( expect=main.TRUE,
38 actual=swResult,
39 onpass="Successfully connect all switches to FSFW",
40 onfail="Failed to connect all switches to FSFW" )
pingping-lin26990f02015-11-30 15:48:06 -080041 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-lin26990f02015-11-30 15:48:06 -080071
pingping-lin14776632015-12-16 12:05:30 -080072 global pr64514
73 global pr64515
74 global pr64516
75 pr64514 = main.params['config']['pr64514']
76 pr64515 = main.params['config']['pr64515']
77 pr64516 = main.params['config']['pr64516']
78
79 global fsfwIp
80 global fsfwPort
81 fsfwIp = main.params[ 'CTRL' ][ 'fsfwIp' ]
82 fsfwPort = main.params[ 'CTRL' ][ 'fsfwPort' ]
pingping-lin26990f02015-11-30 15:48:06 -080083
Jon Hall70b768c2016-04-19 08:38:29 -070084 main.step( "Copying config files" )
85 src = os.path.dirname( main.testFile ) + "/network-cfg.json"
86 dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json"
87 status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" )
88 utilities.assert_equals( expect=main.TRUE,
89 actual=status,
90 onpass="Copy config file succeeded",
91 onfail="Copy config file failed" )
92
Jon Hall6e9897d2016-02-29 14:41:32 -080093 main.step( "Create cell file" )
94 cellAppString = main.params[ 'ENV' ][ 'appString' ]
95 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
96 main.Mininet.ip_address,
97 cellAppString, ipList )
98
pingping-lin26990f02015-11-30 15:48:06 -080099 main.step( "Applying cell variable to environment" )
100 cellResult = main.ONOSbench.setCell( cellName )
Jon Hall6e9897d2016-02-29 14:41:32 -0800101 utilities.assert_equals( expect=main.TRUE,
102 actual=cellResult,
103 onpass="Set cell succeeded",
104 onfail="Set cell failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800105
Jon Hall70b768c2016-04-19 08:38:29 -0700106 main.step( "Verify cell connectivity" )
pingping-lin26990f02015-11-30 15:48:06 -0800107 verifyResult = main.ONOSbench.verifyCell()
Jon Hall6e9897d2016-02-29 14:41:32 -0800108 utilities.assert_equals( expect=main.TRUE,
109 actual=verifyResult,
110 onpass="Verify cell succeeded",
111 onfail="Verify cell failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800112
113 branchName = main.ONOSbench.getBranchName()
114 main.log.report( "ONOS is on branch: " + branchName )
115
116 main.log.step( "Uninstalling ONOS" )
117 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) \
118 and main.ONOSbench.onosUninstall( ONOS2Ip ) \
119 and main.ONOSbench.onosUninstall( ONOS3Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -0800120 utilities.assert_equals( expect=main.TRUE,
121 actual=uninstallResult,
122 onpass="Uninstall ONOS from nodes succeeded",
123 onfail="Uninstall ONOS form nodes failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800124
Jon Hall6e9897d2016-02-29 14:41:32 -0800125 main.ONOSbench.getVersion( report=True )
pingping-lin26990f02015-11-30 15:48:06 -0800126
127 main.step( "Creating ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800128 packageResult = main.ONOSbench.onosPackage( opTimeout=500 )
129 utilities.assert_equals( expect=main.TRUE,
130 actual=packageResult,
131 onpass="Package ONOS succeeded",
132 onfail="Package ONOS failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800133
134 main.step( "Installing ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800135 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
136 node=ONOS1Ip )
137 onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
138 node=ONOS2Ip )
139 onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
140 node=ONOS3Ip )
pingping-lin26990f02015-11-30 15:48:06 -0800141 onosInstallResult = onos1InstallResult and onos2InstallResult \
142 and onos3InstallResult
Jon Hall6e9897d2016-02-29 14:41:32 -0800143 utilities.assert_equals( expect=main.TRUE,
144 actual=onosInstallResult,
145 onpass="Install ONOS to nodes succeeded",
146 onfail="Install ONOS to nodes failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800147
148 main.step( "Checking if ONOS is up yet" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800149 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
150 onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
151 onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout=420 )
pingping-lin26990f02015-11-30 15:48:06 -0800152 onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult
Jon Hall6e9897d2016-02-29 14:41:32 -0800153 utilities.assert_equals( expect=main.TRUE,
154 actual=onosUpResult,
155 onpass="ONOS nodes are up",
156 onfail="ONOS nodes are NOT up" )
pingping-lin26990f02015-11-30 15:48:06 -0800157
158 main.step( "Checking if ONOS CLI is ready" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800159 main.CLIs = []
pingping-lin26990f02015-11-30 15:48:06 -0800160 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800161 commandlineTimeout=100, onosStartTimeout=600 )
162 main.CLIs.append( main.ONOScli1 )
pingping-lin26990f02015-11-30 15:48:06 -0800163 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800164 commandlineTimeout=100, onosStartTimeout=600 )
165 main.CLIs.append( main.ONOScli2 )
166 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
167 commandlineTimeout=100, onosStartTimeout=600 )
168 main.CLIs.append( main.ONOScli3 )
169 cliResult = cliResult1 and cliResult2 and cliResult3
170 utilities.assert_equals( expect=main.TRUE,
171 actual=cliResult,
172 onpass="ONOS CLIs are ready",
173 onfail="ONOS CLIs are not ready" )
pingping-lin26990f02015-11-30 15:48:06 -0800174
Jon Hall6e9897d2016-02-29 14:41:32 -0800175 for i in range( 10 ):
176 ready = True
177 for cli in main.CLIs:
178 output = cli.summary()
179 if not output:
180 ready = False
181 if ready:
182 break
183 time.sleep( 30 )
184 utilities.assert_equals( expect=True, actual=ready,
185 onpass="ONOS summary command succeded",
186 onfail="ONOS summary command failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800187
Jon Hall6e9897d2016-02-29 14:41:32 -0800188 if not ready:
pingping-lin26990f02015-11-30 15:48:06 -0800189 main.log.error( "ONOS startup failed!" )
190 main.cleanup()
191 main.exit()
192
pingping-lin26990f02015-11-30 15:48:06 -0800193 def CASE200( self, main ):
194 main.case( "Activate sdn-ip application" )
195 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800196 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-lin26990f02015-11-30 15:48:06 -0800197
198 main.log.info( "Get links in the network" )
199 summaryResult = main.ONOScli1.summary()
200 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall6e9897d2016-02-29 14:41:32 -0800201 listResult = main.ONOScli1.links( jsonFormat=False )
pingping-lin26990f02015-11-30 15:48:06 -0800202 main.log.info( listResult )
pingping-lin26990f02015-11-30 15:48:06 -0800203 if linkNum < 100:
204 main.log.error( "Link number is wrong!" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800205 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
206 listResult = main.ONOScli1.links( jsonFormat=False )
207 main.log.info( listResult )
pingping-lin26990f02015-11-30 15:48:06 -0800208 main.cleanup()
209 main.exit()
210
211 main.step( "Activate sdn-ip application" )
212 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800213 utilities.assert_equals( expect=main.TRUE,
214 actual=activeSDNIPresult,
215 onpass="Activate SDN-IP succeeded",
216 onfail="Activate SDN-IP failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800217 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800218 main.log.info( "Activate SDN-IP failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800219 main.cleanup()
220 main.exit()
221
222
223 def CASE102( self, main ):
224 '''
225 This test case is to load the methods from other Python files, and create
226 tunnels from mininet host to onos nodes.
227 '''
228 import time
229 main.case( "Load methods from other Python file and create tunnels" )
230 # load the methods from other file
231 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
232 main.Functions = imp.load_source( wrapperFile1,
233 main.dependencyPath +
234 wrapperFile1 +
235 ".py" )
236 # Create tunnels
237 main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
238 main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
239 main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
240
241 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
242 and the BGP paths in data plane are ready..." )
243 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
244
245 main.log.info( "Wait Quagga to finish delivery all routes to each \
246 other and to sdn-ip, plus finish installing all intents..." )
247 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-lin26990f02015-11-30 15:48:06 -0800248
249 def CASE1( self, main ):
250 '''
251 ping test from 3 bgp peers to BGP speaker
252 '''
253
254 main.case( "Ping tests between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800255 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
256 peers=["pr64514", "pr64515", "pr64516"],
257 expectAllSuccess=True )
258 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
259 peers=[pr64514, pr64515, pr64516],
260 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800261
262 def CASE2( self, main ):
263 '''
264 point-to-point intents test for each BGP peer and BGP speaker pair
265 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800266 import time
pingping-lin26990f02015-11-30 15:48:06 -0800267 main.case( "Check point-to-point intents" )
268 main.log.info( "There are %s BGP peers in total "
269 % main.params[ 'config' ][ 'peerNum' ] )
270 main.step( "Check P2P intents number from ONOS CLI" )
271
Jon Hall6e9897d2016-02-29 14:41:32 -0800272 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-lin26990f02015-11-30 15:48:06 -0800273 bgpIntentsActualNum = \
274 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
275 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
Jon Hall6e9897d2016-02-29 14:41:32 -0800276 if bgpIntentsActualNum != bgpIntentsExpectedNum:
277 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700278 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800279 bgpIntentsActualNum = \
280 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
pingping-lin26990f02015-11-30 15:48:06 -0800281 main.log.info( "bgpIntentsExpected num is:" )
282 main.log.info( bgpIntentsExpectedNum )
283 main.log.info( "bgpIntentsActual num is:" )
284 main.log.info( bgpIntentsActualNum )
285 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800286 expect=True,
287 actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
288 onpass="PointToPointIntent Intent Num is correct!",
289 onfail="PointToPointIntent Intent Num is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800290
291
292 def CASE3( self, main ):
293 '''
294 routes and intents check to all BGP peers
295 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800296 import time
pingping-lin26990f02015-11-30 15:48:06 -0800297 main.case( "Check routes and M2S intents to all BGP peers" )
298
299 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-lin26990f02015-11-30 15:48:06 -0800305 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-lin26990f02015-11-30 15:48:06 -0800315
316 main.step( "Check routes installed" )
317 main.log.info( "Routes expected:" )
318 main.log.info( allRoutesStrExpected )
319 main.log.info( "Routes get from ONOS CLI:" )
320 main.log.info( allRoutesStrActual )
321 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800322 expect=allRoutesStrExpected, actual=allRoutesStrActual,
323 onpass="Routes are correct!",
324 onfail="Routes are wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800325
326 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800327 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-lin26990f02015-11-30 15:48:06 -0800328 routeIntentsActualNum = \
329 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
330 routeIntentsExpectedNum = 3
Jon Hall6e9897d2016-02-29 14:41:32 -0800331 if routeIntentsActualNum != routeIntentsExpectedNum:
332 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700333 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800334 routeIntentsActualNum = \
335 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-lin26990f02015-11-30 15:48:06 -0800336
337 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
338 main.log.info( routeIntentsExpectedNum )
339 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
340 main.log.info( routeIntentsActualNum )
341 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800342 expect=routeIntentsExpectedNum,
343 actual=routeIntentsActualNum,
344 onpass="MultiPointToSinglePoint Intent Num is correct!",
345 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800346
347 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800348 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
349 main.FALSE,
350 kwargs={'isPENDING':False},
351 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800352 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800353 expect=main.TRUE,
354 actual=flowCheck,
355 onpass="Flow status is correct!",
356 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800357
358
359 def CASE4( self, main ):
360 '''
361 Ping test in data plane for each route
362 '''
363 main.case( "Ping test for each route, all hosts behind BGP peers" )
364 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800365 hosts=["host64514", "host64515", "host64516"],
366 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800367
368
369 def CASE5( self, main ):
370 '''
371 Cut links to peers one by one, check routes/intents
372 '''
373 import time
374 main.case( "Bring down links and check routes/intents" )
375 main.step( "Bring down the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800376 linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514",
377 OPTION="down" )
pingping-lin3806f112016-01-04 10:38:25 -0800378 # When bring down a link, Mininet will bring down both the interfaces
379 # at the two sides of the link. Here we do not want to bring down the
380 # host side interface, since I noticed when bring up in CASE6, some of
381 # the configuration information will lost.
Jon Hall6e9897d2016-02-29 14:41:32 -0800382 utilities.assertEquals( expect=main.TRUE,
383 actual=linkResult1,
384 onpass="Bring down link succeeded!",
385 onfail="Bring down link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800386
387 if linkResult1 == main.TRUE:
388 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
389 main.Functions.checkRouteNum( main, 2 )
390 main.Functions.checkM2SintentNum( main, 2 )
391 else:
392 main.log.error( "Bring down link failed!" )
393 main.cleanup()
394 main.exit()
395
396 main.step( "Bring down the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800397 linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515",
398 OPTION="down" )
399 utilities.assertEquals( expect=main.TRUE,
400 actual=linkResult2,
401 onpass="Bring down link succeeded!",
402 onfail="Bring down link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800403 if linkResult2 == main.TRUE:
404 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
405 main.Functions.checkRouteNum( main, 1 )
406 main.Functions.checkM2SintentNum( main, 1 )
407 else:
408 main.log.error( "Bring down link failed!" )
409 main.cleanup()
410 main.exit()
411
412 main.step( "Bring down the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800413 linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516",
414 OPTION="down" )
415 utilities.assertEquals( expect=main.TRUE,
416 actual=linkResult3,
417 onpass="Bring down link succeeded!",
418 onfail="Bring down link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800419 if linkResult3 == main.TRUE:
420 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
421 main.Functions.checkRouteNum( main, 0 )
422 main.Functions.checkM2SintentNum( main, 0 )
423 else:
424 main.log.error( "Bring down link failed!" )
425 main.cleanup()
426 main.exit()
427
428 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800429 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
430 main.FALSE,
431 kwargs={'isPENDING':False},
432 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800433 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800434 expect=main.TRUE,
435 actual=flowCheck,
436 onpass="Flow status is correct!",
437 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800438
439 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800440 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
441 peers=["pr64514", "pr64515", "pr64516"],
442 expectAllSuccess=False )
pingping-lin26990f02015-11-30 15:48:06 -0800443 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800444 hosts=["host64514", "host64515", "host64516"],
445 expectAllSuccess=False )
pingping-lin26990f02015-11-30 15:48:06 -0800446
447
448 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="pr64514",
456 OPTION="up" )
457 utilities.assertEquals( expect=main.TRUE,
458 actual=linkResult1,
459 onpass="Bring up link succeeded!",
460 onfail="Bring up link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800461 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="pr64515",
472 OPTION="up" )
473 utilities.assertEquals( expect=main.TRUE,
474 actual=linkResult2,
475 onpass="Bring up link succeeded!",
476 onfail="Bring up link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800477 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="pr64516",
488 OPTION="up" )
489 utilities.assertEquals( expect=main.TRUE,
490 actual=linkResult3,
491 onpass="Bring up link succeeded!",
492 onfail="Bring up link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800493 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 )
pingping-lin26990f02015-11-30 15:48:06 -0800507 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800508 expect=main.TRUE,
509 actual=flowCheck,
510 onpass="Flow status is correct!",
511 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800512
513 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800514 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
515 peers=["pr64514", "pr64515", "pr64516"],
516 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800517 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800518 hosts=["host64514", "host64515", "host64516"],
519 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800520
521
522 def CASE7( self, main ):
523 '''
524 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
525 '''
526 import time
527 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
528 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800529 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
530 utilities.assertEquals( expect=main.TRUE, actual=result,
531 onpass="Stopping switch succeeded!",
532 onfail="Stopping switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800533
534 if result == main.TRUE:
535 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
536 main.Functions.checkRouteNum( main, 2 )
537 main.Functions.checkM2SintentNum( main, 2 )
538 main.Functions.checkP2PintentNum( main, 12 * 2 )
539 else:
540 main.log.error( "Stopping switch failed!" )
541 main.cleanup()
542 main.exit()
543
544 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800545 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
546 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
547 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-lin26990f02015-11-30 15:48:06 -0800548
549 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
550 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800551 utilities.assert_equals( expect=True, actual=pingResult1,
552 onpass="Ping test result is correct",
553 onfail="Ping test result is wrong" )
pingping-lin26990f02015-11-30 15:48:06 -0800554
555 if pingResult1 == False:
556 main.cleanup()
557 main.exit()
558
559 main.step( "Check ping between BGP peers and speaker1" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800560 result4 = main.Mininet.pingHost( src="speaker1", target="pr64514" )
561 result5 = main.Mininet.pingHost( src="speaker1", target="pr64515" )
562 result6 = main.Mininet.pingHost( src="speaker1", target="pr64516" )
pingping-lin26990f02015-11-30 15:48:06 -0800563
564 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
565 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800566 utilities.assert_equals( expect=True, actual=pingResult2,
567 onpass="Speaker1 ping peers successful",
568 onfail="Speaker1 ping peers NOT successful" )
pingping-lin26990f02015-11-30 15:48:06 -0800569
570 if pingResult2 == False:
571 main.cleanup()
572 main.exit()
573
574 main.step( "Check ping between BGP peers and speaker2" )
575 # TODO
Jon Hall6e9897d2016-02-29 14:41:32 -0800576 result7 = main.Mininet.pingHost( src="speaker2", target=pr64514 )
577 result8 = main.Mininet.pingHost( src="speaker2", target=pr64515 )
578 result9 = main.Mininet.pingHost( src="speaker2", target=pr64516 )
pingping-lin26990f02015-11-30 15:48:06 -0800579
580 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
581 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800582 utilities.assert_equals( expect=True, actual=pingResult2,
583 onpass="Speaker2 ping peers successful",
584 onfail="Speaker2 ping peers NOT successful" )
pingping-lin26990f02015-11-30 15:48:06 -0800585
586 if pingResult3 == False:
587 main.cleanup()
588 main.exit()
589
590 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800591 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
592 main.FALSE,
593 kwargs={'isPENDING':False},
594 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800595 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800596 expect=main.TRUE,
597 actual=flowCheck,
598 onpass="Flow status is correct!",
599 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800600
601
602 def CASE8( self, main ):
603 '''
604 Bring up the edge switch (sw32) which was shut down in CASE7,
605 check P-2-P and M-2-S intents, ping test
606 '''
607 import time
608 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
609 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800610 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-lin26990f02015-11-30 15:48:06 -0800611 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800612 expect=main.TRUE,
613 actual=result1,
614 onpass="Starting switch succeeded!",
615 onfail="Starting switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800616
pingping-lin3806f112016-01-04 10:38:25 -0800617 result2 = main.Mininet.assignSwController( "sw32", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800618 port=fsfwPort )
pingping-lin26990f02015-11-30 15:48:06 -0800619 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800620 expect=main.TRUE,
621 actual=result2,
622 onpass="Connect switch to FSFW succeeded!",
623 onfail="Connect switch to FSFW failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800624
625 if result1 and result2:
626 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
627 main.Functions.checkRouteNum( main, 3 )
628 main.Functions.checkM2SintentNum( main, 3 )
629 main.Functions.checkP2PintentNum( main, 18 * 2 )
630 else:
631 main.log.error( "Starting switch failed!" )
632 main.cleanup()
633 main.exit()
634
635 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800636 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
637 main.FALSE,
638 kwargs={'isPENDING':False},
639 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800640 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800641 expect=main.TRUE,
642 actual=flowCheck,
643 onpass="Flow status is correct!",
644 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800645
646 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800647 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
648 peers=["pr64514", "pr64515", "pr64516"],
649 expectAllSuccess=True )
650 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
651 peers=[pr64514, pr64515, pr64516],
652 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800653 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800654 hosts=["host64514", "host64515", "host64516"],
655 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800656
657
658 def CASE9( self, main ):
659 '''
660 Bring down a switch in best path, check:
661 route number, P2P intent number, M2S intent number, ping test
662 '''
663 main.case( "Stop sw11 located in best path, \
664 check route number, P2P intent number, M2S intent number, ping test" )
665
666 main.log.info( "Check the flow number correctness before stopping sw11" )
667 main.Functions.checkFlowNum( main, "sw11", 19 )
668 main.Functions.checkFlowNum( main, "sw1", 3 )
669 main.Functions.checkFlowNum( main, "sw7", 3 )
670 main.log.info( main.Mininet.checkFlows( "sw11" ) )
671 main.log.info( main.Mininet.checkFlows( "sw1" ) )
672 main.log.info( main.Mininet.checkFlows( "sw7" ) )
673
674 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800675 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
676 utilities.assertEquals( expect=main.TRUE, actual=result,
677 onpass="Stopping switch succeeded!",
678 onfail="Stopping switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800679 if result:
680 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
681 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
682 main.Functions.checkRouteNum( main, 3 )
683 main.Functions.checkM2SintentNum( main, 3 )
684 main.Functions.checkP2PintentNum( main, 18 * 2 )
685 else:
686 main.log.error( "Stopping switch failed!" )
687 main.cleanup()
688 main.exit()
689
690 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800691 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
692 main.FALSE,
693 kwargs={'isPENDING':False},
694 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800695 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800696 expect=main.TRUE,
697 actual=flowCheck,
698 onpass="Flow status is correct!",
699 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800700 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800701 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
702 peers=["pr64514", "pr64515", "pr64516"],
703 expectAllSuccess=True )
704 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
705 peers=[pr64514, pr64515, pr64516],
706 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800707 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800708 hosts=["host64514", "host64515", "host64516"],
709 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800710
711
712 def CASE10( self, main ):
713 '''
714 Bring up the switch which was stopped in CASE9, check:
715 route number, P2P intent number, M2S intent number, ping test
716 '''
717 main.case( "Start sw11 which was stopped in CASE9, \
718 check route number, P2P intent number, M2S intent number, ping test" )
719
720 main.log.info( "Check the flow status before starting sw11" )
721 main.Functions.checkFlowNum( main, "sw1", 17 )
722 main.Functions.checkFlowNum( main, "sw7", 5 )
723 main.log.info( main.Mininet.checkFlows( "sw1" ) )
724 main.log.info( main.Mininet.checkFlows( "sw7" ) )
725
726 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800727 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
728 utilities.assertEquals( expect=main.TRUE, actual=result1,
729 onpass="Starting switch succeeded!",
730 onfail="Starting switch failed!" )
pingping-lin3806f112016-01-04 10:38:25 -0800731 result2 = main.Mininet.assignSwController( "sw11", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800732 port=fsfwPort )
733 utilities.assertEquals( expect=main.TRUE, actual=result2,
734 onpass="Connect switch to FSFW succeeded!",
735 onfail="Connect switch to FSFW failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800736 if result1 and result2:
737 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
738 main.Functions.checkRouteNum( main, 3 )
739 main.Functions.checkM2SintentNum( main, 3 )
740 main.Functions.checkP2PintentNum( main, 18 * 2 )
741
742 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
743 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
744 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
745 else:
746 main.log.error( "Starting switch failed!" )
747 main.cleanup()
748 main.exit()
749
750 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800751 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
752 main.FALSE,
753 kwargs={'isPENDING':False},
754 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800755 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800756 expect=main.TRUE,
757 actual=flowCheck,
758 onpass="Flow status is correct!",
759 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800760 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800761 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
762 peers=["pr64514", "pr64515", "pr64516"],
763 expectAllSuccess=True )
764 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
765 peers=[pr64514, pr64515, pr64516],
766 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800767 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800768 hosts=["host64514", "host64515", "host64516"],
769 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800770
771
772 def CASE11(self, main):
773 import time
774 main.case( "Kill speaker1, check:\
775 route number, P2P intent number, M2S intent number, ping test" )
776 main.log.info( "Check network status before killing speaker1" )
777 main.Functions.checkRouteNum( main, 3 )
778 main.Functions.checkM2SintentNum( main, 3 )
779 main.Functions.checkP2PintentNum( main, 18 * 2 )
780 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800781 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
782 main.FALSE,
783 kwargs={'isPENDING':False},
784 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800785 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800786 expect=main.TRUE,
787 actual=flowCheck,
788 onpass="Flow status is correct!",
789 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800790
Jon Hall6e9897d2016-02-29 14:41:32 -0800791 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
792 peers=["pr64514", "pr64515", "pr64516"],
793 expectAllSuccess=True )
794 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
795 peers=[pr64514, pr64515, pr64516],
796 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800797 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800798 hosts=["host64514", "host64515", "host64516"],
799 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800800
801 main.step( "Kill speaker1" )
802 command1 = "ps -e | grep bgp -c"
803 result1 = main.Mininet.node( "root", command1 )
804
805 # The total BGP daemon number in this test environment is 5.
806 if "5" in result1:
807 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
808 else:
809 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
810 main.log.info( result1 )
811
812 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
813 result2 = main.Mininet.node( "root", command2 )
814
815 result3 = main.Mininet.node( "root", command1 )
816
Jon Hall6e9897d2016-02-29 14:41:32 -0800817 utilities.assert_equals( expect=True,
818 actual=( "4" in result3 ),
819 onpass="Kill speaker1 succeeded",
820 onfail="Kill speaker1 failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800821 if ( "4" not in result3 ) :
822 main.log.info( result3 )
823 main.cleanup()
824 main.exit()
825
826 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
827 main.Functions.checkRouteNum( main, 3 )
828 main.Functions.checkM2SintentNum( main, 3 )
829 main.Functions.checkP2PintentNum( main, 18 * 2 )
830
831 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800832 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
833 main.FALSE,
834 kwargs={'isPENDING':False},
835 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800836 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800837 expect=main.TRUE,
838 actual=flowCheck,
839 onpass="Flow status is correct!",
840 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800841
842 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800843 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
844 peers=["pr64514", "pr64515", "pr64516"],
845 expectAllSuccess=False )
pingping-lin26990f02015-11-30 15:48:06 -0800846 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800847 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
848 peers=[pr64514, pr64515, pr64516],
849 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800850 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800851 hosts=["host64514", "host64515", "host64516"],
852 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800853
854
855 def CASE12( self, main ):
856 import time
857 import json
858 main.case( "Bring down leader ONOS node, check: \
859 route number, P2P intent number, M2S intent number, ping test" )
860 main.step( "Find out ONOS leader node" )
861 result = main.ONOScli1.leaders()
862 jsonResult = json.loads( result )
863 leaderIP = ""
864 for entry in jsonResult:
865 if entry["topic"] == "org.onosproject.sdnip":
866 leaderIP = entry["leader"]
867 main.log.info( "leaderIP is: " )
868 main.log.info( leaderIP )
869
870 main.step( "Uninstall ONOS/SDN-IP leader node" )
871 if leaderIP == ONOS1Ip:
872 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
873 elif leaderIP == ONOS2Ip:
874 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
875 else:
876 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
877
Jon Hall6e9897d2016-02-29 14:41:32 -0800878 utilities.assert_equals( expect=main.TRUE,
879 actual=uninstallResult,
880 onpass="Uninstall ONOS leader succeeded",
881 onfail="Uninstall ONOS leader failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800882 if uninstallResult != main.TRUE:
883 main.cleanup()
884 main.exit()
885 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
886
887 if leaderIP == ONOS1Ip:
Jon Hall6e9897d2016-02-29 14:41:32 -0800888 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
889 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
890 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
pingping-lin26990f02015-11-30 15:48:06 -0800891
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 )
pingping-lin26990f02015-11-30 15:48:06 -0800897 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800898 expect=main.TRUE,
899 actual=flowCheck,
900 onpass="Flow status is correct!",
901 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800902 else:
903 main.Functions.checkRouteNum( main, 3 )
904 main.Functions.checkM2SintentNum( main, 3 )
905 main.Functions.checkP2PintentNum( main, 18 * 2 )
906
907 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800908 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
909 main.FALSE,
910 kwargs={'isPENDING':False},
911 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800912 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800913 expect=main.TRUE,
914 actual=flowCheck,
915 onpass="Flow status is correct!",
916 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800917
Jon Hall6e9897d2016-02-29 14:41:32 -0800918 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
919 peers=["pr64514", "pr64515", "pr64516"],
920 expectAllSuccess=True )
921 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
922 peers=[pr64514, pr64515, pr64516],
923 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800924 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800925 hosts=["host64514", "host64515", "host64516"],
926 expectAllSuccess=True )