blob: b24631d290c62255e15add38c07da2766442f667 [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 Hall53c3bde2016-03-18 09:45:08 -070065 #main.stop()
Jon Hallbc401252016-03-03 14:44:04 -080066
67 cellName = main.params[ 'ENV' ][ 'cellName' ]
68 global ONOS1Ip
69 global ONOS2Ip
70 global ONOS3Ip
71 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
72 ONOS2Ip = os.getenv( main.params[ 'CTRL' ][ 'ip2' ] )
73 ONOS3Ip = os.getenv( main.params[ 'CTRL' ][ 'ip3' ] )
74 ipList = [ ONOS1Ip, ONOS2Ip, ONOS3Ip ]
75
76 global peer64514
77 global peer64515
78 global peer64516
79 peer64514 = main.params['config']['peer64514']
80 peer64515 = main.params['config']['peer64515']
81 peer64516 = main.params['config']['peer64516']
82
Jon Halld1baa9e2016-03-08 09:46:09 -080083 main.step( "Applying cell variable to environment" )
Jon Hallbc401252016-03-03 14:44:04 -080084 cellAppString = main.params[ 'ENV' ][ 'appString' ]
85 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
86 main.Mininet.ip_address,
87 cellAppString, ipList )
88
Jon Hallbc401252016-03-03 14:44:04 -080089 cellResult = main.ONOSbench.setCell( cellName )
90 utilities.assert_equals( expect=main.TRUE,
91 actual=cellResult,
92 onpass="Set cell succeeded",
93 onfail="Set cell failed" )
94
95 verifyResult = main.ONOSbench.verifyCell()
96 utilities.assert_equals( expect=main.TRUE,
97 actual=verifyResult,
98 onpass="Verify cell succeeded",
99 onfail="Verify cell failed" )
100
Jon Halld1baa9e2016-03-08 09:46:09 -0800101 main.log.demoSummary( "DEMO: ONOS: Connecting to ONOS" )
102 '''
103 p = main.ONOSbench.handle
104 p.sendline( "stc setup" )
105 p.expect( "\$", timeout=180 )
106 # TODO: add assert here after converting to a function
107 '''
Jon Hallbc401252016-03-03 14:44:04 -0800108
Jon Halld1baa9e2016-03-08 09:46:09 -0800109 main.step( "Checking if ONOS CLI is ready to start" )
Jon Hallbc401252016-03-03 14:44:04 -0800110 main.CLIs = []
Jon Hallf9572352016-03-09 10:21:18 -0800111 main.log.demoSummary( "DEMO: ONOS1: Connecting to ONOS1" )
Jon Hallbc401252016-03-03 14:44:04 -0800112 cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
113 commandlineTimeout=100, onosStartTimeout=600 )
114 main.CLIs.append( main.ONOScli1 )
Jon Hallf9572352016-03-09 10:21:18 -0800115 main.log.demoSummary( "DEMO: ONOS2: Connecting to ONOS2" )
Jon Hallbc401252016-03-03 14:44:04 -0800116 cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
117 commandlineTimeout=100, onosStartTimeout=600 )
118 main.CLIs.append( main.ONOScli2 )
Jon Hallf9572352016-03-09 10:21:18 -0800119 main.log.demoSummary( "DEMO: ONOS3: Connecting to ONOS3" )
Jon Hallbc401252016-03-03 14:44:04 -0800120 cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
121 commandlineTimeout=100, onosStartTimeout=600 )
122 main.CLIs.append( main.ONOScli3 )
123 cliResult = cliResult1 and cliResult2 and cliResult3
124 utilities.assert_equals( expect=main.TRUE,
125 actual=cliResult,
126 onpass="ONOS CLI is ready",
127 onfail="ONOS CLI is not ready" )
128
Jon Halld1baa9e2016-03-08 09:46:09 -0800129 main.step( "Checking if ONOS CLI is ready for issuing commands" )
130 main.log.demoSummary( "DEMO: ONOS: Checking CLI" )
Jon Hallbc401252016-03-03 14:44:04 -0800131 for i in range( 10 ):
132 ready = True
133 for cli in main.CLIs:
134 output = cli.summary()
135 if not output:
136 ready = False
137 if ready:
138 break
139 time.sleep( 30 )
140 utilities.assert_equals( expect=True, actual=ready,
141 onpass="ONOS summary command succeded",
142 onfail="ONOS summary command failed" )
143
144 if not ready:
145 main.log.error( "ONOS startup failed!" )
146 main.cleanup()
147 main.exit()
Jon Halld1baa9e2016-03-08 09:46:09 -0800148 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800149
Jon Halld1baa9e2016-03-08 09:46:09 -0800150 def CASE199( self, main ):
151 main.case( "Verify topology discovery" )
152 main.log.info( "Waiting for link discovery......" )
Jon Hallbc401252016-03-03 14:44:04 -0800153 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
154
Jon Hallf9572352016-03-09 10:21:18 -0800155 main.step( "Get links in the network" )
Jon Hallbc401252016-03-03 14:44:04 -0800156 summaryResult = main.ONOScli1.summary()
157 linkNum = json.loads( summaryResult )[ "links" ]
Jon Halld1baa9e2016-03-08 09:46:09 -0800158 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
Jon Hallbc401252016-03-03 14:44:04 -0800159 if linkNum < 100:
Jon Halld1baa9e2016-03-08 09:46:09 -0800160 main.log.error( "Link number is wrong! Retrying..." )
Jon Hallbc401252016-03-03 14:44:04 -0800161 time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
Jon Hall776bfc52016-03-04 13:51:47 -0800162 summaryResult = main.ONOScli1.summary()
163 linkNum = json.loads( summaryResult )[ "links" ]
Jon Halld1baa9e2016-03-08 09:46:09 -0800164 main.log.info( "Expected 100 links, actual number is: {}".format( linkNum ) )
165 utilities.assert_equals( expect=100,
166 actual=linkNum,
167 onpass="ONOS correctly discovered all links",
168 onfail="ONOS Failed to discover all links" )
169 if linkNum < 100:
Jon Hallbc401252016-03-03 14:44:04 -0800170 main.cleanup()
171 main.exit()
Jon Halld1baa9e2016-03-08 09:46:09 -0800172 time.sleep( int( main.params['timers']['Readability'] ) )
173
174 def CASE200( self, main ):
175 main.case( "Activate sdn-ip application" )
Jon Hallbc401252016-03-03 14:44:04 -0800176
177 main.step( "Activate sdn-ip application" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800178 main.log.demoSummary( "DEMO:ONOS1: Activate sdn-ip application" )
Jon Hallbc401252016-03-03 14:44:04 -0800179 activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
180 utilities.assert_equals( expect=main.TRUE,
181 actual=activeSDNIPresult,
182 onpass="Activate SDN-IP succeeded",
183 onfail="Activate SDN-IP failed" )
184 if not activeSDNIPresult:
185 main.log.info( "Activate SDN-IP failed!" )
186 main.cleanup()
187 main.exit()
Jon Halld1baa9e2016-03-08 09:46:09 -0800188 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800189
190
191 def CASE102( self, main ):
192 '''
193 This test case is to load the methods from other Python files, and create
194 tunnels from mininet host to onos nodes.
195 '''
196 import time
Jon Halld1baa9e2016-03-08 09:46:09 -0800197 main.case( "Create tunnels between Quagga and SDNIP Application" )
Jon Hallbc401252016-03-03 14:44:04 -0800198 # load the methods from other file
199 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
200 main.Functions = imp.load_source( wrapperFile1,
201 main.dependencyPath +
202 wrapperFile1 +
203 ".py" )
204 # Create tunnels
Jon Hall88de9ee2016-03-04 12:29:56 -0800205 main.log.demoSummary( "DEMO:Mininet: Creating tunnels between bgp speakers" )
Jon Hallbc401252016-03-03 14:44:04 -0800206 # ONOS1
207 main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
208 # ONOS2
209 main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
210 # ONOS3
211 main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
212
Jon Hallbc401252016-03-03 14:44:04 -0800213 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
214
Jon Hallbc401252016-03-03 14:44:04 -0800215
216 def CASE1( self, main ):
217 '''
218 ping test from 3 bgp peers to BGP speaker
219 '''
220
221 main.case( "Ping between BGP peers and speakers" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800222 main.log.demoSummary( "DEMO:Mininet: Ping between bgp peers and speakers" )
Jon Hallbc401252016-03-03 14:44:04 -0800223 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
224 peers=["peer64514", "peer64515", "peer64516"],
225 expectAllSuccess=True )
226 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
227 peers=[peer64514, peer64515, peer64516],
228 expectAllSuccess=True )
Jon Halld1baa9e2016-03-08 09:46:09 -0800229 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800230
Jon Hallbc401252016-03-03 14:44:04 -0800231 def CASE2( self, main ):
232 '''
233 point-to-point intents test for each BGP peer and BGP speaker pair
234 '''
235 import time
236 main.case( "Check point-to-point intents" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800237 main.log.demoSummary( "DEMO:ONOS1: Verify Point-to-Point intents" )
Jon Hallbc401252016-03-03 14:44:04 -0800238 main.log.info( "There are %s BGP peers in total "
239 % main.params[ 'config' ][ 'peerNum' ] )
240 main.step( "Check P2P intents number from ONOS CLI" )
241
242 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
243 bgpIntentsActualNum = \
244 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
Jon Halld1baa9e2016-03-08 09:46:09 -0800245 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
Jon Hallbc401252016-03-03 14:44:04 -0800246 if bgpIntentsActualNum != bgpIntentsExpectedNum:
247 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallf9572352016-03-09 10:21:18 -0800248 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hallbc401252016-03-03 14:44:04 -0800249 bgpIntentsActualNum = \
250 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
251 main.log.info( "bgpIntentsExpected num is:" )
252 main.log.info( bgpIntentsExpectedNum )
253 main.log.info( "bgpIntentsActual num is:" )
254 main.log.info( bgpIntentsActualNum )
Jon Halld1baa9e2016-03-08 09:46:09 -0800255 utilities.assert_equals( \
256 expect=bgpIntentsExpectedNum,
257 actual=bgpIntentsActualNum,
Jon Hallbc401252016-03-03 14:44:04 -0800258 onpass="PointToPointIntent Intent Num is correct!",
259 onfail="PointToPointIntent Intent Num is wrong!" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800260 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800261
Jon Hallbc401252016-03-03 14:44:04 -0800262 def CASE3( self, main ):
263 '''
264 routes and intents check to all BGP peers
265 '''
266 import time
267 main.case( "Check routes and M2S intents to all BGP peers" )
Jon Hallbc401252016-03-03 14:44:04 -0800268
Jon Hallf9572352016-03-09 10:21:18 -0800269 main.step( "Check routes installed" )
Jon Hallbc401252016-03-03 14:44:04 -0800270 allRoutesExpected = []
271 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
272 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
273 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
274
Jon Hallf9572352016-03-09 10:21:18 -0800275 main.log.demoSummary( "DEMO:Quagga: Check BGP routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800276 getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
277 allRoutesActual = \
278 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
279 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
280 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
281 if allRoutesStrActual != allRoutesStrExpected:
282 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
283 allRoutesActual = \
284 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
285 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
286
Jon Hallbc401252016-03-03 14:44:04 -0800287 main.log.info( "Routes expected:" )
288 main.log.info( allRoutesStrExpected )
289 main.log.info( "Routes get from ONOS CLI:" )
290 main.log.info( allRoutesStrActual )
Jon Halld1baa9e2016-03-08 09:46:09 -0800291 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800292 expect=allRoutesStrExpected, actual=allRoutesStrActual,
293 onpass="Routes are correct!",
294 onfail="Routes are wrong!" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800295 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800296
297 main.step( "Check M2S intents installed" )
Jon Hallf9572352016-03-09 10:21:18 -0800298 main.log.demoSummary( "DEMO:ONOS1: Check Multi-point intents" )
Jon Hallbc401252016-03-03 14:44:04 -0800299 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
300 routeIntentsActualNum = \
301 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
302 routeIntentsExpectedNum = 3
303 if routeIntentsActualNum != routeIntentsExpectedNum:
304 time.sleep( int( main.params['timers']['RouteDelivery'] ) )
Jon Hallf9572352016-03-09 10:21:18 -0800305 getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
Jon Hallbc401252016-03-03 14:44:04 -0800306 routeIntentsActualNum = \
307 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
308
309 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
310 main.log.info( routeIntentsExpectedNum )
311 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
312 main.log.info( routeIntentsActualNum )
Jon Halld1baa9e2016-03-08 09:46:09 -0800313 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800314 expect=routeIntentsExpectedNum,
315 actual=routeIntentsActualNum,
316 onpass="MultiPointToSinglePoint Intent Num is correct!",
317 onfail="MultiPointToSinglePoint Intent Num is wrong!" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800318 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800319
Jon Hallf9572352016-03-09 10:21:18 -0800320 main.log.demoSummary( "DEMO:ONOS1: Check flows" )
Jon Hallbc401252016-03-03 14:44:04 -0800321 main.step( "Check whether all flow status are ADDED" )
322 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
323 main.FALSE,
324 kwargs={'isPENDING':False},
325 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800326 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800327 expect=main.TRUE,
328 actual=flowCheck,
329 onpass="Flow status is correct!",
330 onfail="Flow status is wrong!" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800331 time.sleep( int( main.params['timers']['Readability'] ) )
Jon Hallbc401252016-03-03 14:44:04 -0800332
333
334 def CASE4( self, main ):
335 '''
336 Ping test in data plane for each route
337 '''
338 main.case( "Ping test for each route, all hosts behind BGP peers" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800339 main.log.demoSummary( "DEMO:Mininet: Pinging across BGP routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800340 main.Functions.pingHostToHost( main,
341 hosts=["host64514", "host64515", "host64516"],
342 expectAllSuccess=True )
Jon Halld1baa9e2016-03-08 09:46:09 -0800343 time.sleep( int( main.params['timers']['Readability'] ) )
344 #main.log.demoSummary( "DEMO: STOP" ) #FIXME For testing
Jon Hallbc401252016-03-03 14:44:04 -0800345
346 def CASE5( self, main ):
347 '''
348 Cut links to peers one by one, check routes/intents
349 '''
350 import time
351 main.case( "Bring down links and check routes/intents" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800352 main.log.demoSummary( "DEMO:Mininet: Bringing down links between Quagga and the network" )
Jon Hallbc401252016-03-03 14:44:04 -0800353 main.step( "Bring down the link between sw32 and peer64514" )
354 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
355 OPTION="down" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800356 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800357 actual=linkResult1,
358 onpass="Bring down link succeeded!",
359 onfail="Bring down link failed!" )
360
361 if linkResult1 == main.TRUE:
362 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
363 main.log.debug( main.ONOScli1.links() ) #FIXME: DEBUG
364 main.Functions.checkRouteNum( main, 2 )
365 main.Functions.checkM2SintentNum( main, 2 )
366 else:
367 main.log.error( "Bring down link failed!" )
368 main.cleanup()
369 main.exit()
370
371 main.step( "Bring down the link between sw8 and peer64515" )
372 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
373 OPTION="down" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800374 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800375 actual=linkResult2,
376 onpass="Bring down link succeeded!",
377 onfail="Bring down link failed!" )
378 if linkResult2 == main.TRUE:
379 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
380 main.Functions.checkRouteNum( main, 1 )
381 main.Functions.checkM2SintentNum( main, 1 )
382 else:
383 main.log.error( "Bring down link failed!" )
384 main.cleanup()
385 main.exit()
386
387 main.step( "Bring down the link between sw28 and peer64516" )
388 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
389 OPTION="down" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800390 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800391 actual=linkResult3,
392 onpass="Bring down link succeeded!",
393 onfail="Bring down link failed!" )
394 if linkResult3 == main.TRUE:
395 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
396 main.Functions.checkRouteNum( main, 0 )
397 main.Functions.checkM2SintentNum( main, 0 )
398 else:
399 main.log.error( "Bring down link failed!" )
400 main.cleanup()
401 main.exit()
402
403 main.step( "Check whether all flow status are ADDED" )
404 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
405 main.FALSE,
406 kwargs={'isPENDING':False},
407 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800408 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800409 expect=main.TRUE,
410 actual=flowCheck,
411 onpass="Flow status is correct!",
412 onfail="Flow status is wrong!" )
413
414 # Ping test
Jon Hall88de9ee2016-03-04 12:29:56 -0800415 main.log.demoSummary( "DEMO:Mininet: Verify lost connectivity across routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800416 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
417 peers=["peer64514", "peer64515", "peer64516"],
418 expectAllSuccess=False )
419 main.Functions.pingHostToHost( main,
420 hosts=["host64514", "host64515", "host64516"],
421 expectAllSuccess=False )
422
423
424 def CASE6( self, main ):
425 '''
426 Recover links to peers one by one, check routes/intents
427 '''
428 import time
429 main.case( "Bring up links and check routes/intents" )
430 main.step( "Bring up the link between sw32 and peer64514" )
Jon Hall88de9ee2016-03-04 12:29:56 -0800431 main.log.demoSummary( "DEMO:Mininet: Bring back up links between Quagga and the network" )
Jon Hallbc401252016-03-03 14:44:04 -0800432 linkResult1 = main.Mininet.link( END1="sw32", END2="peer64514",
433 OPTION="up" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800434 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800435 actual=linkResult1,
436 onpass="Bring up link succeeded!",
437 onfail="Bring up link failed!" )
438 if linkResult1 == main.TRUE:
439 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
440 main.Functions.checkRouteNum( main, 1 )
441 main.Functions.checkM2SintentNum( main, 1 )
442 else:
443 main.log.error( "Bring up link failed!" )
444 main.cleanup()
445 main.exit()
446
447 main.step( "Bring up the link between sw8 and peer64515" )
448 linkResult2 = main.Mininet.link( END1="sw8", END2="peer64515",
449 OPTION="up" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800450 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800451 actual=linkResult2,
452 onpass="Bring up link succeeded!",
453 onfail="Bring up link failed!" )
454 if linkResult2 == main.TRUE:
455 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
456 main.Functions.checkRouteNum( main, 2 )
457 main.Functions.checkM2SintentNum( main, 2 )
458 else:
459 main.log.error( "Bring up link failed!" )
460 main.cleanup()
461 main.exit()
462
463 main.step( "Bring up the link between sw28 and peer64516" )
464 linkResult3 = main.Mininet.link( END1="sw28", END2="peer64516",
465 OPTION="up" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800466 utilities.assert_equals( expect=main.TRUE,
Jon Hallbc401252016-03-03 14:44:04 -0800467 actual=linkResult3,
468 onpass="Bring up link succeeded!",
469 onfail="Bring up link failed!" )
470 if linkResult3 == main.TRUE:
471 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
472 main.Functions.checkRouteNum( main, 3 )
473 main.Functions.checkM2SintentNum( main, 3 )
474 else:
475 main.log.error( "Bring up link failed!" )
476 main.cleanup()
477 main.exit()
478
479 main.step( "Check whether all flow status are ADDED" )
480 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
481 main.FALSE,
482 kwargs={'isPENDING':False},
483 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800484 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800485 expect=main.TRUE,
486 actual=flowCheck,
487 onpass="Flow status is correct!",
488 onfail="Flow status is wrong!" )
489
490 # Ping test
Jon Hall88de9ee2016-03-04 12:29:56 -0800491 main.log.demoSummary( "DEMO:Mininet: Verify connectivity is restored across routes" )
Jon Hallbc401252016-03-03 14:44:04 -0800492 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
493 peers=["peer64514", "peer64515", "peer64516"],
494 expectAllSuccess=True )
495 main.Functions.pingHostToHost( main,
496 hosts=["host64514", "host64515", "host64516"],
497 expectAllSuccess=True )
498
499
500 def CASE7( self, main ):
501 '''
502 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
503 '''
504 import time
505 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
506 main.step( "Stop sw32" )
507 result = main.Mininet.switch( SW="sw32", OPTION="stop" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800508 utilities.assert_equals( expect=main.TRUE, actual=result,
Jon Hallbc401252016-03-03 14:44:04 -0800509 onpass="Stopping switch succeeded!",
510 onfail="Stopping switch failed!" )
511
512 if result == main.TRUE:
513 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
514 main.Functions.checkRouteNum( main, 2 )
515 main.Functions.checkM2SintentNum( main, 2 )
516 main.Functions.checkP2PintentNum( main, 12 * 2 )
517 else:
518 main.log.error( "Stopping switch failed!" )
519 main.cleanup()
520 main.exit()
521
522 main.step( "Check ping between hosts behind BGP peers" )
523 result1 = main.Mininet.pingHost( src="host64514", target="host64515" )
524 result2 = main.Mininet.pingHost( src="host64515", target="host64516" )
525 result3 = main.Mininet.pingHost( src="host64514", target="host64516" )
526
527 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
528 and ( result3 == main.FALSE )
529 utilities.assert_equals( expect=True, actual=pingResult1,
530 onpass="Ping test result is correct",
531 onfail="Ping test result is wrong" )
532
533 if pingResult1 == False:
534 main.cleanup()
535 main.exit()
536
537 main.step( "Check ping between BGP peers and speaker1" )
538 result4 = main.Mininet.pingHost( src="speaker1", target="peer64514" )
539 result5 = main.Mininet.pingHost( src="speaker1", target="peer64515" )
540 result6 = main.Mininet.pingHost( src="speaker1", target="peer64516" )
541
542 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
543 and ( result6 == main.TRUE )
544 utilities.assert_equals( expect=True, actual=pingResult2,
545 onpass="Speaker1 ping peers successful",
546 onfail="Speaker1 ping peers NOT successful" )
547
548 if pingResult2 == False:
549 main.cleanup()
550 main.exit()
551
552 main.step( "Check ping between BGP peers and speaker2" )
553 # TODO
554 result7 = main.Mininet.pingHost( src="speaker2", target=peer64514 )
555 result8 = main.Mininet.pingHost( src="speaker2", target=peer64515 )
556 result9 = main.Mininet.pingHost( src="speaker2", target=peer64516 )
557
558 pingResult3 = ( result7 == main.FALSE ) and ( result8 == main.TRUE ) \
559 and ( result9 == main.TRUE )
560 utilities.assert_equals( expect=True, actual=pingResult2,
561 onpass="Speaker2 ping peers successful",
562 onfail="Speaker2 ping peers NOT successful" )
563
564 if pingResult3 == False:
565 main.cleanup()
566 main.exit()
567
568 main.step( "Check whether all flow status are ADDED" )
569 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
570 main.FALSE,
571 kwargs={'isPENDING':False},
572 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800573 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800574 expect=main.TRUE,
575 actual=flowCheck,
576 onpass="Flow status is correct!",
577 onfail="Flow status is wrong!" )
578
579
580 def CASE8( self, main ):
581 '''
582 Bring up the edge switch (sw32) which was shut down in CASE7,
583 check P-2-P and M-2-S intents, ping test
584 '''
585 import time
586 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
587 main.step( "Start sw32" )
588 result1 = main.Mininet.switch( SW="sw32", OPTION="start" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800589 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800590 expect=main.TRUE,
591 actual=result1,
592 onpass="Starting switch succeeded!",
593 onfail="Starting switch failed!" )
594
595 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
Jon Halld1baa9e2016-03-08 09:46:09 -0800596 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800597 expect=main.TRUE,
598 actual=result2,
599 onpass="Connect switch to ONOS succeeded!",
600 onfail="Connect switch to ONOS failed!" )
601
602 if result1 and result2:
603 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
604 main.Functions.checkRouteNum( main, 3 )
605 main.Functions.checkM2SintentNum( main, 3 )
606 main.Functions.checkP2PintentNum( main, 18 * 2 )
607 else:
608 main.log.error( "Starting switch failed!" )
609 main.cleanup()
610 main.exit()
611
612 main.step( "Check whether all flow status are ADDED" )
613 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
614 main.FALSE,
615 kwargs={'isPENDING':False},
616 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800617 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800618 expect=main.TRUE,
619 actual=flowCheck,
620 onpass="Flow status is correct!",
621 onfail="Flow status is wrong!" )
622
623 # Ping test
624 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
625 peers=["peer64514", "peer64515", "peer64516"],
626 expectAllSuccess=True )
627 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
628 peers=[peer64514, peer64515, peer64516],
629 expectAllSuccess=True )
630 main.Functions.pingHostToHost( main,
631 hosts=["host64514", "host64515", "host64516"],
632 expectAllSuccess=True )
633
634
635 def CASE9( self, main ):
636 '''
637 Bring down a switch in best path, check:
638 route number, P2P intent number, M2S intent number, ping test
639 '''
640 main.case( "Stop sw11 located in best path, \
641 check route number, P2P intent number, M2S intent number, ping test" )
642
643 main.log.info( "Check the flow number correctness before stopping sw11" )
644 main.Functions.checkFlowNum( main, "sw11", 19 )
645 main.Functions.checkFlowNum( main, "sw1", 3 )
646 main.Functions.checkFlowNum( main, "sw7", 3 )
647
648 main.step( "Stop sw11" )
649 result = main.Mininet.switch( SW="sw11", OPTION="stop" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800650 utilities.assert_equals( expect=main.TRUE, actual=result,
Jon Hallbc401252016-03-03 14:44:04 -0800651 onpass="Stopping switch succeeded!",
652 onfail="Stopping switch failed!" )
653 if result:
654 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
655 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
656 main.Functions.checkRouteNum( main, 3 )
657 main.Functions.checkM2SintentNum( main, 3 )
658 main.Functions.checkP2PintentNum( main, 18 * 2 )
659 else:
660 main.log.error( "Stopping switch failed!" )
661 main.cleanup()
662 main.exit()
663
664 main.step( "Check whether all flow status are ADDED" )
665 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
666 main.FALSE,
667 kwargs={'isPENDING':False},
668 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800669 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800670 expect=main.TRUE,
671 actual=flowCheck,
672 onpass="Flow status is correct!",
673 onfail="Flow status is wrong!" )
674 # Ping test
675 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
676 peers=["peer64514", "peer64515", "peer64516"],
677 expectAllSuccess=True )
678 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
679 peers=[peer64514, peer64515, peer64516],
680 expectAllSuccess=True )
681 main.Functions.pingHostToHost( main,
682 hosts=["host64514", "host64515", "host64516"],
683 expectAllSuccess=True )
684
685
686 def CASE10( self, main ):
687 '''
688 Bring up the switch which was stopped in CASE9, check:
689 route number, P2P intent number, M2S intent number, ping test
690 '''
691 main.case( "Start sw11 which was stopped in CASE9, \
692 check route number, P2P intent number, M2S intent number, ping test" )
693
694 main.log.info( "Check the flow status before starting sw11" )
695 main.Functions.checkFlowNum( main, "sw1", 17 )
696 main.Functions.checkFlowNum( main, "sw7", 5 )
697
698 main.step( "Start sw11" )
699 result1 = main.Mininet.switch( SW="sw11", OPTION="start" )
Jon Halld1baa9e2016-03-08 09:46:09 -0800700 utilities.assert_equals( expect=main.TRUE, actual=result1,
Jon Hallbc401252016-03-03 14:44:04 -0800701 onpass="Starting switch succeeded!",
702 onfail="Starting switch failed!" )
703 result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
Jon Halld1baa9e2016-03-08 09:46:09 -0800704 utilities.assert_equals( expect=main.TRUE, actual=result2,
Jon Hallbc401252016-03-03 14:44:04 -0800705 onpass="Connect switch to ONOS succeeded!",
706 onfail="Connect switch to ONOS failed!" )
707 if result1 and result2:
708 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
709 main.Functions.checkRouteNum( main, 3 )
710 main.Functions.checkM2SintentNum( main, 3 )
711 main.Functions.checkP2PintentNum( main, 18 * 2 )
712
713 else:
714 main.log.error( "Starting switch failed!" )
715 main.cleanup()
716 main.exit()
717
718 main.step( "Check whether all flow status are ADDED" )
719 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
720 main.FALSE,
721 kwargs={'isPENDING':False},
722 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800723 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800724 expect=main.TRUE,
725 actual=flowCheck,
726 onpass="Flow status is correct!",
727 onfail="Flow status is wrong!" )
728 # Ping test
729 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
730 peers=["peer64514", "peer64515", "peer64516"],
731 expectAllSuccess=True )
732 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
733 peers=[peer64514, peer64515, peer64516],
734 expectAllSuccess=True )
735 main.Functions.pingHostToHost( main,
736 hosts=["host64514", "host64515", "host64516"],
737 expectAllSuccess=True )
738
739
740 def CASE11(self, main):
741 import time
742 main.case( "Kill speaker1, check:\
743 route number, P2P intent number, M2S intent number, ping test" )
744 main.log.info( "Check network status before killing speaker1" )
745 main.Functions.checkRouteNum( main, 3 )
746 main.Functions.checkM2SintentNum( main, 3 )
747 main.Functions.checkP2PintentNum( main, 18 * 2 )
748 main.step( "Check whether all flow status are ADDED" )
749 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
750 main.FALSE,
751 kwargs={'isPENDING':False},
752 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800753 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800754 expect=main.TRUE,
755 actual=flowCheck,
756 onpass="Flow status is correct!",
757 onfail="Flow status is wrong!" )
758
759 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
760 peers=["peer64514", "peer64515", "peer64516"],
761 expectAllSuccess=True )
762 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
763 peers=[peer64514, peer64515, peer64516],
764 expectAllSuccess=True )
765 main.Functions.pingHostToHost( main,
766 hosts=["host64514", "host64515", "host64516"],
767 expectAllSuccess=True )
768
769 main.step( "Kill speaker1" )
770 command1 = "ps -e | grep bgp -c"
771 result1 = main.Mininet.node( "root", command1 )
772
773 # The total BGP daemon number in this test environment is 5.
774 if "5" in result1:
775 main.log.debug( "Before kill speaker1, 5 BGP daemons - correct" )
776 else:
777 main.log.warn( "Before kill speaker1, number of BGP daemons is wrong" )
778 main.log.info( result1 )
779
780 command2 = "sudo kill -9 `ps -ef | grep quagga-sdn.conf | grep -v grep | awk '{print $2}'`"
781 result2 = main.Mininet.node( "root", command2 )
782
783 result3 = main.Mininet.node( "root", command1 )
784
785 utilities.assert_equals( expect=True,
786 actual=( "4" in result3 ),
787 onpass="Kill speaker1 succeeded",
788 onfail="Kill speaker1 failed" )
789 if ( "4" not in result3 ) :
790 main.log.info( result3 )
791 main.cleanup()
792 main.exit()
793
794 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
795 main.Functions.checkRouteNum( main, 3 )
796 main.Functions.checkM2SintentNum( main, 3 )
797 main.Functions.checkP2PintentNum( main, 18 * 2 )
798
799 main.step( "Check whether all flow status are ADDED" )
800 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
801 main.FALSE,
802 kwargs={'isPENDING':False},
803 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800804 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800805 expect=main.TRUE,
806 actual=flowCheck,
807 onpass="Flow status is correct!",
808 onfail="Flow status is wrong!" )
809
810 '''
811 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
812 peers=["peer64514", "peer64515", "peer64516"],
813 expectAllSuccess=False )
814 '''
815 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
816 peers=[peer64514, peer64515, peer64516],
817 expectAllSuccess=True )
818 main.Functions.pingHostToHost( main,
819 hosts=["host64514", "host64515", "host64516"],
820 expectAllSuccess=True )
821
822
823 def CASE12( self, main ):
824 import time
825 import json
826 main.case( "Bring down leader ONOS node, check: \
827 route number, P2P intent number, M2S intent number, ping test" )
828 main.step( "Find out ONOS leader node" )
829 result = main.ONOScli1.leaders()
830 jsonResult = json.loads( result )
831 leaderIP = ""
832 for entry in jsonResult:
833 if entry["topic"] == "org.onosproject.sdnip":
834 leaderIP = entry["leader"]
835 main.log.info( "leaderIP is: " )
836 main.log.info( leaderIP )
837
838 main.step( "Uninstall ONOS/SDN-IP leader node" )
839 if leaderIP == ONOS1Ip:
840 uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
841 elif leaderIP == ONOS2Ip:
842 uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
843 else:
844 uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
845
846 utilities.assert_equals( expect=main.TRUE,
847 actual=uninstallResult,
848 onpass="Uninstall ONOS leader succeeded",
849 onfail="Uninstall ONOS leader failed" )
850 if uninstallResult != main.TRUE:
851 main.cleanup()
852 main.exit()
853 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
854
855 if leaderIP == ONOS1Ip:
856 main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
857 main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
858 main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
859
860 main.step( "Check whether all flow status are ADDED" )
861 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
862 main.FALSE,
863 kwargs={'isPENDING':False},
864 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800865 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800866 expect=main.TRUE,
867 actual=flowCheck,
868 onpass="Flow status is correct!",
869 onfail="Flow status is wrong!" )
870 else:
871 main.Functions.checkRouteNum( main, 3 )
872 main.Functions.checkM2SintentNum( main, 3 )
873 main.Functions.checkP2PintentNum( main, 18 * 2 )
874
875 main.step( "Check whether all flow status are ADDED" )
876 flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
877 main.FALSE,
878 kwargs={'isPENDING':False},
879 attempts=10 )
Jon Halld1baa9e2016-03-08 09:46:09 -0800880 utilities.assert_equals( \
Jon Hallbc401252016-03-03 14:44:04 -0800881 expect=main.TRUE,
882 actual=flowCheck,
883 onpass="Flow status is correct!",
884 onfail="Flow status is wrong!" )
885
886 main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
887 peers=["peer64514", "peer64515", "peer64516"],
888 expectAllSuccess=True )
889 main.Functions.pingSpeakerToPeer( main, speakers=["speaker2"],
890 peers=[peer64514, peer64515, peer64516],
891 expectAllSuccess=True )
892 main.Functions.pingHostToHost( main,
893 hosts=["host64514", "host64515", "host64516"],
894 expectAllSuccess=True )
Jon Hallff099c72016-03-11 11:22:02 -0800895
896 def CASE1001( self, main):
897 '''
898 Check onos node log for ERROR
899 '''
900 import time
901
902 main.case( "Checking onos logs for ERRORs...")
903 main.step( "Checking onos logs for ERRORs ...")
904 main.log.demoSummary( "DEMO:ONOS: Check onos logs for ERRORs")
905
906 onosErrors={}
907 result = True
908 for node in [ ONOS1Ip, ONOS2Ip, ONOS3Ip ]:
909 onosErrors[ node ] = main.ONOSbench.logReport(node, ["ERROR", "WARNING", "EXCEPT"] )
Jon Hall53c3bde2016-03-18 09:45:08 -0700910 result = (not bool(onosErrors[ node ])) & result
Jon Hallff099c72016-03-11 11:22:02 -0800911
912 utilities.assert_equals( \
913 expect=main.TRUE,
914 actual=result,
915 onpass="No onos WARNINGs/ERRORs/Exceptions at the end of the test!",
916 onfail="onos has WARNINGs/ERRORs/Exceptions at the end of the test!" )
917
918 time.sleep( int( main.params['timers']['Readability'] ) )