blob: 938b6e06765cdd6e199923cb2da1d459725e945b [file] [log] [blame]
pingping-linffca7e22015-11-13 15:43:08 -08001# Testing the functionality of SDN-IP with single ONOS instance
2class USECASE_SdnipFunction_fsfw:
3
4 def __init__( self ):
5 self.default = ''
6 global branchName
7
pingping-linffca7e22015-11-13 15:43:08 -08008 def CASE100( self, main ):
9 """
10 Start mininet
11 """
12 import os
13 import imp
14 main.log.case( "Setup the Mininet testbed" )
15 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-linffca7e22015-11-13 15:43:08 -080026 # Exit if topology did not load properly
27 if not topoResult:
28 main.cleanup()
29 main.exit()
pingping-lin14776632015-12-16 12:05:30 -080030 main.step( "Connect switches to FSFW" )
pingping-linffca7e22015-11-13 15:43:08 -080031
32 global ONOS1Ip
33 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
pingping-lin8c178802015-11-30 17:25:43 -080034 global fsfwIp
pingping-line9107e42015-11-30 19:19:38 -080035 # TDOO: there is some setup sequence issue, will fix it later
36 # fsfwIp = os.getenv( main.params[ 'CTRL' ][ 'ipN' ] )
37 fsfwIp = main.params[ 'CTRL' ][ 'fsfwIp' ]
pingping-lin15fa4be2015-11-30 18:27:58 -080038 global fsfwPort
pingping-line9107e42015-11-30 19:19:38 -080039 fsfwPort = main.params[ 'CTRL' ][ 'fsfwPort' ]
pingping-lin8c178802015-11-30 17:25:43 -080040
pingping-linffca7e22015-11-13 15:43:08 -080041 # connect all switches to controller
42 swResult = main.TRUE
43 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
44 sw = "sw%s" % ( i )
pingping-lin15fa4be2015-11-30 18:27:58 -080045 swResult = swResult and main.Mininet.assignSwController( sw, fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -080046 port=fsfwPort )
47 utilities.assert_equals( expect=main.TRUE,
48 actual=swResult,
49 onpass="Successfully connect all switches to ONOS",
50 onfail="Failed to connect all switches to ONOS" )
pingping-linffca7e22015-11-13 15:43:08 -080051 if not swResult:
52 main.cleanup()
53 main.exit()
54
55 main.step( "Set up tunnel from Mininet node to onos node" )
56 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -080057 command = 'ssh -nNT -o "PasswordAuthentication no"'
58 command += ' -o "StrictHostKeyChecking no" -l sdn'
59 command += ' -L %s %s & ' % ( forwarding1, ONOS1Ip )
pingping-linffca7e22015-11-13 15:43:08 -080060
61 tunnelResult = main.TRUE
62 tunnelResult = main.Mininet.node( "root", command )
Jon Hall6e9897d2016-02-29 14:41:32 -080063 utilities.assert_equals( expect=True,
64 actual=( "PasswordAuthentication" in tunnelResult ),
65 onpass="Created tunnel succeeded",
66 onfail="Create tunnel failed" )
pingping-linffca7e22015-11-13 15:43:08 -080067 if ("PasswordAuthentication" not in tunnelResult) :
68 main.cleanup()
69 main.exit()
70
pingping-linffca7e22015-11-13 15:43:08 -080071 def CASE101( self, main ):
72 """
73 Package ONOS and install it
74 Startup sequence:
75 cell <name>
76 onos-verify-cell
77 onos-package
78 onos-install -f
79 onos-wait-for-start
80 """
81 import json
82 import time
Jon Hall6e9897d2016-02-29 14:41:32 -080083 import os
pingping-linffca7e22015-11-13 15:43:08 -080084 from operator import eq
85
86 main.case( "Setting up test environment" )
87
88 cellName = main.params[ 'ENV' ][ 'cellName' ]
Jon Hall6e9897d2016-02-29 14:41:32 -080089 global ONOS1Ip
90 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
91 ipList = [ ONOS1Ip ]
92
93 main.step( "Create cell file" )
94 cellAppString = main.params[ 'ENV' ][ 'appString' ]
95 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
96 main.Mininet.ip_address,
97 cellAppString, ipList )
pingping-linffca7e22015-11-13 15:43:08 -080098
99 main.step( "Applying cell variable to environment" )
100 cellResult = main.ONOSbench.setCell( cellName )
Jon Hall6e9897d2016-02-29 14:41:32 -0800101 utilities.assert_equals( expect=main.TRUE,
102 actual=cellResult,
103 onpass="Set cell succeeded",
104 onfail="Set cell failed" )
pingping-linffca7e22015-11-13 15:43:08 -0800105
106 verifyResult = main.ONOSbench.verifyCell()
Jon Hall6e9897d2016-02-29 14:41:32 -0800107 utilities.assert_equals( expect=main.TRUE,
108 actual=verifyResult,
109 onpass="Verify cell succeeded",
110 onfail="Verify cell failed" )
pingping-linffca7e22015-11-13 15:43:08 -0800111
112 branchName = main.ONOSbench.getBranchName()
113 main.log.report( "ONOS is on branch: " + branchName )
114
115 main.log.step( "Uninstalling ONOS" )
116 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
Jon Hall6e9897d2016-02-29 14:41:32 -0800117 utilities.assert_equals( expect=main.TRUE,
118 actual=uninstallResult,
119 onpass="Uninstall ONOS succeeded",
120 onfail="Uninstall ONOS failed" )
pingping-linffca7e22015-11-13 15:43:08 -0800121
Jon Hall6e9897d2016-02-29 14:41:32 -0800122 main.ONOSbench.getVersion( report=True )
pingping-linffca7e22015-11-13 15:43:08 -0800123
124 main.step( "Creating ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800125 packageResult = main.ONOSbench.onosPackage( opTimeout=500 )
126 utilities.assert_equals( expect=main.TRUE,
127 actual=packageResult,
128 onpass="Package ONOS succeeded",
129 onfail="Package ONOS failed" )
pingping-linffca7e22015-11-13 15:43:08 -0800130
131 main.step( "Installing ONOS package" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800132 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
133 node=ONOS1Ip )
134 utilities.assert_equals( expect=main.TRUE,
135 actual=onos1InstallResult,
136 onpass="Install ONOS succeeded",
137 onfail="Install ONOS failed" )
pingping-linffca7e22015-11-13 15:43:08 -0800138
139 main.step( "Checking if ONOS is up yet" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800140 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
141 utilities.assert_equals( expect=main.TRUE,
142 actual=onos1UpResult,
143 onpass="ONOS is up",
144 onfail="ONOS is NOT up" )
pingping-linffca7e22015-11-13 15:43:08 -0800145
146 main.step( "Checking if ONOS CLI is ready" )
147 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
Jon Hall6e9897d2016-02-29 14:41:32 -0800148 commandlineTimeout=100,
149 onosStartTimeout=600 )
150 utilities.assert_equals( expect=main.TRUE,
151 actual=cliResult,
152 onpass="ONOS CLI is ready",
153 onfail="ONOS CLI is not ready" )
pingping-linffca7e22015-11-13 15:43:08 -0800154
Jon Hall6e9897d2016-02-29 14:41:32 -0800155 for i in range( 10 ):
156 ready = True
157 output = main.ONOScli.summary()
158 if not output:
159 ready = False
160 if ready:
161 break
162 time.sleep( 30 )
163 utilities.assert_equals( expect=True, actual=ready,
164 onpass="ONOS summary command succeded",
165 onfail="ONOS summary command failed" )
pingping-linffca7e22015-11-13 15:43:08 -0800166
Jon Hall6e9897d2016-02-29 14:41:32 -0800167 if not ready:
168 main.log.error( "ONOS startup failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800169 main.cleanup()
170 main.exit()
171
172 main.log.info( "Get links in the network" )
173 time.sleep( int ( main.params['timers']['TopoDiscovery'] ) )
174 summaryResult = main.ONOScli.summary()
175 linkNum = json.loads( summaryResult )[ "links" ]
Jon Hall6e9897d2016-02-29 14:41:32 -0800176 listResult = main.ONOScli.links( jsonFormat=False )
177 main.log.info( listResult )
pingping-linffca7e22015-11-13 15:43:08 -0800178 if linkNum < 100:
Jon Hall6e9897d2016-02-29 14:41:32 -0800179 main.log.error( "Link number is wrong!" )
180 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
181 listResult = main.ONOScli.links( jsonFormat=False )
pingping-linffca7e22015-11-13 15:43:08 -0800182 main.log.info( listResult )
183 main.cleanup()
184 main.exit()
185
pingping-linffca7e22015-11-13 15:43:08 -0800186 main.step( "Activate sdn-ip application" )
187 activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800188 utilities.assert_equals( expect=main.TRUE,
189 actual=activeSDNIPresult,
190 onpass="Activate SDN-IP succeeded",
191 onfail="Activate SDN-IP failed" )
pingping-linffca7e22015-11-13 15:43:08 -0800192 if not activeSDNIPresult:
193 main.log.info( "Activate SDN-IP failed!" )
194 main.cleanup()
195 main.exit()
196
197
Jon Hall6e9897d2016-02-29 14:41:32 -0800198 main.log.info( "Wait for SDN-IP to finish installing connectivity intents " +
199 "and for the BGP paths in the data plane to be ready..." )
pingping-linffca7e22015-11-13 15:43:08 -0800200 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
Jon Hall6e9897d2016-02-29 14:41:32 -0800201 main.log.info( "Wait for Quagga to finish delivery of all routes to each " +
202 "other and sdn-ip, plus finish installing all intents..." )
pingping-linffca7e22015-11-13 15:43:08 -0800203 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
204 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
205
206
207 def CASE102( self, main ):
208 '''
209 This test case is to load the methods from other Python files.
210 '''
211 main.case( "Loading methods from other Python file" )
212 # load the methods from other file
213 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
214 main.Functions = imp.load_source( wrapperFile,
215 main.dependencyPath +
216 wrapperFile +
217 ".py" )
218
219
220 def CASE1( self, main ):
221 '''
222 ping test from 3 bgp peers to BGP speaker
223 '''
224
225 main.case( "Ping tests between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800226 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
227 peers=["pr64514", "pr64515", "pr64516"],
228 expectAllSuccess=True )
pingping-linffca7e22015-11-13 15:43:08 -0800229
230
231 def CASE2( self, main ):
232 '''
233 point-to-point intents test for each BGP peer and BGP speaker pair
234 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800235 import time
pingping-linffca7e22015-11-13 15:43:08 -0800236 main.case( "Check point-to-point intents" )
237 main.log.info( "There are %s BGP peers in total "
238 % main.params[ 'config' ][ 'peerNum' ] )
239 main.step( "Check P2P intents number from ONOS CLI" )
240
Jon Hall6e9897d2016-02-29 14:41:32 -0800241 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-linffca7e22015-11-13 15:43:08 -0800242 bgpIntentsActualNum = \
243 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
244 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
Jon Hall6e9897d2016-02-29 14:41:32 -0800245 if bgpIntentsActualNum != bgpIntentsExpectedNum:
246 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
247 bgpIntentsActualNum = \
248 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
pingping-linffca7e22015-11-13 15:43:08 -0800249 main.log.info( "bgpIntentsExpected num is:" )
250 main.log.info( bgpIntentsExpectedNum )
251 main.log.info( "bgpIntentsActual num is:" )
252 main.log.info( bgpIntentsActualNum )
253 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800254 expect=True,
255 actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
256 onpass="PointToPointIntent Intent Num is correct!",
257 onfail="PointToPointIntent Intent Num is wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800258
259
260 def CASE3( self, main ):
261 '''
262 routes and intents check to all BGP peers
263 '''
Jon Hall6e9897d2016-02-29 14:41:32 -0800264 import time
pingping-linffca7e22015-11-13 15:43:08 -0800265 main.case( "Check routes and M2S intents to all BGP peers" )
266
267 allRoutesExpected = []
268 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
269 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
270 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
271
Jon Hall6e9897d2016-02-29 14:41:32 -0800272 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-linffca7e22015-11-13 15:43:08 -0800273 allRoutesActual = \
274 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
275 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
276 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800277 if allRoutesStrActual != allRoutesStrExpected:
278 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
279 allRoutesActual = \
280 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
281 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
pingping-linffca7e22015-11-13 15:43:08 -0800282
283 main.step( "Check routes installed" )
284 main.log.info( "Routes expected:" )
285 main.log.info( allRoutesStrExpected )
286 main.log.info( "Routes get from ONOS CLI:" )
287 main.log.info( allRoutesStrActual )
288 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800289 expect=allRoutesStrExpected, actual=allRoutesStrActual,
290 onpass="Routes are correct!",
291 onfail="Routes are wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800292
293 main.step( "Check M2S intents installed" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800294 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-linffca7e22015-11-13 15:43:08 -0800295 routeIntentsActualNum = \
296 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
297 routeIntentsExpectedNum = 3
Jon Hall6e9897d2016-02-29 14:41:32 -0800298 if routeIntentsActualNum != routeIntentsExpectedNum:
299 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
300 routeIntentsActualNum = \
301 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
pingping-linffca7e22015-11-13 15:43:08 -0800302
303 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
304 main.log.info( routeIntentsExpectedNum )
305 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
306 main.log.info( routeIntentsActualNum )
307 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800308 expect=routeIntentsExpectedNum,
309 actual=routeIntentsActualNum,
310 onpass="MultiPointToSinglePoint Intent Num is correct!",
311 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800312
313 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800314 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
315 main.FALSE,
316 kwargs={'isPENDING':False},
317 attempts=10 )
pingping-linffca7e22015-11-13 15:43:08 -0800318 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800319 expect=main.TRUE,
320 actual=flowCheck,
321 onpass="Flow status is correct!",
322 onfail="Flow status is wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800323
324
325 def CASE4( self, main ):
326 '''
327 Ping test in data plane for each route
328 '''
329 main.case( "Ping test for each route, all hosts behind BGP peers" )
330 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800331 hosts=["host64514", "host64515", "host64516"],
332 expectAllSuccess=True )
pingping-linffca7e22015-11-13 15:43:08 -0800333
334
335 def CASE5( self, main ):
336 '''
337 Cut links to peers one by one, check routes/intents
338 '''
339 import time
340 main.case( "Bring down links and check routes/intents" )
341 main.step( "Bring down the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800342 linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514",
343 OPTION="down" )
344 utilities.assertEquals( expect=main.TRUE,
345 actual=linkResult1,
346 onpass="Bring down link succeeded!",
347 onfail="Bring down link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800348
349 if linkResult1 == main.TRUE:
350 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
351 main.Functions.checkRouteNum( main, 2 )
352 main.Functions.checkM2SintentNum( main, 2 )
353 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800354 main.log.error( "Bring down link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800355 main.cleanup()
356 main.exit()
357
358 main.step( "Bring down the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800359 linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515",
360 OPTION="down" )
361 utilities.assertEquals( expect=main.TRUE,
362 actual=linkResult2,
363 onpass="Bring down link succeeded!",
364 onfail="Bring down link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800365 if linkResult2 == main.TRUE:
366 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
367 main.Functions.checkRouteNum( main, 1 )
368 main.Functions.checkM2SintentNum( main, 1 )
369 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800370 main.log.error( "Bring down link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800371 main.cleanup()
372 main.exit()
373
374 main.step( "Bring down the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800375 linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516",
376 OPTION="down" )
377 utilities.assertEquals( expect=main.TRUE,
378 actual=linkResult3,
379 onpass="Bring down link succeeded!",
380 onfail="Bring down link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800381 if linkResult3 == main.TRUE:
382 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
383 main.Functions.checkRouteNum( main, 0 )
384 main.Functions.checkM2SintentNum( main, 0 )
385 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800386 main.log.error( "Bring down link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800387 main.cleanup()
388 main.exit()
389
390 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800391 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
392 main.FALSE,
393 kwargs={'isPENDING':False},
394 attempts=10 )
pingping-linffca7e22015-11-13 15:43:08 -0800395 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800396 expect=main.TRUE,
397 actual=flowCheck,
398 onpass="Flow status is correct!",
399 onfail="Flow status is wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800400
401 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800402 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
403 peers=["pr64514", "pr64515", "pr64516"],
404 expectAllSuccess=False )
pingping-linffca7e22015-11-13 15:43:08 -0800405 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800406 hosts=["host64514", "host64515", "host64516"],
407 expectAllSuccess=False )
pingping-linffca7e22015-11-13 15:43:08 -0800408
409
410 def CASE6( self, main ):
411 '''
412 Recover links to peers one by one, check routes/intents
413 '''
414 import time
415 main.case( "Bring up links and check routes/intents" )
416 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800417 linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514",
418 OPTION="up" )
419 utilities.assertEquals( expect=main.TRUE,
420 actual=linkResult1,
421 onpass="Bring up link succeeded!",
422 onfail="Bring up link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800423 if linkResult1 == main.TRUE:
424 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
425 main.Functions.checkRouteNum( main, 1 )
426 main.Functions.checkM2SintentNum( main, 1 )
427 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800428 main.log.error( "Bring up link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800429 main.cleanup()
430 main.exit()
431
432 main.step( "Bring up the link between sw8 and peer64515" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800433 linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515",
434 OPTION="up" )
435 utilities.assertEquals( expect=main.TRUE,
436 actual=linkResult2,
437 onpass="Bring up link succeeded!",
438 onfail="Bring up link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800439 if linkResult2 == main.TRUE:
440 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
441 main.Functions.checkRouteNum( main, 2 )
442 main.Functions.checkM2SintentNum( main, 2 )
443 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800444 main.log.error( "Bring up link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800445 main.cleanup()
446 main.exit()
447
448 main.step( "Bring up the link between sw28 and peer64516" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800449 linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516",
450 OPTION="up" )
451 utilities.assertEquals( expect=main.TRUE,
452 actual=linkResult3,
453 onpass="Bring up link succeeded!",
454 onfail="Bring up link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800455 if linkResult3 == main.TRUE:
456 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
457 main.Functions.checkRouteNum( main, 3 )
458 main.Functions.checkM2SintentNum( main, 3 )
459 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800460 main.log.error( "Bring up link failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800461 main.cleanup()
462 main.exit()
463
464 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800465 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
466 main.FALSE,
467 kwargs={'isPENDING':False},
468 attempts=10 )
pingping-linffca7e22015-11-13 15:43:08 -0800469 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800470 expect=main.TRUE,
471 actual=flowCheck,
472 onpass="Flow status is correct!",
473 onfail="Flow status is wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800474
475 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800476 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
477 peers=["pr64514", "pr64515", "pr64516"],
478 expectAllSuccess=True )
pingping-linffca7e22015-11-13 15:43:08 -0800479 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800480 hosts=["host64514", "host64515", "host64516"],
481 expectAllSuccess=True )
pingping-linffca7e22015-11-13 15:43:08 -0800482
483
484 def CASE7( self, main ):
485 '''
486 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
487 '''
488 import time
489 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
490 main.step( "Stop sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800491 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
492 utilities.assertEquals( expect=main.TRUE, actual=result,
493 onpass="Stopping switch succeeded!",
494 onfail="Stopping switch failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800495
496 if result == main.TRUE:
497 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
498 main.Functions.checkRouteNum( main, 2 )
499 main.Functions.checkM2SintentNum( main, 2 )
500 main.Functions.checkP2PintentNum( main, 12 )
501 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800502 main.log.error( "Stopping switch failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800503 main.cleanup()
504 main.exit()
505
506 main.step( "Check ping between hosts behind BGP peers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800507 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
508 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
509 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
pingping-linffca7e22015-11-13 15:43:08 -0800510
511 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
512 and ( result3 == main.FALSE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800513 utilities.assert_equals( expect=True, actual=pingResult1,
514 onpass="Ping test result is correct",
515 onfail="Ping test result is wrong" )
pingping-linffca7e22015-11-13 15:43:08 -0800516
517 if pingResult1 == False:
518 main.cleanup()
519 main.exit()
520
521 main.step( "Check ping between BGP peers and speakers" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800522 result4 = main.Mininet.pingHost( src="speaker1", target="pr64514" )
523 result5 = main.Mininet.pingHost( src="speaker1", target="pr64515" )
524 result6 = main.Mininet.pingHost( src="speaker1", target="pr64516" )
pingping-linffca7e22015-11-13 15:43:08 -0800525
526 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
527 and ( result6 == main.TRUE )
Jon Hall6e9897d2016-02-29 14:41:32 -0800528 utilities.assert_equals( expect=True, actual=pingResult2,
529 onpass="Speaker1 ping peers successful",
530 onfail="Speaker1 ping peers NOT successful" )
pingping-linffca7e22015-11-13 15:43:08 -0800531
532 if pingResult2 == False:
533 main.cleanup()
534 main.exit()
535
536 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800537 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
538 main.FALSE,
539 kwargs={'isPENDING':False},
540 attempts=10 )
pingping-linffca7e22015-11-13 15:43:08 -0800541 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800542 expect=main.TRUE,
543 actual=flowCheck,
544 onpass="Flow status is correct!",
545 onfail="Flow status is wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800546
547
548 def CASE8( self, main ):
549 '''
550 Bring up the edge switch (sw32) which was shut down in CASE7,
551 check P-2-P and M-2-S intents, ping test
552 '''
553 import time
554 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
555 main.step( "Start sw32" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800556 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
pingping-linffca7e22015-11-13 15:43:08 -0800557 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800558 expect=main.TRUE,
559 actual=result1,
560 onpass="Starting switch succeeded!",
561 onfail="Starting switch failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800562
pingping-lin6cae4422016-01-04 10:00:35 -0800563 result2 = main.Mininet.assignSwController( "sw32", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800564 port=fsfwPort )
pingping-linffca7e22015-11-13 15:43:08 -0800565 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800566 expect=main.TRUE,
567 actual=result2,
568 onpass="Connect switch to FSFW succeeded!",
569 onfail="Connect switch to FSFW failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800570
571 if result1 and result2:
572 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
573 main.Functions.checkRouteNum( main, 3 )
574 main.Functions.checkM2SintentNum( main, 3 )
575 main.Functions.checkP2PintentNum( main, 18 )
576 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800577 main.log.error( "Starting switch failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800578 main.cleanup()
579 main.exit()
580
581 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800582 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
583 main.FALSE,
584 kwargs={'isPENDING':False},
585 attempts=10 )
pingping-linffca7e22015-11-13 15:43:08 -0800586 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800587 expect=main.TRUE,
588 actual=flowCheck,
589 onpass="Flow status is correct!",
590 onfail="Flow status is wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800591
592 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800593 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
594 peers=["pr64514", "pr64515", "pr64516"],
595 expectAllSuccess=True )
pingping-linffca7e22015-11-13 15:43:08 -0800596 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800597 hosts=["host64514", "host64515", "host64516"],
598 expectAllSuccess=True )
pingping-linffca7e22015-11-13 15:43:08 -0800599
600
601 def CASE9( self, main ):
602 '''
603 Bring down a switch in best path, check:
604 route number, P2P intent number, M2S intent number, ping test
605 '''
606 main.case( "Stop sw11 located in best path, \
607 check route number, P2P intent number, M2S intent number, ping test" )
608
609 main.log.info( "Check the flow number correctness before stopping sw11" )
610 main.Functions.checkFlowNum( main, "sw11", 13 )
611 main.Functions.checkFlowNum( main, "sw1", 3 )
612 main.Functions.checkFlowNum( main, "sw7", 3 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800613 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
614 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
615 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linffca7e22015-11-13 15:43:08 -0800616
617 main.step( "Stop sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800618 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
619 utilities.assertEquals( expect=main.TRUE, actual=result,
620 onpass="Stopping switch succeeded!",
621 onfail="Stopping switch failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800622 if result:
623 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
624 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
625 main.Functions.checkRouteNum( main, 3 )
626 main.Functions.checkM2SintentNum( main, 3 )
627 main.Functions.checkP2PintentNum( main, 18 )
628 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800629 main.log.error( "Stopping switch failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800630 main.cleanup()
631 main.exit()
632
633 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800634 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
635 main.FALSE,
636 kwargs={'isPENDING':False},
637 attempts=10 )
pingping-linffca7e22015-11-13 15:43:08 -0800638 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800639 expect=main.TRUE,
640 actual=flowCheck,
641 onpass="Flow status is correct!",
642 onfail="Flow status is wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800643 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800644 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
645 peers=["pr64514", "pr64515", "pr64516"],
646 expectAllSuccess=True )
pingping-linffca7e22015-11-13 15:43:08 -0800647 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800648 hosts=["host64514", "host64515", "host64516"],
649 expectAllSuccess=True )
pingping-linffca7e22015-11-13 15:43:08 -0800650
651
652 def CASE10( self, main ):
653 '''
654 Bring up the switch which was stopped in CASE9, check:
655 route number, P2P intent number, M2S intent number, ping test
656 '''
657 main.case( "Start sw11 which was stopped in CASE9, \
658 check route number, P2P intent number, M2S intent number, ping test" )
659
660 main.log.info( "Check the flow status before starting sw11" )
661 main.Functions.checkFlowNum( main, "sw1", 11 )
662 main.Functions.checkFlowNum( main, "sw7", 5 )
Jon Hall6e9897d2016-02-29 14:41:32 -0800663 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
664 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
pingping-linffca7e22015-11-13 15:43:08 -0800665
666 main.step( "Start sw11" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800667 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
668 utilities.assertEquals( expect=main.TRUE, actual=result1,
669 onpass="Starting switch succeeded!",
670 onfail="Starting switch failed!" )
pingping-lin6cae4422016-01-04 10:00:35 -0800671 result2 = main.Mininet.assignSwController( "sw11", fsfwIp,
Jon Hall6e9897d2016-02-29 14:41:32 -0800672 port=fsfwPort )
673 utilities.assertEquals( expect=main.TRUE, actual=result2,
674 onpass="Connect switch to FSFW succeeded!",
675 onfail="Connect switch to FSFW failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800676 if result1 and result2:
677 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
678 main.Functions.checkRouteNum( main, 3 )
679 main.Functions.checkM2SintentNum( main, 3 )
680 main.Functions.checkP2PintentNum( main, 18 )
681
682 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
683 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
684 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
685 else:
Jon Hall6e9897d2016-02-29 14:41:32 -0800686 main.log.error( "Starting switch failed!" )
pingping-linffca7e22015-11-13 15:43:08 -0800687 main.cleanup()
688 main.exit()
689
690 main.step( "Check whether all flow status are ADDED" )
Jon Hall6e9897d2016-02-29 14:41:32 -0800691 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
692 main.FALSE,
693 kwargs={'isPENDING':False},
694 attempts=10 )
pingping-linffca7e22015-11-13 15:43:08 -0800695 utilities.assertEquals( \
Jon Hall6e9897d2016-02-29 14:41:32 -0800696 expect=main.TRUE,
697 actual=flowCheck,
698 onpass="Flow status is correct!",
699 onfail="Flow status is wrong!" )
pingping-linffca7e22015-11-13 15:43:08 -0800700 # Ping test
Jon Hall6e9897d2016-02-29 14:41:32 -0800701 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
702 peers=["pr64514", "pr64515", "pr64516"],
703 expectAllSuccess=True )
pingping-linffca7e22015-11-13 15:43:08 -0800704 main.Functions.pingHostToHost( main,
Jon Hall6e9897d2016-02-29 14:41:32 -0800705 hosts=["host64514", "host64515", "host64516"],
706 expectAllSuccess=True )