blob: c3910b59a3634013c9bd0a438580a582c5a5b17e [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 ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -070011 import os
12 import imp
kelvin-onlab1d381fe2015-07-14 16:24:56 -070013 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
GlennRC475f50d2015-10-23 15:01:09 -070022 main.case( "Constructing test variables" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -070023 main.step( "Constructing test variables" )
24 stepResult = main.FALSE
Chiyu Chengb8c2c842016-10-05 12:40:49 -070025 # The variable to decide if the data should be written into data base.
26 # 1 means Yes and -1 means No.
27 main.writeData = 1
28 main.searchTerm = main.params[ 'SearchTerm' ]
GlennRC475f50d2015-10-23 15:01:09 -070029 main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
30 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
31 gitBranch = main.params[ 'GIT' ][ 'branch' ]
32 main.dependencyPath = main.testOnDirectory + \
33 main.params[ 'DEPENDENCY' ][ 'path' ]
Chiyu Cheng899621b2016-11-14 11:14:48 -080034 main.tsharkResultPath = main.params[ 'TsharkPath' ]
35 main.roleRequest = main.params[ 'SearchTerm' ]['roleRequest']
GlennRC475f50d2015-10-23 15:01:09 -070036 main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
37 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 )
41 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
42 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
43 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
44 main.topoCmpAttempts = int( main.params[ 'ATTEMPTS' ][ 'topoCmp' ] )
45 main.pingallAttempts = int( main.params[ 'ATTEMPTS' ][ 'pingall' ] )
46 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
GlennRC475f50d2015-10-23 15:01:09 -070047 main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] )
GlennRCe283c4b2016-01-07 13:04:10 -080048 main.nodeSleep = int( main.params[ 'SLEEP' ][ 'nodeSleep' ] )
GlennRC475f50d2015-10-23 15:01:09 -070049 main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] )
GlennRCe283c4b2016-01-07 13:04:10 -080050 main.MNSleep = int( main.params[ 'SLEEP' ][ 'MNsleep' ] )
YPZhang85024fc2016-02-09 16:59:27 -080051 main.pingTimeout = float( main.params[ 'TIMEOUT' ][ 'pingall' ] )
YPZhangacaaf422016-07-26 09:34:03 -070052 main.hostDiscover = main.params[ 'TOPOLOGY' ][ 'host' ]
53 main.hostDiscoverSleep = float( main.params['SLEEP']['host'] )
54 if main.hostDiscover == 'True':
55 main.hostDiscover = True
56 else:
57 main.hostDiscover = False
GlennRC475f50d2015-10-23 15:01:09 -070058 gitPull = main.params[ 'GIT' ][ 'pull' ]
59 main.homeDir = os.path.expanduser('~')
60 main.cellData = {} # for creating cell file
61 main.hostsData = {}
62 main.CLIs = []
63 main.ONOSip = []
64 main.activeNodes = []
65 main.ONOSip = main.ONOSbench.getOnosIps()
kelvin-onlab1d381fe2015-07-14 16:24:56 -070066
GlennRC475f50d2015-10-23 15:01:09 -070067 for i in range(main.numCtrls):
GlennRC632e2892015-10-19 18:58:41 -070068 main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) )
69
Chiyu Chengb8c2c842016-10-05 12:40:49 -070070 main.allinfo = {} # The dictionary to record all the data from karaf.log
Chiyu Cheng899621b2016-11-14 11:14:48 -080071
Chiyu Chengb8c2c842016-10-05 12:40:49 -070072 for i in range( 2 ):
73 main.allinfo[ i ]={}
74 for w in range ( 3 ):
75 # Totaltime: the time from the new switchConnection to its end
76 # swConnection: the time from the first new switchConnection to the last new switchConnection
Chiyu Cheng899621b2016-11-14 11:14:48 -080077 # lastSwToLastRr: the time from the last new switchConnection to the last role request
78 # lastRrToLastTopology: the time form the last role request to the last topology
Chiyu Chengb8c2c842016-10-05 12:40:49 -070079 # disconnectRate: the rate that shows how many switch disconnect after connection
Chiyu Cheng899621b2016-11-14 11:14:48 -080080 main.allinfo[ i ][ 'info' + str( w ) ]= { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
Chiyu Chengb8c2c842016-10-05 12:40:49 -070081
82 main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
83 main.log.info( "Create Database file " + main.dbFilePath )
84 resultDB = open(main.dbFilePath, 'w+' )
85 resultDB.close()
86
Chiyu Cheng899621b2016-11-14 11:14:48 -080087
GlennRC475f50d2015-10-23 15:01:09 -070088 main.startUp = imp.load_source( wrapperFile1,
89 main.dependencyPath +
90 wrapperFile1 +
91 ".py" )
Chiyu Cheng899621b2016-11-14 11:14:48 -080092
GlennRC475f50d2015-10-23 15:01:09 -070093 main.scaleTopoFunction = imp.load_source( wrapperFile2,
94 main.dependencyPath +
95 wrapperFile2 +
96 ".py" )
Chiyu Cheng899621b2016-11-14 11:14:48 -080097
GlennRC475f50d2015-10-23 15:01:09 -070098 main.topo = imp.load_source( wrapperFile3,
99 main.dependencyPath +
100 wrapperFile3 +
101 ".py" )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800102
GlennRC632e2892015-10-19 18:58:41 -0700103 main.ONOSbench.scp( main.Mininet1,
104 main.dependencyPath +
105 main.multiovs,
106 main.Mininet1.home,
107 direction="to" )
108
109 if main.CLIs:
110 stepResult = main.TRUE
111 else:
112 main.log.error( "Did not properly created list of " +
113 "ONOS CLI handle" )
114 stepResult = main.FALSE
115
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700116 utilities.assert_equals( expect=main.TRUE,
117 actual=stepResult,
118 onpass="Successfully construct " +
119 "test variables ",
120 onfail="Failed to construct test variables" )
121
122 if gitPull == 'True':
123 main.step( "Building ONOS in " + gitBranch + " branch" )
124 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
125 stepResult = onosBuildResult
126 utilities.assert_equals( expect=main.TRUE,
127 actual=stepResult,
128 onpass="Successfully compiled " +
129 "latest ONOS",
130 onfail="Failed to compile " +
131 "latest ONOS" )
132 else:
133 main.log.warn( "Did not pull new code so skipping mvn " +
134 "clean install" )
135
GlennRC632e2892015-10-19 18:58:41 -0700136
137 def CASE2( self, main):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700138 """
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 """
YPZhangacaaf422016-07-26 09:34:03 -0700149 import time
YPZhang29c2d642016-06-22 16:15:19 -0700150 main.log.info( "Checking if mininet is already running" )
151 if len( main.topoScale ) < main.topoScaleSize:
152 main.log.info( "Mininet is already running. Stopping mininet." )
153 main.Mininet1.stopNet()
154 time.sleep(main.MNSleep)
155 else:
156 main.log.info( "Mininet was not running" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700157
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700158 main.case( "Starting up " + str( main.numCtrls ) +
159 " node(s) ONOS cluster" )
GlennRC632e2892015-10-19 18:58:41 -0700160 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
161 " node(s) ONOS cluster"
162
163
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700164
165 #kill off all onos processes
166 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800167 " before initiating environment setup" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700168
GlennRC632e2892015-10-19 18:58:41 -0700169 for i in range( main.numCtrls ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700170 main.ONOSbench.onosDie( main.ONOSip[ i ] )
171
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700172 tempOnosIp = []
173 for i in range( main.numCtrls ):
174 tempOnosIp.append( main.ONOSip[i] )
175
176 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
177 "temp", main.Mininet1.ip_address,
GlennRC632e2892015-10-19 18:58:41 -0700178 main.apps, tempOnosIp )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700179
180 main.step( "Apply cell to environment" )
181 cellResult = main.ONOSbench.setCell( "temp" )
182 verifyResult = main.ONOSbench.verifyCell()
183 stepResult = cellResult and verifyResult
184 utilities.assert_equals( expect=main.TRUE,
185 actual=stepResult,
186 onpass="Successfully applied cell to " + \
187 "environment",
188 onfail="Failed to apply cell to environment " )
189
190 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700191 packageResult = main.ONOSbench.buckBuild()
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700192 stepResult = packageResult
193 utilities.assert_equals( expect=main.TRUE,
194 actual=stepResult,
195 onpass="Successfully created ONOS package",
196 onfail="Failed to create ONOS package" )
197
GlennRC632e2892015-10-19 18:58:41 -0700198 time.sleep( main.startUpSleep )
199 main.step( "Uninstalling ONOS package" )
200 onosUninstallResult = main.TRUE
201 for ip in main.ONOSip:
202 onosUninstallResult = onosUninstallResult and \
203 main.ONOSbench.onosUninstall( nodeIp=ip )
204 stepResult = onosUninstallResult
205 utilities.assert_equals( expect=main.TRUE,
206 actual=stepResult,
207 onpass="Successfully uninstalled ONOS package",
208 onfail="Failed to uninstall ONOS package" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700209
GlennRC632e2892015-10-19 18:58:41 -0700210 time.sleep( main.startUpSleep )
211 main.step( "Installing ONOS package" )
212 onosInstallResult = main.TRUE
213 for i in range( main.numCtrls ):
214 onosInstallResult = onosInstallResult and \
215 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
216 stepResult = onosInstallResult
217 utilities.assert_equals( expect=main.TRUE,
218 actual=stepResult,
219 onpass="Successfully installed ONOS package",
220 onfail="Failed to install ONOS package" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700221
GlennRC632e2892015-10-19 18:58:41 -0700222 time.sleep( main.startUpSleep )
223 main.step( "Starting ONOS service" )
224 stopResult = main.TRUE
225 startResult = main.TRUE
226 onosIsUp = main.TRUE
227
228 for i in range( main.numCtrls ):
229 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
230 if onosIsUp == main.TRUE:
231 main.log.report( "ONOS instance is up and ready" )
232 else:
233 main.log.report( "ONOS instance may not be up, stop and " +
234 "start ONOS again " )
235
236 for i in range( main.numCtrls ):
237 stopResult = stopResult and \
238 main.ONOSbench.onosStop( main.ONOSip[ i ] )
239 for i in range( main.numCtrls ):
240 startResult = startResult and \
241 main.ONOSbench.onosStart( main.ONOSip[ i ] )
242 stepResult = onosIsUp and stopResult and startResult
243 utilities.assert_equals( expect=main.TRUE,
244 actual=stepResult,
245 onpass="ONOS service is ready",
246 onfail="ONOS service did not start properly" )
247
248 main.step( "Start ONOS cli" )
249 cliResult = main.TRUE
YPZhang29c2d642016-06-22 16:15:19 -0700250 main.activeNodes = []
GlennRC632e2892015-10-19 18:58:41 -0700251 for i in range( main.numCtrls ):
252 cliResult = cliResult and \
253 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
254 main.activeNodes.append( i )
255 stepResult = cliResult
256 utilities.assert_equals( expect=main.TRUE,
257 actual=stepResult,
258 onpass="Successfully start ONOS cli",
259 onfail="Failed to start ONOS cli" )
YPZhang29c2d642016-06-22 16:15:19 -0700260 time.sleep( main.startUpSleep )
GlennRC632e2892015-10-19 18:58:41 -0700261
262 def CASE10( self, main ):
263 """
YPZhang85024fc2016-02-09 16:59:27 -0800264 Starting up torus topology
GlennRC632e2892015-10-19 18:58:41 -0700265 """
GlennRC475f50d2015-10-23 15:01:09 -0700266
267 main.case( "Starting up Mininet and verifying topology" )
268 main.caseExplanation = "Starting Mininet with a scalling topology and " +\
269 "comparing topology elements between Mininet and ONOS"
GlennRC475f50d2015-10-23 15:01:09 -0700270 if main.topoScale:
GlennRC90d43952015-10-27 11:36:15 -0700271 main.currScale = main.topoScale.pop(0)
GlennRC475f50d2015-10-23 15:01:09 -0700272 else: main.log.error( "topology scale is empty" )
GlennRC90d43952015-10-27 11:36:15 -0700273 main.step( "Starting up TORUS %sx%s topology" % (main.currScale, main.currScale) )
GlennRC475f50d2015-10-23 15:01:09 -0700274
275 main.log.info( "Constructing Mininet command" )
YPZhangacaaf422016-07-26 09:34:03 -0700276 mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
277 " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
GlennRC475f50d2015-10-23 15:01:09 -0700278 for i in range( main.numCtrls ):
279 mnCmd += " --controller remote,ip=" + main.ONOSip[ i ]
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700280 stepResult = main.Mininet1.startNet( mnCmd=mnCmd )
GlennRC632e2892015-10-19 18:58:41 -0700281 utilities.assert_equals( expect=main.TRUE,
282 actual=stepResult,
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700283 onpass=main.topoName +
GlennRC632e2892015-10-19 18:58:41 -0700284 " topology started successfully",
285 onfail=main.topoName +
286 " topology failed to start" )
287
GlennRCe283c4b2016-01-07 13:04:10 -0800288 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800289 main.log.info( "Clean up Tshark" )
290 with open(main.tsharkResultPath, "w" ) as tshark:
291 tshark.write( "" )
292 main.log.info( "Starting Tshark capture" )
293 main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' )
Chiyu Cheng81499422016-11-09 11:04:23 -0800294 main.CLIs[ 0 ].activateApp( "org.onosproject.openflow" )
295 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800296 main.log.info( "Stop Tshark" )
297 main.ONOSbench.tsharkStop()
298 main.log.info( "Get role request time" )
299 with open( main.tsharkResultPath, "r" ) as resultFile:
300 resultText = resultFile.readlines()
301 resultFile.close()
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700302
GlennRC475f50d2015-10-23 15:01:09 -0700303 def CASE11( self, main ):
304 """
YPZhangacaaf422016-07-26 09:34:03 -0700305 Compare topo, and sending Arping package
YPZhang85024fc2016-02-09 16:59:27 -0800306 if the topology is same, then Pass.
GlennRC475f50d2015-10-23 15:01:09 -0700307 """
308 import json
YPZhangacaaf422016-07-26 09:34:03 -0700309 import time
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700310 # First capture
311 for i in range( 3 ):
312 # Calculate total time
313 main.allinfo[ 0 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
314 # Calculate switch connection time
315 main.allinfo[ 0 ][ 'info' + str( i )][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'start' ], 'last', index=i, funcMode='TD' )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800316 # Calculate the time from last switch connection to the last role request
317 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
318 # Calculate the time from the last role request to the last topology
319 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700320 # Calculate the disconnecti rate
321 main.allinfo[ 0 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ], 'num', index=i, funcMode='DR' )
322 main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) )
GlennRC475f50d2015-10-23 15:01:09 -0700323
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700324 main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) )
YPZhang85024fc2016-02-09 16:59:27 -0800325 main.caseExplanation = "Pinging all hosts and comparing topology " +\
GlennRC475f50d2015-10-23 15:01:09 -0700326 "elements between Mininet and ONOS"
GlennRCe283c4b2016-01-07 13:04:10 -0800327
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700328 main.log.info( "Gathering topology information")
YPZhang85024fc2016-02-09 16:59:27 -0800329 time.sleep( main.MNSleep )
YPZhang85024fc2016-02-09 16:59:27 -0800330 stepResult = main.TRUE
GlennRC475f50d2015-10-23 15:01:09 -0700331 main.step( "Comparing MN topology to ONOS topology" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700332 compareRetry = 0
333 while compareRetry < 3:
YPZhang81a7d4e2016-04-18 13:10:17 -0700334 #While loop for retry
335 devices = main.topo.getAllDevices( main )
YPZhang81a7d4e2016-04-18 13:10:17 -0700336 ports = main.topo.getAllPorts( main )
337 links = main.topo.getAllLinks( main)
YPZhang81a7d4e2016-04-18 13:10:17 -0700338 mnSwitches = main.Mininet1.getSwitches()
339 mnLinks = main.Mininet1.getLinks(timeout=180)
GlennRC475f50d2015-10-23 15:01:09 -0700340
YPZhang81a7d4e2016-04-18 13:10:17 -0700341 for controller in range(len(main.activeNodes)):
YPZhangacaaf422016-07-26 09:34:03 -0700342 # controllerStr = str( main.activeNodes[controller] + 1 )
343 if devices[ controller ] and ports[ controller ] and \
344 "Error" not in devices[ controller ] and \
345 "Error" not in ports[ controller ]:
YPZhang81a7d4e2016-04-18 13:10:17 -0700346 currentDevicesResult = main.Mininet1.compareSwitches(
347 mnSwitches,
348 json.loads( devices[ controller ] ),
349 json.loads( ports[ controller ] ) )
350 else:
351 currentDevicesResult = main.FALSE
352
353 if links[ controller ] and "Error" not in links[ controller ]:
354 currentLinksResult = main.Mininet1.compareLinks(
355 mnSwitches, mnLinks,
356 json.loads( links[ controller ] ) )
357 else:
358 currentLinksResult = main.FALSE
359
YPZhangacaaf422016-07-26 09:34:03 -0700360 stepResult = stepResult and currentDevicesResult and currentLinksResult
YPZhang81a7d4e2016-04-18 13:10:17 -0700361 if stepResult:
362 break
363 compareRetry += 1
YPZhangacaaf422016-07-26 09:34:03 -0700364 utilities.assert_equals(expect=main.TRUE,
365 actual=stepResult,
366 onpass=" Topology match Mininet",
367 onfail="ONOS Topology doesn't match Mininet")
YPZhang81a7d4e2016-04-18 13:10:17 -0700368
YPZhangacaaf422016-07-26 09:34:03 -0700369 if stepResult:
370 if main.hostDiscover:
371 hostList = []
372 for i in range( 1, int( main.currScale ) + 1 ):
373 for j in range( 1, int( main.currScale ) + 1) :
374 # Generate host list
375 hoststr = "h" + str(i) + "x" + str(j)
376 hostList.append(hoststr)
377 for i in range( len(hostList) ):
378 totalHost = main.topo.sendArpPackage( main, hostList[i] )
379 time.sleep( main.hostDiscoverSleep )
380 if totalHost < 0:
381 # if totalHost less than 0 which means dependence function has exception.
382 main.log.info( "Error when discover host!" )
383 break
384 if totalHost == int( main.currScale ) * int( main.currScale ):
385 main.log.info( "Discovered all hosts" )
You Wang7bb9c462016-08-10 14:18:16 -0700386 stepResult = stepResult and main.TRUE
YPZhangacaaf422016-07-26 09:34:03 -0700387 else:
388 main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
You Wang7bb9c462016-08-10 14:18:16 -0700389 stepResult = main.FALSE
YPZhangacaaf422016-07-26 09:34:03 -0700390 utilities.assert_equals(expect=main.TRUE,
391 actual=stepResult,
392 onpass=" Topology match Mininet",
393 onfail="ONOS Topology doesn't match Mininet")
394 main.log.info( "Finished this iteration, continue to scale next topology." )
YPZhang81a7d4e2016-04-18 13:10:17 -0700395 else:
YPZhangacaaf422016-07-26 09:34:03 -0700396 main.log.info( "Clean up and exit TestON. Finished this test." )
397 main.cleanup()
398 main.exit()
GlennRC475f50d2015-10-23 15:01:09 -0700399
GlennRC632e2892015-10-19 18:58:41 -0700400 def CASE100( self, main ):
401 '''
YPZhang81a7d4e2016-04-18 13:10:17 -0700402 Bring Down node 3
GlennRC632e2892015-10-19 18:58:41 -0700403 '''
GlennRC475f50d2015-10-23 15:01:09 -0700404
YPZhangacaaf422016-07-26 09:34:03 -0700405 main.case("Bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700406 main.caseExplanation = "Balance masters to make sure " +\
407 "each controller has some devices and " +\
408 "stop ONOS node 3 service. "
409
GlennRC475f50d2015-10-23 15:01:09 -0700410 stepResult = main.FALSE
GlennRCed2122e2015-10-21 14:38:46 -0700411 main.step( "Bringing down node 3" )
GlennRCed2122e2015-10-21 14:38:46 -0700412 # Always bring down the third node
413 main.deadNode = 2
GlennRCed2122e2015-10-21 14:38:46 -0700414 # Printing purposes
GlennRC632e2892015-10-19 18:58:41 -0700415 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700416 main.log.info( "Stopping node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700417 stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] )
GlennRC475f50d2015-10-23 15:01:09 -0700418 main.log.info( "Removing dead node from list of active nodes" )
419 main.activeNodes.pop( main.deadNode )
GlennRC632e2892015-10-19 18:58:41 -0700420
YPZhang77badfc2016-03-09 10:28:59 -0800421 utilities.assert_equals( expect=main.TRUE,
422 actual=stepResult,
423 onpass="Successfully bring down node 3",
424 onfail="Failed to bring down node 3" )
GlennRC632e2892015-10-19 18:58:41 -0700425
GlennRC475f50d2015-10-23 15:01:09 -0700426 def CASE200( self, main ):
GlennRC632e2892015-10-19 18:58:41 -0700427 '''
YPZhangacaaf422016-07-26 09:34:03 -0700428 Bring up onos node
GlennRC632e2892015-10-19 18:58:41 -0700429 '''
GlennRC475f50d2015-10-23 15:01:09 -0700430
YPZhangacaaf422016-07-26 09:34:03 -0700431 main.case("Bring ONOS node 3 up: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700432 main.caseExplanation = "Bring node 3 back up and balance the masters"
GlennRC632e2892015-10-19 18:58:41 -0700433
434 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700435 main.log.info( "Starting node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700436 stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700437 main.log.info( "Starting onos cli" )
GlennRC475f50d2015-10-23 15:01:09 -0700438 stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700439
GlennRC475f50d2015-10-23 15:01:09 -0700440 main.log.info( "Adding previously dead node to list of active nodes" )
GlennRC632e2892015-10-19 18:58:41 -0700441 main.activeNodes.append( main.deadNode )
442
GlennRC632e2892015-10-19 18:58:41 -0700443 utilities.assert_equals( expect=main.TRUE,
444 actual=stepResult,
445 onpass="Successfully brought up onos node %s" % node,
446 onfail="Failed to bring up onos node %s" % node )
447
448
GlennRCe283c4b2016-01-07 13:04:10 -0800449 time.sleep(main.nodeSleep)
450
451 def CASE300( self, main ):
452 '''
453
454 Balancing Masters
455 '''
YPZhang85024fc2016-02-09 16:59:27 -0800456 time.sleep(main.balanceSleep)
GlennRC475f50d2015-10-23 15:01:09 -0700457 main.step( "Balancing Masters" )
GlennRCe283c4b2016-01-07 13:04:10 -0800458
GlennRC475f50d2015-10-23 15:01:09 -0700459 stepResult = main.FALSE
460 if main.activeNodes:
461 controller = main.activeNodes[0]
YPZhang924ccfe2016-01-26 14:17:30 -0800462 stepResult = utilities.retry( main.CLIs[controller].balanceMasters,
463 main.FALSE,
464 [],
465 sleep=3,
466 attempts=3 )
467
GlennRCe283c4b2016-01-07 13:04:10 -0800468 else:
469 main.log.error( "List of active nodes is empty" )
GlennRC475f50d2015-10-23 15:01:09 -0700470 utilities.assert_equals( expect=main.TRUE,
471 actual=stepResult,
472 onpass="Balance masters was successfull",
473 onfail="Failed to balance masters")
GlennRC475f50d2015-10-23 15:01:09 -0700474 time.sleep(main.balanceSleep)
475
GlennRC632e2892015-10-19 18:58:41 -0700476 def CASE1000( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700477 '''
478 Report errors/warnings/exceptions
479 '''
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700480 # Compare the slowest Node through total time of each node
481 slowestNode = 0
482 slowestTotalTime = 0
483 # Second capture
484 for i in range( 3 ):
485 # Calculate total time
486 main.allinfo[ 1 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
487 # Compare the total time
488 if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
489 slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
490 slowestNode = i
491 # Calculate switch connection time
492 main.allinfo[ 1 ][ 'info' + str( i )][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'start' ], 'last', index=i, funcMode='TD' )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800493 # Calculate the time from last switch connection to the last role request
494 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
495 # Calculate the time from the last role request to the last topology
496 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700497 # Calculate the disconnecti rate
498 main.allinfo[ 1 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ],'num', index=i, funcMode='DR' )
499
500 if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
501 main.log.error( "The results of two capture are different!" )
502 main.log.debug( "The data is " + str( main.allinfo ) )
503 if main.writeData != -1:
504 main.log.info( "Write the date into database" )
505 # write the date into data base
506 with open( main.dbFilePath, "a" ) as dbFile:
507 temp = str( main.currScale )
508 temp += ",'baremetal1'"
509 # put result from second capture into data base
510 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'totalTime' ] )
511 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'swConnection' ] )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800512 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastSwToLastRr' ] )
513 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastRrToLastTopology' ] )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700514 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'disconnectRate' ] )
515 temp += "\n"
516 dbFile.write( temp )
517 else:
518 main.log.error( "The data from log is wrong!" )
519 main.writeData = 1
GlennRC475f50d2015-10-23 15:01:09 -0700520 main.case( "Checking logs for errors, warnings, and exceptions" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700521 main.log.info( "Error report: \n" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700522 main.ONOSbench.logReport( main.ONOSip[ 0 ],
GlennRC475f50d2015-10-23 15:01:09 -0700523 [ "INFO",
524 "FOLLOWER",
525 "WARN",
526 "flow",
527 "ERROR",
528 "Except" ],
Chiyu Cheng899621b2016-11-14 11:14:48 -0800529 "s" )