blob: 680857677b105231df6a78f1eec8818bd4456537 [file] [log] [blame]
pingping-lin28e7b212015-09-10 10:14:58 -07001# Testing the functionality of SDN-IP with single ONOS instance
2class USECASE_SdnipI2:
3
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-linb702c602015-09-10 17:00:29 -070015 main.log.case( "Start Mininet topology" )
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 stepResult = topoResult
24 utilities.assert_equals( expect = main.TRUE,
25 actual = stepResult,
26 onpass = "Successfully loaded topology",
27 onfail = "Failed to load topology" )
28 # Exit if topology did not load properly
29 if not topoResult:
30 main.cleanup()
31 main.exit()
pingping-lin28e7b212015-09-10 10:14:58 -070032
33 # This case is to setup ONOS
pingping-linb702c602015-09-10 17:00:29 -070034 def CASE101( self, main ):
pingping-lin28e7b212015-09-10 10:14:58 -070035 """
36 CASE100 is to compile ONOS and install it
37 Startup sequence:
38 cell <name>
39 onos-verify-cell
40 git pull
41 mvn clean install
42 onos-package
43 onos-install -f
44 onos-wait-for-start
45 """
46 import json
47 import time
48 from operator import eq
49
50 main.case( "Setting up test environment" )
51
52 cellName = main.params[ 'ENV' ][ 'cellName' ]
53 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
54
55 main.step( "Applying cell variable to environment" )
56 cellResult = main.ONOSbench.setCell( cellName )
57 verifyResult = main.ONOSbench.verifyCell()
58
59 branchName = main.ONOSbench.getBranchName()
60 main.log.info( "ONOS is on branch: " + branchName )
61
62 main.log.report( "Uninstalling ONOS" )
63 main.ONOSbench.onosUninstall( ONOS1Ip )
64
65 # cleanInstallResult = main.TRUE
66 # gitPullResult = main.TRUE
67
68 main.step( "Git pull" )
69 gitPullResult = main.ONOSbench.gitPull()
70
71 main.step( "Using mvn clean install" )
72 if gitPullResult == main.TRUE:
73 cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 )
74 else:
75 main.log.warn( "Did not pull new code so skipping mvn " +
76 "clean install" )
77 cleanInstallResult = main.TRUE
78
79 main.ONOSbench.getVersion( report = True )
80
81 main.step( "Creating ONOS package" )
82 packageResult = main.ONOSbench.onosPackage( opTimeout = 500 )
83
84 main.step( "Installing ONOS package" )
85 onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
86 node = ONOS1Ip )
87
88 main.step( "Checking if ONOS is up yet" )
89 for i in range( 2 ):
90 onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
91 if onos1Isup:
92 break
93 if not onos1Isup:
94 main.log.report( "ONOS1 didn't start!" )
95
96 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
97 commandlineTimeout = 100, onosStartTimeout = 600 )
98
pingping-linb702c602015-09-10 17:00:29 -070099 caseResult = ( cleanInstallResult and packageResult and
pingping-lin28e7b212015-09-10 10:14:58 -0700100 cellResult and verifyResult and
101 onos1InstallResult and
102 onos1Isup and cliResult )
103
pingping-linb702c602015-09-10 17:00:29 -0700104 utilities.assert_equals( expect = main.TRUE, actual = caseResult,
pingping-lin28e7b212015-09-10 10:14:58 -0700105 onpass = "ONOS startup successful",
106 onfail = "ONOS startup NOT successful" )
107
pingping-linb702c602015-09-10 17:00:29 -0700108 if caseResult == main.FALSE:
pingping-lin28e7b212015-09-10 10:14:58 -0700109 main.cleanup()
110 main.exit()
111
pingping-lin28e7b212015-09-10 10:14:58 -0700112 main.step( "Get links in the network" )
113 listResult = main.ONOScli.links( jsonFormat = False )
114 main.log.info( listResult )
115 main.log.info( "Activate sdn-ip application" )
116 main.ONOScli.activateApp( "org.onosproject.sdnip" )
pingping-linb702c602015-09-10 17:00:29 -0700117
118 main.log.info( "Wait sdn-ip to finish installing connectivity intents, \
119 and the BGP paths in data plane are ready..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700120 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-linb702c602015-09-10 17:00:29 -0700121 main.log.info( "Wait Quagga to finish delivery all routes to each \
122 other and to sdn-ip, plus finish installing all intents..." )
pingping-lin28e7b212015-09-10 10:14:58 -0700123 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
124 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
125
126
pingping-lin4f80c492015-09-15 14:34:42 -0700127 def CASE102( self, main ):
128 '''
129 This test case is to load the methods from other Python files.
130 '''
131 main.case( "Loading the methods from other Python file" )
132 # load the methods from other file
133 wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
134 main.Functions = imp.load_source( wrapperFile,
135 main.dependencyPath +
136 wrapperFile +
137 ".py" )
138
139
pingping-lin0ce60622015-09-10 14:37:33 -0700140 def CASE1( self, main ):
141 '''
142 ping test from 3 bgp peers to BGP speaker
143 '''
pingping-lin950b50d2015-09-14 12:00:08 -0700144
145 m2SIntentsNumberActual = main.ONOScli.m2SIntentInstalledNumber()
146 main.log.info( "MultiPointToSinglePoint intent number actual is:" )
147 main.log.info( m2SIntentsNumberActual )
148
pingping-lin0ce60622015-09-10 14:37:33 -0700149 main.case( "This case is to check ping between BGP peers and speakers" )
pingping-linb702c602015-09-10 17:00:29 -0700150 result1 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" )
151 result2 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" )
152 result3 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" )
153
pingping-lin950b50d2015-09-14 12:00:08 -0700154
pingping-linb702c602015-09-10 17:00:29 -0700155 caseResult = result1 and result2 and result3
156 utilities.assert_equals( expect = main.TRUE, actual = caseResult,
157 onpass = "Speaker1 ping peers successful",
158 onfail = "Speaker1 ping peers NOT successful" )
159
160 if caseResult == main.FALSE:
161 main.cleanup()
162 main.exit()
pingping-lin0ce60622015-09-10 14:37:33 -0700163
pingping-lin950b50d2015-09-14 12:00:08 -0700164
pingping-lin0ce60622015-09-10 14:37:33 -0700165 def CASE2( self, main ):
166 '''
167 point-to-point intents test for each BGP peer and BGP speaker pair
168 '''
169 main.case( "This case is to check point-to-point intents" )
170 main.log.info( "There are %s BGP peers in total "
171 % main.params[ 'config' ][ 'peerNum' ] )
172 main.step( "Get point-to-point intents from ONOS CLI" )
173
174 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
175 bgpIntentsActualNum = \
176 main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
177 bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
178 main.log.info( "bgpIntentsExpected num is:" )
179 main.log.info( bgpIntentsExpectedNum )
180 main.log.info( "bgpIntentsActual num is:" )
181 main.log.info( bgpIntentsActualNum )
182 utilities.assertEquals( \
183 expect = True,
184 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
185 onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***",
186 onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" )
187
188
189 def CASE3( self, main ):
190 '''
191 routes and intents check to all BGP peers
192 '''
193 main.case( "This case is to check routes and intents to all BGP peers" )
194
pingping-lin28e7b212015-09-10 10:14:58 -0700195 allRoutesExpected = []
196 allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
197 allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
198 allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
199
200 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
201 allRoutesActual = \
202 main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
203 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
204 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
205
206 main.step( "Check routes installed" )
207 main.log.info( "Routes expected:" )
208 main.log.info( allRoutesStrExpected )
209 main.log.info( "Routes get from ONOS CLI:" )
210 main.log.info( allRoutesStrActual )
211 utilities.assertEquals( \
212 expect = allRoutesStrExpected, actual = allRoutesStrActual,
213 onpass = "***Routes in SDN-IP are correct!***",
214 onfail = "***Routes in SDN-IP are wrong!***" )
215
216 main.step( "Check MultiPointToSinglePointIntent intents installed" )
217 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
218 routeIntentsActualNum = \
219 main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
220 routeIntentsExpectedNum = 3
221
222 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
223 main.log.info( routeIntentsExpectedNum )
224 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
225 main.log.info( routeIntentsActualNum )
226 utilities.assertEquals( \
227 expect = True,
228 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
229 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
230 correct!***",
231 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
232 wrong!***" )
233
pingping-lin950b50d2015-09-14 12:00:08 -0700234
235 def CASE4( self, main ):
236 '''
237 Ping test in data plane for each route
238 '''
239 main.case( "This case is to check ping for each route" )
240 result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
241 result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
242 result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )
243
244 caseResult = result1 and result2 and result3
245 utilities.assert_equals( expect = main.TRUE, actual = caseResult,
246 onpass = "Ping test for each route successful",
247 onfail = "Ping test for each route NOT successful" )
248
249 if caseResult == main.FALSE:
250 main.cleanup()
251 main.exit()
pingping-lin4f80c492015-09-15 14:34:42 -0700252
253
254 def CASE5( self, main ):
255 '''
256 Cut links to peers one by one, check routes/intents
257 '''
258 import time
259 main.case( "This case is to bring down links and check routes/intents" )
260 main.step( "Bring down the link between sw32 and peer64514" )
261 result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
262 OPTION = "down" )
263 if result == main.TRUE:
264 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
265 main.Functions.checkRouteNum( main, 2 )
266 main.Functions.checkM2SintentNum( main, 2 )
267 else:
268 main.log.info( "Bring down link failed!!!" )
269 main.exit();
270
271 main.step( "Bring down the link between sw8 and peer64515" )
272 result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
273 OPTION = "down" )
274 if result == main.TRUE:
275 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
276 main.Functions.checkRouteNum( main, 1 )
277 main.Functions.checkM2SintentNum( main, 1 )
278 else:
279 main.log.info( "Bring down link failed!!!" )
280 main.exit();
281
282 main.step( "Bring down the link between sw28 and peer64516" )
283 result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
284 OPTION = "down" )
285 if result == main.TRUE:
286 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
287 main.Functions.checkRouteNum( main, 0 )
288 main.Functions.checkM2SintentNum( main, 0 )
289 else:
290 main.log.info( "Bring down link failed!!!" )
291 main.exit();
292
293
294 def CASE6(self, main):
295 '''
296 Recover links to peers one by one, check routes/intents
297 '''
298 import time
299 main.case( "This case is to bring up links and check routes/intents" )
300 main.step( "Bring up the link between sw32 and peer64514" )
301 result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
302 OPTION = "up" )
303 if result == main.TRUE:
304 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
305 main.Functions.checkRouteNum( main, 1 )
306 main.Functions.checkM2SintentNum( main, 1 )
307 else:
308 main.log.info( "Bring up link failed!!!" )
309 main.exit();
310
311 main.step( "Bring up the link between sw8 and peer64515" )
312 result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
313 OPTION = "up" )
314 if result == main.TRUE:
315 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
316 main.Functions.checkRouteNum( main, 2 )
317 main.Functions.checkM2SintentNum( main, 2 )
318 else:
319 main.log.info( "Bring up link failed!!!" )
320 main.exit();
321
322 main.step( "Bring up the link between sw28 and peer64516" )
323 result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
324 OPTION = "up" )
325 if result == main.TRUE:
326 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
327 main.Functions.checkRouteNum( main, 3 )
328 main.Functions.checkM2SintentNum( main, 3 )
329 else:
330 main.log.info( "Bring up link failed!!!" )
331 main.exit();
pingping-lin8244a3b2015-09-16 13:36:56 -0700332 '''
333 Note: at the end of this test case, we should carry out ping test.
334 So we run CASE4 again after CASE6
335 '''
336
337
338 def CASE7(self, main):
339 '''
340 shut down a edge switch, check P-2-P and M-2-S intents, ping test
341 '''
342 import time
343 main.case( "This case is to stop 1 edge switch,\
344 check P-2-P and M-2-S intents, ping test")
345 main.step( "Stop sw32" )
346 result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
347 if result == main.TRUE:
348 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
349 main.Functions.checkRouteNum( main, 2 )
350 main.Functions.checkM2SintentNum( main, 2 )
351 main.Functions.checkP2PintentNum( main, 12 )
352 else:
353 main.log.info( "Stop switch failed!!!" )
354 main.exit();
355
356 '''
357 main.step( "Stop sw8" )
358 result = main.Mininet.switch( SW = "sw8", OPTION = "stop" )
359 if result == main.TRUE:
360 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
361 main.Functions.checkRouteNum( main, 1 )
362
363 # Note: there should be 0 M2S intent, not 1.
364 main.Functions.checkM2SintentNum( main, 0 )
365 main.Functions.checkP2PintentNum( main, 6 )
366 else:
367 main.log.info( "Stop switch failed!!!" )
368 main.exit();
369
370 main.step( "Stop sw28" )
371 result = main.Mininet.switch( SW = "sw28", OPTION = "stop" )
372 if result == main.TRUE:
373 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
374 main.Functions.checkRouteNum( main, 0 )
375 main.Functions.checkM2SintentNum( main, 0 )
376 main.Functions.checkP2PintentNum( main, 0 )
377 else:
378 main.log.info( "Stop switch failed!!!" )
379 main.exit();
380 '''
381 '''
382 ping test between BGP speaker and BGP peers, ping test between hosts
383 behind BGP peers ===
384 '''
385
386 def CASE8( self, main ):
387 main.case( "This case is to bring up 1 edge switch,\
388 check P-2-P and M-2-S intents, ping test" )
pingping-lin4f80c492015-09-15 14:34:42 -0700389
pingping-lin9563aec2015-09-16 17:20:07 -0700390
391 def CASE20( self, main ):
392 '''
393 ping test from 3 bgp peers to BGP speaker
394 '''
395 main.case( "This case is to check ping between BGP peers and speakers" )
396 result1 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" )
397 result2 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" )
398 result3 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" )
399
400
401 caseResult = result1 or result2 or result3
402 utilities.assert_equals( expect = main.FALSE, actual = caseResult,
403 onpass = "Speaker1 failed to ping all peers - Correct",
404 onfail = "Speaker1 did not fail to ping all peers- NOT Correct" )
405
406 if caseResult == main.TRUE:
407 main.cleanup()
408 main.exit()
409
410
411 def CASE21( self, main ):
412 '''
413 Ping test in data plane for each route
414 '''
415 main.case( "This case is to check ping for each route" )
416 result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
417 result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
418 result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )
419
420 caseResult = result1 or result2 or result3
421 utilities.assert_equals( expect = main.FALSE, actual = caseResult,
422 onpass = "Ping test for all routes failed- Correct",
423 onfail = "Ping test for all routes NOT failed- NOT Correct" )
424
425 if caseResult == main.TRUE:
426 main.cleanup()
427 main.exit()
428