blob: 5094f4dff4ca321536db8c0c7a1711ed0802bd9c [file] [log] [blame]
kelvin-onlab1d381fe2015-07-14 16:24:56 -07001
2# Testing network scalability, this test suite scales up a network topology
3# using mininet and verifies ONOS stability
4
GlennRC1c5df3c2015-08-27 16:12:09 -07005class SCPFscaleTopo:
kelvin-onlab1d381fe2015-07-14 16:24:56 -07006
7 def __init__( self ):
8 self.default = ''
9
10 def CASE1( self, main ):
11 import time
12 import os
13 import imp
Jon Hallf632d202015-07-30 15:45:11 -070014 import re
kelvin-onlab1d381fe2015-07-14 16:24:56 -070015
16 """
17 - Construct tests variables
18 - GIT ( optional )
19 - Checkout ONOS master branch
20 - Pull latest ONOS code
21 - Building ONOS ( optional )
22 - Install ONOS package
23 - Build ONOS package
24 """
25
26 main.case( "Constructing test variables and building ONOS package" )
27 main.step( "Constructing test variables" )
28 stepResult = main.FALSE
29
kelvin-onlabd9e23de2015-08-06 10:34:44 -070030 try:
31 main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
32 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
33 gitBranch = main.params[ 'GIT' ][ 'branch' ]
34 main.dependencyPath = main.testOnDirectory + \
35 main.params[ 'DEPENDENCY' ][ 'path' ]
kelvin-onlabd9e23de2015-08-06 10:34:44 -070036 main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
GlennRC632e2892015-10-19 18:58:41 -070037 main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ]
38 main.numCtrls = int( main.params[ 'CTRL' ][ 'numCtrls' ] )
39 main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," )
40 main.topoScaleSize = len( main.topoScale )
kelvin-onlabd9e23de2015-08-06 10:34:44 -070041 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
42 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
43 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
GlennRC632e2892015-10-19 18:58:41 -070044 main.checkTopoAttempts = int( main.params['SLEEP']['topoAttempts'])
kelvin-onlabd9e23de2015-08-06 10:34:44 -070045 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
46 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
GlennRC632e2892015-10-19 18:58:41 -070047 main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] )
48 main.nodeDownSleep = int( main.params[ 'SLEEP' ][ 'nodeDown' ] )
49 main.nodeUpSleep = int( main.params[ 'SLEEP' ][ 'nodeUp' ] )
50 main.pingallTimeout = int( main.params[ 'TIMEOUT' ][ 'pingall' ] )
kelvin-onlabd9e23de2015-08-06 10:34:44 -070051 gitPull = main.params[ 'GIT' ][ 'pull' ]
GlennRC632e2892015-10-19 18:58:41 -070052 main.homeDir = os.path.expanduser('~')
kelvin-onlabd9e23de2015-08-06 10:34:44 -070053 main.cellData = {} # for creating cell file
54 main.hostsData = {}
55 main.CLIs = []
56 main.ONOSip = []
GlennRC632e2892015-10-19 18:58:41 -070057 main.activeNodes = []
kelvin-onlabd9e23de2015-08-06 10:34:44 -070058 main.ONOSip = main.ONOSbench.getOnosIps()
kelvin-onlab1d381fe2015-07-14 16:24:56 -070059
GlennRC632e2892015-10-19 18:58:41 -070060 except Exception:
61 main.log.exception( "Exception: constructing test variables" )
62 main.cleanup()
63 main.exit()
kelvin-onlab1d381fe2015-07-14 16:24:56 -070064
GlennRC632e2892015-10-19 18:58:41 -070065 try:
66 for i in range(main.numCtrls):
67 main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) )
68
69 except Exception:
70 main.log.exception( "Exception: assinging ONOS cli handles to a list" )
71 main.cleanup()
72 main.exit()
73
74 try:
kelvin-onlabd9e23de2015-08-06 10:34:44 -070075 main.startUp = imp.load_source( wrapperFile1,
76 main.dependencyPath +
77 wrapperFile1 +
78 ".py" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -070079
kelvin-onlabd9e23de2015-08-06 10:34:44 -070080 main.scaleTopoFunction = imp.load_source( wrapperFile2,
GlennRC632e2892015-10-19 18:58:41 -070081 main.dependencyPath +
82 wrapperFile2 +
83 ".py" )
kelvin-onlabd9e23de2015-08-06 10:34:44 -070084
85 main.topo = imp.load_source( wrapperFile3,
86 main.dependencyPath +
87 wrapperFile3 +
88 ".py" )
GlennRC632e2892015-10-19 18:58:41 -070089 except Exception:
90 main.log.exception( "Exception: importing wrapper files" )
kelvin-onlabd9e23de2015-08-06 10:34:44 -070091 main.cleanup()
92 main.exit()
kelvin-onlab1d381fe2015-07-14 16:24:56 -070093
GlennRC632e2892015-10-19 18:58:41 -070094 main.ONOSbench.scp( main.Mininet1,
95 main.dependencyPath +
96 main.multiovs,
97 main.Mininet1.home,
98 direction="to" )
99
100 if main.CLIs:
101 stepResult = main.TRUE
102 else:
103 main.log.error( "Did not properly created list of " +
104 "ONOS CLI handle" )
105 stepResult = main.FALSE
106
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700107 utilities.assert_equals( expect=main.TRUE,
108 actual=stepResult,
109 onpass="Successfully construct " +
110 "test variables ",
111 onfail="Failed to construct test variables" )
112
113 if gitPull == 'True':
114 main.step( "Building ONOS in " + gitBranch + " branch" )
115 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
116 stepResult = onosBuildResult
117 utilities.assert_equals( expect=main.TRUE,
118 actual=stepResult,
119 onpass="Successfully compiled " +
120 "latest ONOS",
121 onfail="Failed to compile " +
122 "latest ONOS" )
123 else:
124 main.log.warn( "Did not pull new code so skipping mvn " +
125 "clean install" )
126
GlennRC632e2892015-10-19 18:58:41 -0700127
128 def CASE2( self, main):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700129 """
130 - Set up cell
131 - Create cell file
132 - Set cell file
133 - Verify cell file
134 - Kill ONOS process
135 - Uninstall ONOS cluster
136 - Verify ONOS start up
137 - Install ONOS cluster
138 - Connect to cli
139 """
140
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700141 main.case( "Starting up " + str( main.numCtrls ) +
142 " node(s) ONOS cluster" )
GlennRC632e2892015-10-19 18:58:41 -0700143 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
144 " node(s) ONOS cluster"
145
146
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700147
148 #kill off all onos processes
149 main.log.info( "Safety check, killing all ONOS processes" +
150 " before initiating enviornment setup" )
151
GlennRC632e2892015-10-19 18:58:41 -0700152 for i in range( main.numCtrls ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700153 main.ONOSbench.onosDie( main.ONOSip[ i ] )
154
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700155 tempOnosIp = []
156 for i in range( main.numCtrls ):
157 tempOnosIp.append( main.ONOSip[i] )
158
159 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
160 "temp", main.Mininet1.ip_address,
GlennRC632e2892015-10-19 18:58:41 -0700161 main.apps, tempOnosIp )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700162
163 main.step( "Apply cell to environment" )
164 cellResult = main.ONOSbench.setCell( "temp" )
165 verifyResult = main.ONOSbench.verifyCell()
166 stepResult = cellResult and verifyResult
167 utilities.assert_equals( expect=main.TRUE,
168 actual=stepResult,
169 onpass="Successfully applied cell to " + \
170 "environment",
171 onfail="Failed to apply cell to environment " )
172
173 main.step( "Creating ONOS package" )
174 packageResult = main.ONOSbench.onosPackage()
175 stepResult = packageResult
176 utilities.assert_equals( expect=main.TRUE,
177 actual=stepResult,
178 onpass="Successfully created ONOS package",
179 onfail="Failed to create ONOS package" )
180
GlennRC632e2892015-10-19 18:58:41 -0700181 time.sleep( main.startUpSleep )
182 main.step( "Uninstalling ONOS package" )
183 onosUninstallResult = main.TRUE
184 for ip in main.ONOSip:
185 onosUninstallResult = onosUninstallResult and \
186 main.ONOSbench.onosUninstall( nodeIp=ip )
187 stepResult = onosUninstallResult
188 utilities.assert_equals( expect=main.TRUE,
189 actual=stepResult,
190 onpass="Successfully uninstalled ONOS package",
191 onfail="Failed to uninstall ONOS package" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700192
GlennRC632e2892015-10-19 18:58:41 -0700193 time.sleep( main.startUpSleep )
194 main.step( "Installing ONOS package" )
195 onosInstallResult = main.TRUE
196 for i in range( main.numCtrls ):
197 onosInstallResult = onosInstallResult and \
198 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
199 stepResult = onosInstallResult
200 utilities.assert_equals( expect=main.TRUE,
201 actual=stepResult,
202 onpass="Successfully installed ONOS package",
203 onfail="Failed to install ONOS package" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700204
GlennRC632e2892015-10-19 18:58:41 -0700205 time.sleep( main.startUpSleep )
206 main.step( "Starting ONOS service" )
207 stopResult = main.TRUE
208 startResult = main.TRUE
209 onosIsUp = main.TRUE
210
211 for i in range( main.numCtrls ):
212 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
213 if onosIsUp == main.TRUE:
214 main.log.report( "ONOS instance is up and ready" )
215 else:
216 main.log.report( "ONOS instance may not be up, stop and " +
217 "start ONOS again " )
218
219 for i in range( main.numCtrls ):
220 stopResult = stopResult and \
221 main.ONOSbench.onosStop( main.ONOSip[ i ] )
222 for i in range( main.numCtrls ):
223 startResult = startResult and \
224 main.ONOSbench.onosStart( main.ONOSip[ i ] )
225 stepResult = onosIsUp and stopResult and startResult
226 utilities.assert_equals( expect=main.TRUE,
227 actual=stepResult,
228 onpass="ONOS service is ready",
229 onfail="ONOS service did not start properly" )
230
231 main.step( "Start ONOS cli" )
232 cliResult = main.TRUE
233 for i in range( main.numCtrls ):
234 cliResult = cliResult and \
235 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
236 main.activeNodes.append( i )
237 stepResult = cliResult
238 utilities.assert_equals( expect=main.TRUE,
239 actual=stepResult,
240 onpass="Successfully start ONOS cli",
241 onfail="Failed to start ONOS cli" )
242
243
244 def CASE10( self, main ):
245 """
246 Starting up torus topology
247 """
248 main.case( "Starting up torus topology" )
249 main.step( "Starting up torus topology" )
250
251 main.log.info( "Checking if mininet is already running" )
252 if len( main.topoScale ) < main.topoScaleSize:
253 main.log.info( "Mininet is already running. Stopping mininet." )
254 main.Mininet1.stopNet()
255 time.sleep(5)
256 else:
257 main.log.info( "Mininet was not running" )
258
259 try:
260 scale = main.topoScale.pop(0)
261 except Exception:
262 main.log.exception("Exception: popping from list of topology scales ")
263 main.cleanup()
264 main.exit()
265
266 mnCmd = " mn --custom=" + main.homeDir + "/mininet/custom/multiovs.py " +\
267 "--switch=ovsm --topo " + main.topoName + ","+ scale + "," + scale +\
268 " --controller=remote,ip=" + main.ONOSip[ 0 ] +\
269 " --controller=remote,ip=" + main.ONOSip[ 1 ] +\
270 " --controller=remote,ip=" + main.ONOSip[ 2 ] + " --mac"
271 stepResult = main.Mininet1.startNet(mnCmd=mnCmd)
272 utilities.assert_equals( expect=main.TRUE,
273 actual=stepResult,
274 onpass=main.topoName +
275 " topology started successfully",
276 onfail=main.topoName +
277 " topology failed to start" )
278
279
280 def CASE11( self, main ):
281 '''
282 Pingall
283 '''
284 main.case( "Pingall" )
285 main.step( "Pingall" )
286 pingResult = main.Mininet1.pingall()
287 if not pingResult:
288 main.log.warn( "First pingall failed. Retrying..." )
289 time.sleep(3)
290 pingResult = main.Mininet1.pingall( timeout=main.pingallTimeout )
291
292 utilities.assert_equals( expect=main.TRUE,
293 actual=pingResult,
294 onpass="Pingall successfull",
295 onfail="Pingall failed" )
296
297
298 def CASE12( self, main ):
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700299 """
300 Compare Topo
301 """
302 import json
303
304 main.case( "Compare ONOS Topology view to Mininet topology" )
305 main.caseExplanation = "Compare topology elements between Mininet" +\
306 " and ONOS"
307
308 main.step( "Gathering topology information" )
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700309 devicesResults = main.TRUE
310 linksResults = main.TRUE
311 hostsResults = main.TRUE
GlennRC632e2892015-10-19 18:58:41 -0700312
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700313 devices = main.topo.getAllDevices( main )
314 hosts = main.topo.getAllHosts( main )
315 ports = main.topo.getAllPorts( main )
316 links = main.topo.getAllLinks( main )
317 clusters = main.topo.getAllClusters( main )
318
319 mnSwitches = main.Mininet1.getSwitches()
320 mnLinks = main.Mininet1.getLinks()
321 mnHosts = main.Mininet1.getHosts()
322
GlennRC632e2892015-10-19 18:58:41 -0700323 main.step( "Comparing MN topology to ONOS topology" )
324
325 for controller in range(len(main.activeNodes)):
326 controllerStr = str( main.activeNodes[controller] + 1 )
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700327 if devices[ controller ] and ports[ controller ] and\
328 "Error" not in devices[ controller ] and\
329 "Error" not in ports[ controller ]:
330
331 currentDevicesResult = main.Mininet1.compareSwitches(
332 mnSwitches,
333 json.loads( devices[ controller ] ),
334 json.loads( ports[ controller ] ) )
335 else:
336 currentDevicesResult = main.FALSE
337 utilities.assert_equals( expect=main.TRUE,
338 actual=currentDevicesResult,
339 onpass="ONOS" + controllerStr +
340 " Switches view is correct",
341 onfail="ONOS" + controllerStr +
342 " Switches view is incorrect" )
343
344 if links[ controller ] and "Error" not in links[ controller ]:
345 currentLinksResult = main.Mininet1.compareLinks(
346 mnSwitches, mnLinks,
347 json.loads( links[ controller ] ) )
348 else:
349 currentLinksResult = main.FALSE
350 utilities.assert_equals( expect=main.TRUE,
351 actual=currentLinksResult,
352 onpass="ONOS" + controllerStr +
353 " links view is correct",
354 onfail="ONOS" + controllerStr +
355 " links view is incorrect" )
356
357 if hosts[ controller ] or "Error" not in hosts[ controller ]:
358 currentHostsResult = main.Mininet1.compareHosts(
359 mnHosts,
360 json.loads( hosts[ controller ] ) )
361 else:
362 currentHostsResult = main.FALSE
GlennRC632e2892015-10-19 18:58:41 -0700363 utilities.assert_equals( expect=main.TRUE,
364 actual=currentHostsResult,
365 onpass="ONOS" + controllerStr +
366 " hosts exist in Mininet",
367 onfail="ONOS" + controllerStr +
368 " hosts don't match Mininet" )
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700369
GlennRC632e2892015-10-19 18:58:41 -0700370 def CASE100( self, main ):
371 '''
372 Balance master
373 '''
374 main.case("Balancing Masters")
375 main.step("Balancing Masters")
376 try:
377 controller = main.activeNodes[0]
378 stepResult = main.CLIs[controller].balanceMasters()
379 except Exception:
380 main.log.exception("Exception: balancing masters")
381 main.cleanup()
382 main.exit()
383 utilities.assert_equals( expect=main.TRUE,
384 actual=stepResult,
385 onpass="Balance masters was successfull",
386 onfail="Failed to balance masters")
387
388 time.sleep(main.balanceSleep)
389
390
391 def CASE200( self, main ):
392 '''
393 Bring random node down
394 '''
395 import random
396 main.case( "Randomly stopping an ONOS service" )
397 main.step( "Bringing down an onos node" )
398
399 random.seed()
400 # Get the random index of the node
401 main.deadNode = random.randrange(0,main.numCtrls)
402
403 node = main.deadNode + 1
404
405 main.log.info( "deadnode: %s" % node )
406
407 main.log.info( "Stopping node %s" % node )
408 startResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] )
409
410 try:
411 main.activeNodes.pop( main.deadNode )
412 except Exception:
413 main.log.exception( "Exception: popping from list of active nodes" )
414 main.cleanup()
415 main.exit()
416
417 utilities.assert_equals( expect=main.TRUE,
418 actual=stepResult,
419 onpass="Successfully brought down onos node %s" % node,
420 onfail="Failed to bring down onos node %s" % node )
421
422 time.sleep(main.nodeDownSleep)
423
424
425 def CASE300( self, main ):
426 '''
427 Bring up onos node
428 '''
429 main.case( "Bring the dead ONOS node back up" )
430 main.step( "Bringing up an onos node" )
431
432 node = main.deadNode + 1
433
434 main.log.info( "Starting node %s" % node )
435 startResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] )
436
437 main.log.info( "Starting onos cli" )
438 startCliResult = main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] )
439
440 main.activeNodes.append( main.deadNode )
441
442 stepResult = startResult and startCliResult
443
444 utilities.assert_equals( expect=main.TRUE,
445 actual=stepResult,
446 onpass="Successfully brought up onos node %s" % node,
447 onfail="Failed to bring up onos node %s" % node )
448
449
450 time.sleep(main.nodeUpSleep)
451
452 def CASE1000( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700453 '''
454 Report errors/warnings/exceptions
455 '''
456 main.log.info("Error report: \n" )
457 main.ONOSbench.logReport( main.ONOSip[ 0 ],
458 [ "INFO",
459 "FOLLOWER",
460 "WARN",
461 "flow",
462 "ERROR",
463 "Except" ],
464 "s" )