blob: 24e8842c632c5fc09a58c45fd1f58983a86b0568 [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' ]
36 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
37 main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
GlennRC8f545df2015-08-28 09:26:38 -070038 main.torus = main.params[ 'DEPENDENCY' ][ 'torus' ]
39 main.spine = main.params[ 'DEPENDENCY' ][ 'spine' ]
kelvin-onlabd9e23de2015-08-06 10:34:44 -070040 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
41 if main.ONOSbench.maxNodes:
42 main.maxNodes = int( main.ONOSbench.maxNodes )
43 else:
44 main.maxNodes = 0
45 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
46 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
47 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
48 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
49 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
50 gitPull = main.params[ 'GIT' ][ 'pull' ]
51 main.cellData = {} # for creating cell file
52 main.hostsData = {}
53 main.CLIs = []
54 main.ONOSip = []
kelvin-onlab1d381fe2015-07-14 16:24:56 -070055
kelvin-onlabd9e23de2015-08-06 10:34:44 -070056 main.ONOSip = main.ONOSbench.getOnosIps()
57 print main.ONOSip
kelvin-onlab1d381fe2015-07-14 16:24:56 -070058
kelvin-onlabd9e23de2015-08-06 10:34:44 -070059 # Assigning ONOS cli handles to a list
60 for i in range( 1, main.maxNodes + 1 ):
61 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlab1d381fe2015-07-14 16:24:56 -070062
kelvin-onlabd9e23de2015-08-06 10:34:44 -070063 # -- INIT SECTION, ONLY RUNS ONCE -- #
64 main.startUp = imp.load_source( wrapperFile1,
65 main.dependencyPath +
66 wrapperFile1 +
67 ".py" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -070068
kelvin-onlabd9e23de2015-08-06 10:34:44 -070069 main.scaleTopoFunction = imp.load_source( wrapperFile2,
70 main.dependencyPath +
71 wrapperFile2 +
72 ".py" )
73
74 main.topo = imp.load_source( wrapperFile3,
75 main.dependencyPath +
76 wrapperFile3 +
77 ".py" )
78
79 copyResult1 = main.ONOSbench.scp( main.Mininet1,
80 main.dependencyPath +
81 main.topology,
82 main.Mininet1.home,
83 direction="to" )
GlennRC8f545df2015-08-28 09:26:38 -070084 time.sleep(3)
kelvin-onlabd9e23de2015-08-06 10:34:44 -070085 copyResult2 = main.ONOSbench.scp( main.Mininet1,
86 main.dependencyPath +
87 main.multiovs,
88 main.Mininet1.home,
89 direction="to" )
GlennRC8f545df2015-08-28 09:26:38 -070090 time.sleep(3)
kelvin-onlabd9e23de2015-08-06 10:34:44 -070091 if main.CLIs:
92 stepResult = main.TRUE
93 else:
94 main.log.error( "Did not properly created list of " +
95 "ONOS CLI handle" )
96 stepResult = main.FALSE
97
98 except Exception as e:
99 main.log.exception(e)
100 main.cleanup()
101 main.exit()
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700102
103 utilities.assert_equals( expect=main.TRUE,
104 actual=stepResult,
105 onpass="Successfully construct " +
106 "test variables ",
107 onfail="Failed to construct test variables" )
108
109 if gitPull == 'True':
110 main.step( "Building ONOS in " + gitBranch + " branch" )
111 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
112 stepResult = onosBuildResult
113 utilities.assert_equals( expect=main.TRUE,
114 actual=stepResult,
115 onpass="Successfully compiled " +
116 "latest ONOS",
117 onfail="Failed to compile " +
118 "latest ONOS" )
119 else:
120 main.log.warn( "Did not pull new code so skipping mvn " +
121 "clean install" )
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700122 main.ONOSbench.getVersion( report=True )
123 if gitPull == 'True':
124 main.step( "Building ONOS in " + gitBranch + " branch" )
125 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
126 stepResult = onosBuildResult
127 utilities.assert_equals( expect=main.TRUE,
128 actual=stepResult,
129 onpass="Successfully compiled " +
130 "latest ONOS",
131 onfail="Failed to compile " +
132 "latest ONOS" )
133 else:
134 main.log.warn( "Did not pull new code so skipping mvn " +
135 "clean install" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700136
137 def CASE2( self, main ):
138 """
139 - Set up cell
140 - Create cell file
141 - Set cell file
142 - Verify cell file
143 - Kill ONOS process
144 - Uninstall ONOS cluster
145 - Verify ONOS start up
146 - Install ONOS cluster
147 - Connect to cli
148 """
149
150 # main.scale[ 0 ] determines the current number of ONOS controller
151 main.numCtrls = int( main.scale[ 0 ] )
152
153 main.case( "Starting up " + str( main.numCtrls ) +
154 " node(s) ONOS cluster" )
155
156 #kill off all onos processes
157 main.log.info( "Safety check, killing all ONOS processes" +
158 " before initiating enviornment setup" )
159
160 for i in range( main.maxNodes ):
161 main.ONOSbench.onosDie( main.ONOSip[ i ] )
162
163 print "NODE COUNT = ", main.numCtrls
164
165 tempOnosIp = []
166 for i in range( main.numCtrls ):
167 tempOnosIp.append( main.ONOSip[i] )
168
169 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
170 "temp", main.Mininet1.ip_address,
171 main.apps,
172 tempOnosIp )
173
174 main.step( "Apply cell to environment" )
175 cellResult = main.ONOSbench.setCell( "temp" )
176 verifyResult = main.ONOSbench.verifyCell()
177 stepResult = cellResult and verifyResult
178 utilities.assert_equals( expect=main.TRUE,
179 actual=stepResult,
180 onpass="Successfully applied cell to " + \
181 "environment",
182 onfail="Failed to apply cell to environment " )
183
184 main.step( "Creating ONOS package" )
185 packageResult = main.ONOSbench.onosPackage()
186 stepResult = packageResult
187 utilities.assert_equals( expect=main.TRUE,
188 actual=stepResult,
189 onpass="Successfully created ONOS package",
190 onfail="Failed to create ONOS package" )
191
192
193 # Remove the first element in main.scale list
GlennRC8f545df2015-08-28 09:26:38 -0700194 #main.scale.remove( main.scale[ 0 ] )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700195
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700196 def CASE8( self, main ):
197 """
198 Compare Topo
199 """
200 import json
201
202 main.case( "Compare ONOS Topology view to Mininet topology" )
203 main.caseExplanation = "Compare topology elements between Mininet" +\
204 " and ONOS"
205
206 main.step( "Gathering topology information" )
207 # TODO: add a paramaterized sleep here
208 devicesResults = main.TRUE
209 linksResults = main.TRUE
210 hostsResults = main.TRUE
211 devices = main.topo.getAllDevices( main )
212 hosts = main.topo.getAllHosts( main )
213 ports = main.topo.getAllPorts( main )
214 links = main.topo.getAllLinks( main )
215 clusters = main.topo.getAllClusters( main )
216
217 mnSwitches = main.Mininet1.getSwitches()
218 mnLinks = main.Mininet1.getLinks()
219 mnHosts = main.Mininet1.getHosts()
220
221 main.step( "Conmparing MN topology to ONOS topology" )
222 for controller in range( main.numCtrls ):
223 controllerStr = str( controller + 1 )
224 if devices[ controller ] and ports[ controller ] and\
225 "Error" not in devices[ controller ] and\
226 "Error" not in ports[ controller ]:
227
228 currentDevicesResult = main.Mininet1.compareSwitches(
229 mnSwitches,
230 json.loads( devices[ controller ] ),
231 json.loads( ports[ controller ] ) )
232 else:
233 currentDevicesResult = main.FALSE
234 utilities.assert_equals( expect=main.TRUE,
235 actual=currentDevicesResult,
236 onpass="ONOS" + controllerStr +
237 " Switches view is correct",
238 onfail="ONOS" + controllerStr +
239 " Switches view is incorrect" )
240
241 if links[ controller ] and "Error" not in links[ controller ]:
242 currentLinksResult = main.Mininet1.compareLinks(
243 mnSwitches, mnLinks,
244 json.loads( links[ controller ] ) )
245 else:
246 currentLinksResult = main.FALSE
247 utilities.assert_equals( expect=main.TRUE,
248 actual=currentLinksResult,
249 onpass="ONOS" + controllerStr +
250 " links view is correct",
251 onfail="ONOS" + controllerStr +
252 " links view is incorrect" )
253
254 if hosts[ controller ] or "Error" not in hosts[ controller ]:
255 currentHostsResult = main.Mininet1.compareHosts(
256 mnHosts,
257 json.loads( hosts[ controller ] ) )
258 else:
259 currentHostsResult = main.FALSE
260 utilities.assert_equals( expect=main.TRUE,
261 actual=currentHostsResult,
262 onpass="ONOS" + controllerStr +
263 " hosts exist in Mininet",
264 onfail="ONOS" + controllerStr +
265 " hosts don't match Mininet" )
266
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700267 def CASE9( self, main ):
268 '''
269 Report errors/warnings/exceptions
270 '''
271 main.log.info("Error report: \n" )
272 main.ONOSbench.logReport( main.ONOSip[ 0 ],
273 [ "INFO",
274 "FOLLOWER",
275 "WARN",
276 "flow",
277 "ERROR",
278 "Except" ],
279 "s" )
280
281 def CASE11( self, main ):
282 """
283 Start mininet
284 """
285 main.log.report( "Start Mininet topology" )
286 main.log.case( "Start Mininet topology" )
287
288 main.step( "Starting Mininet Topology" )
GlennRC1c5df3c2015-08-27 16:12:09 -0700289 topology = main.dependencyPath + main.topology
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700290 topoResult = main.Mininet1.startNet( topoFile=topology )
291 stepResult = topoResult
292 utilities.assert_equals( expect=main.TRUE,
293 actual=stepResult,
294 onpass="Successfully loaded topology",
295 onfail="Failed to load topology" )
296 # Exit if topology did not load properly
297 if not topoResult:
298 main.cleanup()
299 main.exit()
300
301 def CASE1001( self, main ):
302 """
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700303 Topology test
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700304 """
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700305 import time
306 main.topoName = "SPINE"
307 main.case( "Spine topology test" )
308 main.step( main.topoName + " topology" )
309 mnCmd = "sudo mn --custom " + main.dependencyPath +\
310 main.multiovs + " --switch=ovsm --custom " +\
311 main.dependencyPath + main.topology +\
GlennRC8f545df2015-08-28 09:26:38 -0700312 " --topo " + main.spine + " --controller=remote,ip=" +\
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700313 main.ONOSip[ 0 ] + " --mac"
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700314
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700315 stepResult = main.scaleTopoFunction.testTopology( main,
316 mnCmd=mnCmd,
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700317 timeout=900,
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700318 clean=False )
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700319
GlennRC8f545df2015-08-28 09:26:38 -0700320 time.sleep(3)
GlennRC781b43b2015-08-31 16:26:28 -0700321
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700322 utilities.assert_equals( expect=main.TRUE,
323 actual=stepResult,
GlennRC8f545df2015-08-28 09:26:38 -0700324 onpass=main.spine + " topology successful",
325 onfail=main.spine +
GlennRC1c5df3c2015-08-27 16:12:09 -0700326 "Spine topology failed" )
GlennRC781b43b2015-08-31 16:26:28 -0700327
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700328 time.sleep(60)
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700329
GlennRC4cc11182015-09-01 15:19:15 -0700330 '''
331 main.ONOSbench.scp( main.Mininet1,
332 "~/mininet/custom/spine.json",
333 "/tmp/",
334 direction="to" )
335 '''
336
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700337 def CASE1002( self, main ):
338 """
339 Topology test
340 """
GlennRC8f545df2015-08-28 09:26:38 -0700341 main.topoName = "TORUS"
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700342 main.case( "Topology discovery test" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700343 stepResult = main.TRUE
GlennRC8f545df2015-08-28 09:26:38 -0700344 main.step( main.torus + " topology" )
GlennRC1c5df3c2015-08-27 16:12:09 -0700345 mnCmd = "sudo mn --custom=mininet/custom/multiovs.py " +\
GlennRC8f545df2015-08-28 09:26:38 -0700346 "--switch=ovsm --topo " + main.torus +\
347 " --controller=remote,ip=" + main.ONOSip[ 0 ] +" --mac"
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700348 stepResult = main.scaleTopoFunction.testTopology( main,
349 mnCmd=mnCmd,
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700350 timeout=900,
GlennRC781b43b2015-08-31 16:26:28 -0700351 clean=True )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700352 utilities.assert_equals( expect=main.TRUE,
353 actual=stepResult,
GlennRC8f545df2015-08-28 09:26:38 -0700354 onpass=main.torus + " topology successful",
355 onfail=main.torus + " topology failed" )