blob: 983ac75631ae1a2a077e2d9836d77b8f9041e1dc [file] [log] [blame]
pingping-lin28e7b212015-09-10 10:14:58 -07001# Testing the functionality of SDN-IP with single ONOS instance
pingping-lin5bb663b2015-09-24 11:47:50 -07002class USECASE_SdnipFunction:
pingping-lin28e7b212015-09-10 10:14:58 -07003
4 def __init__( self ):
5 self.default = ''
6 global branchName
7
pingping-linb702c602015-09-10 17:00:29 -07008 def CASE100( self, main ):
9 """
10 Start mininet
11 """
12 import os
Jon Hall70b768c2016-04-19 08:38:29 -070013 main.case( "Setup the Mininet testbed" )
pingping-linb702c602015-09-10 17:00:29 -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-linb702c602015-09-10 17:00:29 -070025 # Exit if topology did not load properly
26 if not topoResult:
27 main.cleanup()
28 main.exit()
pingping-lin5bb663b2015-09-24 11:47:50 -070029 main.step( "Connect switches to controller" )
30
31 global ONOS1Ip
32 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
33 # connect all switches to controller
34 swResult = main.TRUE
35 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
36 sw = "sw%s" % ( i )
37 swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -080038 utilities.assert_equals( expect=main.TRUE,
39 actual=swResult,
40 onpass="Successfully connect all switches to ONOS",
41 onfail="Failed to connect all switches to ONOS" )
pingping-lin5bb663b2015-09-24 11:47:50 -070042 if not swResult:
43 main.cleanup()
44 main.exit()
45
46 main.step( "Set up tunnel from Mininet node to onos node" )
47 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip )
48 command = 'ssh -nNT -o "PasswordAuthentication no" \
49 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, ONOS1Ip )
50
51 tunnelResult = main.TRUE
52 tunnelResult = main.Mininet.node( "root", command )
Jon Hall6e9897d2016-02-29 14:41:32 -080053 utilities.assert_equals( expect=True,
54 actual=( "PasswordAuthentication" in tunnelResult ),
55 onpass="Created tunnel succeeded",
56 onfail="Create tunnel failed" )
pingping-linb3ebd3f2015-09-28 22:17:05 -070057 if ("PasswordAuthentication" not in tunnelResult) :
pingping-lin5bb663b2015-09-24 11:47:50 -070058 main.cleanup()
59 main.exit()
pingping-lin5bb663b2015-09-24 11:47:50 -070060
pingping-linb702c602015-09-10 17:00:29 -070061 def CASE101( self, main ):
pingping-lin28e7b212015-09-10 10:14:58 -070062 """
pingping-linea32cf82015-10-08 22:37:37 -070063 Package ONOS and install it
pingping-lin28e7b212015-09-10 10:14:58 -070064 Startup sequence:
65 cell <name>
66 onos-verify-cell
pingping-lin28e7b212015-09-10 10:14:58 -070067 onos-package
68 onos-install -f
69 onos-wait-for-start
70 """
pingping-lin28e7b212015-09-10 10:14:58 -070071 import time
Jon Hall6e9897d2016-02-29 14:41:32 -080072 import os
pingping-lin28e7b212015-09-10 10:14:58 -070073
Jon Hall6e9897d2016-02-29 14:41:32 -080074 main.case( "Setting up ONOS environment" )
pingping-lin28e7b212015-09-10 10:14:58 -070075
76 cellName = main.params[ 'ENV' ][ 'cellName' ]
Jon Hall6e9897d2016-02-29 14:41:32 -080077 global ONOS1Ip
78 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
79 ipList = [ ONOS1Ip ]
80
Jon Hall70b768c2016-04-19 08:38:29 -070081 main.step( "Copying config files" )
82 src = os.path.dirname( main.testFile ) + "/network-cfg.json"
83 dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json"
84 status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" )
85 utilities.assert_equals( expect=main.TRUE,
86 actual=status,
87 onpass="Copy config file succeeded",
88 onfail="Copy config file failed" )
89
Jon Hall6e9897d2016-02-29 14:41:32 -080090 main.step( "Create cell file" )
91 cellAppString = main.params[ 'ENV' ][ 'appString' ]
92 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
93 main.Mininet.ip_address,
Devin Lim461f0872017-06-05 16:49:33 -070094 cellAppString, ipList, main.ONOScli1.user_name )
pingping-lin28e7b212015-09-10 10:14:58 -070095
96 main.step( "Applying cell variable to environment" )
97 cellResult = main.ONOSbench.setCell( cellName )
Jon Hall6e9897d2016-02-29 14:41:32 -080098 utilities.assert_equals( expect=main.TRUE,
99 actual=cellResult,
100 onpass="Set cell succeeded",
101 onfail="Set cell failed" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700102
Jon Hall70b768c2016-04-19 08:38:29 -0700103 main.step( "Verify cell connectivity" )
pingping-lin28e7b212015-09-10 10:14:58 -0700104 verifyResult = main.ONOSbench.verifyCell()
Jon Hall6e9897d2016-02-29 14:41:32 -0800105 utilities.assert_equals( expect=main.TRUE,
106 actual=verifyResult,
107 onpass="Verify cell succeeded",
108 onfail="Verify cell failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700109
110 branchName = main.ONOSbench.getBranchName()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700111 main.log.report( "ONOS is on branch: " + branchName )
pingping-lin28e7b212015-09-10 10:14:58 -0700112
Jon Hall6509dbf2016-06-21 17:01:17 -0700113 main.step( "Uninstalling ONOS" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700114 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -0800115 utilities.assert_equals( expect=main.TRUE,
116 actual=uninstallResult,
117 onpass="Uninstall ONOS succeeded",
118 onfail="Uninstall ONOS failed" )
pingping-linaede0312015-09-30 17:53:19 -0700119 '''
pingping-lin28e7b212015-09-10 10:14:58 -0700120 main.step( "Git pull" )
121 gitPullResult = main.ONOSbench.gitPull()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700122 main.log.info( "gitPullResult" )
123 main.log.info( gitPullResult )
124 gitPullResult2 = ( gitPullResult == main.TRUE ) or ( gitPullResult == 3 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800125 utilities.assert_equals( expect=True,
126 actual=gitPullResult2,
127 onpass="Git pull ONOS succeeded",
128 onfail="Git pull ONOS failed" )
pingping-linaede0312015-09-30 17:53:19 -0700129 '''
pingping-lin28e7b212015-09-10 10:14:58 -0700130
Jon Hall6e9897d2016-02-29 14:41:32 -0800131 main.ONOSbench.getVersion( report=True )
pingping-lin28e7b212015-09-10 10:14:58 -0700132
133 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700134 packageResult = main.ONOSbench.buckBuild()
Jon Hall6e9897d2016-02-29 14:41:32 -0800135 utilities.assert_equals( expect=main.TRUE,
136 actual=packageResult,
137 onpass="Package ONOS succeeded",
138 onfail="Package ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700139
140 main.step( "Installing ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800141 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
142 node=ONOS1Ip )
143 utilities.assert_equals( expect=main.TRUE,
144 actual=onos1InstallResult,
145 onpass="Install ONOS succeeded",
146 onfail="Install ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700147
Chiyu Chengef109502016-11-21 15:51:38 -0800148 main.step( "Set up ONOS secure SSH" )
149 secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
150 utilities.assert_equals( expect=main.TRUE,
151 actual=secureSshResult,
152 onpass="Set up ONOS secure SSH succeeded",
153 onfail="Set up ONOS secure SSH failed " )
154
You Wangf5de25b2017-01-06 15:13:01 -0800155 main.step( "Checking if ONOS is up yet" )
156 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
157 utilities.assert_equals( expect=main.TRUE,
158 actual=onos1UpResult,
159 onpass="ONOS is up",
160 onfail="ONOS is NOT up" )
161
pingping-linb3ebd3f2015-09-28 22:17:05 -0700162 main.step( "Checking if ONOS CLI is ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700163 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800164 commandlineTimeout=100, onosStartTimeout=600 )
165 utilities.assert_equals( expect=main.TRUE,
166 actual=cliResult,
167 onpass="ONOS CLI is ready",
168 onfail="ONOS CLI is not ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700169
Jon Hall6e9897d2016-02-29 14:41:32 -0800170 for i in range( 10 ):
171 ready = True
172 output = main.ONOScli.summary()
173 if not output:
174 ready = False
175 if ready:
176 break
177 time.sleep( 30 )
178 utilities.assert_equals( expect=True, actual=ready,
179 onpass="ONOS summary command succeded",
180 onfail="ONOS summary command failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700181
Jon Hall6e9897d2016-02-29 14:41:32 -0800182 if not ready:
183 main.log.error( "ONOS startup failed!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700184 main.cleanup()
185 main.exit()
186
Jon Hall6e9897d2016-02-29 14:41:32 -0800187 def CASE200( self, main ):
alisone4121a92016-11-22 16:31:36 -0800188 import json
189 import time
190
Jon Hall6e9897d2016-02-29 14:41:32 -0800191 main.case( "Activate sdn-ip application" )
192 main.log.info( "waiting link discovery......" )
193 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
194
pingping-linb3ebd3f2015-09-28 22:17:05 -0700195 main.log.info( "Get links in the network" )
pingping-lin3f091d62015-09-29 12:00:05 -0700196 summaryResult = main.ONOScli.summary()
197 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall6e9897d2016-02-29 14:41:32 -0800198 listResult = main.ONOScli.links( jsonFormat=False )
199 main.log.info( listResult )
pingping-lin3f091d62015-09-29 12:00:05 -0700200 if linkNum < 100:
Jon Hall6e9897d2016-02-29 14:41:32 -0800201 main.log.error( "Link number is wrong!" )
202 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
203 listResult = main.ONOScli.links( jsonFormat=False )
pingping-lin3f091d62015-09-29 12:00:05 -0700204 main.log.info( listResult )
205 main.cleanup()
206 main.exit()
207
pingping-linb3ebd3f2015-09-28 22:17:05 -0700208 main.step( "Activate sdn-ip application" )
209 activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800210 utilities.assert_equals( expect=main.TRUE,
211 actual=activeSDNIPresult,
212 onpass="Activate SDN-IP succeeded",
213 onfail="Activate SDN-IP failed" )
pingping-lin3f091d62015-09-29 12:00:05 -0700214 if not activeSDNIPresult:
215 main.log.info( "Activate SDN-IP failed!" )
216 main.cleanup()
217 main.exit()
218
pingping-linb3ebd3f2015-09-28 22:17:05 -0700219
220 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
pingping-linb702c602015-09-10 17:00:29 -0700221 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700222 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700223 main.log.info( "Wait Quagga to finish delivery all routes to each \
224 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700225 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
226 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
227
228
pingping-lin4f80c492015-09-15 14:34:42 -0700229 def CASE102( self, main ):
230 '''
231 This test case is to load the methods from other Python files.
232 '''
alisone4121a92016-11-22 16:31:36 -0800233 import imp
234
pingping-linb3ebd3f2015-09-28 22:17:05 -0700235 main.case( "Loading methods from other Python file" )
pingping-lin4f80c492015-09-15 14:34:42 -0700236 # load the methods from other file
237 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
238 main.Functions = imp.load_source( wrapperFile,
239 main.dependencyPath +
240 wrapperFile +
241 ".py" )
242
243
pingping-lin0ce60622015-09-10 14:37:33 -0700244 def CASE1( self, main ):
245 '''
alisone4121a92016-11-22 16:31:36 -0800246 ping test from 7 bgp peers to BGP speaker
pingping-lin0ce60622015-09-10 14:37:33 -0700247 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700248
pingping-linb3ebd3f2015-09-28 22:17:05 -0700249 main.case( "Ping tests between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800250 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk1" ],
251 peers=[ "p64514", "p64515", "p64516" ],
252 expectAllSuccess=True )
pingping-lin0ce60622015-09-10 14:37:33 -0700253
alisone4121a92016-11-22 16:31:36 -0800254 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk2" ],
255 peers=[ "p64517", "p64518" ],
256 expectAllSuccess=True )
257
258 main.Functions.pingSpeakerToPeer( main, speakers=[ "spk3" ],
259 peers=[ "p64519", "p64520" ],
260 expectAllSuccess=True )
pingping-lin950b50d2015-09-14 12:00:08 -0700261
pingping-lin0ce60622015-09-10 14:37:33 -0700262 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
alisone4121a92016-11-22 16:31:36 -0800267 from operator import eq
268
pingping-linb3ebd3f2015-09-28 22:17:05 -0700269 main.case( "Check point-to-point intents" )
pingping-lin0ce60622015-09-10 14:37:33 -0700270 main.log.info( "There are %s BGP peers in total "
271 % main.params[ 'config' ][ 'peerNum' ] )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700272 main.step( "Check P2P intents number from ONOS CLI" )
pingping-lin0ce60622015-09-10 14:37:33 -0700273
Jon Hall6e9897d2016-02-29 14:41:32 -0800274 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin0ce60622015-09-10 14:37:33 -0700275 bgpIntentsActualNum = \
276 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
277 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
Jon Hall6e9897d2016-02-29 14:41:32 -0800278 if bgpIntentsActualNum != bgpIntentsExpectedNum:
279 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700280 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800281 bgpIntentsActualNum = \
282 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
pingping-lin0ce60622015-09-10 14:37:33 -0700283 main.log.info( "bgpIntentsExpected num is:" )
284 main.log.info( bgpIntentsExpectedNum )
285 main.log.info( "bgpIntentsActual num is:" )
286 main.log.info( bgpIntentsActualNum )
287 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800288 expect=True,
289 actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
290 onpass="PointToPointIntent Intent Num is correct!",
291 onfail="PointToPointIntent Intent Num is wrong!" )
pingping-lin0ce60622015-09-10 14:37:33 -0700292
293
294 def CASE3( self, main ):
295 '''
296 routes and intents check to all BGP peers
297 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800298 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700299 main.case( "Check routes and M2S intents to all BGP peers" )
pingping-lin0ce60622015-09-10 14:37:33 -0700300
pingping-lin28e7b212015-09-10 10:14:58 -0700301 allRoutesExpected = []
302 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
303 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
304 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
305
alisone4121a92016-11-22 16:31:36 -0800306 allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" )
307 allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" )
308 allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
309 allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
310
Jon Hall6e9897d2016-02-29 14:41:32 -0800311 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-lin28e7b212015-09-10 10:14:58 -0700312 allRoutesActual = \
313 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
314 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
315 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800316 if allRoutesStrActual != allRoutesStrExpected:
317 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700318 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800319 allRoutesActual = \
320 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
321 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
pingping-lin28e7b212015-09-10 10:14:58 -0700322
323 main.step( "Check routes installed" )
324 main.log.info( "Routes expected:" )
325 main.log.info( allRoutesStrExpected )
326 main.log.info( "Routes get from ONOS CLI:" )
327 main.log.info( allRoutesStrActual )
328 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800329 expect=allRoutesStrExpected, actual=allRoutesStrActual,
330 onpass="Routes are correct!",
331 onfail="Routes are wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700332
pingping-linb3ebd3f2015-09-28 22:17:05 -0700333 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800334 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin28e7b212015-09-10 10:14:58 -0700335 routeIntentsActualNum = \
336 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
alisone4121a92016-11-22 16:31:36 -0800337 routeIntentsExpectedNum = 7
Jon Hall6e9897d2016-02-29 14:41:32 -0800338 if routeIntentsActualNum != routeIntentsExpectedNum:
339 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallfabd7e52016-04-19 19:20:59 -0700340 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
Jon Hall6e9897d2016-02-29 14:41:32 -0800341 routeIntentsActualNum = \
342 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-lin28e7b212015-09-10 10:14:58 -0700343
344 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
345 main.log.info( routeIntentsExpectedNum )
346 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
347 main.log.info( routeIntentsActualNum )
348 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800349 expect=routeIntentsExpectedNum,
350 actual=routeIntentsActualNum,
351 onpass="MultiPointToSinglePoint Intent Num is correct!",
352 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700353
pingping-linbab7f8a2015-09-21 17:33:36 -0700354 main.step( "Check whether all flow status are ADDED" )
Jon Hall1aa05602016-04-05 10:25:39 -0700355 flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800356 main.FALSE,
357 kwargs={'isPENDING':False},
358 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700359 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800360 expect=main.TRUE,
361 actual=flowCheck,
362 onpass="Flow status is correct!",
363 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700364
pingping-lin950b50d2015-09-14 12:00:08 -0700365
366 def CASE4( self, main ):
367 '''
368 Ping test in data plane for each route
369 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700370 main.case( "Ping test for each route, all hosts behind BGP peers" )
alisone4121a92016-11-22 16:31:36 -0800371 #No vlan
pingping-lin829428d2015-09-22 20:50:00 -0700372 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800373 hosts=[ "h64514", "h64515", "h64516" ],
374 expectAllSuccess=True )
375 #vlan 10
376 main.Functions.pingHostToHost( main,
377 hosts=[ "h64519", "h64520" ],
378 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700379
alisone4121a92016-11-22 16:31:36 -0800380 # vlan 20
381 main.Functions.pingHostToHost( main,
382 hosts=[ "h64517", "h64518" ],
383 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700384
385 def CASE5( self, main ):
386 '''
387 Cut links to peers one by one, check routes/intents
388 '''
389 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700390 main.case( "Bring down links and check routes/intents" )
alisone4121a92016-11-22 16:31:36 -0800391 main.step( "Bring down the link between sw32 and p64514" )
392 linkResult1 = main.Mininet.link( END1="sw32", END2="p64514",
Jon Hall6e9897d2016-02-29 14:41:32 -0800393 OPTION="down" )
394 utilities.assertEquals( expect=main.TRUE,
395 actual=linkResult1,
396 onpass="Bring down link succeeded!",
397 onfail="Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700398
399 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700400 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800401 main.Functions.checkRouteNum( main, 6 ) #We have 7 links between peers and sw. After one link down, 7-1=6.
402 main.Functions.checkM2SintentNum( main, 6 )
pingping-lin4f80c492015-09-15 14:34:42 -0700403 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800404 main.log.error( "Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700405 main.cleanup()
406 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700407
alisone4121a92016-11-22 16:31:36 -0800408 main.step( "Bring down the link between sw8 and p64515" )
409 linkResult2 = main.Mininet.link( END1="sw8", END2="p64515",
Jon Hall6e9897d2016-02-29 14:41:32 -0800410 OPTION="down" )
411 utilities.assertEquals( expect=main.TRUE,
412 actual=linkResult2,
413 onpass="Bring down link succeeded!",
414 onfail="Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700415 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700416 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800417 main.Functions.checkRouteNum( main, 5 ) #2 links down, 7-2=5.
418 main.Functions.checkM2SintentNum( main, 5 )
pingping-lin4f80c492015-09-15 14:34:42 -0700419 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800420 main.log.error( "Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700421 main.cleanup()
422 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700423
alisone4121a92016-11-22 16:31:36 -0800424 main.step( "Bring down the link between sw28 and p64516" )
425 linkResult3 = main.Mininet.link( END1="sw28", END2="p64516",
Jon Hall6e9897d2016-02-29 14:41:32 -0800426 OPTION="down" )
427 utilities.assertEquals( expect=main.TRUE,
428 actual=linkResult3,
429 onpass="Bring down link succeeded!",
430 onfail="Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700431 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700432 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800433 main.Functions.checkRouteNum( main, 4 ) #3 links downs 7-3=4
434 main.Functions.checkM2SintentNum( main, 4 )
pingping-lin4f80c492015-09-15 14:34:42 -0700435 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800436 main.log.error( "Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700437 main.cleanup()
438 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700439
pingping-linbab7f8a2015-09-21 17:33:36 -0700440 main.step( "Check whether all flow status are ADDED" )
Jon Hall1aa05602016-04-05 10:25:39 -0700441 flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800442 main.FALSE,
443 kwargs={'isPENDING':False},
444 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700445 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800446 expect=main.TRUE,
447 actual=flowCheck,
448 onpass="Flow status is correct!",
449 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700450
pingping-lin829428d2015-09-22 20:50:00 -0700451 # Ping test
alisone4121a92016-11-22 16:31:36 -0800452 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
453 peers=["p64514", "p64515", "p64516"],
454 expectAllSuccess=False )
455
pingping-lin829428d2015-09-22 20:50:00 -0700456 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800457 hosts=["h64514", "h64515", "h64516"],
458 expectAllSuccess=False )
pingping-lin4f80c492015-09-15 14:34:42 -0700459
pingping-lin829428d2015-09-22 20:50:00 -0700460
461 def CASE6( self, main ):
pingping-lin4f80c492015-09-15 14:34:42 -0700462 '''
463 Recover links to peers one by one, check routes/intents
464 '''
465 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700466 main.case( "Bring up links and check routes/intents" )
alisone4121a92016-11-22 16:31:36 -0800467 main.step( "Bring up the link between sw32 and p64514" )
468 linkResult1 = main.Mininet.link( END1="sw32", END2="p64514",
Jon Hall6e9897d2016-02-29 14:41:32 -0800469 OPTION="up" )
470 utilities.assertEquals( expect=main.TRUE,
471 actual=linkResult1,
472 onpass="Bring up link succeeded!",
473 onfail="Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700474 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700475 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800476 main.Functions.checkRouteNum( main, 5 ) #one links up, 4+1=5
477 main.Functions.checkM2SintentNum( main, 5 )
pingping-lin4f80c492015-09-15 14:34:42 -0700478 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800479 main.log.error( "Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700480 main.cleanup()
481 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700482
alisone4121a92016-11-22 16:31:36 -0800483 main.step( "Bring up the link between sw8 and p64515" )
484 linkResult2 = main.Mininet.link( END1="sw8", END2="p64515",
Jon Hall6e9897d2016-02-29 14:41:32 -0800485 OPTION="up" )
486 utilities.assertEquals( expect=main.TRUE,
487 actual=linkResult2,
488 onpass="Bring up link succeeded!",
489 onfail="Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700490 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700491 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800492 main.Functions.checkRouteNum( main, 6 )
493 main.Functions.checkM2SintentNum( main, 6 )
pingping-lin4f80c492015-09-15 14:34:42 -0700494 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800495 main.log.error( "Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700496 main.cleanup()
497 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700498
alisone4121a92016-11-22 16:31:36 -0800499 main.step( "Bring up the link between sw28 and p64516" )
500 linkResult3 = main.Mininet.link( END1="sw28", END2="p64516",
Jon Hall6e9897d2016-02-29 14:41:32 -0800501 OPTION="up" )
502 utilities.assertEquals( expect=main.TRUE,
503 actual=linkResult3,
504 onpass="Bring up link succeeded!",
505 onfail="Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700506 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700507 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800508 main.Functions.checkRouteNum( main, 7 )
509 main.Functions.checkM2SintentNum( main, 7 )
pingping-lin4f80c492015-09-15 14:34:42 -0700510 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800511 main.log.error( "Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700512 main.cleanup()
513 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700514
515 main.step( "Check whether all flow status are ADDED" )
Jon Hall1aa05602016-04-05 10:25:39 -0700516 flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800517 main.FALSE,
518 kwargs={'isPENDING':False},
519 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700520 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800521 expect=main.TRUE,
522 actual=flowCheck,
523 onpass="Flow status is correct!",
524 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700525
526 # Ping test
alisone4121a92016-11-22 16:31:36 -0800527 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
528 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800529 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700530 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800531 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800532 expectAllSuccess=True )
pingping-lin8244a3b2015-09-16 13:36:56 -0700533
534
pingping-lin829428d2015-09-22 20:50:00 -0700535 def CASE7( self, main ):
pingping-lin8244a3b2015-09-16 13:36:56 -0700536 '''
pingping-lin829428d2015-09-22 20:50:00 -0700537 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
pingping-lin8244a3b2015-09-16 13:36:56 -0700538 '''
539 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700540 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700541 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800542 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
543 utilities.assertEquals( expect=main.TRUE, actual=result,
544 onpass="Stopping switch succeeded!",
545 onfail="Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700546
pingping-lin8244a3b2015-09-16 13:36:56 -0700547 if result == main.TRUE:
548 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800549 main.Functions.checkRouteNum( main, 6 ) #stop one sw, which bring one link between peer and sw down.
550 main.Functions.checkM2SintentNum( main, 6 )
551 main.Functions.checkP2PintentNum( main, 36 ) #6 intents from sw to speakers x 6 intents to sw x 2 intents between them
pingping-lin8244a3b2015-09-16 13:36:56 -0700552 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800553 main.log.error( "Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700554 main.cleanup()
555 main.exit()
pingping-lin8244a3b2015-09-16 13:36:56 -0700556
pingping-lin829428d2015-09-22 20:50:00 -0700557 main.step( "Check ping between hosts behind BGP peers" )
alisone4121a92016-11-22 16:31:36 -0800558 result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
559 result2 = main.Mininet.pingHost( src="h64515", target="h64516" )
560 result3 = main.Mininet.pingHost( src="h64514", target="h64516" )
pingping-lin829428d2015-09-22 20:50:00 -0700561
562 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
563 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800564 utilities.assert_equals( expect=True, actual=pingResult1,
565 onpass="Ping test result is correct",
566 onfail="Ping test result is wrong" )
pingping-lin829428d2015-09-22 20:50:00 -0700567
568 if pingResult1 == False:
569 main.cleanup()
570 main.exit()
571
572 main.step( "Check ping between BGP peers and speakers" )
alisone4121a92016-11-22 16:31:36 -0800573 result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
574 result5 = main.Mininet.pingHost( src="spk1", target="p64515" )
575 result6 = main.Mininet.pingHost( src="spk1", target="p64516" )
pingping-lin829428d2015-09-22 20:50:00 -0700576
577 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
578 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800579 utilities.assert_equals( expect=True, actual=pingResult2,
580 onpass="Speaker1 ping peers successful",
581 onfail="Speaker1 ping peers NOT successful" )
pingping-lin829428d2015-09-22 20:50:00 -0700582
583 if pingResult2 == False:
584 main.cleanup()
585 main.exit()
586
pingping-linbab7f8a2015-09-21 17:33:36 -0700587 main.step( "Check whether all flow status are ADDED" )
Jon Hall1aa05602016-04-05 10:25:39 -0700588 flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800589 main.FALSE,
590 kwargs={'isPENDING':False},
591 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700592 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800593 expect=main.TRUE,
594 actual=flowCheck,
595 onpass="Flow status is correct!",
596 onfail="Flow status is wrong!" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700597
pingping-lind791d342015-09-17 18:34:31 -0700598
pingping-lin8244a3b2015-09-16 13:36:56 -0700599 def CASE8( self, main ):
pingping-lind791d342015-09-17 18:34:31 -0700600 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700601 Bring up the edge switch (sw32) which was shut down in CASE7,
pingping-lind791d342015-09-17 18:34:31 -0700602 check P-2-P and M-2-S intents, ping test
603 '''
604 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700605 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700606 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800607 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700608 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800609 expect=main.TRUE,
610 actual=result1,
611 onpass="Starting switch succeeded!",
612 onfail="Starting switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700613
pingping-lind791d342015-09-17 18:34:31 -0700614 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700615 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800616 expect=main.TRUE,
617 actual=result2,
618 onpass="Connect switch to ONOS succeeded!",
619 onfail="Connect switch to ONOS failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700620
621 if result1 and result2:
622 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800623 main.Functions.checkRouteNum( main, 7 )
624 main.Functions.checkM2SintentNum( main, 7 )
625 main.Functions.checkP2PintentNum( main, 42 )
pingping-lind791d342015-09-17 18:34:31 -0700626 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800627 main.log.error( "Starting switch failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700628 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700629 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700630
pingping-linbab7f8a2015-09-21 17:33:36 -0700631 main.step( "Check whether all flow status are ADDED" )
Jon Hall1aa05602016-04-05 10:25:39 -0700632 flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800633 main.FALSE,
634 kwargs={'isPENDING':False},
635 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700636 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800637 expect=main.TRUE,
638 actual=flowCheck,
639 onpass="Flow status is correct!",
640 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700641
pingping-lin829428d2015-09-22 20:50:00 -0700642 # Ping test
alisone4121a92016-11-22 16:31:36 -0800643 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
644 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800645 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700646 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800647 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800648 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700649
pingping-lin829428d2015-09-22 20:50:00 -0700650
651 def CASE9( self, main ):
pingping-linbab7f8a2015-09-21 17:33:36 -0700652 '''
653 Bring down a switch in best path, check:
654 route number, P2P intent number, M2S intent number, ping test
655 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700656 main.case( "Stop sw11 located in best path, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700657 check route number, P2P intent number, M2S intent number, ping test" )
658
pingping-lin581a3662015-09-29 17:43:39 -0700659 main.log.info( "Check the flow number correctness before stopping sw11" )
alisone4121a92016-11-22 16:31:36 -0800660 main.Functions.checkFlowNum( main, "sw11", 43 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700661 main.Functions.checkFlowNum( main, "sw1", 3 )
alisone4121a92016-11-22 16:31:36 -0800662 main.Functions.checkFlowNum( main, "sw7", 34 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800663 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
664 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
665 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700666
667 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800668 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
669 utilities.assertEquals( expect=main.TRUE, actual=result,
670 onpass="Stopping switch succeeded!",
671 onfail="Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700672 if result:
673 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700674 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800675 main.Functions.checkRouteNum( main, 7 )
676 main.Functions.checkM2SintentNum( main, 7 )
677 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700678 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800679 main.log.error( "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700680 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700681 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700682
683 main.step( "Check whether all flow status are ADDED" )
Jon Hall1aa05602016-04-05 10:25:39 -0700684 flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800685 main.FALSE,
686 kwargs={'isPENDING':False},
687 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700688 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800689 expect=main.TRUE,
690 actual=flowCheck,
691 onpass="Flow status is correct!",
692 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700693 # Ping test
alisone4121a92016-11-22 16:31:36 -0800694 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
695 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800696 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700697 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800698 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800699 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700700
701
702 def CASE10( self, main ):
703 '''
704 Bring up the switch which was stopped in CASE9, check:
705 route number, P2P intent number, M2S intent number, ping test
706 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700707 main.case( "Start sw11 which was stopped in CASE9, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700708 check route number, P2P intent number, M2S intent number, ping test" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700709
pingping-lin581a3662015-09-29 17:43:39 -0700710 main.log.info( "Check the flow status before starting sw11" )
alisone4121a92016-11-22 16:31:36 -0800711 main.Functions.checkFlowNum( main, "sw1", 33 )
712 main.Functions.checkFlowNum( main, "sw7", 28 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800713 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
714 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700715
pingping-linbab7f8a2015-09-21 17:33:36 -0700716 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800717 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
718 utilities.assertEquals( expect=main.TRUE, actual=result1,
719 onpass="Starting switch succeeded!",
720 onfail="Starting switch failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700721 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -0800722 utilities.assertEquals( expect=main.TRUE, actual=result2,
723 onpass="Connect switch to ONOS succeeded!",
724 onfail="Connect switch to ONOS failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700725 if result1 and result2:
pingping-linbab7f8a2015-09-21 17:33:36 -0700726 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
alisone4121a92016-11-22 16:31:36 -0800727 main.Functions.checkRouteNum( main, 7 )
728 main.Functions.checkM2SintentNum( main, 7 )
729 main.Functions.checkP2PintentNum( main, 42 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700730
pingping-lin3f091d62015-09-29 12:00:05 -0700731 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
732 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
733 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700734 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800735 main.log.error( "Starting switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700736 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700737 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700738
739 main.step( "Check whether all flow status are ADDED" )
Jon Hall1aa05602016-04-05 10:25:39 -0700740 flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
Jon Hall6e9897d2016-02-29 14:41:32 -0800741 main.FALSE,
742 kwargs={'isPENDING':False},
743 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700744 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800745 expect=main.TRUE,
746 actual=flowCheck,
747 onpass="Flow status is correct!",
748 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700749 # Ping test
alisone4121a92016-11-22 16:31:36 -0800750 main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
751 peers=["p64514", "p64515", "p64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800752 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700753 main.Functions.pingHostToHost( main,
alisone4121a92016-11-22 16:31:36 -0800754 hosts=["h64514", "h64515", "h64516"],
Jon Hall6e9897d2016-02-29 14:41:32 -0800755 expectAllSuccess=True )