blob: 5801fcd53b6fa41abd0dad36efbee8d419c8de55 [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
kelvin-onlabf0336882015-07-21 11:09:22 -07005class SAMPscaleTopo:
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' ]
38 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
39 if main.ONOSbench.maxNodes:
40 main.maxNodes = int( main.ONOSbench.maxNodes )
41 else:
42 main.maxNodes = 0
43 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
44 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
45 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
46 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
47 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
48 gitPull = main.params[ 'GIT' ][ 'pull' ]
49 main.cellData = {} # for creating cell file
50 main.hostsData = {}
51 main.CLIs = []
52 main.ONOSip = []
kelvin-onlab1d381fe2015-07-14 16:24:56 -070053
kelvin-onlabd9e23de2015-08-06 10:34:44 -070054 main.ONOSip = main.ONOSbench.getOnosIps()
55 print main.ONOSip
kelvin-onlab1d381fe2015-07-14 16:24:56 -070056
kelvin-onlabd9e23de2015-08-06 10:34:44 -070057 # Assigning ONOS cli handles to a list
58 for i in range( 1, main.maxNodes + 1 ):
59 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlab1d381fe2015-07-14 16:24:56 -070060
kelvin-onlabd9e23de2015-08-06 10:34:44 -070061 # -- INIT SECTION, ONLY RUNS ONCE -- #
62 main.startUp = imp.load_source( wrapperFile1,
63 main.dependencyPath +
64 wrapperFile1 +
65 ".py" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -070066
kelvin-onlabd9e23de2015-08-06 10:34:44 -070067 main.scaleTopoFunction = imp.load_source( wrapperFile2,
68 main.dependencyPath +
69 wrapperFile2 +
70 ".py" )
71
72 main.topo = imp.load_source( wrapperFile3,
73 main.dependencyPath +
74 wrapperFile3 +
75 ".py" )
76
77 copyResult1 = main.ONOSbench.scp( main.Mininet1,
78 main.dependencyPath +
79 main.topology,
80 main.Mininet1.home,
81 direction="to" )
82
83 copyResult2 = main.ONOSbench.scp( main.Mininet1,
84 main.dependencyPath +
85 main.multiovs,
86 main.Mininet1.home,
87 direction="to" )
88
89 if main.CLIs:
90 stepResult = main.TRUE
91 else:
92 main.log.error( "Did not properly created list of " +
93 "ONOS CLI handle" )
94 stepResult = main.FALSE
95
96 except Exception as e:
97 main.log.exception(e)
98 main.cleanup()
99 main.exit()
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700100
101 utilities.assert_equals( expect=main.TRUE,
102 actual=stepResult,
103 onpass="Successfully construct " +
104 "test variables ",
105 onfail="Failed to construct test variables" )
106
107 if gitPull == 'True':
108 main.step( "Building ONOS in " + gitBranch + " branch" )
109 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
110 stepResult = onosBuildResult
111 utilities.assert_equals( expect=main.TRUE,
112 actual=stepResult,
113 onpass="Successfully compiled " +
114 "latest ONOS",
115 onfail="Failed to compile " +
116 "latest ONOS" )
117 else:
118 main.log.warn( "Did not pull new code so skipping mvn " +
119 "clean install" )
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700120 main.ONOSbench.getVersion( report=True )
121 if gitPull == 'True':
122 main.step( "Building ONOS in " + gitBranch + " branch" )
123 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
124 stepResult = onosBuildResult
125 utilities.assert_equals( expect=main.TRUE,
126 actual=stepResult,
127 onpass="Successfully compiled " +
128 "latest ONOS",
129 onfail="Failed to compile " +
130 "latest ONOS" )
131 else:
132 main.log.warn( "Did not pull new code so skipping mvn " +
133 "clean install" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700134
135 def CASE2( self, main ):
136 """
137 - Set up cell
138 - Create cell file
139 - Set cell file
140 - Verify cell file
141 - Kill ONOS process
142 - Uninstall ONOS cluster
143 - Verify ONOS start up
144 - Install ONOS cluster
145 - Connect to cli
146 """
147
148 # main.scale[ 0 ] determines the current number of ONOS controller
149 main.numCtrls = int( main.scale[ 0 ] )
150
151 main.case( "Starting up " + str( main.numCtrls ) +
152 " node(s) ONOS cluster" )
153
154 #kill off all onos processes
155 main.log.info( "Safety check, killing all ONOS processes" +
156 " before initiating enviornment setup" )
157
158 for i in range( main.maxNodes ):
159 main.ONOSbench.onosDie( main.ONOSip[ i ] )
160
161 print "NODE COUNT = ", main.numCtrls
162
163 tempOnosIp = []
164 for i in range( main.numCtrls ):
165 tempOnosIp.append( main.ONOSip[i] )
166
167 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
168 "temp", main.Mininet1.ip_address,
169 main.apps,
170 tempOnosIp )
171
172 main.step( "Apply cell to environment" )
173 cellResult = main.ONOSbench.setCell( "temp" )
174 verifyResult = main.ONOSbench.verifyCell()
175 stepResult = cellResult and verifyResult
176 utilities.assert_equals( expect=main.TRUE,
177 actual=stepResult,
178 onpass="Successfully applied cell to " + \
179 "environment",
180 onfail="Failed to apply cell to environment " )
181
182 main.step( "Creating ONOS package" )
183 packageResult = main.ONOSbench.onosPackage()
184 stepResult = packageResult
185 utilities.assert_equals( expect=main.TRUE,
186 actual=stepResult,
187 onpass="Successfully created ONOS package",
188 onfail="Failed to create ONOS package" )
189
190
191 # Remove the first element in main.scale list
192 main.scale.remove( main.scale[ 0 ] )
193
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700194 def CASE8( self, main ):
195 """
196 Compare Topo
197 """
198 import json
199
200 main.case( "Compare ONOS Topology view to Mininet topology" )
201 main.caseExplanation = "Compare topology elements between Mininet" +\
202 " and ONOS"
203
204 main.step( "Gathering topology information" )
205 # TODO: add a paramaterized sleep here
206 devicesResults = main.TRUE
207 linksResults = main.TRUE
208 hostsResults = main.TRUE
209 devices = main.topo.getAllDevices( main )
210 hosts = main.topo.getAllHosts( main )
211 ports = main.topo.getAllPorts( main )
212 links = main.topo.getAllLinks( main )
213 clusters = main.topo.getAllClusters( main )
214
215 mnSwitches = main.Mininet1.getSwitches()
216 mnLinks = main.Mininet1.getLinks()
217 mnHosts = main.Mininet1.getHosts()
218
219 main.step( "Conmparing MN topology to ONOS topology" )
220 for controller in range( main.numCtrls ):
221 controllerStr = str( controller + 1 )
222 if devices[ controller ] and ports[ controller ] and\
223 "Error" not in devices[ controller ] and\
224 "Error" not in ports[ controller ]:
225
226 currentDevicesResult = main.Mininet1.compareSwitches(
227 mnSwitches,
228 json.loads( devices[ controller ] ),
229 json.loads( ports[ controller ] ) )
230 else:
231 currentDevicesResult = main.FALSE
232 utilities.assert_equals( expect=main.TRUE,
233 actual=currentDevicesResult,
234 onpass="ONOS" + controllerStr +
235 " Switches view is correct",
236 onfail="ONOS" + controllerStr +
237 " Switches view is incorrect" )
238
239 if links[ controller ] and "Error" not in links[ controller ]:
240 currentLinksResult = main.Mininet1.compareLinks(
241 mnSwitches, mnLinks,
242 json.loads( links[ controller ] ) )
243 else:
244 currentLinksResult = main.FALSE
245 utilities.assert_equals( expect=main.TRUE,
246 actual=currentLinksResult,
247 onpass="ONOS" + controllerStr +
248 " links view is correct",
249 onfail="ONOS" + controllerStr +
250 " links view is incorrect" )
251
252 if hosts[ controller ] or "Error" not in hosts[ controller ]:
253 currentHostsResult = main.Mininet1.compareHosts(
254 mnHosts,
255 json.loads( hosts[ controller ] ) )
256 else:
257 currentHostsResult = main.FALSE
258 utilities.assert_equals( expect=main.TRUE,
259 actual=currentHostsResult,
260 onpass="ONOS" + controllerStr +
261 " hosts exist in Mininet",
262 onfail="ONOS" + controllerStr +
263 " hosts don't match Mininet" )
264
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700265 def CASE9( self, main ):
266 '''
267 Report errors/warnings/exceptions
268 '''
269 main.log.info("Error report: \n" )
270 main.ONOSbench.logReport( main.ONOSip[ 0 ],
271 [ "INFO",
272 "FOLLOWER",
273 "WARN",
274 "flow",
275 "ERROR",
276 "Except" ],
277 "s" )
278
279 def CASE11( self, main ):
280 """
281 Start mininet
282 """
283 main.log.report( "Start Mininet topology" )
284 main.log.case( "Start Mininet topology" )
285
286 main.step( "Starting Mininet Topology" )
287 topoResult = main.Mininet1.startNet( topoFile=topology )
288 stepResult = topoResult
289 utilities.assert_equals( expect=main.TRUE,
290 actual=stepResult,
291 onpass="Successfully loaded topology",
292 onfail="Failed to load topology" )
293 # Exit if topology did not load properly
294 if not topoResult:
295 main.cleanup()
296 main.exit()
297
298 def CASE1001( self, main ):
299 """
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700300 Topology test
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700301 """
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700302 import time
303 main.topoName = "SPINE"
304 main.case( "Spine topology test" )
305 main.step( main.topoName + " topology" )
306 mnCmd = "sudo mn --custom " + main.dependencyPath +\
307 main.multiovs + " --switch=ovsm --custom " +\
308 main.dependencyPath + main.topology +\
309 " --topo spine,3,6 --controller=remote,ip=" +\
310 main.ONOSip[ 0 ] + " --mac"
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700311
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700312 stepResult = main.scaleTopoFunction.testTopology( main,
313 mnCmd=mnCmd,
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700314 timeout=900,
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700315 clean=False )
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700316
317 main.ONOSbench.scp( main.Mininet1,
318 "~/mininet/custom/spine.json",
319 "/tmp/",
320 direction="to" )
321
322 time.sleep(10)
323
324 main.ONOSbench.onosTopoCfg( main.ONOSip[ 0 ],
325 main.dependencyPath + 'spine.json' )
326
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700327 utilities.assert_equals( expect=main.TRUE,
328 actual=stepResult,
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700329 onpass=main.topoName + " topology successful",
330 onfail=main.topoName +
331 "Torus 5-5 topology failed" )
332 time.sleep(60)
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700333
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700334 def CASE1002( self, main ):
335 """
336 Topology test
337 """
338 main.topoName = "TORUS10-10"
339 main.case( "Topology discovery test" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700340 stepResult = main.TRUE
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700341 main.step( main.topoName + " topology" )
342 mnCmd = "sudo mn --custom=mininet/examples/multiovs.py " +\
343 "--switch=ovsm --topo=torus,10,10 " +\
344 "--controller=remote,ip=10.128.10.21 --mac"
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700345 stepResult = main.scaleTopoFunction.testTopology( main,
346 mnCmd=mnCmd,
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700347 timeout=900,
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700348 clean=True )
349 utilities.assert_equals( expect=main.TRUE,
350 actual=stepResult,
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700351 onpass=main.topoName + " topology successful",
352 onfail=main.topoName + "Torus 5-5 topology failed" )