blob: 9e160d3aa593f87ad2566e01e391433bfe2f0607 [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-lin28e7b212015-09-10 10:14:58 -0700108
109 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-lin28e7b212015-09-10 10:14:58 -0700130
131 main.ONOSbench.getVersion( report = True )
132
133 main.step( "Creating ONOS package" )
134 packageResult = main.ONOSbench.onosPackage( opTimeout = 500 )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700135 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" )
141 onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
pingping-linb3ebd3f2015-09-28 22:17:05 -0700142 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
148 main.step( "Checking if ONOS is up yet" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700149 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
150 utilities.assert_equals( expect = main.TRUE,
151 actual = onos1UpResult,
152 onpass = "ONOS is up",
153 onfail = "ONOS is NOT up" )
pingping-lin28e7b212015-09-10 10:14:58 -0700154
pingping-linb3ebd3f2015-09-28 22:17:05 -0700155 main.step( "Checking if ONOS CLI is ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700156 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
157 commandlineTimeout = 100, onosStartTimeout = 600 )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700158 utilities.assert_equals( expect = main.TRUE,
159 actual = cliResult,
160 onpass = "ONOS CLI is ready",
161 onfail = "ONOS CLI is NOT ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700162
pingping-linb3ebd3f2015-09-28 22:17:05 -0700163 caseResult = ( cellResult and verifyResult and
pingping-lin3f091d62015-09-29 12:00:05 -0700164 gitPullResult2 and mciResult and packageResult and
pingping-linb3ebd3f2015-09-28 22:17:05 -0700165 onos1InstallResult and onos1UpResult and cliResult )
pingping-lin28e7b212015-09-10 10:14:58 -0700166
pingping-linb702c602015-09-10 17:00:29 -0700167 utilities.assert_equals( expect = main.TRUE, actual = caseResult,
pingping-lin28e7b212015-09-10 10:14:58 -0700168 onpass = "ONOS startup successful",
169 onfail = "ONOS startup NOT successful" )
170
pingping-linb702c602015-09-10 17:00:29 -0700171 if caseResult == main.FALSE:
pingping-lin3f091d62015-09-29 12:00:05 -0700172 main.log.info( "ONOS startup failed!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700173 main.cleanup()
174 main.exit()
175
pingping-linb3ebd3f2015-09-28 22:17:05 -0700176 main.log.info( "Get links in the network" )
pingping-lin3f091d62015-09-29 12:00:05 -0700177 time.sleep( int ( main.params['timers']['TopoDiscovery'] ) )
178 summaryResult = main.ONOScli.summary()
179 linkNum = json.loads( summaryResult )[ "links" ]
180 if linkNum < 100:
181 main.log.info( "Link number is wrong!" )
182 listResult = main.ONOScli.links( jsonFormat = False )
183 main.log.info( listResult )
184 main.cleanup()
185 main.exit()
186
pingping-lin28e7b212015-09-10 10:14:58 -0700187 listResult = main.ONOScli.links( jsonFormat = False )
188 main.log.info( listResult )
pingping-linb702c602015-09-10 17:00:29 -0700189
pingping-linb3ebd3f2015-09-28 22:17:05 -0700190 main.step( "Activate sdn-ip application" )
191 activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" )
192 utilities.assert_equals( expect = main.TRUE,
193 actual = activeSDNIPresult,
194 onpass = "Activate SDN-IP succeeded",
195 onfail = "Activate SDN-IP failed" )
pingping-lin3f091d62015-09-29 12:00:05 -0700196 if not activeSDNIPresult:
197 main.log.info( "Activate SDN-IP failed!" )
198 main.cleanup()
199 main.exit()
200
pingping-linb3ebd3f2015-09-28 22:17:05 -0700201
202 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
pingping-linb702c602015-09-10 17:00:29 -0700203 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700204 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700205 main.log.info( "Wait Quagga to finish delivery all routes to each \
206 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700207 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
208 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
209
210
pingping-lin4f80c492015-09-15 14:34:42 -0700211 def CASE102( self, main ):
212 '''
213 This test case is to load the methods from other Python files.
214 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700215 main.case( "Loading methods from other Python file" )
pingping-lin4f80c492015-09-15 14:34:42 -0700216 # load the methods from other file
217 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
218 main.Functions = imp.load_source( wrapperFile,
219 main.dependencyPath +
220 wrapperFile +
221 ".py" )
222
223
pingping-lin0ce60622015-09-10 14:37:33 -0700224 def CASE1( self, main ):
225 '''
226 ping test from 3 bgp peers to BGP speaker
227 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700228
pingping-linb3ebd3f2015-09-28 22:17:05 -0700229 main.case( "Ping tests between BGP peers and speakers" )
pingping-lin829428d2015-09-22 20:50:00 -0700230 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
231 peers = ["peer64514", "peer64515", "peer64516"],
232 expectAllSuccess = True )
pingping-lin0ce60622015-09-10 14:37:33 -0700233
pingping-lin950b50d2015-09-14 12:00:08 -0700234
pingping-lin0ce60622015-09-10 14:37:33 -0700235 def CASE2( self, main ):
236 '''
237 point-to-point intents test for each BGP peer and BGP speaker pair
238 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700239 main.case( "Check point-to-point intents" )
pingping-lin0ce60622015-09-10 14:37:33 -0700240 main.log.info( "There are %s BGP peers in total "
241 % main.params[ 'config' ][ 'peerNum' ] )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700242 main.step( "Check P2P intents number from ONOS CLI" )
pingping-lin0ce60622015-09-10 14:37:33 -0700243
244 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
245 bgpIntentsActualNum = \
246 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
247 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
248 main.log.info( "bgpIntentsExpected num is:" )
249 main.log.info( bgpIntentsExpectedNum )
250 main.log.info( "bgpIntentsActual num is:" )
251 main.log.info( bgpIntentsActualNum )
252 utilities.assertEquals( \
253 expect = True,
254 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700255 onpass = "PointToPointIntent Intent Num is correct!",
256 onfail = "PointToPointIntent Intent Num is wrong!" )
pingping-lin0ce60622015-09-10 14:37:33 -0700257
258
259 def CASE3( self, main ):
260 '''
261 routes and intents check to all BGP peers
262 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700263 main.case( "Check routes and M2S intents to all BGP peers" )
pingping-lin0ce60622015-09-10 14:37:33 -0700264
pingping-lin28e7b212015-09-10 10:14:58 -0700265 allRoutesExpected = []
266 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
267 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
268 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
269
270 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
271 allRoutesActual = \
272 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
273 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
274 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
275
276 main.step( "Check routes installed" )
277 main.log.info( "Routes expected:" )
278 main.log.info( allRoutesStrExpected )
279 main.log.info( "Routes get from ONOS CLI:" )
280 main.log.info( allRoutesStrActual )
281 utilities.assertEquals( \
282 expect = allRoutesStrExpected, actual = allRoutesStrActual,
pingping-linb3ebd3f2015-09-28 22:17:05 -0700283 onpass = "Routes are correct!",
284 onfail = "Routes are wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700285
pingping-linb3ebd3f2015-09-28 22:17:05 -0700286 main.step( "Check M2S intents installed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700287 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
288 routeIntentsActualNum = \
289 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
290 routeIntentsExpectedNum = 3
291
292 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
293 main.log.info( routeIntentsExpectedNum )
294 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
295 main.log.info( routeIntentsActualNum )
296 utilities.assertEquals( \
297 expect = True,
298 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700299 onpass = "MultiPointToSinglePoint Intent Num is correct!",
300 onfail = "MultiPointToSinglePoint Intent Num is wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700301
pingping-linbab7f8a2015-09-21 17:33:36 -0700302 main.step( "Check whether all flow status are ADDED" )
303 utilities.assertEquals( \
304 expect = main.TRUE,
305 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700306 onpass = "Flow status is correct!",
307 onfail = "Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700308
pingping-lin950b50d2015-09-14 12:00:08 -0700309
310 def CASE4( self, main ):
311 '''
312 Ping test in data plane for each route
313 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700314 main.case( "Ping test for each route, all hosts behind BGP peers" )
pingping-lin829428d2015-09-22 20:50:00 -0700315 main.Functions.pingHostToHost( main,
316 hosts = ["host64514", "host64515", "host64516"],
317 expectAllSuccess = True )
pingping-lin4f80c492015-09-15 14:34:42 -0700318
319
320 def CASE5( self, main ):
321 '''
322 Cut links to peers one by one, check routes/intents
323 '''
324 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700325 main.case( "Bring down links and check routes/intents" )
pingping-lin4f80c492015-09-15 14:34:42 -0700326 main.step( "Bring down the link between sw32 and peer64514" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700327 linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
328 OPTION = "down" )
329 utilities.assertEquals( expect = main.TRUE,
330 actual = linkResult1,
331 onpass = "Bring down link succeeded!",
332 onfail = "Bring down link failed!" )
333
334 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700335 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
336 main.Functions.checkRouteNum( main, 2 )
337 main.Functions.checkM2SintentNum( main, 2 )
338 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700339 main.log.info( "Bring down link failed!" )
340 main.cleanup()
341 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700342
343 main.step( "Bring down the link between sw8 and peer64515" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700344 linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
345 OPTION = "down" )
346 utilities.assertEquals( expect = main.TRUE,
347 actual = linkResult2,
348 onpass = "Bring down link succeeded!",
349 onfail = "Bring down link failed!" )
350 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700351 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
352 main.Functions.checkRouteNum( main, 1 )
353 main.Functions.checkM2SintentNum( main, 1 )
354 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700355 main.log.info( "Bring down link failed!" )
356 main.cleanup()
357 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700358
359 main.step( "Bring down the link between sw28 and peer64516" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700360 linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
361 OPTION = "down" )
362 utilities.assertEquals( expect = main.TRUE,
363 actual = linkResult3,
364 onpass = "Bring down link succeeded!",
365 onfail = "Bring down link failed!" )
366 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700367 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
368 main.Functions.checkRouteNum( main, 0 )
369 main.Functions.checkM2SintentNum( main, 0 )
370 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700371 main.log.info( "Bring down link failed!" )
372 main.cleanup()
373 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700374
pingping-linbab7f8a2015-09-21 17:33:36 -0700375 main.step( "Check whether all flow status are ADDED" )
376 utilities.assertEquals( \
377 expect = main.TRUE,
378 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700379 onpass = "Flow status is correct!",
380 onfail = "Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700381
pingping-lin829428d2015-09-22 20:50:00 -0700382 # Ping test
383 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
384 peers = ["peer64514", "peer64515", "peer64516"],
385 expectAllSuccess = False )
386 main.Functions.pingHostToHost( main,
387 hosts = ["host64514", "host64515", "host64516"],
388 expectAllSuccess = False )
pingping-lin4f80c492015-09-15 14:34:42 -0700389
pingping-lin829428d2015-09-22 20:50:00 -0700390
391 def CASE6( self, main ):
pingping-lin4f80c492015-09-15 14:34:42 -0700392 '''
393 Recover links to peers one by one, check routes/intents
394 '''
395 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700396 main.case( "Bring up links and check routes/intents" )
pingping-lin4f80c492015-09-15 14:34:42 -0700397 main.step( "Bring up the link between sw32 and peer64514" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700398 linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
399 OPTION = "up" )
400 utilities.assertEquals( expect = main.TRUE,
401 actual = linkResult1,
402 onpass = "Bring up link succeeded!",
403 onfail = "Bring up link failed!" )
404 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700405 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
406 main.Functions.checkRouteNum( main, 1 )
407 main.Functions.checkM2SintentNum( main, 1 )
408 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700409 main.log.info( "Bring up link failed!" )
410 main.cleanup()
411 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700412
413 main.step( "Bring up the link between sw8 and peer64515" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700414 linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
415 OPTION = "up" )
416 utilities.assertEquals( expect = main.TRUE,
417 actual = linkResult2,
418 onpass = "Bring up link succeeded!",
419 onfail = "Bring up link failed!" )
420 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700421 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
422 main.Functions.checkRouteNum( main, 2 )
423 main.Functions.checkM2SintentNum( main, 2 )
424 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700425 main.log.info( "Bring up link failed!" )
426 main.cleanup()
427 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700428
429 main.step( "Bring up the link between sw28 and peer64516" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700430 linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
431 OPTION = "up" )
432 utilities.assertEquals( expect = main.TRUE,
433 actual = linkResult3,
434 onpass = "Bring up link succeeded!",
435 onfail = "Bring up link failed!" )
436 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700437 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
438 main.Functions.checkRouteNum( main, 3 )
439 main.Functions.checkM2SintentNum( main, 3 )
440 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700441 main.log.info( "Bring up link failed!" )
442 main.cleanup()
443 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700444
445 main.step( "Check whether all flow status are ADDED" )
446 utilities.assertEquals( \
447 expect = main.TRUE,
448 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700449 onpass = "Flow status is correct!",
450 onfail = "Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700451
452 # Ping test
453 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
454 peers = ["peer64514", "peer64515", "peer64516"],
455 expectAllSuccess = True )
456 main.Functions.pingHostToHost( main,
457 hosts = ["host64514", "host64515", "host64516"],
458 expectAllSuccess = True )
pingping-lin8244a3b2015-09-16 13:36:56 -0700459
460
pingping-lin829428d2015-09-22 20:50:00 -0700461 def CASE7( self, main ):
pingping-lin8244a3b2015-09-16 13:36:56 -0700462 '''
pingping-lin829428d2015-09-22 20:50:00 -0700463 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
pingping-lin8244a3b2015-09-16 13:36:56 -0700464 '''
465 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700466 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700467 main.step( "Stop sw32" )
468 result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
pingping-lin3f091d62015-09-29 12:00:05 -0700469 utilities.assertEquals( expect = main.TRUE, actual = result,
470 onpass = "Stopping switch succeeded!",
471 onfail = "Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700472
pingping-lin8244a3b2015-09-16 13:36:56 -0700473 if result == main.TRUE:
474 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
475 main.Functions.checkRouteNum( main, 2 )
476 main.Functions.checkM2SintentNum( main, 2 )
477 main.Functions.checkP2PintentNum( main, 12 )
478 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700479 main.log.info( "Stopping switch failed!" )
480 main.cleanup()
481 main.exit()
pingping-lin8244a3b2015-09-16 13:36:56 -0700482
pingping-lin829428d2015-09-22 20:50:00 -0700483 main.step( "Check ping between hosts behind BGP peers" )
484 result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
485 result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
486 result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )
487
488 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
489 and ( result3 == main.FALSE )
490 utilities.assert_equals( expect = True, actual = pingResult1,
491 onpass = "Ping test result is correct",
492 onfail = "Ping test result is wrong" )
493
494 if pingResult1 == False:
495 main.cleanup()
496 main.exit()
497
498 main.step( "Check ping between BGP peers and speakers" )
499 result4 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" )
500 result5 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" )
501 result6 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" )
502
503 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
504 and ( result6 == main.TRUE )
505 utilities.assert_equals( expect = True, actual = pingResult2,
506 onpass = "Speaker1 ping peers successful",
507 onfail = "Speaker1 ping peers NOT successful" )
508
509 if pingResult2 == False:
510 main.cleanup()
511 main.exit()
512
pingping-linbab7f8a2015-09-21 17:33:36 -0700513 main.step( "Check whether all flow status are ADDED" )
514 utilities.assertEquals( \
515 expect = main.TRUE,
516 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700517 onpass = "Flow status is correct!",
518 onfail = "Flow status is wrong!" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700519
pingping-lind791d342015-09-17 18:34:31 -0700520
pingping-lin8244a3b2015-09-16 13:36:56 -0700521 def CASE8( self, main ):
pingping-lind791d342015-09-17 18:34:31 -0700522 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700523 Bring up the edge switch (sw32) which was shut down in CASE7,
pingping-lind791d342015-09-17 18:34:31 -0700524 check P-2-P and M-2-S intents, ping test
525 '''
526 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700527 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700528 main.step( "Start sw32" )
529 result1 = main.Mininet.switch( SW = "sw32", OPTION = "start" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700530 utilities.assertEquals( \
531 expect = main.TRUE,
532 actual = result1,
533 onpass = "Starting switch succeeded!",
534 onfail = "Starting switch failed!" )
535
pingping-lind791d342015-09-17 18:34:31 -0700536 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700537 utilities.assertEquals( \
538 expect = main.TRUE,
539 actual = result2,
540 onpass = "Connect switch to ONOS succeeded!",
541 onfail = "Connect switch to ONOS failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700542
543 if result1 and result2:
544 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
545 main.Functions.checkRouteNum( main, 3 )
546 main.Functions.checkM2SintentNum( main, 3 )
547 main.Functions.checkP2PintentNum( main, 18 )
548 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700549 main.log.info( "Starting switch failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700550 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700551 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700552
pingping-linbab7f8a2015-09-21 17:33:36 -0700553 main.step( "Check whether all flow status are ADDED" )
554 utilities.assertEquals( \
555 expect = main.TRUE,
556 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700557 onpass = "Flow status is correct!",
558 onfail = "Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700559
pingping-lin829428d2015-09-22 20:50:00 -0700560 # Ping test
561 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
562 peers = ["peer64514", "peer64515", "peer64516"],
563 expectAllSuccess = True )
564 main.Functions.pingHostToHost( main,
565 hosts = ["host64514", "host64515", "host64516"],
566 expectAllSuccess = True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700567
pingping-lin829428d2015-09-22 20:50:00 -0700568
569 def CASE9( self, main ):
pingping-linbab7f8a2015-09-21 17:33:36 -0700570 '''
571 Bring down a switch in best path, check:
572 route number, P2P intent number, M2S intent number, ping test
573 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700574 main.case( "Stop sw11 located in best path, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700575 check route number, P2P intent number, M2S intent number, ping test" )
576
pingping-lin581a3662015-09-29 17:43:39 -0700577 main.log.info( "Check the flow number correctness before stopping sw11" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700578 main.Functions.checkFlowNum( main, "sw11", 13 )
579 main.Functions.checkFlowNum( main, "sw1", 3 )
580 main.Functions.checkFlowNum( main, "sw7", 3 )
581 main.log.info( main.Mininet.checkFlows( "sw11" ) )
582 main.log.info( main.Mininet.checkFlows( "sw1" ) )
583 main.log.info( main.Mininet.checkFlows( "sw7" ) )
584
585 main.step( "Stop sw11" )
586 result = main.Mininet.switch( SW = "sw11", OPTION = "stop" )
pingping-lin3f091d62015-09-29 12:00:05 -0700587 utilities.assertEquals( expect = main.TRUE, actual = result,
588 onpass = "Stopping switch succeeded!",
589 onfail = "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700590 if result:
591 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700592 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700593 main.Functions.checkRouteNum( main, 3 )
594 main.Functions.checkM2SintentNum( main, 3 )
595 main.Functions.checkP2PintentNum( main, 18 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700596 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700597 main.log.info( "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700598 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700599 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700600
601 main.step( "Check whether all flow status are ADDED" )
602 utilities.assertEquals( \
603 expect = main.TRUE,
604 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700605 onpass = "Flow status is correct!",
606 onfail = "Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700607 # Ping test
608 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
609 peers = ["peer64514", "peer64515", "peer64516"],
610 expectAllSuccess = True )
611 main.Functions.pingHostToHost( main,
612 hosts = ["host64514", "host64515", "host64516"],
613 expectAllSuccess = True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700614
615
616 def CASE10( self, main ):
617 '''
618 Bring up the switch which was stopped in CASE9, check:
619 route number, P2P intent number, M2S intent number, ping test
620 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700621 main.case( "Start sw11 which was stopped in CASE9, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700622 check route number, P2P intent number, M2S intent number, ping test" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700623
pingping-lin581a3662015-09-29 17:43:39 -0700624 main.log.info( "Check the flow status before starting sw11" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700625 main.Functions.checkFlowNum( main, "sw1", 11 )
626 main.Functions.checkFlowNum( main, "sw7", 5 )
627 main.log.info( main.Mininet.checkFlows( "sw1" ) )
628 main.log.info( main.Mininet.checkFlows( "sw7" ) )
629
pingping-linbab7f8a2015-09-21 17:33:36 -0700630 main.step( "Start sw11" )
pingping-lin0351dee2015-09-28 13:26:35 -0700631 result1 = main.Mininet.switch( SW = "sw11", OPTION = "start" )
pingping-lin3f091d62015-09-29 12:00:05 -0700632 utilities.assertEquals( expect = main.TRUE, actual = result1,
633 onpass = "Starting switch succeeded!",
634 onfail = "Starting switch failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700635 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
pingping-lin3f091d62015-09-29 12:00:05 -0700636 utilities.assertEquals( expect = main.TRUE, actual = result2,
637 onpass = "Connect switch to ONOS succeeded!",
638 onfail = "Connect switch to ONOS failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700639 if result1 and result2:
pingping-linbab7f8a2015-09-21 17:33:36 -0700640 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
641 main.Functions.checkRouteNum( main, 3 )
642 main.Functions.checkM2SintentNum( main, 3 )
643 main.Functions.checkP2PintentNum( main, 18 )
644
pingping-lin3f091d62015-09-29 12:00:05 -0700645 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
646 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
647 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700648 else:
pingping-linb3ebd3f2015-09-28 22:17:05 -0700649 main.log.info( "Starting switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700650 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700651 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700652
653 main.step( "Check whether all flow status are ADDED" )
654 utilities.assertEquals( \
655 expect = main.TRUE,
656 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
pingping-linb3ebd3f2015-09-28 22:17:05 -0700657 onpass = "Flow status is correct!",
658 onfail = "Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700659 # Ping test
660 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
661 peers = ["peer64514", "peer64515", "peer64516"],
662 expectAllSuccess = True )
663 main.Functions.pingHostToHost( main,
664 hosts = ["host64514", "host64515", "host64516"],
665 expectAllSuccess = True )