blob: 5197ba6e3a6cedbd82cf3df2091e799627ebff06 [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,
Devin Limdc78e202017-06-09 18:30:07 -070097 cellAppString, ipList, main.ONOScli1.karafUser )
Jon Hall6e9897d2016-02-29 14:41:32 -080098
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
Jon Hall6509dbf2016-06-21 17:01:17 -0700116 main.step( "Uninstalling ONOS" )
pingping-lin26990f02015-11-30 15:48:06 -0800117 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 Hallbd60ea02016-08-23 10:03:59 -0700128 packageResult = main.ONOSbench.buckBuild()
Jon Hall6e9897d2016-02-29 14:41:32 -0800129 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
You Wangf5de25b2017-01-06 15:13:01 -0800148 main.step( "Set up ONOS secure SSH" )
149 secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
150 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS2Ip )
151 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS3Ip )
152 utilities.assert_equals( expect=main.TRUE,
153 actual=secureSshResult,
154 onpass="Set up ONOS secure SSH succeeded",
155 onfail="Set up ONOS secure SSH failed " )
156
pingping-lin26990f02015-11-30 15:48:06 -0800157 main.step( "Checking if ONOS is up yet" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800158 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
159 onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
160 onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout=420 )
pingping-lin26990f02015-11-30 15:48:06 -0800161 onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult
Jon Hall6e9897d2016-02-29 14:41:32 -0800162 utilities.assert_equals( expect=main.TRUE,
163 actual=onosUpResult,
164 onpass="ONOS nodes are up",
165 onfail="ONOS nodes are NOT up" )
pingping-lin26990f02015-11-30 15:48:06 -0800166
167 main.step( "Checking if ONOS CLI is ready" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800168 main.CLIs = []
pingping-lin26990f02015-11-30 15:48:06 -0800169 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800170 commandlineTimeout=100, onosStartTimeout=600 )
171 main.CLIs.append( main.ONOScli1 )
pingping-lin26990f02015-11-30 15:48:06 -0800172 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800173 commandlineTimeout=100, onosStartTimeout=600 )
174 main.CLIs.append( main.ONOScli2 )
175 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
176 commandlineTimeout=100, onosStartTimeout=600 )
177 main.CLIs.append( main.ONOScli3 )
178 cliResult = cliResult1 and cliResult2 and cliResult3
179 utilities.assert_equals( expect=main.TRUE,
180 actual=cliResult,
181 onpass="ONOS CLIs are ready",
182 onfail="ONOS CLIs are not ready" )
pingping-lin26990f02015-11-30 15:48:06 -0800183
Jon Hall6e9897d2016-02-29 14:41:32 -0800184 for i in range( 10 ):
185 ready = True
186 for cli in main.CLIs:
187 output = cli.summary()
188 if not output:
189 ready = False
190 if ready:
191 break
192 time.sleep( 30 )
193 utilities.assert_equals( expect=True, actual=ready,
194 onpass="ONOS summary command succeded",
195 onfail="ONOS summary command failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800196
Jon Hall6e9897d2016-02-29 14:41:32 -0800197 if not ready:
pingping-lin26990f02015-11-30 15:48:06 -0800198 main.log.error( "ONOS startup failed!" )
199 main.cleanup()
200 main.exit()
201
pingping-lin26990f02015-11-30 15:48:06 -0800202 def CASE200( self, main ):
203 main.case( "Activate sdn-ip application" )
204 main.log.info( "waiting link discovery......" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800205 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
pingping-lin26990f02015-11-30 15:48:06 -0800206
207 main.log.info( "Get links in the network" )
208 summaryResult = main.ONOScli1.summary()
209 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall6e9897d2016-02-29 14:41:32 -0800210 listResult = main.ONOScli1.links( jsonFormat=False )
pingping-lin26990f02015-11-30 15:48:06 -0800211 main.log.info( listResult )
pingping-lin26990f02015-11-30 15:48:06 -0800212 if linkNum < 100:
213 main.log.error( "Link number is wrong!" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800214 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
215 listResult = main.ONOScli1.links( jsonFormat=False )
216 main.log.info( listResult )
pingping-lin26990f02015-11-30 15:48:06 -0800217 main.cleanup()
218 main.exit()
219
220 main.step( "Activate sdn-ip application" )
221 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800222 utilities.assert_equals( expect=main.TRUE,
223 actual=activeSDNIPresult,
224 onpass="Activate SDN-IP succeeded",
225 onfail="Activate SDN-IP failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800226 if not activeSDNIPresult:
Jon Hall6e9897d2016-02-29 14:41:32 -0800227 main.log.info( "Activate SDN-IP failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800228 main.cleanup()
229 main.exit()
230
231
232 def CASE102( self, main ):
233 '''
234 This test case is to load the methods from other Python files, and create
235 tunnels from mininet host to onos nodes.
236 '''
237 import time
238 main.case( "Load methods from other Python file and create tunnels" )
239 # load the methods from other file
240 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
241 main.Functions = imp.load_source( wrapperFile1,
242 main.dependencyPath +
243 wrapperFile1 +
244 ".py" )
245 # Create tunnels
246 main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
247 main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
248 main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
249
250 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
251 and the BGP paths in data plane are ready..." )
252 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
253
254 main.log.info( "Wait Quagga to finish delivery all routes to each \
255 other and to sdn-ip, plus finish installing all intents..." )
256 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-lin26990f02015-11-30 15:48:06 -0800257
258 def CASE1( self, main ):
259 '''
260 ping test from 3 bgp peers to BGP speaker
261 '''
262
263 main.case( "Ping tests between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800264 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
265 peers=["pr64514", "pr64515", "pr64516"],
266 expectAllSuccess=True )
267 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
268 peers=[pr64514, pr64515, pr64516],
269 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800270
271 def CASE2( self, main ):
272 '''
273 point-to-point intents test for each BGP peer and BGP speaker pair
274 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800275 import time
pingping-lin26990f02015-11-30 15:48:06 -0800276 main.case( "Check point-to-point intents" )
277 main.log.info( "There are %s BGP peers in total "
278 % main.params[ 'config' ][ 'peerNum' ] )
279 main.step( "Check P2P intents number from ONOS CLI" )
280
Jon Hall6e9897d2016-02-29 14:41:32 -0800281 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-lin26990f02015-11-30 15:48:06 -0800282 bgpIntentsActualNum = \
283 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
284 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
Jon Hall6e9897d2016-02-29 14:41:32 -0800285 if bgpIntentsActualNum != bgpIntentsExpectedNum:
286 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700287 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800288 bgpIntentsActualNum = \
289 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
pingping-lin26990f02015-11-30 15:48:06 -0800290 main.log.info( "bgpIntentsExpected num is:" )
291 main.log.info( bgpIntentsExpectedNum )
292 main.log.info( "bgpIntentsActual num is:" )
293 main.log.info( bgpIntentsActualNum )
294 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800295 expect=True,
296 actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
297 onpass="PointToPointIntent Intent Num is correct!",
298 onfail="PointToPointIntent Intent Num is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800299
300
301 def CASE3( self, main ):
302 '''
303 routes and intents check to all BGP peers
304 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800305 import time
pingping-lin26990f02015-11-30 15:48:06 -0800306 main.case( "Check routes and M2S intents to all BGP peers" )
307
308 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-lin26990f02015-11-30 15:48:06 -0800314 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-lin26990f02015-11-30 15:48:06 -0800324
325 main.step( "Check routes installed" )
326 main.log.info( "Routes expected:" )
327 main.log.info( allRoutesStrExpected )
328 main.log.info( "Routes get from ONOS CLI:" )
329 main.log.info( allRoutesStrActual )
330 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800331 expect=allRoutesStrExpected, actual=allRoutesStrActual,
332 onpass="Routes are correct!",
333 onfail="Routes are wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800334
335 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800336 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
pingping-lin26990f02015-11-30 15:48:06 -0800337 routeIntentsActualNum = \
338 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
339 routeIntentsExpectedNum = 3
Jon Hall6e9897d2016-02-29 14:41:32 -0800340 if routeIntentsActualNum != routeIntentsExpectedNum:
341 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700342 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800343 routeIntentsActualNum = \
344 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-lin26990f02015-11-30 15:48:06 -0800345
346 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
347 main.log.info( routeIntentsExpectedNum )
348 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
349 main.log.info( routeIntentsActualNum )
350 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800351 expect=routeIntentsExpectedNum,
352 actual=routeIntentsActualNum,
353 onpass="MultiPointToSinglePoint Intent Num is correct!",
354 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800355
356 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800357 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
358 main.FALSE,
359 kwargs={'isPENDING':False},
360 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800361 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800362 expect=main.TRUE,
363 actual=flowCheck,
364 onpass="Flow status is correct!",
365 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800366
367
368 def CASE4( self, main ):
369 '''
370 Ping test in data plane for each route
371 '''
372 main.case( "Ping test for each route, all hosts behind BGP peers" )
373 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800374 hosts=["host64514", "host64515", "host64516"],
375 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800376
377
378 def CASE5( self, main ):
379 '''
380 Cut links to peers one by one, check routes/intents
381 '''
382 import time
383 main.case( "Bring down links and check routes/intents" )
384 main.step( "Bring down the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800385 linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514",
386 OPTION="down" )
pingping-lin3806f112016-01-04 10:38:25 -0800387 # When bring down a link, Mininet will bring down both the interfaces
388 # at the two sides of the link. Here we do not want to bring down the
389 # host side interface, since I noticed when bring up in CASE6, some of
390 # the configuration information will lost.
Jon Hall6e9897d2016-02-29 14:41:32 -0800391 utilities.assertEquals( expect=main.TRUE,
392 actual=linkResult1,
393 onpass="Bring down link succeeded!",
394 onfail="Bring down link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800395
396 if linkResult1 == main.TRUE:
397 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
398 main.Functions.checkRouteNum( main, 2 )
399 main.Functions.checkM2SintentNum( main, 2 )
400 else:
401 main.log.error( "Bring down link failed!" )
402 main.cleanup()
403 main.exit()
404
405 main.step( "Bring down the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800406 linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515",
407 OPTION="down" )
408 utilities.assertEquals( expect=main.TRUE,
409 actual=linkResult2,
410 onpass="Bring down link succeeded!",
411 onfail="Bring down link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800412 if linkResult2 == main.TRUE:
413 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
414 main.Functions.checkRouteNum( main, 1 )
415 main.Functions.checkM2SintentNum( main, 1 )
416 else:
417 main.log.error( "Bring down link failed!" )
418 main.cleanup()
419 main.exit()
420
421 main.step( "Bring down the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800422 linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516",
423 OPTION="down" )
424 utilities.assertEquals( expect=main.TRUE,
425 actual=linkResult3,
426 onpass="Bring down link succeeded!",
427 onfail="Bring down link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800428 if linkResult3 == main.TRUE:
429 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
430 main.Functions.checkRouteNum( main, 0 )
431 main.Functions.checkM2SintentNum( main, 0 )
432 else:
433 main.log.error( "Bring down link failed!" )
434 main.cleanup()
435 main.exit()
436
437 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800438 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
439 main.FALSE,
440 kwargs={'isPENDING':False},
441 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800442 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800443 expect=main.TRUE,
444 actual=flowCheck,
445 onpass="Flow status is correct!",
446 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800447
448 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800449 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
450 peers=["pr64514", "pr64515", "pr64516"],
451 expectAllSuccess=False )
pingping-lin26990f02015-11-30 15:48:06 -0800452 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800453 hosts=["host64514", "host64515", "host64516"],
454 expectAllSuccess=False )
pingping-lin26990f02015-11-30 15:48:06 -0800455
456
457 def CASE6( self, main ):
458 '''
459 Recover links to peers one by one, check routes/intents
460 '''
461 import time
462 main.case( "Bring up links and check routes/intents" )
463 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800464 linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514",
465 OPTION="up" )
466 utilities.assertEquals( expect=main.TRUE,
467 actual=linkResult1,
468 onpass="Bring up link succeeded!",
469 onfail="Bring up link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800470 if linkResult1 == main.TRUE:
471 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
472 main.Functions.checkRouteNum( main, 1 )
473 main.Functions.checkM2SintentNum( main, 1 )
474 else:
475 main.log.error( "Bring up link failed!" )
476 main.cleanup()
477 main.exit()
478
479 main.step( "Bring up the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800480 linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515",
481 OPTION="up" )
482 utilities.assertEquals( expect=main.TRUE,
483 actual=linkResult2,
484 onpass="Bring up link succeeded!",
485 onfail="Bring up link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800486 if linkResult2 == main.TRUE:
487 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
488 main.Functions.checkRouteNum( main, 2 )
489 main.Functions.checkM2SintentNum( main, 2 )
490 else:
491 main.log.error( "Bring up link failed!" )
492 main.cleanup()
493 main.exit()
494
495 main.step( "Bring up the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800496 linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516",
497 OPTION="up" )
498 utilities.assertEquals( expect=main.TRUE,
499 actual=linkResult3,
500 onpass="Bring up link succeeded!",
501 onfail="Bring up link failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800502 if linkResult3 == main.TRUE:
503 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
504 main.Functions.checkRouteNum( main, 3 )
505 main.Functions.checkM2SintentNum( main, 3 )
506 else:
507 main.log.error( "Bring up link failed!" )
508 main.cleanup()
509 main.exit()
510
511 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800512 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
513 main.FALSE,
514 kwargs={'isPENDING':False},
515 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800516 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800517 expect=main.TRUE,
518 actual=flowCheck,
519 onpass="Flow status is correct!",
520 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800521
522 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800523 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
524 peers=["pr64514", "pr64515", "pr64516"],
525 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800526 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800527 hosts=["host64514", "host64515", "host64516"],
528 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800529
530
531 def CASE7( self, main ):
532 '''
533 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
534 '''
535 import time
536 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
537 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800538 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
539 utilities.assertEquals( expect=main.TRUE, actual=result,
540 onpass="Stopping switch succeeded!",
541 onfail="Stopping switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800542
543 if result == main.TRUE:
544 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
545 main.Functions.checkRouteNum( main, 2 )
546 main.Functions.checkM2SintentNum( main, 2 )
547 main.Functions.checkP2PintentNum( main, 12 * 2 )
548 else:
549 main.log.error( "Stopping switch failed!" )
550 main.cleanup()
551 main.exit()
552
553 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800554 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
555 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
556 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-lin26990f02015-11-30 15:48:06 -0800557
558 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
559 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800560 utilities.assert_equals( expect=True, actual=pingResult1,
561 onpass="Ping test result is correct",
562 onfail="Ping test result is wrong" )
pingping-lin26990f02015-11-30 15:48:06 -0800563
564 if pingResult1 == False:
565 main.cleanup()
566 main.exit()
567
568 main.step( "Check ping between BGP peers and speaker1" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800569 result4 = main.Mininet.pingHost( src="speaker1", target="pr64514" )
570 result5 = main.Mininet.pingHost( src="speaker1", target="pr64515" )
571 result6 = main.Mininet.pingHost( src="speaker1", target="pr64516" )
pingping-lin26990f02015-11-30 15:48:06 -0800572
573 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
574 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800575 utilities.assert_equals( expect=True, actual=pingResult2,
576 onpass="Speaker1 ping peers successful",
577 onfail="Speaker1 ping peers NOT successful" )
pingping-lin26990f02015-11-30 15:48:06 -0800578
579 if pingResult2 == False:
580 main.cleanup()
581 main.exit()
582
583 main.step( "Check ping between BGP peers and speaker2" )
584 # TODO
Jon Hall6e9897d2016-02-29 14:41:32 -0800585 result7 = main.Mininet.pingHost( src="speaker2", target=pr64514 )
586 result8 = main.Mininet.pingHost( src="speaker2", target=pr64515 )
587 result9 = main.Mininet.pingHost( src="speaker2", target=pr64516 )
pingping-lin26990f02015-11-30 15:48:06 -0800588
589 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
590 and ( result9 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800591 utilities.assert_equals( expect=True, actual=pingResult2,
592 onpass="Speaker2 ping peers successful",
593 onfail="Speaker2 ping peers NOT successful" )
pingping-lin26990f02015-11-30 15:48:06 -0800594
595 if pingResult3 == False:
596 main.cleanup()
597 main.exit()
598
599 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800600 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
601 main.FALSE,
602 kwargs={'isPENDING':False},
603 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800604 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800605 expect=main.TRUE,
606 actual=flowCheck,
607 onpass="Flow status is correct!",
608 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800609
610
611 def CASE8( self, main ):
612 '''
613 Bring up the edge switch (sw32) which was shut down in CASE7,
614 check P-2-P and M-2-S intents, ping test
615 '''
616 import time
617 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
618 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800619 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-lin26990f02015-11-30 15:48:06 -0800620 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800621 expect=main.TRUE,
622 actual=result1,
623 onpass="Starting switch succeeded!",
624 onfail="Starting switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800625
pingping-lin3806f112016-01-04 10:38:25 -0800626 result2 = main.Mininet.assignSwController( "sw32", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800627 port=fsfwPort )
pingping-lin26990f02015-11-30 15:48:06 -0800628 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800629 expect=main.TRUE,
630 actual=result2,
631 onpass="Connect switch to FSFW succeeded!",
632 onfail="Connect switch to FSFW failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800633
634 if result1 and result2:
635 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
636 main.Functions.checkRouteNum( main, 3 )
637 main.Functions.checkM2SintentNum( main, 3 )
638 main.Functions.checkP2PintentNum( main, 18 * 2 )
639 else:
640 main.log.error( "Starting switch failed!" )
641 main.cleanup()
642 main.exit()
643
644 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800645 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
646 main.FALSE,
647 kwargs={'isPENDING':False},
648 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800649 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800650 expect=main.TRUE,
651 actual=flowCheck,
652 onpass="Flow status is correct!",
653 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800654
655 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800656 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
657 peers=["pr64514", "pr64515", "pr64516"],
658 expectAllSuccess=True )
659 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
660 peers=[pr64514, pr64515, pr64516],
661 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800662 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800663 hosts=["host64514", "host64515", "host64516"],
664 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800665
666
667 def CASE9( self, main ):
668 '''
669 Bring down a switch in best path, check:
670 route number, P2P intent number, M2S intent number, ping test
671 '''
672 main.case( "Stop sw11 located in best path, \
673 check route number, P2P intent number, M2S intent number, ping test" )
674
675 main.log.info( "Check the flow number correctness before stopping sw11" )
676 main.Functions.checkFlowNum( main, "sw11", 19 )
677 main.Functions.checkFlowNum( main, "sw1", 3 )
678 main.Functions.checkFlowNum( main, "sw7", 3 )
679 main.log.info( main.Mininet.checkFlows( "sw11" ) )
680 main.log.info( main.Mininet.checkFlows( "sw1" ) )
681 main.log.info( main.Mininet.checkFlows( "sw7" ) )
682
683 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800684 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
685 utilities.assertEquals( expect=main.TRUE, actual=result,
686 onpass="Stopping switch succeeded!",
687 onfail="Stopping switch failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800688 if result:
689 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
690 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
691 main.Functions.checkRouteNum( main, 3 )
692 main.Functions.checkM2SintentNum( main, 3 )
693 main.Functions.checkP2PintentNum( main, 18 * 2 )
694 else:
695 main.log.error( "Stopping switch failed!" )
696 main.cleanup()
697 main.exit()
698
699 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800700 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
701 main.FALSE,
702 kwargs={'isPENDING':False},
703 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800704 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800705 expect=main.TRUE,
706 actual=flowCheck,
707 onpass="Flow status is correct!",
708 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800709 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800710 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
711 peers=["pr64514", "pr64515", "pr64516"],
712 expectAllSuccess=True )
713 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
714 peers=[pr64514, pr64515, pr64516],
715 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800716 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800717 hosts=["host64514", "host64515", "host64516"],
718 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800719
720
721 def CASE10( self, main ):
722 '''
723 Bring up the switch which was stopped in CASE9, check:
724 route number, P2P intent number, M2S intent number, ping test
725 '''
726 main.case( "Start sw11 which was stopped in CASE9, \
727 check route number, P2P intent number, M2S intent number, ping test" )
728
729 main.log.info( "Check the flow status before starting sw11" )
730 main.Functions.checkFlowNum( main, "sw1", 17 )
731 main.Functions.checkFlowNum( main, "sw7", 5 )
732 main.log.info( main.Mininet.checkFlows( "sw1" ) )
733 main.log.info( main.Mininet.checkFlows( "sw7" ) )
734
735 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800736 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
737 utilities.assertEquals( expect=main.TRUE, actual=result1,
738 onpass="Starting switch succeeded!",
739 onfail="Starting switch failed!" )
pingping-lin3806f112016-01-04 10:38:25 -0800740 result2 = main.Mininet.assignSwController( "sw11", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800741 port=fsfwPort )
742 utilities.assertEquals( expect=main.TRUE, actual=result2,
743 onpass="Connect switch to FSFW succeeded!",
744 onfail="Connect switch to FSFW failed!" )
pingping-lin26990f02015-11-30 15:48:06 -0800745 if result1 and result2:
746 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
747 main.Functions.checkRouteNum( main, 3 )
748 main.Functions.checkM2SintentNum( main, 3 )
749 main.Functions.checkP2PintentNum( main, 18 * 2 )
750
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 )
pingping-lin26990f02015-11-30 15:48:06 -0800764 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800765 expect=main.TRUE,
766 actual=flowCheck,
767 onpass="Flow status is correct!",
768 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800769 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800770 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
771 peers=["pr64514", "pr64515", "pr64516"],
772 expectAllSuccess=True )
773 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
774 peers=[pr64514, pr64515, pr64516],
775 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800776 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800777 hosts=["host64514", "host64515", "host64516"],
778 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800779
780
781 def CASE11(self, main):
782 import time
783 main.case( "Kill speaker1, check:\
784 route number, P2P intent number, M2S intent number, ping test" )
785 main.log.info( "Check network status before killing speaker1" )
786 main.Functions.checkRouteNum( main, 3 )
787 main.Functions.checkM2SintentNum( main, 3 )
788 main.Functions.checkP2PintentNum( main, 18 * 2 )
789 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800790 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
791 main.FALSE,
792 kwargs={'isPENDING':False},
793 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800794 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800795 expect=main.TRUE,
796 actual=flowCheck,
797 onpass="Flow status is correct!",
798 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800799
Jon Hall6e9897d2016-02-29 14:41:32 -0800800 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
801 peers=["pr64514", "pr64515", "pr64516"],
802 expectAllSuccess=True )
803 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
804 peers=[pr64514, pr64515, pr64516],
805 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800806 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800807 hosts=["host64514", "host64515", "host64516"],
808 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800809
810 main.step( "Kill speaker1" )
811 command1 = "ps -e | grep bgp -c"
812 result1 = main.Mininet.node( "root", command1 )
813
814 # The total BGP daemon number in this test environment is 5.
815 if "5" in result1:
816 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
817 else:
818 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
819 main.log.info( result1 )
820
821 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
822 result2 = main.Mininet.node( "root", command2 )
823
824 result3 = main.Mininet.node( "root", command1 )
825
Jon Hall6e9897d2016-02-29 14:41:32 -0800826 utilities.assert_equals( expect=True,
827 actual=( "4" in result3 ),
828 onpass="Kill speaker1 succeeded",
829 onfail="Kill speaker1 failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800830 if ( "4" not in result3 ) :
831 main.log.info( result3 )
832 main.cleanup()
833 main.exit()
834
835 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
836 main.Functions.checkRouteNum( main, 3 )
837 main.Functions.checkM2SintentNum( main, 3 )
838 main.Functions.checkP2PintentNum( main, 18 * 2 )
839
840 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800841 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
842 main.FALSE,
843 kwargs={'isPENDING':False},
844 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800845 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800846 expect=main.TRUE,
847 actual=flowCheck,
848 onpass="Flow status is correct!",
849 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800850
851 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800852 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
853 peers=["pr64514", "pr64515", "pr64516"],
854 expectAllSuccess=False )
pingping-lin26990f02015-11-30 15:48:06 -0800855 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800856 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
857 peers=[pr64514, pr64515, pr64516],
858 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800859 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800860 hosts=["host64514", "host64515", "host64516"],
861 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800862
863
864 def CASE12( self, main ):
865 import time
866 import json
867 main.case( "Bring down leader ONOS node, check: \
868 route number, P2P intent number, M2S intent number, ping test" )
869 main.step( "Find out ONOS leader node" )
870 result = main.ONOScli1.leaders()
871 jsonResult = json.loads( result )
872 leaderIP = ""
873 for entry in jsonResult:
874 if entry["topic"] == "org.onosproject.sdnip":
875 leaderIP = entry["leader"]
876 main.log.info( "leaderIP is: " )
877 main.log.info( leaderIP )
878
879 main.step( "Uninstall ONOS/SDN-IP leader node" )
880 if leaderIP == ONOS1Ip:
881 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
882 elif leaderIP == ONOS2Ip:
883 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
884 else:
885 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
886
Jon Hall6e9897d2016-02-29 14:41:32 -0800887 utilities.assert_equals( expect=main.TRUE,
888 actual=uninstallResult,
889 onpass="Uninstall ONOS leader succeeded",
890 onfail="Uninstall ONOS leader failed" )
pingping-lin26990f02015-11-30 15:48:06 -0800891 if uninstallResult != main.TRUE:
892 main.cleanup()
893 main.exit()
894 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
895
896 if leaderIP == ONOS1Ip:
Jon Hall6e9897d2016-02-29 14:41:32 -0800897 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
898 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
899 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
pingping-lin26990f02015-11-30 15:48:06 -0800900
901 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800902 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
903 main.FALSE,
904 kwargs={'isPENDING':False},
905 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800906 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800907 expect=main.TRUE,
908 actual=flowCheck,
909 onpass="Flow status is correct!",
910 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800911 else:
912 main.Functions.checkRouteNum( main, 3 )
913 main.Functions.checkM2SintentNum( main, 3 )
914 main.Functions.checkP2PintentNum( main, 18 * 2 )
915
916 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800917 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
918 main.FALSE,
919 kwargs={'isPENDING':False},
920 attempts=10 )
pingping-lin26990f02015-11-30 15:48:06 -0800921 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800922 expect=main.TRUE,
923 actual=flowCheck,
924 onpass="Flow status is correct!",
925 onfail="Flow status is wrong!" )
pingping-lin26990f02015-11-30 15:48:06 -0800926
Jon Hall6e9897d2016-02-29 14:41:32 -0800927 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
928 peers=["pr64514", "pr64515", "pr64516"],
929 expectAllSuccess=True )
930 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
931 peers=[pr64514, pr64515, pr64516],
932 expectAllSuccess=True )
pingping-lin26990f02015-11-30 15:48:06 -0800933 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800934 hosts=["host64514", "host64515", "host64516"],
935 expectAllSuccess=True )