blob: ee0b1209ec9b6f128d203e03e3a2309c46d0a3c4 [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-linea32cf82015-10-08 22:37:37 -070068 Package ONOS and install it
pingping-lin28e7b212015-09-10 10:14:58 -070069 Startup sequence:
70 cell <name>
71 onos-verify-cell
pingping-lin28e7b212015-09-10 10:14:58 -070072 onos-package
73 onos-install -f
74 onos-wait-for-start
75 """
76 import json
77 import time
78 from operator import eq
79
80 main.case( "Setting up test environment" )
81
82 cellName = main.params[ 'ENV' ][ 'cellName' ]
pingping-lin28e7b212015-09-10 10:14:58 -070083
84 main.step( "Applying cell variable to environment" )
85 cellResult = main.ONOSbench.setCell( cellName )
pingping-linb3ebd3f2015-09-28 22:17:05 -070086 utilities.assert_equals( expect = main.TRUE,
87 actual = cellResult,
88 onpass = "Set cell succeeded",
89 onfail = "Set cell failed" )
90
pingping-lin28e7b212015-09-10 10:14:58 -070091 verifyResult = main.ONOSbench.verifyCell()
pingping-linb3ebd3f2015-09-28 22:17:05 -070092 utilities.assert_equals( expect = main.TRUE,
93 actual = verifyResult,
94 onpass = "Verify cell succeeded",
95 onfail = "Verify cell failed" )
pingping-lin28e7b212015-09-10 10:14:58 -070096
97 branchName = main.ONOSbench.getBranchName()
pingping-linb3ebd3f2015-09-28 22:17:05 -070098 main.log.report( "ONOS is on branch: " + branchName )
pingping-lin28e7b212015-09-10 10:14:58 -070099
pingping-linb3ebd3f2015-09-28 22:17:05 -0700100 main.log.step( "Uninstalling ONOS" )
101 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
102 utilities.assert_equals( expect = main.TRUE,
103 actual = uninstallResult,
104 onpass = "Uninstall ONOS succeeded",
105 onfail = "Uninstall ONOS failed" )
pingping-linaede0312015-09-30 17:53:19 -0700106 '''
pingping-lin28e7b212015-09-10 10:14:58 -0700107 main.step( "Git pull" )
108 gitPullResult = main.ONOSbench.gitPull()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700109 main.log.info( "gitPullResult" )
110 main.log.info( gitPullResult )
111 gitPullResult2 = ( gitPullResult == main.TRUE ) or ( gitPullResult == 3 )
112 utilities.assert_equals( expect = True,
113 actual = gitPullResult2,
114 onpass = "Git pull ONOS succeeded",
115 onfail = "Git pull ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700116
117 main.step( "Using mvn clean install" )
118 if gitPullResult == main.TRUE:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700119 mciResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 )
120 utilities.assert_equals( expect = main.TRUE,
121 actual = mciResult,
122 onpass = "Maven clean install ONOS succeeded",
123 onfail = "Maven clean install ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700124 else:
125 main.log.warn( "Did not pull new code so skipping mvn " +
126 "clean install" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700127 mciResult = main.TRUE
pingping-linaede0312015-09-30 17:53:19 -0700128 '''
pingping-lin28e7b212015-09-10 10:14:58 -0700129
130 main.ONOSbench.getVersion( report = True )
131
132 main.step( "Creating ONOS package" )
133 packageResult = main.ONOSbench.onosPackage( opTimeout = 500 )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700134 utilities.assert_equals( expect = main.TRUE,
135 actual = packageResult,
136 onpass = "Package ONOS succeeded",
137 onfail = "Package ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700138
139 main.step( "Installing ONOS package" )
140 onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
pingping-linb3ebd3f2015-09-28 22:17:05 -0700141 node = ONOS1Ip )
142 utilities.assert_equals( expect = main.TRUE,
143 actual = onos1InstallResult,
144 onpass = "Install ONOS succeeded",
145 onfail = "Install ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700146
147 main.step( "Checking if ONOS is up yet" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700148 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
149 utilities.assert_equals( expect = main.TRUE,
150 actual = onos1UpResult,
151 onpass = "ONOS is up",
152 onfail = "ONOS is NOT up" )
pingping-lin28e7b212015-09-10 10:14:58 -0700153
pingping-linb3ebd3f2015-09-28 22:17:05 -0700154 main.step( "Checking if ONOS CLI is ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700155 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
156 commandlineTimeout = 100, onosStartTimeout = 600 )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700157 utilities.assert_equals( expect = main.TRUE,
158 actual = cliResult,
159 onpass = "ONOS CLI is ready",
160 onfail = "ONOS CLI is NOT ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700161
pingping-linb3ebd3f2015-09-28 22:17:05 -0700162 caseResult = ( cellResult and verifyResult and
pingping-linaede0312015-09-30 17:53:19 -0700163 packageResult and
pingping-linb3ebd3f2015-09-28 22:17:05 -0700164 onos1InstallResult and onos1UpResult and cliResult )
pingping-lin28e7b212015-09-10 10:14:58 -0700165
pingping-linb702c602015-09-10 17:00:29 -0700166 utilities.assert_equals( expect = main.TRUE, actual = caseResult,
pingping-lin28e7b212015-09-10 10:14:58 -0700167 onpass = "ONOS startup successful",
168 onfail = "ONOS startup NOT successful" )
169
pingping-linb702c602015-09-10 17:00:29 -0700170 if caseResult == main.FALSE:
pingping-lin3f091d62015-09-29 12:00:05 -0700171 main.log.info( "ONOS startup failed!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700172 main.cleanup()
173 main.exit()
174
pingping-linb3ebd3f2015-09-28 22:17:05 -0700175 main.log.info( "Get links in the network" )
pingping-lin3f091d62015-09-29 12:00:05 -0700176 time.sleep( int ( main.params['timers']['TopoDiscovery'] ) )
177 summaryResult = main.ONOScli.summary()
178 linkNum = json.loads( summaryResult )[ "links" ]
179 if linkNum < 100:
180 main.log.info( "Link number is wrong!" )
181 listResult = main.ONOScli.links( jsonFormat = False )
182 main.log.info( listResult )
183 main.cleanup()
184 main.exit()
185
pingping-lin28e7b212015-09-10 10:14:58 -0700186 listResult = main.ONOScli.links( jsonFormat = False )
187 main.log.info( listResult )
pingping-linb702c602015-09-10 17:00:29 -0700188
pingping-linb3ebd3f2015-09-28 22:17:05 -0700189 main.step( "Activate sdn-ip application" )
190 activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" )
191 utilities.assert_equals( expect = main.TRUE,
192 actual = activeSDNIPresult,
193 onpass = "Activate SDN-IP succeeded",
194 onfail = "Activate SDN-IP failed" )
pingping-lin3f091d62015-09-29 12:00:05 -0700195 if not activeSDNIPresult:
196 main.log.info( "Activate SDN-IP failed!" )
197 main.cleanup()
198 main.exit()
199
pingping-linb3ebd3f2015-09-28 22:17:05 -0700200
201 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
pingping-linb702c602015-09-10 17:00:29 -0700202 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700203 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700204 main.log.info( "Wait Quagga to finish delivery all routes to each \
205 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700206 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
207 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
208
209
pingping-lin4f80c492015-09-15 14:34:42 -0700210 def CASE102( self, main ):
211 '''
212 This test case is to load the methods from other Python files.
213 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700214 main.case( "Loading methods from other Python file" )
pingping-lin4f80c492015-09-15 14:34:42 -0700215 # load the methods from other file
216 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
217 main.Functions = imp.load_source( wrapperFile,
218 main.dependencyPath +
219 wrapperFile +
220 ".py" )
221
222
pingping-lin0ce60622015-09-10 14:37:33 -0700223 def CASE1( self, main ):
224 '''
225 ping test from 3 bgp peers to BGP speaker
226 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700227
pingping-linb3ebd3f2015-09-28 22:17:05 -0700228 main.case( "Ping tests between BGP peers and speakers" )
pingping-lin829428d2015-09-22 20:50:00 -0700229 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
230 peers = ["peer64514", "peer64515", "peer64516"],
231 expectAllSuccess = True )
pingping-lin0ce60622015-09-10 14:37:33 -0700232
pingping-lin950b50d2015-09-14 12:00:08 -0700233
pingping-lin0ce60622015-09-10 14:37:33 -0700234 def CASE2( self, main ):
235 '''
236 point-to-point intents test for each BGP peer and BGP speaker pair
237 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700238 main.case( "Check point-to-point intents" )
pingping-lin0ce60622015-09-10 14:37:33 -0700239 main.log.info( "There are %s BGP peers in total "
240 % main.params[ 'config' ][ 'peerNum' ] )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700241 main.step( "Check P2P intents number from ONOS CLI" )
pingping-lin0ce60622015-09-10 14:37:33 -0700242
243 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
244 bgpIntentsActualNum = \
245 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
246 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
247 main.log.info( "bgpIntentsExpected num is:" )
248 main.log.info( bgpIntentsExpectedNum )
249 main.log.info( "bgpIntentsActual num is:" )
250 main.log.info( bgpIntentsActualNum )
251 utilities.assertEquals( \
252 expect = True,
253 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700254 onpass = "PointToPointIntent Intent Num is correct!",
255 onfail = "PointToPointIntent Intent Num is wrong!" )
pingping-lin0ce60622015-09-10 14:37:33 -0700256
257
258 def CASE3( self, main ):
259 '''
260 routes and intents check to all BGP peers
261 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700262 main.case( "Check routes and M2S intents to all BGP peers" )
pingping-lin0ce60622015-09-10 14:37:33 -0700263
pingping-lin28e7b212015-09-10 10:14:58 -0700264 allRoutesExpected = []
265 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
266 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
267 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
268
269 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
270 allRoutesActual = \
271 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
272 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
273 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
274
275 main.step( "Check routes installed" )
276 main.log.info( "Routes expected:" )
277 main.log.info( allRoutesStrExpected )
278 main.log.info( "Routes get from ONOS CLI:" )
279 main.log.info( allRoutesStrActual )
280 utilities.assertEquals( \
281 expect = allRoutesStrExpected, actual = allRoutesStrActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -0700282 onpass = "Routes are correct!",
283 onfail = "Routes are wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700284
pingping-linb3ebd3f2015-09-28 22:17:05 -0700285 main.step( "Check M2S intents installed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700286 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
287 routeIntentsActualNum = \
288 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
289 routeIntentsExpectedNum = 3
290
291 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
292 main.log.info( routeIntentsExpectedNum )
293 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
294 main.log.info( routeIntentsActualNum )
295 utilities.assertEquals( \
296 expect = True,
297 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700298 onpass = "MultiPointToSinglePoint Intent Num is correct!",
299 onfail = "MultiPointToSinglePoint Intent Num is wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700300
pingping-linbab7f8a2015-09-21 17:33:36 -0700301 main.step( "Check whether all flow status are ADDED" )
302 utilities.assertEquals( \
303 expect = main.TRUE,
304 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700305 onpass = "Flow status is correct!",
306 onfail = "Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700307
pingping-lin950b50d2015-09-14 12:00:08 -0700308
309 def CASE4( self, main ):
310 '''
311 Ping test in data plane for each route
312 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700313 main.case( "Ping test for each route, all hosts behind BGP peers" )
pingping-lin829428d2015-09-22 20:50:00 -0700314 main.Functions.pingHostToHost( main,
315 hosts = ["host64514", "host64515", "host64516"],
316 expectAllSuccess = True )
pingping-lin4f80c492015-09-15 14:34:42 -0700317
318
319 def CASE5( self, main ):
320 '''
321 Cut links to peers one by one, check routes/intents
322 '''
323 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700324 main.case( "Bring down links and check routes/intents" )
pingping-lin4f80c492015-09-15 14:34:42 -0700325 main.step( "Bring down the link between sw32 and peer64514" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700326 linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
327 OPTION = "down" )
328 utilities.assertEquals( expect = main.TRUE,
329 actual = linkResult1,
330 onpass = "Bring down link succeeded!",
331 onfail = "Bring down link failed!" )
332
333 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700334 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
335 main.Functions.checkRouteNum( main, 2 )
336 main.Functions.checkM2SintentNum( main, 2 )
337 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700338 main.log.info( "Bring down link failed!" )
339 main.cleanup()
340 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700341
342 main.step( "Bring down the link between sw8 and peer64515" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700343 linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
344 OPTION = "down" )
345 utilities.assertEquals( expect = main.TRUE,
346 actual = linkResult2,
347 onpass = "Bring down link succeeded!",
348 onfail = "Bring down link failed!" )
349 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700350 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
351 main.Functions.checkRouteNum( main, 1 )
352 main.Functions.checkM2SintentNum( main, 1 )
353 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700354 main.log.info( "Bring down link failed!" )
355 main.cleanup()
356 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700357
358 main.step( "Bring down the link between sw28 and peer64516" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700359 linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
360 OPTION = "down" )
361 utilities.assertEquals( expect = main.TRUE,
362 actual = linkResult3,
363 onpass = "Bring down link succeeded!",
364 onfail = "Bring down link failed!" )
365 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700366 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
367 main.Functions.checkRouteNum( main, 0 )
368 main.Functions.checkM2SintentNum( main, 0 )
369 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700370 main.log.info( "Bring down link failed!" )
371 main.cleanup()
372 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700373
pingping-linbab7f8a2015-09-21 17:33:36 -0700374 main.step( "Check whether all flow status are ADDED" )
375 utilities.assertEquals( \
376 expect = main.TRUE,
377 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700378 onpass = "Flow status is correct!",
379 onfail = "Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700380
pingping-lin829428d2015-09-22 20:50:00 -0700381 # Ping test
382 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
383 peers = ["peer64514", "peer64515", "peer64516"],
384 expectAllSuccess = False )
385 main.Functions.pingHostToHost( main,
386 hosts = ["host64514", "host64515", "host64516"],
387 expectAllSuccess = False )
pingping-lin4f80c492015-09-15 14:34:42 -0700388
pingping-lin829428d2015-09-22 20:50:00 -0700389
390 def CASE6( self, main ):
pingping-lin4f80c492015-09-15 14:34:42 -0700391 '''
392 Recover links to peers one by one, check routes/intents
393 '''
394 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700395 main.case( "Bring up links and check routes/intents" )
pingping-lin4f80c492015-09-15 14:34:42 -0700396 main.step( "Bring up the link between sw32 and peer64514" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700397 linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
398 OPTION = "up" )
399 utilities.assertEquals( expect = main.TRUE,
400 actual = linkResult1,
401 onpass = "Bring up link succeeded!",
402 onfail = "Bring up link failed!" )
403 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700404 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
405 main.Functions.checkRouteNum( main, 1 )
406 main.Functions.checkM2SintentNum( main, 1 )
407 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700408 main.log.info( "Bring up link failed!" )
409 main.cleanup()
410 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700411
412 main.step( "Bring up the link between sw8 and peer64515" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700413 linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
414 OPTION = "up" )
415 utilities.assertEquals( expect = main.TRUE,
416 actual = linkResult2,
417 onpass = "Bring up link succeeded!",
418 onfail = "Bring up link failed!" )
419 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700420 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
421 main.Functions.checkRouteNum( main, 2 )
422 main.Functions.checkM2SintentNum( main, 2 )
423 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700424 main.log.info( "Bring up link failed!" )
425 main.cleanup()
426 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700427
428 main.step( "Bring up the link between sw28 and peer64516" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700429 linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
430 OPTION = "up" )
431 utilities.assertEquals( expect = main.TRUE,
432 actual = linkResult3,
433 onpass = "Bring up link succeeded!",
434 onfail = "Bring up link failed!" )
435 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700436 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
437 main.Functions.checkRouteNum( main, 3 )
438 main.Functions.checkM2SintentNum( main, 3 )
439 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700440 main.log.info( "Bring up link failed!" )
441 main.cleanup()
442 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700443
444 main.step( "Check whether all flow status are ADDED" )
445 utilities.assertEquals( \
446 expect = main.TRUE,
447 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700448 onpass = "Flow status is correct!",
449 onfail = "Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700450
451 # Ping test
452 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
453 peers = ["peer64514", "peer64515", "peer64516"],
454 expectAllSuccess = True )
455 main.Functions.pingHostToHost( main,
456 hosts = ["host64514", "host64515", "host64516"],
457 expectAllSuccess = True )
pingping-lin8244a3b2015-09-16 13:36:56 -0700458
459
pingping-lin829428d2015-09-22 20:50:00 -0700460 def CASE7( self, main ):
pingping-lin8244a3b2015-09-16 13:36:56 -0700461 '''
pingping-lin829428d2015-09-22 20:50:00 -0700462 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
pingping-lin8244a3b2015-09-16 13:36:56 -0700463 '''
464 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700465 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700466 main.step( "Stop sw32" )
467 result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
pingping-lin3f091d62015-09-29 12:00:05 -0700468 utilities.assertEquals( expect = main.TRUE, actual = result,
469 onpass = "Stopping switch succeeded!",
470 onfail = "Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700471
pingping-lin8244a3b2015-09-16 13:36:56 -0700472 if result == main.TRUE:
473 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
474 main.Functions.checkRouteNum( main, 2 )
475 main.Functions.checkM2SintentNum( main, 2 )
476 main.Functions.checkP2PintentNum( main, 12 )
477 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700478 main.log.info( "Stopping switch failed!" )
479 main.cleanup()
480 main.exit()
pingping-lin8244a3b2015-09-16 13:36:56 -0700481
pingping-lin829428d2015-09-22 20:50:00 -0700482 main.step( "Check ping between hosts behind BGP peers" )
483 result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
484 result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
485 result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )
486
487 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
488 and ( result3 == main.FALSE )
489 utilities.assert_equals( expect = True, actual = pingResult1,
490 onpass = "Ping test result is correct",
491 onfail = "Ping test result is wrong" )
492
493 if pingResult1 == False:
494 main.cleanup()
495 main.exit()
496
497 main.step( "Check ping between BGP peers and speakers" )
498 result4 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" )
499 result5 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" )
500 result6 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" )
501
502 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
503 and ( result6 == main.TRUE )
504 utilities.assert_equals( expect = True, actual = pingResult2,
505 onpass = "Speaker1 ping peers successful",
506 onfail = "Speaker1 ping peers NOT successful" )
507
508 if pingResult2 == False:
509 main.cleanup()
510 main.exit()
511
pingping-linbab7f8a2015-09-21 17:33:36 -0700512 main.step( "Check whether all flow status are ADDED" )
513 utilities.assertEquals( \
514 expect = main.TRUE,
515 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700516 onpass = "Flow status is correct!",
517 onfail = "Flow status is wrong!" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700518
pingping-lind791d342015-09-17 18:34:31 -0700519
pingping-lin8244a3b2015-09-16 13:36:56 -0700520 def CASE8( self, main ):
pingping-lind791d342015-09-17 18:34:31 -0700521 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700522 Bring up the edge switch (sw32) which was shut down in CASE7,
pingping-lind791d342015-09-17 18:34:31 -0700523 check P-2-P and M-2-S intents, ping test
524 '''
525 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700526 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700527 main.step( "Start sw32" )
528 result1 = main.Mininet.switch( SW = "sw32", OPTION = "start" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700529 utilities.assertEquals( \
530 expect = main.TRUE,
531 actual = result1,
532 onpass = "Starting switch succeeded!",
533 onfail = "Starting switch failed!" )
534
pingping-lind791d342015-09-17 18:34:31 -0700535 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700536 utilities.assertEquals( \
537 expect = main.TRUE,
538 actual = result2,
539 onpass = "Connect switch to ONOS succeeded!",
540 onfail = "Connect switch to ONOS failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700541
542 if result1 and result2:
543 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
544 main.Functions.checkRouteNum( main, 3 )
545 main.Functions.checkM2SintentNum( main, 3 )
546 main.Functions.checkP2PintentNum( main, 18 )
547 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700548 main.log.info( "Starting switch failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700549 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700550 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700551
pingping-linbab7f8a2015-09-21 17:33:36 -0700552 main.step( "Check whether all flow status are ADDED" )
553 utilities.assertEquals( \
554 expect = main.TRUE,
555 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700556 onpass = "Flow status is correct!",
557 onfail = "Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700558
pingping-lin829428d2015-09-22 20:50:00 -0700559 # Ping test
560 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
561 peers = ["peer64514", "peer64515", "peer64516"],
562 expectAllSuccess = True )
563 main.Functions.pingHostToHost( main,
564 hosts = ["host64514", "host64515", "host64516"],
565 expectAllSuccess = True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700566
pingping-lin829428d2015-09-22 20:50:00 -0700567
568 def CASE9( self, main ):
pingping-linbab7f8a2015-09-21 17:33:36 -0700569 '''
570 Bring down a switch in best path, check:
571 route number, P2P intent number, M2S intent number, ping test
572 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700573 main.case( "Stop sw11 located in best path, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700574 check route number, P2P intent number, M2S intent number, ping test" )
575
pingping-lin581a3662015-09-29 17:43:39 -0700576 main.log.info( "Check the flow number correctness before stopping sw11" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700577 main.Functions.checkFlowNum( main, "sw11", 13 )
578 main.Functions.checkFlowNum( main, "sw1", 3 )
579 main.Functions.checkFlowNum( main, "sw7", 3 )
580 main.log.info( main.Mininet.checkFlows( "sw11" ) )
581 main.log.info( main.Mininet.checkFlows( "sw1" ) )
582 main.log.info( main.Mininet.checkFlows( "sw7" ) )
583
584 main.step( "Stop sw11" )
585 result = main.Mininet.switch( SW = "sw11", OPTION = "stop" )
pingping-lin3f091d62015-09-29 12:00:05 -0700586 utilities.assertEquals( expect = main.TRUE, actual = result,
587 onpass = "Stopping switch succeeded!",
588 onfail = "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700589 if result:
590 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700591 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700592 main.Functions.checkRouteNum( main, 3 )
593 main.Functions.checkM2SintentNum( main, 3 )
594 main.Functions.checkP2PintentNum( main, 18 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700595 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700596 main.log.info( "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700597 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700598 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700599
600 main.step( "Check whether all flow status are ADDED" )
601 utilities.assertEquals( \
602 expect = main.TRUE,
603 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700604 onpass = "Flow status is correct!",
605 onfail = "Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700606 # Ping test
607 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
608 peers = ["peer64514", "peer64515", "peer64516"],
609 expectAllSuccess = True )
610 main.Functions.pingHostToHost( main,
611 hosts = ["host64514", "host64515", "host64516"],
612 expectAllSuccess = True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700613
614
615 def CASE10( self, main ):
616 '''
617 Bring up the switch which was stopped in CASE9, check:
618 route number, P2P intent number, M2S intent number, ping test
619 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700620 main.case( "Start sw11 which was stopped in CASE9, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700621 check route number, P2P intent number, M2S intent number, ping test" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700622
pingping-lin581a3662015-09-29 17:43:39 -0700623 main.log.info( "Check the flow status before starting sw11" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700624 main.Functions.checkFlowNum( main, "sw1", 11 )
625 main.Functions.checkFlowNum( main, "sw7", 5 )
626 main.log.info( main.Mininet.checkFlows( "sw1" ) )
627 main.log.info( main.Mininet.checkFlows( "sw7" ) )
628
pingping-linbab7f8a2015-09-21 17:33:36 -0700629 main.step( "Start sw11" )
pingping-lin0351dee2015-09-28 13:26:35 -0700630 result1 = main.Mininet.switch( SW = "sw11", OPTION = "start" )
pingping-lin3f091d62015-09-29 12:00:05 -0700631 utilities.assertEquals( expect = main.TRUE, actual = result1,
632 onpass = "Starting switch succeeded!",
633 onfail = "Starting switch failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700634 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
pingping-lin3f091d62015-09-29 12:00:05 -0700635 utilities.assertEquals( expect = main.TRUE, actual = result2,
636 onpass = "Connect switch to ONOS succeeded!",
637 onfail = "Connect switch to ONOS failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700638 if result1 and result2:
pingping-linbab7f8a2015-09-21 17:33:36 -0700639 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
640 main.Functions.checkRouteNum( main, 3 )
641 main.Functions.checkM2SintentNum( main, 3 )
642 main.Functions.checkP2PintentNum( main, 18 )
643
pingping-lin3f091d62015-09-29 12:00:05 -0700644 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
645 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
646 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700647 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700648 main.log.info( "Starting switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700649 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700650 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700651
652 main.step( "Check whether all flow status are ADDED" )
653 utilities.assertEquals( \
654 expect = main.TRUE,
655 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700656 onpass = "Flow status is correct!",
657 onfail = "Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700658 # Ping test
659 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
660 peers = ["peer64514", "peer64515", "peer64516"],
661 expectAllSuccess = True )
662 main.Functions.pingHostToHost( main,
663 hosts = ["host64514", "host64515", "host64516"],
664 expectAllSuccess = True )