blob: 526d33c9d5a05fc2b0b90289e699f2a1c5139cb9 [file] [log] [blame]
Jon Hallbc401252016-03-03 14:44:04 -08001# Testing the functionality of SDN-IP with single ONOS instance
2class DEMO_SDNIP:
3
4 def __init__( self ):
5 self.default = ''
6 global branchName
7
8 def CASE100( self, main ):
9 """
10 Start mininet
11 """
12 import imp
13 main.case( "Setup the Mininet testbed" )
Jon Hall88de9ee2016-03-04 12:29:56 -080014 main.log.demoSummary( "DEMO:Mininet: Setup the Mininet testbed" )
Jon Hallbc401252016-03-03 14:44:04 -080015 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
21 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" )
26 # Exit if topology did not load properly
27 if not topoResult:
28 main.cleanup()
29 main.exit()
30 main.step( "Connect switches to controllers" )
Jon Hall88de9ee2016-03-04 12:29:56 -080031 main.log.demoSummary( "DEMO:Mininet: Connecting switches to controllers" )
Jon Hallbc401252016-03-03 14:44:04 -080032
33 # connect all switches to controllers
34 swResult = main.TRUE
35 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
36 sw = "sw%s" % ( i )
37 swResult = swResult and main.Mininet.assignSwController( sw,
38 [ONOS1Ip, ONOS2Ip, ONOS3Ip] )
Jon Hallbc401252016-03-03 14:44:04 -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" )
43 if not swResult:
44 main.cleanup()
45 main.exit()
46
47
48 def CASE101( self, main ):
49 """
50 Package ONOS and install it
51 Startup sequence:
52 cell <name>
53 onos-verify-cell
54 onos-package
55 onos-install -f
56 onos-wait-for-start
57 """
58 import json
59 import time
60 import os
61 from operator import eq
62
63 main.case( "Setting up ONOS environment" )
Jon Hallf9572352016-03-09 10:21:18 -080064 main.log.demoSummary( "DEMO: TestStation: Setting up ONOS environment" )
Jon Hallbc401252016-03-03 14:44:04 -080065
66 cellName = main.params[ 'ENV' ][ 'cellName' ]
67 global ONOS1Ip
68 global ONOS2Ip
69 global ONOS3Ip
70 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
71 ONOS2Ip = os.getenv( main.params[ 'CTRL' ][ 'ip2' ] )
72 ONOS3Ip = os.getenv( main.params[ 'CTRL' ][ 'ip3' ] )
73 ipList = [ ONOS1Ip, ONOS2Ip, ONOS3Ip ]
74
75 global peer64514
76 global peer64515
77 global peer64516
78 peer64514 = main.params['config']['peer64514']
79 peer64515 = main.params['config']['peer64515']
80 peer64516 = main.params['config']['peer64516']
81
Jon Halld1baa9e2016-03-08 09:46:09 -080082 main.step( "Applying cell variable to environment" )
Jon Hallbc401252016-03-03 14:44:04 -080083 cellAppString = main.params[ 'ENV' ][ 'appString' ]
84 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
85 main.Mininet.ip_address,
86 cellAppString, ipList )
87
Jon Hallbc401252016-03-03 14:44:04 -080088 cellResult = main.ONOSbench.setCell( cellName )
89 utilities.assert_equals( expect=main.TRUE,
90 actual=cellResult,
91 onpass="Set cell succeeded",
92 onfail="Set cell failed" )
93
94 verifyResult = main.ONOSbench.verifyCell()
95 utilities.assert_equals( expect=main.TRUE,
96 actual=verifyResult,
97 onpass="Verify cell succeeded",
98 onfail="Verify cell failed" )
99
Jon Halld1baa9e2016-03-08 09:46:09 -0800100 main.log.demoSummary( "DEMO: ONOS: Connecting to ONOS" )
101 '''
102 p = main.ONOSbench.handle
103 p.sendline( "stc setup" )
104 p.expect( "\$", timeout=180 )
105 # TODO: add assert here after converting to a function
106 '''
Jon Hallbc401252016-03-03 14:44:04 -0800107
Jon Halld1baa9e2016-03-08 09:46:09 -0800108 main.step( "Checking if ONOS CLI is ready to start" )
Jon Hallbc401252016-03-03 14:44:04 -0800109 main.CLIs = []
Jon Hallf9572352016-03-09 10:21:18 -0800110 main.log.demoSummary( "DEMO: ONOS1: Connecting to ONOS1" )
Jon Hallbc401252016-03-03 14:44:04 -0800111 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
112 commandlineTimeout=100, onosStartTimeout=600 )
113 main.CLIs.append( main.ONOScli1 )
Jon Hallf9572352016-03-09 10:21:18 -0800114 main.log.demoSummary( "DEMO: ONOS2: Connecting to ONOS2" )
Jon Hallbc401252016-03-03 14:44:04 -0800115 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
116 commandlineTimeout=100, onosStartTimeout=600 )
117 main.CLIs.append( main.ONOScli2 )
Jon Hallf9572352016-03-09 10:21:18 -0800118 main.log.demoSummary( "DEMO: ONOS3: Connecting to ONOS3" )
Jon Hallbc401252016-03-03 14:44:04 -0800119 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
120 commandlineTimeout=100, onosStartTimeout=600 )
121 main.CLIs.append( main.ONOScli3 )
122 cliResult = cliResult1 and cliResult2 and cliResult3
123 utilities.assert_equals( expect=main.TRUE,
124 actual=cliResult,
125 onpass="ONOS CLI is ready",
126 onfail="ONOS CLI is not ready" )
127
Jon Halld1baa9e2016-03-08 09:46:09 -0800128 main.step( "Checking if ONOS CLI is ready for issuing commands" )
129 main.log.demoSummary( "DEMO: ONOS: Checking CLI" )
Jon Hallbc401252016-03-03 14:44:04 -0800130 for i in range( 10 ):
131 ready = True
132 for cli in main.CLIs:
133 output = cli.summary()
134 if not output:
135 ready = False
136 if ready:
137 break
138 time.sleep( 30 )
139 utilities.assert_equals( expect=True, actual=ready,
140 onpass="ONOS summary command succeded",
141 onfail="ONOS summary command failed" )
142
143 if not ready:
144 main.log.error( "ONOS startup failed!" )
145 main.cleanup()
146 main.exit()
Jon Halld1baa9e2016-03-08 09:46:09 -0800147 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800148
Jon Halld1baa9e2016-03-08 09:46:09 -0800149 def CASE199( self, main ):
150 main.case( "Verify topology discovery" )
151 main.log.info( "Waiting for link discovery......" )
Jon Hallbc401252016-03-03 14:44:04 -0800152 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
153
Jon Hallf9572352016-03-09 10:21:18 -0800154 main.step( "Get links in the network" )
Jon Hallbc401252016-03-03 14:44:04 -0800155 summaryResult = main.ONOScli1.summary()
156 linkNum = json.loads( summaryResult )[ "links" ]
Jon Halld1baa9e2016-03-08 09:46:09 -0800157 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
Jon Hallbc401252016-03-03 14:44:04 -0800158 if linkNum < 100:
Jon Halld1baa9e2016-03-08 09:46:09 -0800159 main.log.error( "Link number is wrong! Retrying..." )
Jon Hallbc401252016-03-03 14:44:04 -0800160 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Jon Hall776bfc52016-03-04 13:51:47 -0800161 summaryResult = main.ONOScli1.summary()
162 linkNum = json.loads( summaryResult )[ "links" ]
Jon Halld1baa9e2016-03-08 09:46:09 -0800163 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
164 utilities.assert_equals( expect=100,
165 actual=linkNum,
166 onpass="ONOS correctly discovered all links",
167 onfail="ONOS Failed to discover all links" )
168 if linkNum < 100:
Jon Hallbc401252016-03-03 14:44:04 -0800169 main.cleanup()
170 main.exit()
Jon Halld1baa9e2016-03-08 09:46:09 -0800171 time.sleep( int( main.params['timers']['Readability'] ) )
172
173 def CASE200( self, main ):
174 main.case( "Activate sdn-ip application" )
Jon Hallbc401252016-03-03 14:44:04 -0800175
176 main.step( "Activate sdn-ip application" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800177 main.log.demoSummary( "DEMO:ONOS1: Activate sdn-ip application" )
Jon Hallbc401252016-03-03 14:44:04 -0800178 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
179 utilities.assert_equals( expect=main.TRUE,
180 actual=activeSDNIPresult,
181 onpass="Activate SDN-IP succeeded",
182 onfail="Activate SDN-IP failed" )
183 if not activeSDNIPresult:
184 main.log.info( "Activate SDN-IP failed!" )
185 main.cleanup()
186 main.exit()
Jon Halld1baa9e2016-03-08 09:46:09 -0800187 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800188
189
190 def CASE102( self, main ):
191 '''
192 This test case is to load the methods from other Python files, and create
193 tunnels from mininet host to onos nodes.
194 '''
195 import time
Jon Halld1baa9e2016-03-08 09:46:09 -0800196 main.case( "Create tunnels between Quagga and SDNIP Application" )
Jon Hallbc401252016-03-03 14:44:04 -0800197 # load the methods from other file
198 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
199 main.Functions = imp.load_source( wrapperFile1,
200 main.dependencyPath +
201 wrapperFile1 +
202 ".py" )
203 # Create tunnels
Jon Hall88de9ee2016-03-04 12:29:56 -0800204 main.log.demoSummary( "DEMO:Mininet: Creating tunnels between bgp speakers" )
Jon Hallbc401252016-03-03 14:44:04 -0800205 # ONOS1
206 main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
207 # ONOS2
208 main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
209 # ONOS3
210 main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
211
Jon Hallbc401252016-03-03 14:44:04 -0800212 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
213
Jon Hallbc401252016-03-03 14:44:04 -0800214
215 def CASE1( self, main ):
216 '''
217 ping test from 3 bgp peers to BGP speaker
218 '''
219
220 main.case( "Ping between BGP peers and speakers" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800221 main.log.demoSummary( "DEMO:Mininet: Ping between bgp peers and speakers" )
Jon Hallbc401252016-03-03 14:44:04 -0800222 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
223 peers=["peer64514", "peer64515", "peer64516"],
224 expectAllSuccess=True )
225 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
226 peers=[peer64514, peer64515, peer64516],
227 expectAllSuccess=True )
Jon Halld1baa9e2016-03-08 09:46:09 -0800228 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800229
Jon Hallbc401252016-03-03 14:44:04 -0800230 def CASE2( self, main ):
231 '''
232 point-to-point intents test for each BGP peer and BGP speaker pair
233 '''
234 import time
235 main.case( "Check point-to-point intents" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800236 main.log.demoSummary( "DEMO:ONOS1: Verify Point-to-Point intents" )
Jon Hallbc401252016-03-03 14:44:04 -0800237 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
241 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
242 bgpIntentsActualNum = \
243 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
Jon Halld1baa9e2016-03-08 09:46:09 -0800244 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
Jon Hallbc401252016-03-03 14:44:04 -0800245 if bgpIntentsActualNum != bgpIntentsExpectedNum:
246 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallf9572352016-03-09 10:21:18 -0800247 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hallbc401252016-03-03 14:44:04 -0800248 bgpIntentsActualNum = \
249 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
250 main.log.info( "bgpIntentsExpected num is:" )
251 main.log.info( bgpIntentsExpectedNum )
252 main.log.info( "bgpIntentsActual num is:" )
253 main.log.info( bgpIntentsActualNum )
Jon Halld1baa9e2016-03-08 09:46:09 -0800254 utilities.assert_equals( \
255 expect=bgpIntentsExpectedNum,
256 actual=bgpIntentsActualNum,
Jon Hallbc401252016-03-03 14:44:04 -0800257 onpass="PointToPointIntent Intent Num is correct!",
258 onfail="PointToPointIntent Intent Num is wrong!" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800259 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800260
Jon Hallbc401252016-03-03 14:44:04 -0800261 def CASE3( self, main ):
262 '''
263 routes and intents check to all BGP peers
264 '''
265 import time
266 main.case( "Check routes and M2S intents to all BGP peers" )
Jon Hallbc401252016-03-03 14:44:04 -0800267
Jon Hallf9572352016-03-09 10:21:18 -0800268 main.step( "Check routes installed" )
Jon Hallbc401252016-03-03 14:44:04 -0800269 allRoutesExpected = []
270 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
271 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
272 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
273
Jon Hallf9572352016-03-09 10:21:18 -0800274 main.log.demoSummary( "DEMO:Quagga: Check BGP routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800275 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
276 allRoutesActual = \
277 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
278 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
279 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
280 if allRoutesStrActual != allRoutesStrExpected:
281 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
282 allRoutesActual = \
283 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
284 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
285
Jon Hallbc401252016-03-03 14:44:04 -0800286 main.log.info( "Routes expected:" )
287 main.log.info( allRoutesStrExpected )
288 main.log.info( "Routes get from ONOS CLI:" )
289 main.log.info( allRoutesStrActual )
Jon Halld1baa9e2016-03-08 09:46:09 -0800290 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800291 expect=allRoutesStrExpected, actual=allRoutesStrActual,
292 onpass="Routes are correct!",
293 onfail="Routes are wrong!" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800294 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800295
296 main.step( "Check M2S intents installed" )
Jon Hallf9572352016-03-09 10:21:18 -0800297 main.log.demoSummary( "DEMO:ONOS1: Check Multi-point intents" )
Jon Hallbc401252016-03-03 14:44:04 -0800298 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
299 routeIntentsActualNum = \
300 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
301 routeIntentsExpectedNum = 3
302 if routeIntentsActualNum != routeIntentsExpectedNum:
303 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallf9572352016-03-09 10:21:18 -0800304 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hallbc401252016-03-03 14:44:04 -0800305 routeIntentsActualNum = \
306 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
307
308 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
309 main.log.info( routeIntentsExpectedNum )
310 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
311 main.log.info( routeIntentsActualNum )
Jon Halld1baa9e2016-03-08 09:46:09 -0800312 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800313 expect=routeIntentsExpectedNum,
314 actual=routeIntentsActualNum,
315 onpass="MultiPointToSinglePoint Intent Num is correct!",
316 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800317 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800318
Jon Hallf9572352016-03-09 10:21:18 -0800319 main.log.demoSummary( "DEMO:ONOS1: Check flows" )
Jon Hallbc401252016-03-03 14:44:04 -0800320 main.step( "Check whether all flow status are ADDED" )
321 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
322 main.FALSE,
323 kwargs={'isPENDING':False},
324 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800325 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800326 expect=main.TRUE,
327 actual=flowCheck,
328 onpass="Flow status is correct!",
329 onfail="Flow status is wrong!" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800330 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800331
332
333 def CASE4( self, main ):
334 '''
335 Ping test in data plane for each route
336 '''
337 main.case( "Ping test for each route, all hosts behind BGP peers" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800338 main.log.demoSummary( "DEMO:Mininet: Pinging across BGP routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800339 main.Functions.pingHostToHost( main,
340 hosts=["host64514", "host64515", "host64516"],
341 expectAllSuccess=True )
Jon Halld1baa9e2016-03-08 09:46:09 -0800342 time.sleep( int( main.params['timers']['Readability'] ) )
343 #main.log.demoSummary( "DEMO: STOP" ) #FIXME For testing
Jon Hallbc401252016-03-03 14:44:04 -0800344
345 def CASE5( self, main ):
346 '''
347 Cut links to peers one by one, check routes/intents
348 '''
349 import time
350 main.case( "Bring down links and check routes/intents" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800351 main.log.demoSummary( "DEMO:Mininet: Bringing down links between Quagga and the network" )
Jon Hallbc401252016-03-03 14:44:04 -0800352 main.step( "Bring down the link between sw32 and peer64514" )
353 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
354 OPTION="down" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800355 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800356 actual=linkResult1,
357 onpass="Bring down link succeeded!",
358 onfail="Bring down link failed!" )
359
360 if linkResult1 == main.TRUE:
361 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
362 main.log.debug( main.ONOScli1.links() ) #FIXME: DEBUG
363 main.Functions.checkRouteNum( main, 2 )
364 main.Functions.checkM2SintentNum( main, 2 )
365 else:
366 main.log.error( "Bring down link failed!" )
367 main.cleanup()
368 main.exit()
369
370 main.step( "Bring down the link between sw8 and peer64515" )
371 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
372 OPTION="down" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800373 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800374 actual=linkResult2,
375 onpass="Bring down link succeeded!",
376 onfail="Bring down link failed!" )
377 if linkResult2 == main.TRUE:
378 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
379 main.Functions.checkRouteNum( main, 1 )
380 main.Functions.checkM2SintentNum( main, 1 )
381 else:
382 main.log.error( "Bring down link failed!" )
383 main.cleanup()
384 main.exit()
385
386 main.step( "Bring down the link between sw28 and peer64516" )
387 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
388 OPTION="down" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800389 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800390 actual=linkResult3,
391 onpass="Bring down link succeeded!",
392 onfail="Bring down link failed!" )
393 if linkResult3 == main.TRUE:
394 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
395 main.Functions.checkRouteNum( main, 0 )
396 main.Functions.checkM2SintentNum( main, 0 )
397 else:
398 main.log.error( "Bring down link failed!" )
399 main.cleanup()
400 main.exit()
401
402 main.step( "Check whether all flow status are ADDED" )
403 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
404 main.FALSE,
405 kwargs={'isPENDING':False},
406 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800407 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800408 expect=main.TRUE,
409 actual=flowCheck,
410 onpass="Flow status is correct!",
411 onfail="Flow status is wrong!" )
412
413 # Ping test
Jon Hall88de9ee2016-03-04 12:29:56 -0800414 main.log.demoSummary( "DEMO:Mininet: Verify lost connectivity across routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800415 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
416 peers=["peer64514", "peer64515", "peer64516"],
417 expectAllSuccess=False )
418 main.Functions.pingHostToHost( main,
419 hosts=["host64514", "host64515", "host64516"],
420 expectAllSuccess=False )
421
422
423 def CASE6( self, main ):
424 '''
425 Recover links to peers one by one, check routes/intents
426 '''
427 import time
428 main.case( "Bring up links and check routes/intents" )
429 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800430 main.log.demoSummary( "DEMO:Mininet: Bring back up links between Quagga and the network" )
Jon Hallbc401252016-03-03 14:44:04 -0800431 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
432 OPTION="up" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800433 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800434 actual=linkResult1,
435 onpass="Bring up link succeeded!",
436 onfail="Bring up link failed!" )
437 if linkResult1 == main.TRUE:
438 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
439 main.Functions.checkRouteNum( main, 1 )
440 main.Functions.checkM2SintentNum( main, 1 )
441 else:
442 main.log.error( "Bring up link failed!" )
443 main.cleanup()
444 main.exit()
445
446 main.step( "Bring up the link between sw8 and peer64515" )
447 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
448 OPTION="up" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800449 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800450 actual=linkResult2,
451 onpass="Bring up link succeeded!",
452 onfail="Bring up link failed!" )
453 if linkResult2 == main.TRUE:
454 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
455 main.Functions.checkRouteNum( main, 2 )
456 main.Functions.checkM2SintentNum( main, 2 )
457 else:
458 main.log.error( "Bring up link failed!" )
459 main.cleanup()
460 main.exit()
461
462 main.step( "Bring up the link between sw28 and peer64516" )
463 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
464 OPTION="up" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800465 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800466 actual=linkResult3,
467 onpass="Bring up link succeeded!",
468 onfail="Bring up link failed!" )
469 if linkResult3 == main.TRUE:
470 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
471 main.Functions.checkRouteNum( main, 3 )
472 main.Functions.checkM2SintentNum( main, 3 )
473 else:
474 main.log.error( "Bring up link failed!" )
475 main.cleanup()
476 main.exit()
477
478 main.step( "Check whether all flow status are ADDED" )
479 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
480 main.FALSE,
481 kwargs={'isPENDING':False},
482 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800483 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800484 expect=main.TRUE,
485 actual=flowCheck,
486 onpass="Flow status is correct!",
487 onfail="Flow status is wrong!" )
488
489 # Ping test
Jon Hall88de9ee2016-03-04 12:29:56 -0800490 main.log.demoSummary( "DEMO:Mininet: Verify connectivity is restored across routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800491 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
492 peers=["peer64514", "peer64515", "peer64516"],
493 expectAllSuccess=True )
494 main.Functions.pingHostToHost( main,
495 hosts=["host64514", "host64515", "host64516"],
496 expectAllSuccess=True )
497
498
499 def CASE7( self, main ):
500 '''
501 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
502 '''
503 import time
504 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
505 main.step( "Stop sw32" )
506 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800507 utilities.assert_equals( expect=main.TRUE, actual=result,
Jon Hallbc401252016-03-03 14:44:04 -0800508 onpass="Stopping switch succeeded!",
509 onfail="Stopping switch failed!" )
510
511 if result == main.TRUE:
512 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
513 main.Functions.checkRouteNum( main, 2 )
514 main.Functions.checkM2SintentNum( main, 2 )
515 main.Functions.checkP2PintentNum( main, 12 * 2 )
516 else:
517 main.log.error( "Stopping switch failed!" )
518 main.cleanup()
519 main.exit()
520
521 main.step( "Check ping between hosts behind BGP peers" )
522 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
523 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
524 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
525
526 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
527 and ( result3 == main.FALSE )
528 utilities.assert_equals( expect=True, actual=pingResult1,
529 onpass="Ping test result is correct",
530 onfail="Ping test result is wrong" )
531
532 if pingResult1 == False:
533 main.cleanup()
534 main.exit()
535
536 main.step( "Check ping between BGP peers and speaker1" )
537 result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" )
538 result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" )
539 result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" )
540
541 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
542 and ( result6 == main.TRUE )
543 utilities.assert_equals( expect=True, actual=pingResult2,
544 onpass="Speaker1 ping peers successful",
545 onfail="Speaker1 ping peers NOT successful" )
546
547 if pingResult2 == False:
548 main.cleanup()
549 main.exit()
550
551 main.step( "Check ping between BGP peers and speaker2" )
552 # TODO
553 result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 )
554 result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 )
555 result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 )
556
557 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
558 and ( result9 == main.TRUE )
559 utilities.assert_equals( expect=True, actual=pingResult2,
560 onpass="Speaker2 ping peers successful",
561 onfail="Speaker2 ping peers NOT successful" )
562
563 if pingResult3 == False:
564 main.cleanup()
565 main.exit()
566
567 main.step( "Check whether all flow status are ADDED" )
568 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
569 main.FALSE,
570 kwargs={'isPENDING':False},
571 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800572 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800573 expect=main.TRUE,
574 actual=flowCheck,
575 onpass="Flow status is correct!",
576 onfail="Flow status is wrong!" )
577
578
579 def CASE8( self, main ):
580 '''
581 Bring up the edge switch (sw32) which was shut down in CASE7,
582 check P-2-P and M-2-S intents, ping test
583 '''
584 import time
585 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
586 main.step( "Start sw32" )
587 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800588 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800589 expect=main.TRUE,
590 actual=result1,
591 onpass="Starting switch succeeded!",
592 onfail="Starting switch failed!" )
593
594 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
Jon Halld1baa9e2016-03-08 09:46:09 -0800595 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800596 expect=main.TRUE,
597 actual=result2,
598 onpass="Connect switch to ONOS succeeded!",
599 onfail="Connect switch to ONOS failed!" )
600
601 if result1 and result2:
602 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
603 main.Functions.checkRouteNum( main, 3 )
604 main.Functions.checkM2SintentNum( main, 3 )
605 main.Functions.checkP2PintentNum( main, 18 * 2 )
606 else:
607 main.log.error( "Starting switch failed!" )
608 main.cleanup()
609 main.exit()
610
611 main.step( "Check whether all flow status are ADDED" )
612 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
613 main.FALSE,
614 kwargs={'isPENDING':False},
615 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800616 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800617 expect=main.TRUE,
618 actual=flowCheck,
619 onpass="Flow status is correct!",
620 onfail="Flow status is wrong!" )
621
622 # Ping test
623 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
624 peers=["peer64514", "peer64515", "peer64516"],
625 expectAllSuccess=True )
626 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
627 peers=[peer64514, peer64515, peer64516],
628 expectAllSuccess=True )
629 main.Functions.pingHostToHost( main,
630 hosts=["host64514", "host64515", "host64516"],
631 expectAllSuccess=True )
632
633
634 def CASE9( self, main ):
635 '''
636 Bring down a switch in best path, check:
637 route number, P2P intent number, M2S intent number, ping test
638 '''
639 main.case( "Stop sw11 located in best path, \
640 check route number, P2P intent number, M2S intent number, ping test" )
641
642 main.log.info( "Check the flow number correctness before stopping sw11" )
643 main.Functions.checkFlowNum( main, "sw11", 19 )
644 main.Functions.checkFlowNum( main, "sw1", 3 )
645 main.Functions.checkFlowNum( main, "sw7", 3 )
646
647 main.step( "Stop sw11" )
648 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800649 utilities.assert_equals( expect=main.TRUE, actual=result,
Jon Hallbc401252016-03-03 14:44:04 -0800650 onpass="Stopping switch succeeded!",
651 onfail="Stopping switch failed!" )
652 if result:
653 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
654 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
655 main.Functions.checkRouteNum( main, 3 )
656 main.Functions.checkM2SintentNum( main, 3 )
657 main.Functions.checkP2PintentNum( main, 18 * 2 )
658 else:
659 main.log.error( "Stopping switch failed!" )
660 main.cleanup()
661 main.exit()
662
663 main.step( "Check whether all flow status are ADDED" )
664 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
665 main.FALSE,
666 kwargs={'isPENDING':False},
667 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800668 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800669 expect=main.TRUE,
670 actual=flowCheck,
671 onpass="Flow status is correct!",
672 onfail="Flow status is wrong!" )
673 # Ping test
674 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
675 peers=["peer64514", "peer64515", "peer64516"],
676 expectAllSuccess=True )
677 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
678 peers=[peer64514, peer64515, peer64516],
679 expectAllSuccess=True )
680 main.Functions.pingHostToHost( main,
681 hosts=["host64514", "host64515", "host64516"],
682 expectAllSuccess=True )
683
684
685 def CASE10( self, main ):
686 '''
687 Bring up the switch which was stopped in CASE9, check:
688 route number, P2P intent number, M2S intent number, ping test
689 '''
690 main.case( "Start sw11 which was stopped in CASE9, \
691 check route number, P2P intent number, M2S intent number, ping test" )
692
693 main.log.info( "Check the flow status before starting sw11" )
694 main.Functions.checkFlowNum( main, "sw1", 17 )
695 main.Functions.checkFlowNum( main, "sw7", 5 )
696
697 main.step( "Start sw11" )
698 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800699 utilities.assert_equals( expect=main.TRUE, actual=result1,
Jon Hallbc401252016-03-03 14:44:04 -0800700 onpass="Starting switch succeeded!",
701 onfail="Starting switch failed!" )
702 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
Jon Halld1baa9e2016-03-08 09:46:09 -0800703 utilities.assert_equals( expect=main.TRUE, actual=result2,
Jon Hallbc401252016-03-03 14:44:04 -0800704 onpass="Connect switch to ONOS succeeded!",
705 onfail="Connect switch to ONOS failed!" )
706 if result1 and result2:
707 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
708 main.Functions.checkRouteNum( main, 3 )
709 main.Functions.checkM2SintentNum( main, 3 )
710 main.Functions.checkP2PintentNum( main, 18 * 2 )
711
712 else:
713 main.log.error( "Starting switch failed!" )
714 main.cleanup()
715 main.exit()
716
717 main.step( "Check whether all flow status are ADDED" )
718 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
719 main.FALSE,
720 kwargs={'isPENDING':False},
721 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800722 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800723 expect=main.TRUE,
724 actual=flowCheck,
725 onpass="Flow status is correct!",
726 onfail="Flow status is wrong!" )
727 # Ping test
728 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
729 peers=["peer64514", "peer64515", "peer64516"],
730 expectAllSuccess=True )
731 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
732 peers=[peer64514, peer64515, peer64516],
733 expectAllSuccess=True )
734 main.Functions.pingHostToHost( main,
735 hosts=["host64514", "host64515", "host64516"],
736 expectAllSuccess=True )
737
738
739 def CASE11(self, main):
740 import time
741 main.case( "Kill speaker1, check:\
742 route number, P2P intent number, M2S intent number, ping test" )
743 main.log.info( "Check network status before killing speaker1" )
744 main.Functions.checkRouteNum( main, 3 )
745 main.Functions.checkM2SintentNum( main, 3 )
746 main.Functions.checkP2PintentNum( main, 18 * 2 )
747 main.step( "Check whether all flow status are ADDED" )
748 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
749 main.FALSE,
750 kwargs={'isPENDING':False},
751 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800752 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800753 expect=main.TRUE,
754 actual=flowCheck,
755 onpass="Flow status is correct!",
756 onfail="Flow status is wrong!" )
757
758 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
759 peers=["peer64514", "peer64515", "peer64516"],
760 expectAllSuccess=True )
761 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
762 peers=[peer64514, peer64515, peer64516],
763 expectAllSuccess=True )
764 main.Functions.pingHostToHost( main,
765 hosts=["host64514", "host64515", "host64516"],
766 expectAllSuccess=True )
767
768 main.step( "Kill speaker1" )
769 command1 = "ps -e | grep bgp -c"
770 result1 = main.Mininet.node( "root", command1 )
771
772 # The total BGP daemon number in this test environment is 5.
773 if "5" in result1:
774 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
775 else:
776 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
777 main.log.info( result1 )
778
779 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
780 result2 = main.Mininet.node( "root", command2 )
781
782 result3 = main.Mininet.node( "root", command1 )
783
784 utilities.assert_equals( expect=True,
785 actual=( "4" in result3 ),
786 onpass="Kill speaker1 succeeded",
787 onfail="Kill speaker1 failed" )
788 if ( "4" not in result3 ) :
789 main.log.info( result3 )
790 main.cleanup()
791 main.exit()
792
793 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
794 main.Functions.checkRouteNum( main, 3 )
795 main.Functions.checkM2SintentNum( main, 3 )
796 main.Functions.checkP2PintentNum( main, 18 * 2 )
797
798 main.step( "Check whether all flow status are ADDED" )
799 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
800 main.FALSE,
801 kwargs={'isPENDING':False},
802 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800803 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800804 expect=main.TRUE,
805 actual=flowCheck,
806 onpass="Flow status is correct!",
807 onfail="Flow status is wrong!" )
808
809 '''
810 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
811 peers=["peer64514", "peer64515", "peer64516"],
812 expectAllSuccess=False )
813 '''
814 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
815 peers=[peer64514, peer64515, peer64516],
816 expectAllSuccess=True )
817 main.Functions.pingHostToHost( main,
818 hosts=["host64514", "host64515", "host64516"],
819 expectAllSuccess=True )
820
821
822 def CASE12( self, main ):
823 import time
824 import json
825 main.case( "Bring down leader ONOS node, check: \
826 route number, P2P intent number, M2S intent number, ping test" )
827 main.step( "Find out ONOS leader node" )
828 result = main.ONOScli1.leaders()
829 jsonResult = json.loads( result )
830 leaderIP = ""
831 for entry in jsonResult:
832 if entry["topic"] == "org.onosproject.sdnip":
833 leaderIP = entry["leader"]
834 main.log.info( "leaderIP is: " )
835 main.log.info( leaderIP )
836
837 main.step( "Uninstall ONOS/SDN-IP leader node" )
838 if leaderIP == ONOS1Ip:
839 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
840 elif leaderIP == ONOS2Ip:
841 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
842 else:
843 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
844
845 utilities.assert_equals( expect=main.TRUE,
846 actual=uninstallResult,
847 onpass="Uninstall ONOS leader succeeded",
848 onfail="Uninstall ONOS leader failed" )
849 if uninstallResult != main.TRUE:
850 main.cleanup()
851 main.exit()
852 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
853
854 if leaderIP == ONOS1Ip:
855 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
856 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
857 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
858
859 main.step( "Check whether all flow status are ADDED" )
860 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
861 main.FALSE,
862 kwargs={'isPENDING':False},
863 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800864 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800865 expect=main.TRUE,
866 actual=flowCheck,
867 onpass="Flow status is correct!",
868 onfail="Flow status is wrong!" )
869 else:
870 main.Functions.checkRouteNum( main, 3 )
871 main.Functions.checkM2SintentNum( main, 3 )
872 main.Functions.checkP2PintentNum( main, 18 * 2 )
873
874 main.step( "Check whether all flow status are ADDED" )
875 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
876 main.FALSE,
877 kwargs={'isPENDING':False},
878 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800879 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800880 expect=main.TRUE,
881 actual=flowCheck,
882 onpass="Flow status is correct!",
883 onfail="Flow status is wrong!" )
884
885 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
886 peers=["peer64514", "peer64515", "peer64516"],
887 expectAllSuccess=True )
888 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
889 peers=[peer64514, peer64515, peer64516],
890 expectAllSuccess=True )
891 main.Functions.pingHostToHost( main,
892 hosts=["host64514", "host64515", "host64516"],
893 expectAllSuccess=True )