blob: ed93999b64b5c2bad8f75ee33c22ae790c11bac5 [file] [log] [blame]
pingping-lin28e7b212015-09-10 10:14:58 -07001# Testing the functionality of SDN-IP with single ONOS instance
pingping-lin5bb663b2015-09-24 11:47:50 -07002class USECASE_SdnipFunction:
pingping-lin28e7b212015-09-10 10:14:58 -07003
4 def __init__( self ):
5 self.default = ''
6 global branchName
7
pingping-linb702c602015-09-10 17:00:29 -07008 # This case is to setup Mininet testbed
9 def CASE100( self, main ):
10 """
11 Start mininet
12 """
13 import os
pingping-lin4f80c492015-09-15 14:34:42 -070014 import imp
pingping-lin5bb663b2015-09-24 11:47:50 -070015 main.log.case( "This case is to setup the Mininet testbed" )
pingping-linb702c602015-09-10 17:00:29 -070016 main.dependencyPath = main.testDir + \
17 main.params[ 'DEPENDENCY' ][ 'path' ]
18 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
19
20 main.step( "Starting Mininet Topology" )
21 topology = main.dependencyPath + main.topology
22 topoResult = main.Mininet.startNet( topoFile = topology )
pingping-linb702c602015-09-10 17:00:29 -070023 utilities.assert_equals( expect = main.TRUE,
pingping-lin5bb663b2015-09-24 11:47:50 -070024 actual = topoResult,
pingping-linb702c602015-09-10 17:00:29 -070025 onpass = "Successfully loaded topology",
26 onfail = "Failed to load topology" )
27 # Exit if topology did not load properly
28 if not topoResult:
29 main.cleanup()
30 main.exit()
pingping-lin5bb663b2015-09-24 11:47:50 -070031 main.step( "Connect switches to controller" )
32
33 global ONOS1Ip
34 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
35 # connect all switches to controller
36 swResult = main.TRUE
37 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
38 sw = "sw%s" % ( i )
39 swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip )
40 # swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip, port = "6633" )
41 utilities.assert_equals( expect = main.TRUE,
42 actual = swResult,
43 onpass = "Successfully connect all switches to ONOS",
44 onfail = "Failed to connect all switches to ONOS" )
45 if not swResult:
46 main.cleanup()
47 main.exit()
48
49 main.step( "Set up tunnel from Mininet node to onos node" )
50 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip )
51 command = 'ssh -nNT -o "PasswordAuthentication no" \
52 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, ONOS1Ip )
53
54 tunnelResult = main.TRUE
55 tunnelResult = main.Mininet.node( "root", command )
56 if not tunnelResult:
57 main.log.report("Failed to create tunnel")
58 main.cleanup()
59 main.exit()
60 elif "PasswordAuthentication" in tunnelResult:
61 main.log.report("Successfully created tunnel")
62
pingping-lin28e7b212015-09-10 10:14:58 -070063
64 # This case is to setup ONOS
pingping-linb702c602015-09-10 17:00:29 -070065 def CASE101( self, main ):
pingping-lin28e7b212015-09-10 10:14:58 -070066 """
67 CASE100 is to compile ONOS and install it
68 Startup sequence:
69 cell <name>
70 onos-verify-cell
71 git pull
72 mvn clean install
73 onos-package
74 onos-install -f
75 onos-wait-for-start
76 """
77 import json
78 import time
79 from operator import eq
80
81 main.case( "Setting up test environment" )
82
83 cellName = main.params[ 'ENV' ][ 'cellName' ]
pingping-lin28e7b212015-09-10 10:14:58 -070084
85 main.step( "Applying cell variable to environment" )
86 cellResult = main.ONOSbench.setCell( cellName )
87 verifyResult = main.ONOSbench.verifyCell()
88
89 branchName = main.ONOSbench.getBranchName()
90 main.log.info( "ONOS is on branch: " + branchName )
91
92 main.log.report( "Uninstalling ONOS" )
93 main.ONOSbench.onosUninstall( ONOS1Ip )
94
95 # cleanInstallResult = main.TRUE
96 # gitPullResult = main.TRUE
97
98 main.step( "Git pull" )
99 gitPullResult = main.ONOSbench.gitPull()
100
101 main.step( "Using mvn clean install" )
102 if gitPullResult == main.TRUE:
103 cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 )
104 else:
105 main.log.warn( "Did not pull new code so skipping mvn " +
106 "clean install" )
107 cleanInstallResult = main.TRUE
108
109 main.ONOSbench.getVersion( report = True )
110
111 main.step( "Creating ONOS package" )
112 packageResult = main.ONOSbench.onosPackage( opTimeout = 500 )
113
114 main.step( "Installing ONOS package" )
115 onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
116 node = ONOS1Ip )
117
118 main.step( "Checking if ONOS is up yet" )
119 for i in range( 2 ):
120 onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
121 if onos1Isup:
122 break
123 if not onos1Isup:
124 main.log.report( "ONOS1 didn't start!" )
125
126 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
127 commandlineTimeout = 100, onosStartTimeout = 600 )
128
pingping-linb702c602015-09-10 17:00:29 -0700129 caseResult = ( cleanInstallResult and packageResult and
pingping-lin28e7b212015-09-10 10:14:58 -0700130 cellResult and verifyResult and
131 onos1InstallResult and
132 onos1Isup and cliResult )
133
pingping-linb702c602015-09-10 17:00:29 -0700134 utilities.assert_equals( expect = main.TRUE, actual = caseResult,
pingping-lin28e7b212015-09-10 10:14:58 -0700135 onpass = "ONOS startup successful",
136 onfail = "ONOS startup NOT successful" )
137
pingping-linb702c602015-09-10 17:00:29 -0700138 if caseResult == main.FALSE:
pingping-lin28e7b212015-09-10 10:14:58 -0700139 main.cleanup()
140 main.exit()
141
pingping-lin28e7b212015-09-10 10:14:58 -0700142 main.step( "Get links in the network" )
143 listResult = main.ONOScli.links( jsonFormat = False )
144 main.log.info( listResult )
145 main.log.info( "Activate sdn-ip application" )
146 main.ONOScli.activateApp( "org.onosproject.sdnip" )
pingping-linb702c602015-09-10 17:00:29 -0700147
148 main.log.info( "Wait sdn-ip to finish installing connectivity intents, \
149 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700150 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700151 main.log.info( "Wait Quagga to finish delivery all routes to each \
152 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700153 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
154 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
155
156
pingping-lin4f80c492015-09-15 14:34:42 -0700157 def CASE102( self, main ):
158 '''
159 This test case is to load the methods from other Python files.
160 '''
161 main.case( "Loading the methods from other Python file" )
162 # load the methods from other file
163 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
164 main.Functions = imp.load_source( wrapperFile,
165 main.dependencyPath +
166 wrapperFile +
167 ".py" )
168
169
pingping-lin0ce60622015-09-10 14:37:33 -0700170 def CASE1( self, main ):
171 '''
172 ping test from 3 bgp peers to BGP speaker
173 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700174
pingping-lin0ce60622015-09-10 14:37:33 -0700175 main.case( "This case is to check ping between BGP peers and speakers" )
pingping-lin829428d2015-09-22 20:50:00 -0700176 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
177 peers = ["peer64514", "peer64515", "peer64516"],
178 expectAllSuccess = True )
pingping-lin0ce60622015-09-10 14:37:33 -0700179
pingping-lin950b50d2015-09-14 12:00:08 -0700180
pingping-lin0ce60622015-09-10 14:37:33 -0700181 def CASE2( self, main ):
182 '''
183 point-to-point intents test for each BGP peer and BGP speaker pair
184 '''
185 main.case( "This case is to check point-to-point intents" )
186 main.log.info( "There are %s BGP peers in total "
187 % main.params[ 'config' ][ 'peerNum' ] )
188 main.step( "Get point-to-point intents from ONOS CLI" )
189
190 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
191 bgpIntentsActualNum = \
192 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
193 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
194 main.log.info( "bgpIntentsExpected num is:" )
195 main.log.info( bgpIntentsExpectedNum )
196 main.log.info( "bgpIntentsActual num is:" )
197 main.log.info( bgpIntentsActualNum )
198 utilities.assertEquals( \
199 expect = True,
200 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
201 onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***",
202 onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" )
203
204
205 def CASE3( self, main ):
206 '''
207 routes and intents check to all BGP peers
208 '''
209 main.case( "This case is to check routes and intents to all BGP peers" )
210
pingping-lin28e7b212015-09-10 10:14:58 -0700211 allRoutesExpected = []
212 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
213 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
214 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
215
216 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
217 allRoutesActual = \
218 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
219 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
220 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
221
222 main.step( "Check routes installed" )
223 main.log.info( "Routes expected:" )
224 main.log.info( allRoutesStrExpected )
225 main.log.info( "Routes get from ONOS CLI:" )
226 main.log.info( allRoutesStrActual )
227 utilities.assertEquals( \
228 expect = allRoutesStrExpected, actual = allRoutesStrActual,
229 onpass = "***Routes in SDN-IP are correct!***",
230 onfail = "***Routes in SDN-IP are wrong!***" )
231
232 main.step( "Check MultiPointToSinglePointIntent intents installed" )
233 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
234 routeIntentsActualNum = \
235 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
236 routeIntentsExpectedNum = 3
237
238 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
239 main.log.info( routeIntentsExpectedNum )
240 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
241 main.log.info( routeIntentsActualNum )
242 utilities.assertEquals( \
243 expect = True,
244 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
245 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
246 correct!***",
247 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
248 wrong!***" )
249
pingping-linbab7f8a2015-09-21 17:33:36 -0700250 main.step( "Check whether all flow status are ADDED" )
251 utilities.assertEquals( \
252 expect = main.TRUE,
253 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
254 onpass = "***Flow status is correct!***",
255 onfail = "***Flow status is wrong!***" )
256
pingping-lin950b50d2015-09-14 12:00:08 -0700257
258 def CASE4( self, main ):
259 '''
260 Ping test in data plane for each route
261 '''
pingping-lin829428d2015-09-22 20:50:00 -0700262 main.case( "This case is to check ping for each route, \
263 all hosts behind BGP peers" )
264 main.Functions.pingHostToHost( main,
265 hosts = ["host64514", "host64515", "host64516"],
266 expectAllSuccess = True )
pingping-lin4f80c492015-09-15 14:34:42 -0700267
268
269 def CASE5( self, main ):
270 '''
271 Cut links to peers one by one, check routes/intents
272 '''
273 import time
274 main.case( "This case is to bring down links and check routes/intents" )
275 main.step( "Bring down the link between sw32 and peer64514" )
276 result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
277 OPTION = "down" )
278 if result == main.TRUE:
279 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
280 main.Functions.checkRouteNum( main, 2 )
281 main.Functions.checkM2SintentNum( main, 2 )
282 else:
283 main.log.info( "Bring down link failed!!!" )
284 main.exit();
285
286 main.step( "Bring down the link between sw8 and peer64515" )
287 result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
288 OPTION = "down" )
289 if result == main.TRUE:
290 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
291 main.Functions.checkRouteNum( main, 1 )
292 main.Functions.checkM2SintentNum( main, 1 )
293 else:
294 main.log.info( "Bring down link failed!!!" )
295 main.exit();
296
297 main.step( "Bring down the link between sw28 and peer64516" )
298 result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
299 OPTION = "down" )
300 if result == main.TRUE:
301 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
302 main.Functions.checkRouteNum( main, 0 )
303 main.Functions.checkM2SintentNum( main, 0 )
304 else:
305 main.log.info( "Bring down link failed!!!" )
306 main.exit();
307
pingping-linbab7f8a2015-09-21 17:33:36 -0700308 main.step( "Check whether all flow status are ADDED" )
309 utilities.assertEquals( \
310 expect = main.TRUE,
311 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
312 onpass = "***Flow status is correct!***",
313 onfail = "***Flow status is wrong!***" )
314
pingping-lin829428d2015-09-22 20:50:00 -0700315 # Ping test
316 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
317 peers = ["peer64514", "peer64515", "peer64516"],
318 expectAllSuccess = False )
319 main.Functions.pingHostToHost( main,
320 hosts = ["host64514", "host64515", "host64516"],
321 expectAllSuccess = False )
pingping-lin4f80c492015-09-15 14:34:42 -0700322
pingping-lin829428d2015-09-22 20:50:00 -0700323
324 def CASE6( self, main ):
pingping-lin4f80c492015-09-15 14:34:42 -0700325 '''
326 Recover links to peers one by one, check routes/intents
327 '''
328 import time
329 main.case( "This case is to bring up links and check routes/intents" )
330 main.step( "Bring up the link between sw32 and peer64514" )
331 result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
332 OPTION = "up" )
333 if result == main.TRUE:
334 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
335 main.Functions.checkRouteNum( main, 1 )
336 main.Functions.checkM2SintentNum( main, 1 )
337 else:
338 main.log.info( "Bring up link failed!!!" )
339 main.exit();
340
341 main.step( "Bring up the link between sw8 and peer64515" )
342 result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
343 OPTION = "up" )
344 if result == main.TRUE:
345 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
346 main.Functions.checkRouteNum( main, 2 )
347 main.Functions.checkM2SintentNum( main, 2 )
348 else:
349 main.log.info( "Bring up link failed!!!" )
350 main.exit();
351
352 main.step( "Bring up the link between sw28 and peer64516" )
353 result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
354 OPTION = "up" )
355 if result == main.TRUE:
356 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
357 main.Functions.checkRouteNum( main, 3 )
358 main.Functions.checkM2SintentNum( main, 3 )
359 else:
360 main.log.info( "Bring up link failed!!!" )
361 main.exit();
pingping-linbab7f8a2015-09-21 17:33:36 -0700362
363 main.step( "Check whether all flow status are ADDED" )
364 utilities.assertEquals( \
365 expect = main.TRUE,
366 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
367 onpass = "***Flow status is correct!***",
368 onfail = "***Flow status is wrong!***" )
pingping-lin829428d2015-09-22 20:50:00 -0700369
370 # Ping test
371 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
372 peers = ["peer64514", "peer64515", "peer64516"],
373 expectAllSuccess = True )
374 main.Functions.pingHostToHost( main,
375 hosts = ["host64514", "host64515", "host64516"],
376 expectAllSuccess = True )
pingping-lin8244a3b2015-09-16 13:36:56 -0700377
378
pingping-lin829428d2015-09-22 20:50:00 -0700379 def CASE7( self, main ):
pingping-lin8244a3b2015-09-16 13:36:56 -0700380 '''
pingping-lin829428d2015-09-22 20:50:00 -0700381 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
pingping-lin8244a3b2015-09-16 13:36:56 -0700382 '''
383 import time
384 main.case( "This case is to stop 1 edge switch,\
pingping-lin829428d2015-09-22 20:50:00 -0700385 check P-2-P and M-2-S intents, ping test" )
pingping-lin8244a3b2015-09-16 13:36:56 -0700386 main.step( "Stop sw32" )
387 result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
388 if result == main.TRUE:
389 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
390 main.Functions.checkRouteNum( main, 2 )
391 main.Functions.checkM2SintentNum( main, 2 )
392 main.Functions.checkP2PintentNum( main, 12 )
393 else:
394 main.log.info( "Stop switch failed!!!" )
395 main.exit();
396
pingping-lin829428d2015-09-22 20:50:00 -0700397 main.step( "Check ping between hosts behind BGP peers" )
398 result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
399 result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
400 result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )
401
402 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
403 and ( result3 == main.FALSE )
404 utilities.assert_equals( expect = True, actual = pingResult1,
405 onpass = "Ping test result is correct",
406 onfail = "Ping test result is wrong" )
407
408 if pingResult1 == False:
409 main.cleanup()
410 main.exit()
411
412 main.step( "Check ping between BGP peers and speakers" )
413 result4 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" )
414 result5 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" )
415 result6 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" )
416
417 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
418 and ( result6 == main.TRUE )
419 utilities.assert_equals( expect = True, actual = pingResult2,
420 onpass = "Speaker1 ping peers successful",
421 onfail = "Speaker1 ping peers NOT successful" )
422
423 if pingResult2 == False:
424 main.cleanup()
425 main.exit()
426
pingping-linbab7f8a2015-09-21 17:33:36 -0700427 main.step( "Check whether all flow status are ADDED" )
428 utilities.assertEquals( \
429 expect = main.TRUE,
430 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
431 onpass = "***Flow status is correct!***",
432 onfail = "***Flow status is wrong!***" )
433
pingping-lin8244a3b2015-09-16 13:36:56 -0700434 '''
435 main.step( "Stop sw8" )
436 result = main.Mininet.switch( SW = "sw8", OPTION = "stop" )
437 if result == main.TRUE:
438 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
439 main.Functions.checkRouteNum( main, 1 )
440
441 # Note: there should be 0 M2S intent, not 1.
442 main.Functions.checkM2SintentNum( main, 0 )
443 main.Functions.checkP2PintentNum( main, 6 )
444 else:
445 main.log.info( "Stop switch failed!!!" )
446 main.exit();
447
448 main.step( "Stop sw28" )
449 result = main.Mininet.switch( SW = "sw28", OPTION = "stop" )
450 if result == main.TRUE:
451 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
452 main.Functions.checkRouteNum( main, 0 )
453 main.Functions.checkM2SintentNum( main, 0 )
454 main.Functions.checkP2PintentNum( main, 0 )
455 else:
456 main.log.info( "Stop switch failed!!!" )
457 main.exit();
458 '''
pingping-lin8244a3b2015-09-16 13:36:56 -0700459
pingping-lind791d342015-09-17 18:34:31 -0700460
pingping-lin8244a3b2015-09-16 13:36:56 -0700461 def CASE8( self, main ):
pingping-lind791d342015-09-17 18:34:31 -0700462 '''
463 Bring up the edge switch which was shut down in CASE7,
464 check P-2-P and M-2-S intents, ping test
465 '''
466 import time
467 main.case( "This case is to start the switch which was shut down in CASE7,\
pingping-lin8244a3b2015-09-16 13:36:56 -0700468 check P-2-P and M-2-S intents, ping test" )
pingping-lind791d342015-09-17 18:34:31 -0700469 main.step( "Start sw32" )
470 result1 = main.Mininet.switch( SW = "sw32", OPTION = "start" )
471 result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
472
473 if result1 and result2:
474 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
475 main.Functions.checkRouteNum( main, 3 )
476 main.Functions.checkM2SintentNum( main, 3 )
477 main.Functions.checkP2PintentNum( main, 18 )
478 else:
479 main.log.info( "Start switch failed!!!" )
480 main.cleanup()
481 main.exit();
pingping-lin4f80c492015-09-15 14:34:42 -0700482
pingping-linbab7f8a2015-09-21 17:33:36 -0700483 main.step( "Check whether all flow status are ADDED" )
484 utilities.assertEquals( \
485 expect = main.TRUE,
486 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
487 onpass = "***Flow status is correct!***",
488 onfail = "***Flow status is wrong!***" )
489
pingping-lin829428d2015-09-22 20:50:00 -0700490 # Ping test
491 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 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700497
pingping-lin829428d2015-09-22 20:50:00 -0700498
499 def CASE9( self, main ):
pingping-linbab7f8a2015-09-21 17:33:36 -0700500 '''
501 Bring down a switch in best path, check:
502 route number, P2P intent number, M2S intent number, ping test
503 '''
504 main.case( "This case is to stop switch in best path, \
505 check route number, P2P intent number, M2S intent number, ping test" )
506
507 main.step( "Check the flow status before stopping sw11" )
508 main.Functions.checkFlowNum( main, "sw11", 13 )
509 main.Functions.checkFlowNum( main, "sw1", 3 )
510 main.Functions.checkFlowNum( main, "sw7", 3 )
511 main.log.info( main.Mininet.checkFlows( "sw11" ) )
512 main.log.info( main.Mininet.checkFlows( "sw1" ) )
513 main.log.info( main.Mininet.checkFlows( "sw7" ) )
514
515 main.step( "Stop sw11" )
516 result = main.Mininet.switch( SW = "sw11", OPTION = "stop" )
517 if result:
518 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
519 main.Functions.checkRouteNum( main, 3 )
520 main.Functions.checkM2SintentNum( main, 3 )
521 main.Functions.checkP2PintentNum( main, 18 )
pingping-linbab7f8a2015-09-21 17:33:36 -0700522 else:
523 main.log.info( "Stop switch failed!!!" )
524 main.cleanup()
525 main.exit();
526
527 main.step( "Check whether all flow status are ADDED" )
528 utilities.assertEquals( \
529 expect = main.TRUE,
530 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
531 onpass = "***Flow status is correct!***",
532 onfail = "***Flow status is wrong!***" )
pingping-lin829428d2015-09-22 20:50:00 -0700533 # Ping test
534 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
535 peers = ["peer64514", "peer64515", "peer64516"],
536 expectAllSuccess = True )
537 main.Functions.pingHostToHost( main,
538 hosts = ["host64514", "host64515", "host64516"],
539 expectAllSuccess = True )
pingping-linbab7f8a2015-09-21 17:33:36 -0700540
541
542 def CASE10( self, main ):
543 '''
544 Bring up the switch which was stopped in CASE9, check:
545 route number, P2P intent number, M2S intent number, ping test
546 '''
547 main.case( "This case is to start switch which was stopped in CASE9, \
548 check route number, P2P intent number, M2S intent number, ping test" )
549 main.step( "Start sw11" )
550 result = main.Mininet.switch( SW = "sw11", OPTION = "start" )
551 if result:
552 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
553 main.Functions.checkRouteNum( main, 3 )
554 main.Functions.checkM2SintentNum( main, 3 )
555 main.Functions.checkP2PintentNum( main, 18 )
556
557 main.step( "Check the flow status after stop and start sw11" )
558 main.Functions.checkFlowNum( main, "sw11", 3 )
559 main.Functions.checkFlowNum( main, "sw1", 11 )
560 main.Functions.checkFlowNum( main, "sw7", 5 )
561 main.log.info( main.Mininet.checkFlows( "sw11" ) )
562 main.log.info( main.Mininet.checkFlows( "sw1" ) )
563 main.log.info( main.Mininet.checkFlows( "sw7" ) )
564 else:
565 main.log.info( "Start switch failed!!!" )
566 main.cleanup()
567 main.exit();
568
569 main.step( "Check whether all flow status are ADDED" )
570 utilities.assertEquals( \
571 expect = main.TRUE,
572 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
573 onpass = "***Flow status is correct!***",
574 onfail = "***Flow status is wrong!***" )
pingping-lin829428d2015-09-22 20:50:00 -0700575 # Ping test
576 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
577 peers = ["peer64514", "peer64515", "peer64516"],
578 expectAllSuccess = True )
579 main.Functions.pingHostToHost( main,
580 hosts = ["host64514", "host64515", "host64516"],
581 expectAllSuccess = True )