blob: 976472c55e18e8be8043d727f18349902d359b5c [file] [log] [blame]
pingping-linffca7e22015-11-13 15:43:08 -08001# Testing the functionality of SDN-IP with single ONOS instance
2class USECASE_SdnipFunction_fsfw:
3
4 def __init__( self ):
5 self.default = ''
6 global branchName
7
8 # This case is to setup Mininet testbed
9 def CASE100( self, main ):
10 """
11 Start mininet
12 """
13 import os
14 import imp
15 main.log.case( "Setup the Mininet testbed" )
16 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 )
23 utilities.assert_equals( expect = main.TRUE,
24 actual = topoResult,
25 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()
31 main.step( "Connect switches to controller" )
32
33 global ONOS1Ip
34 ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
pingping-lin8c178802015-11-30 17:25:43 -080035 global fsfwIp
pingping-line9107e42015-11-30 19:19:38 -080036 # TDOO: there is some setup sequence issue, will fix it later
37 # fsfwIp = os.getenv( main.params[ 'CTRL' ][ 'ipN' ] )
38 fsfwIp = main.params[ 'CTRL' ][ 'fsfwIp' ]
pingping-lin15fa4be2015-11-30 18:27:58 -080039 global fsfwPort
pingping-line9107e42015-11-30 19:19:38 -080040 fsfwPort = main.params[ 'CTRL' ][ 'fsfwPort' ]
pingping-lin8c178802015-11-30 17:25:43 -080041
pingping-linffca7e22015-11-13 15:43:08 -080042 # connect all switches to controller
43 swResult = main.TRUE
44 for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
45 sw = "sw%s" % ( i )
pingping-lin15fa4be2015-11-30 18:27:58 -080046 swResult = swResult and main.Mininet.assignSwController( sw, fsfwIp,
47 port = fsfwPort )
pingping-linffca7e22015-11-13 15:43:08 -080048 # swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip, port = "6633" )
49 utilities.assert_equals( expect = main.TRUE,
50 actual = swResult,
51 onpass = "Successfully connect all switches to ONOS",
52 onfail = "Failed to connect all switches to ONOS" )
53 if not swResult:
54 main.cleanup()
55 main.exit()
56
57 main.step( "Set up tunnel from Mininet node to onos node" )
58 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip )
59 command = 'ssh -nNT -o "PasswordAuthentication no" \
60 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, ONOS1Ip )
61
62 tunnelResult = main.TRUE
63 tunnelResult = main.Mininet.node( "root", command )
64 utilities.assert_equals( expect = True,
65 actual = ( "PasswordAuthentication" in tunnelResult ),
66 onpass = "Created tunnel succeeded",
67 onfail = "Create tunnel failed" )
68 if ("PasswordAuthentication" not in tunnelResult) :
69 main.cleanup()
70 main.exit()
71
72
73 # This case is to setup ONOS
74 def CASE101( self, main ):
75 """
76 Package ONOS and install it
77 Startup sequence:
78 cell <name>
79 onos-verify-cell
80 onos-package
81 onos-install -f
82 onos-wait-for-start
83 """
84 import json
85 import time
86 from operator import eq
87
88 main.case( "Setting up test environment" )
89
90 cellName = main.params[ 'ENV' ][ 'cellName' ]
91
92 main.step( "Applying cell variable to environment" )
93 cellResult = main.ONOSbench.setCell( cellName )
94 utilities.assert_equals( expect = main.TRUE,
95 actual = cellResult,
96 onpass = "Set cell succeeded",
97 onfail = "Set cell failed" )
98
99 verifyResult = main.ONOSbench.verifyCell()
100 utilities.assert_equals( expect = main.TRUE,
101 actual = verifyResult,
102 onpass = "Verify cell succeeded",
103 onfail = "Verify cell failed" )
104
105 branchName = main.ONOSbench.getBranchName()
106 main.log.report( "ONOS is on branch: " + branchName )
107
108 main.log.step( "Uninstalling ONOS" )
109 uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
110 utilities.assert_equals( expect = main.TRUE,
111 actual = uninstallResult,
112 onpass = "Uninstall ONOS succeeded",
113 onfail = "Uninstall ONOS failed" )
114 '''
115 main.step( "Git pull" )
116 gitPullResult = main.ONOSbench.gitPull()
117 main.log.info( "gitPullResult" )
118 main.log.info( gitPullResult )
119 gitPullResult2 = ( gitPullResult == main.TRUE ) or ( gitPullResult == 3 )
120 utilities.assert_equals( expect = True,
121 actual = gitPullResult2,
122 onpass = "Git pull ONOS succeeded",
123 onfail = "Git pull ONOS failed" )
124
125 main.step( "Using mvn clean install" )
126 if gitPullResult == main.TRUE:
127 mciResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 )
128 utilities.assert_equals( expect = main.TRUE,
129 actual = mciResult,
130 onpass = "Maven clean install ONOS succeeded",
131 onfail = "Maven clean install ONOS failed" )
132 else:
133 main.log.warn( "Did not pull new code so skipping mvn " +
134 "clean install" )
135 mciResult = main.TRUE
136 '''
137
138 main.ONOSbench.getVersion( report = True )
139
140 main.step( "Creating ONOS package" )
141 packageResult = main.ONOSbench.onosPackage( opTimeout = 500 )
142 utilities.assert_equals( expect = main.TRUE,
143 actual = packageResult,
144 onpass = "Package ONOS succeeded",
145 onfail = "Package ONOS failed" )
146
147 main.step( "Installing ONOS package" )
148 onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
149 node = ONOS1Ip )
150 utilities.assert_equals( expect = main.TRUE,
151 actual = onos1InstallResult,
152 onpass = "Install ONOS succeeded",
153 onfail = "Install ONOS failed" )
154
155 main.step( "Checking if ONOS is up yet" )
156 onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
157 utilities.assert_equals( expect = main.TRUE,
158 actual = onos1UpResult,
159 onpass = "ONOS is up",
160 onfail = "ONOS is NOT up" )
161
162 main.step( "Checking if ONOS CLI is ready" )
163 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
164 commandlineTimeout = 100, onosStartTimeout = 600 )
165 utilities.assert_equals( expect = main.TRUE,
166 actual = cliResult,
167 onpass = "ONOS CLI is ready",
168 onfail = "ONOS CLI is NOT ready" )
169
170 caseResult = ( cellResult and verifyResult and
171 packageResult and
172 onos1InstallResult and onos1UpResult and cliResult )
173
174 utilities.assert_equals( expect = main.TRUE, actual = caseResult,
175 onpass = "ONOS startup successful",
176 onfail = "ONOS startup NOT successful" )
177
178 if caseResult == main.FALSE:
179 main.log.info( "ONOS startup failed!" )
180 main.cleanup()
181 main.exit()
182
183 main.log.info( "Get links in the network" )
184 time.sleep( int ( main.params['timers']['TopoDiscovery'] ) )
185 summaryResult = main.ONOScli.summary()
186 linkNum = json.loads( summaryResult )[ "links" ]
187 if linkNum < 100:
188 main.log.info( "Link number is wrong!" )
189 listResult = main.ONOScli.links( jsonFormat = False )
190 main.log.info( listResult )
191 main.cleanup()
192 main.exit()
193
194 listResult = main.ONOScli.links( jsonFormat = False )
195 main.log.info( listResult )
196
197 main.step( "Activate sdn-ip application" )
198 activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" )
199 utilities.assert_equals( expect = main.TRUE,
200 actual = activeSDNIPresult,
201 onpass = "Activate SDN-IP succeeded",
202 onfail = "Activate SDN-IP failed" )
203 if not activeSDNIPresult:
204 main.log.info( "Activate SDN-IP failed!" )
205 main.cleanup()
206 main.exit()
207
208
209 main.log.info( "Wait SDN-IP to finish installing connectivity intents \
210 and the BGP paths in data plane are ready..." )
211 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
212 main.log.info( "Wait Quagga to finish delivery all routes to each \
213 other and to sdn-ip, plus finish installing all intents..." )
214 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
215 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
216
217
218 def CASE102( self, main ):
219 '''
220 This test case is to load the methods from other Python files.
221 '''
222 main.case( "Loading methods from other Python file" )
223 # load the methods from other file
224 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
225 main.Functions = imp.load_source( wrapperFile,
226 main.dependencyPath +
227 wrapperFile +
228 ".py" )
229
230
231 def CASE1( self, main ):
232 '''
233 ping test from 3 bgp peers to BGP speaker
234 '''
235
236 main.case( "Ping tests between BGP peers and speakers" )
237 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
pingping-lin8a6070a2015-12-15 17:55:17 -0800238 peers = ["pr64514", "pr64515", "pr64516"],
pingping-linffca7e22015-11-13 15:43:08 -0800239 expectAllSuccess = True )
240
241
242 def CASE2( self, main ):
243 '''
244 point-to-point intents test for each BGP peer and BGP speaker pair
245 '''
246 main.case( "Check point-to-point intents" )
247 main.log.info( "There are %s BGP peers in total "
248 % main.params[ 'config' ][ 'peerNum' ] )
249 main.step( "Check P2P intents number from ONOS CLI" )
250
251 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
252 bgpIntentsActualNum = \
253 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
254 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
255 main.log.info( "bgpIntentsExpected num is:" )
256 main.log.info( bgpIntentsExpectedNum )
257 main.log.info( "bgpIntentsActual num is:" )
258 main.log.info( bgpIntentsActualNum )
259 utilities.assertEquals( \
260 expect = True,
261 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
262 onpass = "PointToPointIntent Intent Num is correct!",
263 onfail = "PointToPointIntent Intent Num is wrong!" )
264
265
266 def CASE3( self, main ):
267 '''
268 routes and intents check to all BGP peers
269 '''
270 main.case( "Check routes and M2S intents to all BGP peers" )
271
272 allRoutesExpected = []
273 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
274 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
275 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
276
277 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
278 allRoutesActual = \
279 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
280 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
281 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
282
283 main.step( "Check routes installed" )
284 main.log.info( "Routes expected:" )
285 main.log.info( allRoutesStrExpected )
286 main.log.info( "Routes get from ONOS CLI:" )
287 main.log.info( allRoutesStrActual )
288 utilities.assertEquals( \
289 expect = allRoutesStrExpected, actual = allRoutesStrActual,
290 onpass = "Routes are correct!",
291 onfail = "Routes are wrong!" )
292
293 main.step( "Check M2S intents installed" )
294 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
295 routeIntentsActualNum = \
296 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
297 routeIntentsExpectedNum = 3
298
299 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
300 main.log.info( routeIntentsExpectedNum )
301 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
302 main.log.info( routeIntentsActualNum )
303 utilities.assertEquals( \
304 expect = True,
305 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
306 onpass = "MultiPointToSinglePoint Intent Num is correct!",
307 onfail = "MultiPointToSinglePoint Intent Num is wrong!" )
308
309 main.step( "Check whether all flow status are ADDED" )
310 utilities.assertEquals( \
311 expect = main.TRUE,
312 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
313 onpass = "Flow status is correct!",
314 onfail = "Flow status is wrong!" )
315
316
317 def CASE4( self, main ):
318 '''
319 Ping test in data plane for each route
320 '''
321 main.case( "Ping test for each route, all hosts behind BGP peers" )
322 main.Functions.pingHostToHost( main,
323 hosts = ["host64514", "host64515", "host64516"],
324 expectAllSuccess = True )
325
326
327 def CASE5( self, main ):
328 '''
329 Cut links to peers one by one, check routes/intents
330 '''
331 import time
332 main.case( "Bring down links and check routes/intents" )
333 main.step( "Bring down the link between sw32 and peer64514" )
pingping-lin8a6070a2015-12-15 17:55:17 -0800334 linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "pr64514",
pingping-linffca7e22015-11-13 15:43:08 -0800335 OPTION = "down" )
336 utilities.assertEquals( expect = main.TRUE,
337 actual = linkResult1,
338 onpass = "Bring down link succeeded!",
339 onfail = "Bring down link failed!" )
340
341 if linkResult1 == main.TRUE:
342 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
343 main.Functions.checkRouteNum( main, 2 )
344 main.Functions.checkM2SintentNum( main, 2 )
345 else:
346 main.log.info( "Bring down link failed!" )
347 main.cleanup()
348 main.exit()
349
350 main.step( "Bring down the link between sw8 and peer64515" )
pingping-lin8a6070a2015-12-15 17:55:17 -0800351 linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "pr64515",
pingping-linffca7e22015-11-13 15:43:08 -0800352 OPTION = "down" )
353 utilities.assertEquals( expect = main.TRUE,
354 actual = linkResult2,
355 onpass = "Bring down link succeeded!",
356 onfail = "Bring down link failed!" )
357 if linkResult2 == main.TRUE:
358 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
359 main.Functions.checkRouteNum( main, 1 )
360 main.Functions.checkM2SintentNum( main, 1 )
361 else:
362 main.log.info( "Bring down link failed!" )
363 main.cleanup()
364 main.exit()
365
366 main.step( "Bring down the link between sw28 and peer64516" )
pingping-lin8a6070a2015-12-15 17:55:17 -0800367 linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "pr64516",
pingping-linffca7e22015-11-13 15:43:08 -0800368 OPTION = "down" )
369 utilities.assertEquals( expect = main.TRUE,
370 actual = linkResult3,
371 onpass = "Bring down link succeeded!",
372 onfail = "Bring down link failed!" )
373 if linkResult3 == main.TRUE:
374 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
375 main.Functions.checkRouteNum( main, 0 )
376 main.Functions.checkM2SintentNum( main, 0 )
377 else:
378 main.log.info( "Bring down link failed!" )
379 main.cleanup()
380 main.exit()
381
382 main.step( "Check whether all flow status are ADDED" )
383 utilities.assertEquals( \
384 expect = main.TRUE,
385 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
386 onpass = "Flow status is correct!",
387 onfail = "Flow status is wrong!" )
388
389 # Ping test
390 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
pingping-lin8a6070a2015-12-15 17:55:17 -0800391 peers = ["pr64514", "pr64515", "pr64516"],
pingping-linffca7e22015-11-13 15:43:08 -0800392 expectAllSuccess = False )
393 main.Functions.pingHostToHost( main,
394 hosts = ["host64514", "host64515", "host64516"],
395 expectAllSuccess = False )
396
397
398 def CASE6( self, main ):
399 '''
400 Recover links to peers one by one, check routes/intents
401 '''
402 import time
403 main.case( "Bring up links and check routes/intents" )
404 main.step( "Bring up the link between sw32 and peer64514" )
pingping-lin8a6070a2015-12-15 17:55:17 -0800405 linkResult1 = main.Mininet.link( END1 = "sw32", END2 = "pr64514",
pingping-linffca7e22015-11-13 15:43:08 -0800406 OPTION = "up" )
407 utilities.assertEquals( expect = main.TRUE,
408 actual = linkResult1,
409 onpass = "Bring up link succeeded!",
410 onfail = "Bring up link failed!" )
411 if linkResult1 == main.TRUE:
412 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
413 main.Functions.checkRouteNum( main, 1 )
414 main.Functions.checkM2SintentNum( main, 1 )
415 else:
416 main.log.info( "Bring up link failed!" )
417 main.cleanup()
418 main.exit()
419
420 main.step( "Bring up the link between sw8 and peer64515" )
pingping-lin8a6070a2015-12-15 17:55:17 -0800421 linkResult2 = main.Mininet.link( END1 = "sw8", END2 = "pr64515",
pingping-linffca7e22015-11-13 15:43:08 -0800422 OPTION = "up" )
423 utilities.assertEquals( expect = main.TRUE,
424 actual = linkResult2,
425 onpass = "Bring up link succeeded!",
426 onfail = "Bring up link failed!" )
427 if linkResult2 == main.TRUE:
428 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
429 main.Functions.checkRouteNum( main, 2 )
430 main.Functions.checkM2SintentNum( main, 2 )
431 else:
432 main.log.info( "Bring up link failed!" )
433 main.cleanup()
434 main.exit()
435
436 main.step( "Bring up the link between sw28 and peer64516" )
pingping-lin8a6070a2015-12-15 17:55:17 -0800437 linkResult3 = main.Mininet.link( END1 = "sw28", END2 = "pr64516",
pingping-linffca7e22015-11-13 15:43:08 -0800438 OPTION = "up" )
439 utilities.assertEquals( expect = main.TRUE,
440 actual = linkResult3,
441 onpass = "Bring up link succeeded!",
442 onfail = "Bring up link failed!" )
443 if linkResult3 == main.TRUE:
444 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
445 main.Functions.checkRouteNum( main, 3 )
446 main.Functions.checkM2SintentNum( main, 3 )
447 else:
448 main.log.info( "Bring up link failed!" )
449 main.cleanup()
450 main.exit()
451
452 main.step( "Check whether all flow status are ADDED" )
453 utilities.assertEquals( \
454 expect = main.TRUE,
455 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
456 onpass = "Flow status is correct!",
457 onfail = "Flow status is wrong!" )
458
459 # Ping test
460 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
pingping-lin8a6070a2015-12-15 17:55:17 -0800461 peers = ["pr64514", "pr64515", "pr64516"],
pingping-linffca7e22015-11-13 15:43:08 -0800462 expectAllSuccess = True )
463 main.Functions.pingHostToHost( main,
464 hosts = ["host64514", "host64515", "host64516"],
465 expectAllSuccess = True )
466
467
468 def CASE7( self, main ):
469 '''
470 Shut down a edge switch, check P-2-P and M-2-S intents, ping test
471 '''
472 import time
473 main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
474 main.step( "Stop sw32" )
475 result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
476 utilities.assertEquals( expect = main.TRUE, actual = result,
477 onpass = "Stopping switch succeeded!",
478 onfail = "Stopping switch failed!" )
479
480 if result == main.TRUE:
481 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
482 main.Functions.checkRouteNum( main, 2 )
483 main.Functions.checkM2SintentNum( main, 2 )
484 main.Functions.checkP2PintentNum( main, 12 )
485 else:
486 main.log.info( "Stopping switch failed!" )
487 main.cleanup()
488 main.exit()
489
490 main.step( "Check ping between hosts behind BGP peers" )
491 result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
492 result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
493 result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )
494
495 pingResult1 = ( result1 == main.FALSE ) and ( result2 == main.TRUE ) \
496 and ( result3 == main.FALSE )
497 utilities.assert_equals( expect = True, actual = pingResult1,
498 onpass = "Ping test result is correct",
499 onfail = "Ping test result is wrong" )
500
501 if pingResult1 == False:
502 main.cleanup()
503 main.exit()
504
505 main.step( "Check ping between BGP peers and speakers" )
pingping-lin8a6070a2015-12-15 17:55:17 -0800506 result4 = main.Mininet.pingHost( src = "speaker1", target = "pr64514" )
507 result5 = main.Mininet.pingHost( src = "speaker1", target = "pr64515" )
508 result6 = main.Mininet.pingHost( src = "speaker1", target = "pr64516" )
pingping-linffca7e22015-11-13 15:43:08 -0800509
510 pingResult2 = ( result4 == main.FALSE ) and ( result5 == main.TRUE ) \
511 and ( result6 == main.TRUE )
512 utilities.assert_equals( expect = True, actual = pingResult2,
513 onpass = "Speaker1 ping peers successful",
514 onfail = "Speaker1 ping peers NOT successful" )
515
516 if pingResult2 == False:
517 main.cleanup()
518 main.exit()
519
520 main.step( "Check whether all flow status are ADDED" )
521 utilities.assertEquals( \
522 expect = main.TRUE,
523 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
524 onpass = "Flow status is correct!",
525 onfail = "Flow status is wrong!" )
526
527
528 def CASE8( self, main ):
529 '''
530 Bring up the edge switch (sw32) which was shut down in CASE7,
531 check P-2-P and M-2-S intents, ping test
532 '''
533 import time
534 main.case( "Start the edge sw32, check P-2-P and M-2-S intents, ping test" )
535 main.step( "Start sw32" )
536 result1 = main.Mininet.switch( SW = "sw32", OPTION = "start" )
537 utilities.assertEquals( \
538 expect = main.TRUE,
539 actual = result1,
540 onpass = "Starting switch succeeded!",
541 onfail = "Starting switch failed!" )
542
pingping-lin8c178802015-11-30 17:25:43 -0800543 result2 = main.Mininet.assignSwController( "sw32", fsfwIp )
pingping-linffca7e22015-11-13 15:43:08 -0800544 utilities.assertEquals( \
545 expect = main.TRUE,
546 actual = result2,
547 onpass = "Connect switch to ONOS succeeded!",
548 onfail = "Connect switch to ONOS failed!" )
549
550 if result1 and result2:
551 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
552 main.Functions.checkRouteNum( main, 3 )
553 main.Functions.checkM2SintentNum( main, 3 )
554 main.Functions.checkP2PintentNum( main, 18 )
555 else:
556 main.log.info( "Starting switch failed!" )
557 main.cleanup()
558 main.exit()
559
560 main.step( "Check whether all flow status are ADDED" )
561 utilities.assertEquals( \
562 expect = main.TRUE,
563 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
564 onpass = "Flow status is correct!",
565 onfail = "Flow status is wrong!" )
566
567 # Ping test
568 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
pingping-lin8a6070a2015-12-15 17:55:17 -0800569 peers = ["pr64514", "pr64515", "pr64516"],
pingping-linffca7e22015-11-13 15:43:08 -0800570 expectAllSuccess = True )
571 main.Functions.pingHostToHost( main,
572 hosts = ["host64514", "host64515", "host64516"],
573 expectAllSuccess = True )
574
575
576 def CASE9( self, main ):
577 '''
578 Bring down a switch in best path, check:
579 route number, P2P intent number, M2S intent number, ping test
580 '''
581 main.case( "Stop sw11 located in best path, \
582 check route number, P2P intent number, M2S intent number, ping test" )
583
584 main.log.info( "Check the flow number correctness before stopping sw11" )
585 main.Functions.checkFlowNum( main, "sw11", 13 )
586 main.Functions.checkFlowNum( main, "sw1", 3 )
587 main.Functions.checkFlowNum( main, "sw7", 3 )
588 main.log.info( main.Mininet.checkFlows( "sw11" ) )
589 main.log.info( main.Mininet.checkFlows( "sw1" ) )
590 main.log.info( main.Mininet.checkFlows( "sw7" ) )
591
592 main.step( "Stop sw11" )
593 result = main.Mininet.switch( SW = "sw11", OPTION = "stop" )
594 utilities.assertEquals( expect = main.TRUE, actual = result,
595 onpass = "Stopping switch succeeded!",
596 onfail = "Stopping switch failed!" )
597 if result:
598 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
599 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
600 main.Functions.checkRouteNum( main, 3 )
601 main.Functions.checkM2SintentNum( main, 3 )
602 main.Functions.checkP2PintentNum( main, 18 )
603 else:
604 main.log.info( "Stopping switch failed!" )
605 main.cleanup()
606 main.exit()
607
608 main.step( "Check whether all flow status are ADDED" )
609 utilities.assertEquals( \
610 expect = main.TRUE,
611 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
612 onpass = "Flow status is correct!",
613 onfail = "Flow status is wrong!" )
614 # Ping test
615 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
pingping-lin8a6070a2015-12-15 17:55:17 -0800616 peers = ["pr64514", "pr64515", "pr64516"],
pingping-linffca7e22015-11-13 15:43:08 -0800617 expectAllSuccess = True )
618 main.Functions.pingHostToHost( main,
619 hosts = ["host64514", "host64515", "host64516"],
620 expectAllSuccess = True )
621
622
623 def CASE10( self, main ):
624 '''
625 Bring up the switch which was stopped in CASE9, check:
626 route number, P2P intent number, M2S intent number, ping test
627 '''
628 main.case( "Start sw11 which was stopped in CASE9, \
629 check route number, P2P intent number, M2S intent number, ping test" )
630
631 main.log.info( "Check the flow status before starting sw11" )
632 main.Functions.checkFlowNum( main, "sw1", 11 )
633 main.Functions.checkFlowNum( main, "sw7", 5 )
634 main.log.info( main.Mininet.checkFlows( "sw1" ) )
635 main.log.info( main.Mininet.checkFlows( "sw7" ) )
636
637 main.step( "Start sw11" )
638 result1 = main.Mininet.switch( SW = "sw11", OPTION = "start" )
639 utilities.assertEquals( expect = main.TRUE, actual = result1,
640 onpass = "Starting switch succeeded!",
641 onfail = "Starting switch failed!" )
pingping-lin8c178802015-11-30 17:25:43 -0800642 result2 = main.Mininet.assignSwController( "sw11", fsfwIp )
pingping-linffca7e22015-11-13 15:43:08 -0800643 utilities.assertEquals( expect = main.TRUE, actual = result2,
644 onpass = "Connect switch to ONOS succeeded!",
645 onfail = "Connect switch to ONOS failed!" )
646 if result1 and result2:
647 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
648 main.Functions.checkRouteNum( main, 3 )
649 main.Functions.checkM2SintentNum( main, 3 )
650 main.Functions.checkP2PintentNum( main, 18 )
651
652 main.log.debug( main.Mininet.checkFlows( "sw11" ) )
653 main.log.debug( main.Mininet.checkFlows( "sw1" ) )
654 main.log.debug( main.Mininet.checkFlows( "sw7" ) )
655 else:
656 main.log.info( "Starting switch failed!" )
657 main.cleanup()
658 main.exit()
659
660 main.step( "Check whether all flow status are ADDED" )
661 utilities.assertEquals( \
662 expect = main.TRUE,
663 actual = main.ONOScli.checkFlowsState( isPENDING_ADD = False ),
664 onpass = "Flow status is correct!",
665 onfail = "Flow status is wrong!" )
666 # Ping test
667 main.Functions.pingSpeakerToPeer( main, speakers = ["speaker1"],
pingping-lin8a6070a2015-12-15 17:55:17 -0800668 peers = ["pr64514", "pr64515", "pr64516"],
pingping-linffca7e22015-11-13 15:43:08 -0800669 expectAllSuccess = True )
670 main.Functions.pingHostToHost( main,
671 hosts = ["host64514", "host64515", "host64516"],
672 expectAllSuccess = True )