blob: 41bad860f89586bb4e00bd2bc7a4f9f06d2dba87 [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 # This case is to setup Mininet testbed
9 def CASE100( self, main ):
10 """
11 Start mininet
12 """
13 import os
pingping-lin4f80c492015-09-15 14:34:42 -070014 import imp
pingping-linb3ebd3f2015-09-28 22:17:05 -070015 main.log.case( "Setup the Mininet testbed" )
pingping-linb702c602015-09-10 17:00:29 -070016 main.dependencyPath = main.testDir + \
17 main.params[ 'DEPENDENCY' ][ 'path' ]
18 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
19
20 main.step( "Starting Mininet Topology" )
21 topology = main.dependencyPath + main.topology
22 topoResult = main.Mininet.startNet( topoFile = topology )
pingping-linb702c602015-09-10 17:00:29 -070023 utilities.assert_equals( expect = main.TRUE,
pingping-lin5bb663b2015-09-24 11:47:50 -070024 actual = topoResult,
pingping-linb702c602015-09-10 17:00:29 -070025 onpass = "Successfully loaded topology",
26 onfail = "Failed to load topology" )
27 # Exit if topology did not load properly
28 if not topoResult:
29 main.cleanup()
30 main.exit()
pingping-lin5bb663b2015-09-24 11:47:50 -070031 main.step( "Connect switches to controller" )
32
33 global ONOS1Ip
34 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
35 # connect all switches to controller
36 swResult = main.TRUE
37 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
38 sw = "sw%s" % ( i )
39 swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip )
40 # swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip, port = "6633" )
41 utilities.assert_equals( expect = main.TRUE,
42 actual = swResult,
43 onpass = "Successfully connect all switches to ONOS",
44 onfail = "Failed to connect all switches to ONOS" )
45 if not swResult:
46 main.cleanup()
47 main.exit()
48
49 main.step( "Set up tunnel from Mininet node to onos node" )
50 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip )
51 command = 'ssh -nNT -o "PasswordAuthentication no" \
52 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, ONOS1Ip )
53
54 tunnelResult = main.TRUE
55 tunnelResult = main.Mininet.node( "root", command )
pingping-linb3ebd3f2015-09-28 22:17:05 -070056 utilities.assert_equals( expect = True,
57 actual = ( "PasswordAuthentication" in tunnelResult ),
58 onpass = "Created tunnel succeeded",
59 onfail = "Create tunnel failed" )
60 if ("PasswordAuthentication" not in tunnelResult) :
pingping-lin5bb663b2015-09-24 11:47:50 -070061 main.cleanup()
62 main.exit()
pingping-lin5bb663b2015-09-24 11:47:50 -070063
pingping-lin28e7b212015-09-10 10:14:58 -070064
65 # This case is to setup ONOS
pingping-linb702c602015-09-10 17:00:29 -070066 def CASE101( self, main ):
pingping-lin28e7b212015-09-10 10:14:58 -070067 """
pingping-linb3ebd3f2015-09-28 22:17:05 -070068 Compile ONOS and install it
pingping-lin28e7b212015-09-10 10:14:58 -070069 Startup sequence:
70 cell <name>
71 onos-verify-cell
72 git pull
73 mvn clean install
74 onos-package
75 onos-install -f
76 onos-wait-for-start
77 """
78 import json
79 import time
80 from operator import eq
81
82 main.case( "Setting up test environment" )
83
84 cellName = main.params[ 'ENV' ][ 'cellName' ]
pingping-lin28e7b212015-09-10 10:14:58 -070085
86 main.step( "Applying cell variable to environment" )
87 cellResult = main.ONOSbench.setCell( cellName )
pingping-linb3ebd3f2015-09-28 22:17:05 -070088 utilities.assert_equals( expect = main.TRUE,
89 actual = cellResult,
90 onpass = "Set cell succeeded",
91 onfail = "Set cell failed" )
92
pingping-lin28e7b212015-09-10 10:14:58 -070093 verifyResult = main.ONOSbench.verifyCell()
pingping-linb3ebd3f2015-09-28 22:17:05 -070094 utilities.assert_equals( expect = main.TRUE,
95 actual = verifyResult,
96 onpass = "Verify cell succeeded",
97 onfail = "Verify cell failed" )
pingping-lin28e7b212015-09-10 10:14:58 -070098
99 branchName = main.ONOSbench.getBranchName()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700100 main.log.report( "ONOS is on branch: " + branchName )
pingping-lin28e7b212015-09-10 10:14:58 -0700101
pingping-linb3ebd3f2015-09-28 22:17:05 -0700102 main.log.step( "Uninstalling ONOS" )
103 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
104 utilities.assert_equals( expect = main.TRUE,
105 actual = uninstallResult,
106 onpass = "Uninstall ONOS succeeded",
107 onfail = "Uninstall ONOS failed" )
pingping-linaede0312015-09-30 17:53:19 -0700108 '''
pingping-lin28e7b212015-09-10 10:14:58 -0700109 main.step( "Git pull" )
110 gitPullResult = main.ONOSbench.gitPull()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700111 main.log.info( "gitPullResult" )
112 main.log.info( gitPullResult )
113 gitPullResult2 = ( gitPullResult == main.TRUE ) or ( gitPullResult == 3 )
114 utilities.assert_equals( expect = True,
115 actual = gitPullResult2,
116 onpass = "Git pull ONOS succeeded",
117 onfail = "Git pull ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700118
119 main.step( "Using mvn clean install" )
120 if gitPullResult == main.TRUE:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700121 mciResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 )
122 utilities.assert_equals( expect = main.TRUE,
123 actual = mciResult,
124 onpass = "Maven clean install ONOS succeeded",
125 onfail = "Maven clean install ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700126 else:
127 main.log.warn( "Did not pull new code so skipping mvn " +
128 "clean install" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700129 mciResult = main.TRUE
pingping-linaede0312015-09-30 17:53:19 -0700130 '''
pingping-lin28e7b212015-09-10 10:14:58 -0700131
132 main.ONOSbench.getVersion( report = True )
133
134 main.step( "Creating ONOS package" )
135 packageResult = main.ONOSbench.onosPackage( opTimeout = 500 )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700136 utilities.assert_equals( expect = main.TRUE,
137 actual = packageResult,
138 onpass = "Package ONOS succeeded",
139 onfail = "Package ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700140
141 main.step( "Installing ONOS package" )
142 onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
pingping-linb3ebd3f2015-09-28 22:17:05 -0700143 node = ONOS1Ip )
144 utilities.assert_equals( expect = main.TRUE,
145 actual = onos1InstallResult,
146 onpass = "Install ONOS succeeded",
147 onfail = "Install ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700148
149 main.step( "Checking if ONOS is up yet" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700150 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
151 utilities.assert_equals( expect = main.TRUE,
152 actual = onos1UpResult,
153 onpass = "ONOS is up",
154 onfail = "ONOS is NOT up" )
pingping-lin28e7b212015-09-10 10:14:58 -0700155
pingping-linb3ebd3f2015-09-28 22:17:05 -0700156 main.step( "Checking if ONOS CLI is ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700157 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
158 commandlineTimeout = 100, onosStartTimeout = 600 )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700159 utilities.assert_equals( expect = main.TRUE,
160 actual = cliResult,
161 onpass = "ONOS CLI is ready",
162 onfail = "ONOS CLI is NOT ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700163
pingping-linb3ebd3f2015-09-28 22:17:05 -0700164 caseResult = ( cellResult and verifyResult and
pingping-linaede0312015-09-30 17:53:19 -0700165 packageResult and
pingping-linb3ebd3f2015-09-28 22:17:05 -0700166 onos1InstallResult and onos1UpResult and cliResult )
pingping-lin28e7b212015-09-10 10:14:58 -0700167
pingping-linb702c602015-09-10 17:00:29 -0700168 utilities.assert_equals( expect = main.TRUE, actual = caseResult,
pingping-lin28e7b212015-09-10 10:14:58 -0700169 onpass = "ONOS startup successful",
170 onfail = "ONOS startup NOT successful" )
171
pingping-linb702c602015-09-10 17:00:29 -0700172 if caseResult == main.FALSE:
pingping-lin3f091d62015-09-29 12:00:05 -0700173 main.log.info( "ONOS startup failed!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700174 main.cleanup()
175 main.exit()
176
pingping-linb3ebd3f2015-09-28 22:17:05 -0700177 main.log.info( "Get links in the network" )
pingping-lin3f091d62015-09-29 12:00:05 -0700178 time.sleep( int ( main.params['timers']['TopoDiscovery'] ) )
179 summaryResult = main.ONOScli.summary()
180 linkNum = json.loads( summaryResult )[ "links" ]
181 if linkNum < 100:
182 main.log.info( "Link number is wrong!" )
183 listResult = main.ONOScli.links( jsonFormat = False )
184 main.log.info( listResult )
185 main.cleanup()
186 main.exit()
187
pingping-lin28e7b212015-09-10 10:14:58 -0700188 listResult = main.ONOScli.links( jsonFormat = False )
189 main.log.info( listResult )
pingping-linb702c602015-09-10 17:00:29 -0700190
pingping-linb3ebd3f2015-09-28 22:17:05 -0700191 main.step( "Activate sdn-ip application" )
192 activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" )
193 utilities.assert_equals( expect = main.TRUE,
194 actual = activeSDNIPresult,
195 onpass = "Activate SDN-IP succeeded",
196 onfail = "Activate SDN-IP failed" )
pingping-lin3f091d62015-09-29 12:00:05 -0700197 if not activeSDNIPresult:
198 main.log.info( "Activate SDN-IP failed!" )
199 main.cleanup()
200 main.exit()
201
pingping-linb3ebd3f2015-09-28 22:17:05 -0700202
203 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
pingping-linb702c602015-09-10 17:00:29 -0700204 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700205 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700206 main.log.info( "Wait Quagga to finish delivery all routes to each \
207 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700208 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
209 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
210
211
pingping-lin4f80c492015-09-15 14:34:42 -0700212 def CASE102( self, main ):
213 '''
214 This test case is to load the methods from other Python files.
215 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700216 main.case( "Loading methods from other Python file" )
pingping-lin4f80c492015-09-15 14:34:42 -0700217 # load the methods from other file
218 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
219 main.Functions = imp.load_source( wrapperFile,
220 main.dependencyPath +
221 wrapperFile +
222 ".py" )
223
224
pingping-lin0ce60622015-09-10 14:37:33 -0700225 def CASE1( self, main ):
226 '''
227 ping test from 3 bgp peers to BGP speaker
228 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700229
pingping-linb3ebd3f2015-09-28 22:17:05 -0700230 main.case( "Ping tests between BGP peers and speakers" )
pingping-lin829428d2015-09-22 20:50:00 -0700231 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
232 peers = ["peer64514", "peer64515", "peer64516"],
233 expectAllSuccess = True )
pingping-lin0ce60622015-09-10 14:37:33 -0700234
pingping-lin950b50d2015-09-14 12:00:08 -0700235
pingping-lin0ce60622015-09-10 14:37:33 -0700236 def CASE2( self, main ):
237 '''
238 point-to-point intents test for each BGP peer and BGP speaker pair
239 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700240 main.case( "Check point-to-point intents" )
pingping-lin0ce60622015-09-10 14:37:33 -0700241 main.log.info( "There are %s BGP peers in total "
242 % main.params[ 'config' ][ 'peerNum' ] )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700243 main.step( "Check P2P intents number from ONOS CLI" )
pingping-lin0ce60622015-09-10 14:37:33 -0700244
245 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
246 bgpIntentsActualNum = \
247 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
248 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
249 main.log.info( "bgpIntentsExpected num is:" )
250 main.log.info( bgpIntentsExpectedNum )
251 main.log.info( "bgpIntentsActual num is:" )
252 main.log.info( bgpIntentsActualNum )
253 utilities.assertEquals( \
254 expect = True,
255 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700256 onpass = "PointToPointIntent Intent Num is correct!",
257 onfail = "PointToPointIntent Intent Num is wrong!" )
pingping-lin0ce60622015-09-10 14:37:33 -0700258
259
260 def CASE3( self, main ):
261 '''
262 routes and intents check to all BGP peers
263 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700264 main.case( "Check routes and M2S intents to all BGP peers" )
pingping-lin0ce60622015-09-10 14:37:33 -0700265
pingping-lin28e7b212015-09-10 10:14:58 -0700266 allRoutesExpected = []
267 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
268 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
269 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
270
271 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
272 allRoutesActual = \
273 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
274 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
275 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
276
277 main.step( "Check routes installed" )
278 main.log.info( "Routes expected:" )
279 main.log.info( allRoutesStrExpected )
280 main.log.info( "Routes get from ONOS CLI:" )
281 main.log.info( allRoutesStrActual )
282 utilities.assertEquals( \
283 expect = allRoutesStrExpected, actual = allRoutesStrActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -0700284 onpass = "Routes are correct!",
285 onfail = "Routes are wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700286
pingping-linb3ebd3f2015-09-28 22:17:05 -0700287 main.step( "Check M2S intents installed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700288 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
289 routeIntentsActualNum = \
290 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
291 routeIntentsExpectedNum = 3
292
293 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
294 main.log.info( routeIntentsExpectedNum )
295 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
296 main.log.info( routeIntentsActualNum )
297 utilities.assertEquals( \
298 expect = True,
299 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700300 onpass = "MultiPointToSinglePoint Intent Num is correct!",
301 onfail = "MultiPointToSinglePoint Intent Num is wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700302
pingping-linbab7f8a2015-09-21 17:33:36 -0700303 main.step( "Check whether all flow status are ADDED" )
304 utilities.assertEquals( \
305 expect = main.TRUE,
306 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700307 onpass = "Flow status is correct!",
308 onfail = "Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700309
pingping-lin950b50d2015-09-14 12:00:08 -0700310
311 def CASE4( self, main ):
312 '''
313 Ping test in data plane for each route
314 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700315 main.case( "Ping test for each route, all hosts behind BGP peers" )
pingping-lin829428d2015-09-22 20:50:00 -0700316 main.Functions.pingHostToHost( main,
317 hosts = ["host64514", "host64515", "host64516"],
318 expectAllSuccess = True )
pingping-lin4f80c492015-09-15 14:34:42 -0700319
320
321 def CASE5( self, main ):
322 '''
323 Cut links to peers one by one, check routes/intents
324 '''
325 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700326 main.case( "Bring down links and check routes/intents" )
pingping-lin4f80c492015-09-15 14:34:42 -0700327 main.step( "Bring down the link between sw32 and peer64514" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700328 linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
329 OPTION = "down" )
330 utilities.assertEquals( expect = main.TRUE,
331 actual = linkResult1,
332 onpass = "Bring down link succeeded!",
333 onfail = "Bring down link failed!" )
334
335 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700336 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
337 main.Functions.checkRouteNum( main, 2 )
338 main.Functions.checkM2SintentNum( main, 2 )
339 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700340 main.log.info( "Bring down link failed!" )
341 main.cleanup()
342 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700343
344 main.step( "Bring down the link between sw8 and peer64515" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700345 linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
346 OPTION = "down" )
347 utilities.assertEquals( expect = main.TRUE,
348 actual = linkResult2,
349 onpass = "Bring down link succeeded!",
350 onfail = "Bring down link failed!" )
351 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700352 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
353 main.Functions.checkRouteNum( main, 1 )
354 main.Functions.checkM2SintentNum( main, 1 )
355 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700356 main.log.info( "Bring down link failed!" )
357 main.cleanup()
358 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700359
360 main.step( "Bring down the link between sw28 and peer64516" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700361 linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
362 OPTION = "down" )
363 utilities.assertEquals( expect = main.TRUE,
364 actual = linkResult3,
365 onpass = "Bring down link succeeded!",
366 onfail = "Bring down link failed!" )
367 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700368 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
369 main.Functions.checkRouteNum( main, 0 )
370 main.Functions.checkM2SintentNum( main, 0 )
371 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700372 main.log.info( "Bring down link failed!" )
373 main.cleanup()
374 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700375
pingping-linbab7f8a2015-09-21 17:33:36 -0700376 main.step( "Check whether all flow status are ADDED" )
377 utilities.assertEquals( \
378 expect = main.TRUE,
379 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700380 onpass = "Flow status is correct!",
381 onfail = "Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700382
pingping-lin829428d2015-09-22 20:50:00 -0700383 # Ping test
384 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
385 peers = ["peer64514", "peer64515", "peer64516"],
386 expectAllSuccess = False )
387 main.Functions.pingHostToHost( main,
388 hosts = ["host64514", "host64515", "host64516"],
389 expectAllSuccess = False )
pingping-lin4f80c492015-09-15 14:34:42 -0700390
pingping-lin829428d2015-09-22 20:50:00 -0700391
392 def CASE6( self, main ):
pingping-lin4f80c492015-09-15 14:34:42 -0700393 '''
394 Recover links to peers one by one, check routes/intents
395 '''
396 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700397 main.case( "Bring up links and check routes/intents" )
pingping-lin4f80c492015-09-15 14:34:42 -0700398 main.step( "Bring up the link between sw32 and peer64514" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700399 linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
400 OPTION = "up" )
401 utilities.assertEquals( expect = main.TRUE,
402 actual = linkResult1,
403 onpass = "Bring up link succeeded!",
404 onfail = "Bring up link failed!" )
405 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700406 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
407 main.Functions.checkRouteNum( main, 1 )
408 main.Functions.checkM2SintentNum( main, 1 )
409 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700410 main.log.info( "Bring up link failed!" )
411 main.cleanup()
412 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700413
414 main.step( "Bring up the link between sw8 and peer64515" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700415 linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
416 OPTION = "up" )
417 utilities.assertEquals( expect = main.TRUE,
418 actual = linkResult2,
419 onpass = "Bring up link succeeded!",
420 onfail = "Bring up link failed!" )
421 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700422 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
423 main.Functions.checkRouteNum( main, 2 )
424 main.Functions.checkM2SintentNum( main, 2 )
425 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700426 main.log.info( "Bring up link failed!" )
427 main.cleanup()
428 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700429
430 main.step( "Bring up the link between sw28 and peer64516" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700431 linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
432 OPTION = "up" )
433 utilities.assertEquals( expect = main.TRUE,
434 actual = linkResult3,
435 onpass = "Bring up link succeeded!",
436 onfail = "Bring up link failed!" )
437 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700438 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
439 main.Functions.checkRouteNum( main, 3 )
440 main.Functions.checkM2SintentNum( main, 3 )
441 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700442 main.log.info( "Bring up link failed!" )
443 main.cleanup()
444 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700445
446 main.step( "Check whether all flow status are ADDED" )
447 utilities.assertEquals( \
448 expect = main.TRUE,
449 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700450 onpass = "Flow status is correct!",
451 onfail = "Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700452
453 # Ping test
454 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
455 peers = ["peer64514", "peer64515", "peer64516"],
456 expectAllSuccess = True )
457 main.Functions.pingHostToHost( main,
458 hosts = ["host64514", "host64515", "host64516"],
459 expectAllSuccess = True )
pingping-lin8244a3b2015-09-16 13:36:56 -0700460
461
pingping-lin829428d2015-09-22 20:50:00 -0700462 def CASE7( self, main ):
pingping-lin8244a3b2015-09-16 13:36:56 -0700463 '''
pingping-lin829428d2015-09-22 20:50:00 -0700464 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
pingping-lin8244a3b2015-09-16 13:36:56 -0700465 '''
466 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700467 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700468 main.step( "Stop sw32" )
469 result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
pingping-lin3f091d62015-09-29 12:00:05 -0700470 utilities.assertEquals( expect = main.TRUE, actual = result,
471 onpass = "Stopping switch succeeded!",
472 onfail = "Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700473
pingping-lin8244a3b2015-09-16 13:36:56 -0700474 if result == main.TRUE:
475 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
476 main.Functions.checkRouteNum( main, 2 )
477 main.Functions.checkM2SintentNum( main, 2 )
478 main.Functions.checkP2PintentNum( main, 12 )
479 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700480 main.log.info( "Stopping switch failed!" )
481 main.cleanup()
482 main.exit()
pingping-lin8244a3b2015-09-16 13:36:56 -0700483
pingping-lin829428d2015-09-22 20:50:00 -0700484 main.step( "Check ping between hosts behind BGP peers" )
485 result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
486 result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
487 result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )
488
489 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
490 and ( result3 == main.FALSE )
491 utilities.assert_equals( expect = True, actual = pingResult1,
492 onpass = "Ping test result is correct",
493 onfail = "Ping test result is wrong" )
494
495 if pingResult1 == False:
496 main.cleanup()
497 main.exit()
498
499 main.step( "Check ping between BGP peers and speakers" )
500 result4 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" )
501 result5 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" )
502 result6 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" )
503
504 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
505 and ( result6 == main.TRUE )
506 utilities.assert_equals( expect = True, actual = pingResult2,
507 onpass = "Speaker1 ping peers successful",
508 onfail = "Speaker1 ping peers NOT successful" )
509
510 if pingResult2 == False:
511 main.cleanup()
512 main.exit()
513
pingping-linbab7f8a2015-09-21 17:33:36 -0700514 main.step( "Check whether all flow status are ADDED" )
515 utilities.assertEquals( \
516 expect = main.TRUE,
517 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700518 onpass = "Flow status is correct!",
519 onfail = "Flow status is wrong!" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700520
pingping-lind791d342015-09-17 18:34:31 -0700521
pingping-lin8244a3b2015-09-16 13:36:56 -0700522 def CASE8( self, main ):
pingping-lind791d342015-09-17 18:34:31 -0700523 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700524 Bring up the edge switch (sw32) which was shut down in CASE7,
pingping-lind791d342015-09-17 18:34:31 -0700525 check P-2-P and M-2-S intents, ping test
526 '''
527 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700528 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700529 main.step( "Start sw32" )
530 result1 = main.Mininet.switch( SW = "sw32", OPTION = "start" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700531 utilities.assertEquals( \
532 expect = main.TRUE,
533 actual = result1,
534 onpass = "Starting switch succeeded!",
535 onfail = "Starting switch failed!" )
536
pingping-lind791d342015-09-17 18:34:31 -0700537 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700538 utilities.assertEquals( \
539 expect = main.TRUE,
540 actual = result2,
541 onpass = "Connect switch to ONOS succeeded!",
542 onfail = "Connect switch to ONOS failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700543
544 if result1 and result2:
545 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
546 main.Functions.checkRouteNum( main, 3 )
547 main.Functions.checkM2SintentNum( main, 3 )
548 main.Functions.checkP2PintentNum( main, 18 )
549 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700550 main.log.info( "Starting switch failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700551 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700552 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700553
pingping-linbab7f8a2015-09-21 17:33:36 -0700554 main.step( "Check whether all flow status are ADDED" )
555 utilities.assertEquals( \
556 expect = main.TRUE,
557 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700558 onpass = "Flow status is correct!",
559 onfail = "Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700560
pingping-lin829428d2015-09-22 20:50:00 -0700561 # Ping test
562 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
563 peers = ["peer64514", "peer64515", "peer64516"],
564 expectAllSuccess = True )
565 main.Functions.pingHostToHost( main,
566 hosts = ["host64514", "host64515", "host64516"],
567 expectAllSuccess = True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700568
pingping-lin829428d2015-09-22 20:50:00 -0700569
570 def CASE9( self, main ):
pingping-linbab7f8a2015-09-21 17:33:36 -0700571 '''
572 Bring down a switch in best path, check:
573 route number, P2P intent number, M2S intent number, ping test
574 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700575 main.case( "Stop sw11 located in best path, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700576 check route number, P2P intent number, M2S intent number, ping test" )
577
pingping-lin581a3662015-09-29 17:43:39 -0700578 main.log.info( "Check the flow number correctness before stopping sw11" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700579 main.Functions.checkFlowNum( main, "sw11", 13 )
580 main.Functions.checkFlowNum( main, "sw1", 3 )
581 main.Functions.checkFlowNum( main, "sw7", 3 )
582 main.log.info( main.Mininet.checkFlows( "sw11" ) )
583 main.log.info( main.Mininet.checkFlows( "sw1" ) )
584 main.log.info( main.Mininet.checkFlows( "sw7" ) )
585
586 main.step( "Stop sw11" )
587 result = main.Mininet.switch( SW = "sw11", OPTION = "stop" )
pingping-lin3f091d62015-09-29 12:00:05 -0700588 utilities.assertEquals( expect = main.TRUE, actual = result,
589 onpass = "Stopping switch succeeded!",
590 onfail = "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700591 if result:
592 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700593 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700594 main.Functions.checkRouteNum( main, 3 )
595 main.Functions.checkM2SintentNum( main, 3 )
596 main.Functions.checkP2PintentNum( main, 18 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700597 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700598 main.log.info( "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700599 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700600 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700601
602 main.step( "Check whether all flow status are ADDED" )
603 utilities.assertEquals( \
604 expect = main.TRUE,
605 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700606 onpass = "Flow status is correct!",
607 onfail = "Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700608 # Ping test
609 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
610 peers = ["peer64514", "peer64515", "peer64516"],
611 expectAllSuccess = True )
612 main.Functions.pingHostToHost( main,
613 hosts = ["host64514", "host64515", "host64516"],
614 expectAllSuccess = True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700615
616
617 def CASE10( self, main ):
618 '''
619 Bring up the switch which was stopped in CASE9, check:
620 route number, P2P intent number, M2S intent number, ping test
621 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700622 main.case( "Start sw11 which was stopped in CASE9, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700623 check route number, P2P intent number, M2S intent number, ping test" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700624
pingping-lin581a3662015-09-29 17:43:39 -0700625 main.log.info( "Check the flow status before starting sw11" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700626 main.Functions.checkFlowNum( main, "sw1", 11 )
627 main.Functions.checkFlowNum( main, "sw7", 5 )
628 main.log.info( main.Mininet.checkFlows( "sw1" ) )
629 main.log.info( main.Mininet.checkFlows( "sw7" ) )
630
pingping-linbab7f8a2015-09-21 17:33:36 -0700631 main.step( "Start sw11" )
pingping-lin0351dee2015-09-28 13:26:35 -0700632 result1 = main.Mininet.switch( SW = "sw11", OPTION = "start" )
pingping-lin3f091d62015-09-29 12:00:05 -0700633 utilities.assertEquals( expect = main.TRUE, actual = result1,
634 onpass = "Starting switch succeeded!",
635 onfail = "Starting switch failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700636 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
pingping-lin3f091d62015-09-29 12:00:05 -0700637 utilities.assertEquals( expect = main.TRUE, actual = result2,
638 onpass = "Connect switch to ONOS succeeded!",
639 onfail = "Connect switch to ONOS failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700640 if result1 and result2:
pingping-linbab7f8a2015-09-21 17:33:36 -0700641 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
642 main.Functions.checkRouteNum( main, 3 )
643 main.Functions.checkM2SintentNum( main, 3 )
644 main.Functions.checkP2PintentNum( main, 18 )
645
pingping-lin3f091d62015-09-29 12:00:05 -0700646 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
647 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
648 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700649 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700650 main.log.info( "Starting switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700651 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700652 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700653
654 main.step( "Check whether all flow status are ADDED" )
655 utilities.assertEquals( \
656 expect = main.TRUE,
657 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700658 onpass = "Flow status is correct!",
659 onfail = "Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700660 # Ping test
661 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
662 peers = ["peer64514", "peer64515", "peer64516"],
663 expectAllSuccess = True )
664 main.Functions.pingHostToHost( main,
665 hosts = ["host64514", "host64515", "host64516"],
666 expectAllSuccess = True )