blob: 8e601a34b4d2125b5a73c4bde23e11343e42a550 [file] [log] [blame]
pingping-lin28e7b212015-09-10 10:14:58 -07001# Testing the functionality of SDN-IP with single ONOS instance
pingping-lin5bb663b2015-09-24 11:47:50 -07002class USECASE_SdnipFunction:
pingping-lin28e7b212015-09-10 10:14:58 -07003
4 def __init__( self ):
5 self.default = ''
6 global branchName
7
pingping-linb702c602015-09-10 17:00:29 -07008 def CASE100( self, main ):
9 """
10 Start mininet
11 """
12 import os
pingping-lin4f80c492015-09-15 14:34:42 -070013 import imp
pingping-linb3ebd3f2015-09-28 22:17:05 -070014 main.log.case( "Setup the Mininet testbed" )
pingping-linb702c602015-09-10 17:00:29 -070015 main.dependencyPath = main.testDir + \
16 main.params[ 'DEPENDENCY' ][ 'path' ]
17 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
18
19 main.step( "Starting Mininet Topology" )
20 topology = main.dependencyPath + main.topology
Jon Hall6e9897d2016-02-29 14:41:32 -080021 topoResult = main.Mininet.startNet( topoFile=topology )
22 utilities.assert_equals( expect=main.TRUE,
23 actual=topoResult,
24 onpass="Successfully loaded topology",
25 onfail="Failed to load topology" )
pingping-linb702c602015-09-10 17:00:29 -070026 # Exit if topology did not load properly
27 if not topoResult:
28 main.cleanup()
29 main.exit()
pingping-lin5bb663b2015-09-24 11:47:50 -070030 main.step( "Connect switches to controller" )
31
32 global ONOS1Ip
33 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
34 # connect all switches to controller
35 swResult = main.TRUE
36 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
37 sw = "sw%s" % ( i )
38 swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -080039 utilities.assert_equals( expect=main.TRUE,
40 actual=swResult,
41 onpass="Successfully connect all switches to ONOS",
42 onfail="Failed to connect all switches to ONOS" )
pingping-lin5bb663b2015-09-24 11:47:50 -070043 if not swResult:
44 main.cleanup()
45 main.exit()
46
47 main.step( "Set up tunnel from Mininet node to onos node" )
48 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip )
49 command = 'ssh -nNT -o "PasswordAuthentication no" \
50 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, ONOS1Ip )
51
52 tunnelResult = main.TRUE
53 tunnelResult = main.Mininet.node( "root", command )
Jon Hall6e9897d2016-02-29 14:41:32 -080054 utilities.assert_equals( expect=True,
55 actual=( "PasswordAuthentication" in tunnelResult ),
56 onpass="Created tunnel succeeded",
57 onfail="Create tunnel failed" )
pingping-linb3ebd3f2015-09-28 22:17:05 -070058 if ("PasswordAuthentication" not in tunnelResult) :
pingping-lin5bb663b2015-09-24 11:47:50 -070059 main.cleanup()
60 main.exit()
pingping-lin5bb663b2015-09-24 11:47:50 -070061
pingping-linb702c602015-09-10 17:00:29 -070062 def CASE101( self, main ):
pingping-lin28e7b212015-09-10 10:14:58 -070063 """
pingping-linea32cf82015-10-08 22:37:37 -070064 Package ONOS and install it
pingping-lin28e7b212015-09-10 10:14:58 -070065 Startup sequence:
66 cell <name>
67 onos-verify-cell
pingping-lin28e7b212015-09-10 10:14:58 -070068 onos-package
69 onos-install -f
70 onos-wait-for-start
71 """
72 import json
73 import time
Jon Hall6e9897d2016-02-29 14:41:32 -080074 import os
pingping-lin28e7b212015-09-10 10:14:58 -070075 from operator import eq
76
Jon Hall6e9897d2016-02-29 14:41:32 -080077 main.case( "Setting up ONOS environment" )
pingping-lin28e7b212015-09-10 10:14:58 -070078
79 cellName = main.params[ 'ENV' ][ 'cellName' ]
Jon Hall6e9897d2016-02-29 14:41:32 -080080 global ONOS1Ip
81 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
82 ipList = [ ONOS1Ip ]
83
84 main.step( "Create cell file" )
85 cellAppString = main.params[ 'ENV' ][ 'appString' ]
86 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
87 main.Mininet.ip_address,
88 cellAppString, ipList )
pingping-lin28e7b212015-09-10 10:14:58 -070089
90 main.step( "Applying cell variable to environment" )
91 cellResult = main.ONOSbench.setCell( cellName )
Jon Hall6e9897d2016-02-29 14:41:32 -080092 utilities.assert_equals( expect=main.TRUE,
93 actual=cellResult,
94 onpass="Set cell succeeded",
95 onfail="Set cell failed" )
pingping-linb3ebd3f2015-09-28 22:17:05 -070096
pingping-lin28e7b212015-09-10 10:14:58 -070097 verifyResult = main.ONOSbench.verifyCell()
Jon Hall6e9897d2016-02-29 14:41:32 -080098 utilities.assert_equals( expect=main.TRUE,
99 actual=verifyResult,
100 onpass="Verify cell succeeded",
101 onfail="Verify cell failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700102
103 branchName = main.ONOSbench.getBranchName()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700104 main.log.report( "ONOS is on branch: " + branchName )
pingping-lin28e7b212015-09-10 10:14:58 -0700105
pingping-linb3ebd3f2015-09-28 22:17:05 -0700106 main.log.step( "Uninstalling ONOS" )
107 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -0800108 utilities.assert_equals( expect=main.TRUE,
109 actual=uninstallResult,
110 onpass="Uninstall ONOS succeeded",
111 onfail="Uninstall ONOS failed" )
pingping-linaede0312015-09-30 17:53:19 -0700112 '''
pingping-lin28e7b212015-09-10 10:14:58 -0700113 main.step( "Git pull" )
114 gitPullResult = main.ONOSbench.gitPull()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700115 main.log.info( "gitPullResult" )
116 main.log.info( gitPullResult )
117 gitPullResult2 = ( gitPullResult == main.TRUE ) or ( gitPullResult == 3 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800118 utilities.assert_equals( expect=True,
119 actual=gitPullResult2,
120 onpass="Git pull ONOS succeeded",
121 onfail="Git pull ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700122
123 main.step( "Using mvn clean install" )
124 if gitPullResult == main.TRUE:
Jon Hall6e9897d2016-02-29 14:41:32 -0800125 mciResult = main.ONOSbench.cleanInstall( mciTimeout=1000 )
126 utilities.assert_equals( expect=main.TRUE,
127 actual=mciResult,
128 onpass="Maven clean install ONOS succeeded",
129 onfail="Maven clean install ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700130 else:
131 main.log.warn( "Did not pull new code so skipping mvn " +
132 "clean install" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700133 mciResult = main.TRUE
pingping-linaede0312015-09-30 17:53:19 -0700134 '''
pingping-lin28e7b212015-09-10 10:14:58 -0700135
Jon Hall6e9897d2016-02-29 14:41:32 -0800136 main.ONOSbench.getVersion( report=True )
pingping-lin28e7b212015-09-10 10:14:58 -0700137
138 main.step( "Creating ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800139 packageResult = main.ONOSbench.onosPackage( opTimeout=500 )
140 utilities.assert_equals( expect=main.TRUE,
141 actual=packageResult,
142 onpass="Package ONOS succeeded",
143 onfail="Package ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700144
145 main.step( "Installing ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800146 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
147 node=ONOS1Ip )
148 utilities.assert_equals( expect=main.TRUE,
149 actual=onos1InstallResult,
150 onpass="Install ONOS succeeded",
151 onfail="Install ONOS failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700152
153 main.step( "Checking if ONOS is up yet" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800154 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
155 utilities.assert_equals( expect=main.TRUE,
156 actual=onos1UpResult,
157 onpass="ONOS is up",
158 onfail="ONOS is NOT up" )
pingping-lin28e7b212015-09-10 10:14:58 -0700159
pingping-linb3ebd3f2015-09-28 22:17:05 -0700160 main.step( "Checking if ONOS CLI is ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700161 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800162 commandlineTimeout=100, onosStartTimeout=600 )
163 utilities.assert_equals( expect=main.TRUE,
164 actual=cliResult,
165 onpass="ONOS CLI is ready",
166 onfail="ONOS CLI is not ready" )
pingping-lin28e7b212015-09-10 10:14:58 -0700167
Jon Hall6e9897d2016-02-29 14:41:32 -0800168 for i in range( 10 ):
169 ready = True
170 output = main.ONOScli.summary()
171 if not output:
172 ready = False
173 if ready:
174 break
175 time.sleep( 30 )
176 utilities.assert_equals( expect=True, actual=ready,
177 onpass="ONOS summary command succeded",
178 onfail="ONOS summary command failed" )
pingping-lin28e7b212015-09-10 10:14:58 -0700179
Jon Hall6e9897d2016-02-29 14:41:32 -0800180 if not ready:
181 main.log.error( "ONOS startup failed!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700182 main.cleanup()
183 main.exit()
184
Jon Hall6e9897d2016-02-29 14:41:32 -0800185 def CASE200( self, main ):
186 main.case( "Activate sdn-ip application" )
187 main.log.info( "waiting link discovery......" )
188 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
189
pingping-linb3ebd3f2015-09-28 22:17:05 -0700190 main.log.info( "Get links in the network" )
pingping-lin3f091d62015-09-29 12:00:05 -0700191 summaryResult = main.ONOScli.summary()
192 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall6e9897d2016-02-29 14:41:32 -0800193 listResult = main.ONOScli.links( jsonFormat=False )
194 main.log.info( listResult )
pingping-lin3f091d62015-09-29 12:00:05 -0700195 if linkNum < 100:
Jon Hall6e9897d2016-02-29 14:41:32 -0800196 main.log.error( "Link number is wrong!" )
197 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
198 listResult = main.ONOScli.links( jsonFormat=False )
pingping-lin3f091d62015-09-29 12:00:05 -0700199 main.log.info( listResult )
200 main.cleanup()
201 main.exit()
202
pingping-linb3ebd3f2015-09-28 22:17:05 -0700203 main.step( "Activate sdn-ip application" )
204 activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800205 utilities.assert_equals( expect=main.TRUE,
206 actual=activeSDNIPresult,
207 onpass="Activate SDN-IP succeeded",
208 onfail="Activate SDN-IP failed" )
pingping-lin3f091d62015-09-29 12:00:05 -0700209 if not activeSDNIPresult:
210 main.log.info( "Activate SDN-IP failed!" )
211 main.cleanup()
212 main.exit()
213
pingping-linb3ebd3f2015-09-28 22:17:05 -0700214
215 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
pingping-linb702c602015-09-10 17:00:29 -0700216 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700217 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700218 main.log.info( "Wait Quagga to finish delivery all routes to each \
219 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700220 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
221 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
222
223
pingping-lin4f80c492015-09-15 14:34:42 -0700224 def CASE102( self, main ):
225 '''
226 This test case is to load the methods from other Python files.
227 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700228 main.case( "Loading methods from other Python file" )
pingping-lin4f80c492015-09-15 14:34:42 -0700229 # load the methods from other file
230 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
231 main.Functions = imp.load_source( wrapperFile,
232 main.dependencyPath +
233 wrapperFile +
234 ".py" )
235
236
pingping-lin0ce60622015-09-10 14:37:33 -0700237 def CASE1( self, main ):
238 '''
239 ping test from 3 bgp peers to BGP speaker
240 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700241
pingping-linb3ebd3f2015-09-28 22:17:05 -0700242 main.case( "Ping tests between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800243 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
244 peers=["peer64514", "peer64515", "peer64516"],
245 expectAllSuccess=True )
pingping-lin0ce60622015-09-10 14:37:33 -0700246
pingping-lin950b50d2015-09-14 12:00:08 -0700247
pingping-lin0ce60622015-09-10 14:37:33 -0700248 def CASE2( self, main ):
249 '''
250 point-to-point intents test for each BGP peer and BGP speaker pair
251 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800252 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700253 main.case( "Check point-to-point intents" )
pingping-lin0ce60622015-09-10 14:37:33 -0700254 main.log.info( "There are %s BGP peers in total "
255 % main.params[ 'config' ][ 'peerNum' ] )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700256 main.step( "Check P2P intents number from ONOS CLI" )
pingping-lin0ce60622015-09-10 14:37:33 -0700257
Jon Hall6e9897d2016-02-29 14:41:32 -0800258 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin0ce60622015-09-10 14:37:33 -0700259 bgpIntentsActualNum = \
260 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
261 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
Jon Hall6e9897d2016-02-29 14:41:32 -0800262 if bgpIntentsActualNum != bgpIntentsExpectedNum:
263 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
264 bgpIntentsActualNum = \
265 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
pingping-lin0ce60622015-09-10 14:37:33 -0700266 main.log.info( "bgpIntentsExpected num is:" )
267 main.log.info( bgpIntentsExpectedNum )
268 main.log.info( "bgpIntentsActual num is:" )
269 main.log.info( bgpIntentsActualNum )
270 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800271 expect=True,
272 actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
273 onpass="PointToPointIntent Intent Num is correct!",
274 onfail="PointToPointIntent Intent Num is wrong!" )
pingping-lin0ce60622015-09-10 14:37:33 -0700275
276
277 def CASE3( self, main ):
278 '''
279 routes and intents check to all BGP peers
280 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800281 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700282 main.case( "Check routes and M2S intents to all BGP peers" )
pingping-lin0ce60622015-09-10 14:37:33 -0700283
pingping-lin28e7b212015-09-10 10:14:58 -0700284 allRoutesExpected = []
285 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
286 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
287 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
288
Jon Hall6e9897d2016-02-29 14:41:32 -0800289 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-lin28e7b212015-09-10 10:14:58 -0700290 allRoutesActual = \
291 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
292 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
293 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800294 if allRoutesStrActual != allRoutesStrExpected:
295 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
296 allRoutesActual = \
297 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
298 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
pingping-lin28e7b212015-09-10 10:14:58 -0700299
300 main.step( "Check routes installed" )
301 main.log.info( "Routes expected:" )
302 main.log.info( allRoutesStrExpected )
303 main.log.info( "Routes get from ONOS CLI:" )
304 main.log.info( allRoutesStrActual )
305 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800306 expect=allRoutesStrExpected, actual=allRoutesStrActual,
307 onpass="Routes are correct!",
308 onfail="Routes are wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700309
pingping-linb3ebd3f2015-09-28 22:17:05 -0700310 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800311 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin28e7b212015-09-10 10:14:58 -0700312 routeIntentsActualNum = \
313 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
314 routeIntentsExpectedNum = 3
Jon Hall6e9897d2016-02-29 14:41:32 -0800315 if routeIntentsActualNum != routeIntentsExpectedNum:
316 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
317 routeIntentsActualNum = \
318 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-lin28e7b212015-09-10 10:14:58 -0700319
320 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
321 main.log.info( routeIntentsExpectedNum )
322 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
323 main.log.info( routeIntentsActualNum )
324 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800325 expect=routeIntentsExpectedNum,
326 actual=routeIntentsActualNum,
327 onpass="MultiPointToSinglePoint Intent Num is correct!",
328 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-lin28e7b212015-09-10 10:14:58 -0700329
pingping-linbab7f8a2015-09-21 17:33:36 -0700330 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800331 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
332 main.FALSE,
333 kwargs={'isPENDING':False},
334 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700335 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800336 expect=main.TRUE,
337 actual=flowCheck,
338 onpass="Flow status is correct!",
339 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700340
pingping-lin950b50d2015-09-14 12:00:08 -0700341
342 def CASE4( self, main ):
343 '''
344 Ping test in data plane for each route
345 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700346 main.case( "Ping test for each route, all hosts behind BGP peers" )
pingping-lin829428d2015-09-22 20:50:00 -0700347 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800348 hosts=["host64514", "host64515", "host64516"],
349 expectAllSuccess=True )
pingping-lin4f80c492015-09-15 14:34:42 -0700350
351
352 def CASE5( self, main ):
353 '''
354 Cut links to peers one by one, check routes/intents
355 '''
356 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700357 main.case( "Bring down links and check routes/intents" )
pingping-lin4f80c492015-09-15 14:34:42 -0700358 main.step( "Bring down the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800359 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
360 OPTION="down" )
361 utilities.assertEquals( expect=main.TRUE,
362 actual=linkResult1,
363 onpass="Bring down link succeeded!",
364 onfail="Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700365
366 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700367 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
368 main.Functions.checkRouteNum( main, 2 )
369 main.Functions.checkM2SintentNum( main, 2 )
370 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800371 main.log.error( "Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700372 main.cleanup()
373 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700374
375 main.step( "Bring down the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800376 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
377 OPTION="down" )
378 utilities.assertEquals( expect=main.TRUE,
379 actual=linkResult2,
380 onpass="Bring down link succeeded!",
381 onfail="Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700382 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700383 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
384 main.Functions.checkRouteNum( main, 1 )
385 main.Functions.checkM2SintentNum( main, 1 )
386 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800387 main.log.error( "Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700388 main.cleanup()
389 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700390
391 main.step( "Bring down the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800392 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
393 OPTION="down" )
394 utilities.assertEquals( expect=main.TRUE,
395 actual=linkResult3,
396 onpass="Bring down link succeeded!",
397 onfail="Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700398 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700399 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
400 main.Functions.checkRouteNum( main, 0 )
401 main.Functions.checkM2SintentNum( main, 0 )
402 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800403 main.log.error( "Bring down link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700404 main.cleanup()
405 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700406
pingping-linbab7f8a2015-09-21 17:33:36 -0700407 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800408 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
409 main.FALSE,
410 kwargs={'isPENDING':False},
411 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700412 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800413 expect=main.TRUE,
414 actual=flowCheck,
415 onpass="Flow status is correct!",
416 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700417
pingping-lin829428d2015-09-22 20:50:00 -0700418 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800419 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
420 peers=["peer64514", "peer64515", "peer64516"],
421 expectAllSuccess=False )
pingping-lin829428d2015-09-22 20:50:00 -0700422 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800423 hosts=["host64514", "host64515", "host64516"],
424 expectAllSuccess=False )
pingping-lin4f80c492015-09-15 14:34:42 -0700425
pingping-lin829428d2015-09-22 20:50:00 -0700426
427 def CASE6( self, main ):
pingping-lin4f80c492015-09-15 14:34:42 -0700428 '''
429 Recover links to peers one by one, check routes/intents
430 '''
431 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700432 main.case( "Bring up links and check routes/intents" )
pingping-lin4f80c492015-09-15 14:34:42 -0700433 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800434 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
435 OPTION="up" )
436 utilities.assertEquals( expect=main.TRUE,
437 actual=linkResult1,
438 onpass="Bring up link succeeded!",
439 onfail="Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700440 if linkResult1 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700441 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
442 main.Functions.checkRouteNum( main, 1 )
443 main.Functions.checkM2SintentNum( main, 1 )
444 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800445 main.log.error( "Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700446 main.cleanup()
447 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700448
449 main.step( "Bring up the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800450 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
451 OPTION="up" )
452 utilities.assertEquals( expect=main.TRUE,
453 actual=linkResult2,
454 onpass="Bring up link succeeded!",
455 onfail="Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700456 if linkResult2 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700457 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
458 main.Functions.checkRouteNum( main, 2 )
459 main.Functions.checkM2SintentNum( main, 2 )
460 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800461 main.log.error( "Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700462 main.cleanup()
463 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700464
465 main.step( "Bring up the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800466 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
467 OPTION="up" )
468 utilities.assertEquals( expect=main.TRUE,
469 actual=linkResult3,
470 onpass="Bring up link succeeded!",
471 onfail="Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700472 if linkResult3 == main.TRUE:
pingping-lin4f80c492015-09-15 14:34:42 -0700473 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
474 main.Functions.checkRouteNum( main, 3 )
475 main.Functions.checkM2SintentNum( main, 3 )
476 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800477 main.log.error( "Bring up link failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700478 main.cleanup()
479 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700480
481 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800482 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
483 main.FALSE,
484 kwargs={'isPENDING':False},
485 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700486 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800487 expect=main.TRUE,
488 actual=flowCheck,
489 onpass="Flow status is correct!",
490 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700491
492 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800493 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
494 peers=["peer64514", "peer64515", "peer64516"],
495 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700496 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800497 hosts=["host64514", "host64515", "host64516"],
498 expectAllSuccess=True )
pingping-lin8244a3b2015-09-16 13:36:56 -0700499
500
pingping-lin829428d2015-09-22 20:50:00 -0700501 def CASE7( self, main ):
pingping-lin8244a3b2015-09-16 13:36:56 -0700502 '''
pingping-lin829428d2015-09-22 20:50:00 -0700503 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
pingping-lin8244a3b2015-09-16 13:36:56 -0700504 '''
505 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700506 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700507 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800508 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
509 utilities.assertEquals( expect=main.TRUE, actual=result,
510 onpass="Stopping switch succeeded!",
511 onfail="Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700512
pingping-lin8244a3b2015-09-16 13:36:56 -0700513 if result == main.TRUE:
514 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
515 main.Functions.checkRouteNum( main, 2 )
516 main.Functions.checkM2SintentNum( main, 2 )
517 main.Functions.checkP2PintentNum( main, 12 )
518 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800519 main.log.error( "Stopping switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700520 main.cleanup()
521 main.exit()
pingping-lin8244a3b2015-09-16 13:36:56 -0700522
pingping-lin829428d2015-09-22 20:50:00 -0700523 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800524 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
525 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
526 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-lin829428d2015-09-22 20:50:00 -0700527
528 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
529 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800530 utilities.assert_equals( expect=True, actual=pingResult1,
531 onpass="Ping test result is correct",
532 onfail="Ping test result is wrong" )
pingping-lin829428d2015-09-22 20:50:00 -0700533
534 if pingResult1 == False:
535 main.cleanup()
536 main.exit()
537
538 main.step( "Check ping between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800539 result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" )
540 result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" )
541 result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" )
pingping-lin829428d2015-09-22 20:50:00 -0700542
543 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
544 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800545 utilities.assert_equals( expect=True, actual=pingResult2,
546 onpass="Speaker1 ping peers successful",
547 onfail="Speaker1 ping peers NOT successful" )
pingping-lin829428d2015-09-22 20:50:00 -0700548
549 if pingResult2 == False:
550 main.cleanup()
551 main.exit()
552
pingping-linbab7f8a2015-09-21 17:33:36 -0700553 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800554 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
555 main.FALSE,
556 kwargs={'isPENDING':False},
557 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700558 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800559 expect=main.TRUE,
560 actual=flowCheck,
561 onpass="Flow status is correct!",
562 onfail="Flow status is wrong!" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700563
pingping-lind791d342015-09-17 18:34:31 -0700564
pingping-lin8244a3b2015-09-16 13:36:56 -0700565 def CASE8( self, main ):
pingping-lind791d342015-09-17 18:34:31 -0700566 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700567 Bring up the edge switch (sw32) which was shut down in CASE7,
pingping-lind791d342015-09-17 18:34:31 -0700568 check P-2-P and M-2-S intents, ping test
569 '''
570 import time
pingping-linb3ebd3f2015-09-28 22:17:05 -0700571 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700572 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800573 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700574 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800575 expect=main.TRUE,
576 actual=result1,
577 onpass="Starting switch succeeded!",
578 onfail="Starting switch failed!" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700579
pingping-lind791d342015-09-17 18:34:31 -0700580 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700581 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800582 expect=main.TRUE,
583 actual=result2,
584 onpass="Connect switch to ONOS succeeded!",
585 onfail="Connect switch to ONOS failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700586
587 if result1 and result2:
588 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
589 main.Functions.checkRouteNum( main, 3 )
590 main.Functions.checkM2SintentNum( main, 3 )
591 main.Functions.checkP2PintentNum( main, 18 )
592 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800593 main.log.error( "Starting switch failed!" )
pingping-lind791d342015-09-17 18:34:31 -0700594 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700595 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700596
pingping-linbab7f8a2015-09-21 17:33:36 -0700597 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800598 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
599 main.FALSE,
600 kwargs={'isPENDING':False},
601 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700602 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800603 expect=main.TRUE,
604 actual=flowCheck,
605 onpass="Flow status is correct!",
606 onfail="Flow status is wrong!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700607
pingping-lin829428d2015-09-22 20:50:00 -0700608 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800609 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
610 peers=["peer64514", "peer64515", "peer64516"],
611 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700612 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800613 hosts=["host64514", "host64515", "host64516"],
614 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700615
pingping-lin829428d2015-09-22 20:50:00 -0700616
617 def CASE9( self, main ):
pingping-linbab7f8a2015-09-21 17:33:36 -0700618 '''
619 Bring down a switch in best path, check:
620 route number, P2P intent number, M2S intent number, ping test
621 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700622 main.case( "Stop sw11 located in best path, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700623 check route number, P2P intent number, M2S intent number, ping test" )
624
pingping-lin581a3662015-09-29 17:43:39 -0700625 main.log.info( "Check the flow number correctness before stopping sw11" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700626 main.Functions.checkFlowNum( main, "sw11", 13 )
627 main.Functions.checkFlowNum( main, "sw1", 3 )
628 main.Functions.checkFlowNum( main, "sw7", 3 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800629 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
630 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
631 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700632
633 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800634 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
635 utilities.assertEquals( expect=main.TRUE, actual=result,
636 onpass="Stopping switch succeeded!",
637 onfail="Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700638 if result:
639 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700640 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700641 main.Functions.checkRouteNum( main, 3 )
642 main.Functions.checkM2SintentNum( main, 3 )
643 main.Functions.checkP2PintentNum( main, 18 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700644 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800645 main.log.error( "Stopping switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700646 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700647 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700648
649 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800650 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
651 main.FALSE,
652 kwargs={'isPENDING':False},
653 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700654 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800655 expect=main.TRUE,
656 actual=flowCheck,
657 onpass="Flow status is correct!",
658 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700659 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800660 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
661 peers=["peer64514", "peer64515", "peer64516"],
662 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700663 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800664 hosts=["host64514", "host64515", "host64516"],
665 expectAllSuccess=True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700666
667
668 def CASE10( self, main ):
669 '''
670 Bring up the switch which was stopped in CASE9, check:
671 route number, P2P intent number, M2S intent number, ping test
672 '''
pingping-linb3ebd3f2015-09-28 22:17:05 -0700673 main.case( "Start sw11 which was stopped in CASE9, \
pingping-linbab7f8a2015-09-21 17:33:36 -0700674 check route number, P2P intent number, M2S intent number, ping test" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700675
pingping-lin581a3662015-09-29 17:43:39 -0700676 main.log.info( "Check the flow status before starting sw11" )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700677 main.Functions.checkFlowNum( main, "sw1", 11 )
678 main.Functions.checkFlowNum( main, "sw7", 5 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800679 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
680 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linb3ebd3f2015-09-28 22:17:05 -0700681
pingping-linbab7f8a2015-09-21 17:33:36 -0700682 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800683 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
684 utilities.assertEquals( expect=main.TRUE, actual=result1,
685 onpass="Starting switch succeeded!",
686 onfail="Starting switch failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700687 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -0800688 utilities.assertEquals( expect=main.TRUE, actual=result2,
689 onpass="Connect switch to ONOS succeeded!",
690 onfail="Connect switch to ONOS failed!" )
pingping-lin0351dee2015-09-28 13:26:35 -0700691 if result1 and result2:
pingping-linbab7f8a2015-09-21 17:33:36 -0700692 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
693 main.Functions.checkRouteNum( main, 3 )
694 main.Functions.checkM2SintentNum( main, 3 )
695 main.Functions.checkP2PintentNum( main, 18 )
696
pingping-lin3f091d62015-09-29 12:00:05 -0700697 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
698 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
699 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linbab7f8a2015-09-21 17:33:36 -0700700 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800701 main.log.error( "Starting switch failed!" )
pingping-linbab7f8a2015-09-21 17:33:36 -0700702 main.cleanup()
pingping-linb3ebd3f2015-09-28 22:17:05 -0700703 main.exit()
pingping-linbab7f8a2015-09-21 17:33:36 -0700704
705 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800706 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
707 main.FALSE,
708 kwargs={'isPENDING':False},
709 attempts=10 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700710 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800711 expect=main.TRUE,
712 actual=flowCheck,
713 onpass="Flow status is correct!",
714 onfail="Flow status is wrong!" )
pingping-lin829428d2015-09-22 20:50:00 -0700715 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800716 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
717 peers=["peer64514", "peer64515", "peer64516"],
718 expectAllSuccess=True )
pingping-lin829428d2015-09-22 20:50:00 -0700719 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800720 hosts=["host64514", "host64515", "host64516"],
721 expectAllSuccess=True )