blob: a94dfe8f8353d053aced60fd5aabf3d7ecfe3dc8 [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
You Wang5fa68182017-04-17 13:08:13 -0700158 main.commit = main.ONOSbench.getVersion(report=True)
159 main.commit = main.commit.split(" ")[1]
160
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700161 main.case( "Starting up " + str( main.numCtrls ) +
162 " node(s) ONOS cluster" )
GlennRC632e2892015-10-19 18:58:41 -0700163 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
164 " node(s) ONOS cluster"
165
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700166 #kill off all onos processes
167 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800168 " before initiating environment setup" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700169
GlennRC632e2892015-10-19 18:58:41 -0700170 for i in range( main.numCtrls ):
You Wangb98a9fa2017-02-15 17:27:42 -0800171 main.ONOSbench.onosStop( main.ONOSip[ i ] )
172 main.ONOSbench.onosKill( main.ONOSip[ i ] )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700173
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700174 tempOnosIp = []
175 for i in range( main.numCtrls ):
176 tempOnosIp.append( main.ONOSip[i] )
177
178 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
179 "temp", main.Mininet1.ip_address,
GlennRC632e2892015-10-19 18:58:41 -0700180 main.apps, tempOnosIp )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700181
182 main.step( "Apply cell to environment" )
183 cellResult = main.ONOSbench.setCell( "temp" )
184 verifyResult = main.ONOSbench.verifyCell()
185 stepResult = cellResult and verifyResult
186 utilities.assert_equals( expect=main.TRUE,
187 actual=stepResult,
188 onpass="Successfully applied cell to " + \
189 "environment",
190 onfail="Failed to apply cell to environment " )
191
192 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700193 packageResult = main.ONOSbench.buckBuild()
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700194 stepResult = packageResult
195 utilities.assert_equals( expect=main.TRUE,
196 actual=stepResult,
197 onpass="Successfully created ONOS package",
198 onfail="Failed to create ONOS package" )
199
GlennRC632e2892015-10-19 18:58:41 -0700200 time.sleep( main.startUpSleep )
201 main.step( "Uninstalling ONOS package" )
202 onosUninstallResult = main.TRUE
203 for ip in main.ONOSip:
204 onosUninstallResult = onosUninstallResult and \
205 main.ONOSbench.onosUninstall( nodeIp=ip )
206 stepResult = onosUninstallResult
207 utilities.assert_equals( expect=main.TRUE,
208 actual=stepResult,
209 onpass="Successfully uninstalled ONOS package",
210 onfail="Failed to uninstall ONOS package" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700211
GlennRC632e2892015-10-19 18:58:41 -0700212 time.sleep( main.startUpSleep )
213 main.step( "Installing ONOS package" )
214 onosInstallResult = main.TRUE
215 for i in range( main.numCtrls ):
216 onosInstallResult = onosInstallResult and \
217 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
218 stepResult = onosInstallResult
219 utilities.assert_equals( expect=main.TRUE,
220 actual=stepResult,
221 onpass="Successfully installed ONOS package",
222 onfail="Failed to install ONOS package" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700223
You Wangf5de25b2017-01-06 15:13:01 -0800224 main.step( "Set up ONOS secure SSH" )
225 secureSshResult = main.TRUE
226 for i in range( int( main.numCtrls ) ):
227 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
228 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
229 onpass="Test step PASS",
230 onfail="Test step FAIL" )
231
GlennRC632e2892015-10-19 18:58:41 -0700232 time.sleep( main.startUpSleep )
233 main.step( "Starting ONOS service" )
234 stopResult = main.TRUE
235 startResult = main.TRUE
236 onosIsUp = main.TRUE
237
238 for i in range( main.numCtrls ):
239 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
240 if onosIsUp == main.TRUE:
241 main.log.report( "ONOS instance is up and ready" )
242 else:
243 main.log.report( "ONOS instance may not be up, stop and " +
244 "start ONOS again " )
245
246 for i in range( main.numCtrls ):
247 stopResult = stopResult and \
248 main.ONOSbench.onosStop( main.ONOSip[ i ] )
249 for i in range( main.numCtrls ):
250 startResult = startResult and \
251 main.ONOSbench.onosStart( main.ONOSip[ i ] )
252 stepResult = onosIsUp and stopResult and startResult
253 utilities.assert_equals( expect=main.TRUE,
254 actual=stepResult,
255 onpass="ONOS service is ready",
256 onfail="ONOS service did not start properly" )
257
258 main.step( "Start ONOS cli" )
259 cliResult = main.TRUE
YPZhang29c2d642016-06-22 16:15:19 -0700260 main.activeNodes = []
GlennRC632e2892015-10-19 18:58:41 -0700261 for i in range( main.numCtrls ):
262 cliResult = cliResult and \
263 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
264 main.activeNodes.append( i )
265 stepResult = cliResult
266 utilities.assert_equals( expect=main.TRUE,
267 actual=stepResult,
268 onpass="Successfully start ONOS cli",
269 onfail="Failed to start ONOS cli" )
YPZhang29c2d642016-06-22 16:15:19 -0700270 time.sleep( main.startUpSleep )
GlennRC632e2892015-10-19 18:58:41 -0700271
272 def CASE10( self, main ):
273 """
YPZhang85024fc2016-02-09 16:59:27 -0800274 Starting up torus topology
GlennRC632e2892015-10-19 18:58:41 -0700275 """
GlennRC475f50d2015-10-23 15:01:09 -0700276
277 main.case( "Starting up Mininet and verifying topology" )
278 main.caseExplanation = "Starting Mininet with a scalling topology and " +\
279 "comparing topology elements between Mininet and ONOS"
GlennRC475f50d2015-10-23 15:01:09 -0700280 if main.topoScale:
GlennRC90d43952015-10-27 11:36:15 -0700281 main.currScale = main.topoScale.pop(0)
GlennRC475f50d2015-10-23 15:01:09 -0700282 else: main.log.error( "topology scale is empty" )
GlennRC90d43952015-10-27 11:36:15 -0700283 main.step( "Starting up TORUS %sx%s topology" % (main.currScale, main.currScale) )
GlennRC475f50d2015-10-23 15:01:09 -0700284
285 main.log.info( "Constructing Mininet command" )
YPZhangacaaf422016-07-26 09:34:03 -0700286 mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
287 " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
GlennRC475f50d2015-10-23 15:01:09 -0700288 for i in range( main.numCtrls ):
289 mnCmd += " --controller remote,ip=" + main.ONOSip[ i ]
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700290 stepResult = main.Mininet1.startNet( mnCmd=mnCmd )
GlennRC632e2892015-10-19 18:58:41 -0700291 utilities.assert_equals( expect=main.TRUE,
292 actual=stepResult,
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700293 onpass=main.topoName +
GlennRC632e2892015-10-19 18:58:41 -0700294 " topology started successfully",
295 onfail=main.topoName +
296 " topology failed to start" )
297
GlennRCe283c4b2016-01-07 13:04:10 -0800298 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800299 main.log.info( "Clean up Tshark" )
300 with open(main.tsharkResultPath, "w" ) as tshark:
301 tshark.write( "" )
302 main.log.info( "Starting Tshark capture" )
303 main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' )
Chiyu Cheng81499422016-11-09 11:04:23 -0800304 main.CLIs[ 0 ].activateApp( "org.onosproject.openflow" )
305 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800306 main.log.info( "Stop Tshark" )
307 main.ONOSbench.tsharkStop()
308 main.log.info( "Get role request time" )
309 with open( main.tsharkResultPath, "r" ) as resultFile:
310 resultText = resultFile.readlines()
311 resultFile.close()
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700312
GlennRC475f50d2015-10-23 15:01:09 -0700313 def CASE11( self, main ):
314 """
YPZhangacaaf422016-07-26 09:34:03 -0700315 Compare topo, and sending Arping package
YPZhang85024fc2016-02-09 16:59:27 -0800316 if the topology is same, then Pass.
GlennRC475f50d2015-10-23 15:01:09 -0700317 """
318 import json
YPZhangacaaf422016-07-26 09:34:03 -0700319 import time
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700320 # First capture
321 for i in range( 3 ):
322 # Calculate total time
323 main.allinfo[ 0 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
324 # Calculate switch connection time
325 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 -0800326 # Calculate the time from last switch connection to the last role request
327 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
328 # Calculate the time from the last role request to the last topology
329 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700330 # Calculate the disconnecti rate
331 main.allinfo[ 0 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ], 'num', index=i, funcMode='DR' )
332 main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) )
GlennRC475f50d2015-10-23 15:01:09 -0700333
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700334 main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) )
YPZhang85024fc2016-02-09 16:59:27 -0800335 main.caseExplanation = "Pinging all hosts and comparing topology " +\
GlennRC475f50d2015-10-23 15:01:09 -0700336 "elements between Mininet and ONOS"
GlennRCe283c4b2016-01-07 13:04:10 -0800337
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700338 main.log.info( "Gathering topology information")
YPZhang85024fc2016-02-09 16:59:27 -0800339 time.sleep( main.MNSleep )
YPZhang85024fc2016-02-09 16:59:27 -0800340 stepResult = main.TRUE
GlennRC475f50d2015-10-23 15:01:09 -0700341 main.step( "Comparing MN topology to ONOS topology" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700342 compareRetry = 0
343 while compareRetry < 3:
YPZhang81a7d4e2016-04-18 13:10:17 -0700344 #While loop for retry
345 devices = main.topo.getAllDevices( main )
YPZhang81a7d4e2016-04-18 13:10:17 -0700346 ports = main.topo.getAllPorts( main )
347 links = main.topo.getAllLinks( main)
YPZhang81a7d4e2016-04-18 13:10:17 -0700348 mnSwitches = main.Mininet1.getSwitches()
349 mnLinks = main.Mininet1.getLinks(timeout=180)
GlennRC475f50d2015-10-23 15:01:09 -0700350
YPZhang81a7d4e2016-04-18 13:10:17 -0700351 for controller in range(len(main.activeNodes)):
YPZhangacaaf422016-07-26 09:34:03 -0700352 # controllerStr = str( main.activeNodes[controller] + 1 )
353 if devices[ controller ] and ports[ controller ] and \
354 "Error" not in devices[ controller ] and \
355 "Error" not in ports[ controller ]:
YPZhang81a7d4e2016-04-18 13:10:17 -0700356 currentDevicesResult = main.Mininet1.compareSwitches(
357 mnSwitches,
358 json.loads( devices[ controller ] ),
359 json.loads( ports[ controller ] ) )
360 else:
361 currentDevicesResult = main.FALSE
362
363 if links[ controller ] and "Error" not in links[ controller ]:
364 currentLinksResult = main.Mininet1.compareLinks(
365 mnSwitches, mnLinks,
366 json.loads( links[ controller ] ) )
367 else:
368 currentLinksResult = main.FALSE
369
YPZhangacaaf422016-07-26 09:34:03 -0700370 stepResult = stepResult and currentDevicesResult and currentLinksResult
YPZhang81a7d4e2016-04-18 13:10:17 -0700371 if stepResult:
372 break
373 compareRetry += 1
YPZhangacaaf422016-07-26 09:34:03 -0700374 utilities.assert_equals(expect=main.TRUE,
375 actual=stepResult,
376 onpass=" Topology match Mininet",
377 onfail="ONOS Topology doesn't match Mininet")
YPZhang81a7d4e2016-04-18 13:10:17 -0700378
YPZhangacaaf422016-07-26 09:34:03 -0700379 if stepResult:
380 if main.hostDiscover:
381 hostList = []
382 for i in range( 1, int( main.currScale ) + 1 ):
383 for j in range( 1, int( main.currScale ) + 1) :
384 # Generate host list
385 hoststr = "h" + str(i) + "x" + str(j)
386 hostList.append(hoststr)
387 for i in range( len(hostList) ):
388 totalHost = main.topo.sendArpPackage( main, hostList[i] )
389 time.sleep( main.hostDiscoverSleep )
390 if totalHost < 0:
391 # if totalHost less than 0 which means dependence function has exception.
392 main.log.info( "Error when discover host!" )
393 break
394 if totalHost == int( main.currScale ) * int( main.currScale ):
395 main.log.info( "Discovered all hosts" )
You Wang7bb9c462016-08-10 14:18:16 -0700396 stepResult = stepResult and main.TRUE
YPZhangacaaf422016-07-26 09:34:03 -0700397 else:
398 main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
You Wang7bb9c462016-08-10 14:18:16 -0700399 stepResult = main.FALSE
YPZhangacaaf422016-07-26 09:34:03 -0700400 utilities.assert_equals(expect=main.TRUE,
401 actual=stepResult,
402 onpass=" Topology match Mininet",
403 onfail="ONOS Topology doesn't match Mininet")
404 main.log.info( "Finished this iteration, continue to scale next topology." )
YPZhang81a7d4e2016-04-18 13:10:17 -0700405 else:
YPZhangacaaf422016-07-26 09:34:03 -0700406 main.log.info( "Clean up and exit TestON. Finished this test." )
407 main.cleanup()
408 main.exit()
GlennRC475f50d2015-10-23 15:01:09 -0700409
GlennRC632e2892015-10-19 18:58:41 -0700410 def CASE100( self, main ):
411 '''
YPZhang81a7d4e2016-04-18 13:10:17 -0700412 Bring Down node 3
GlennRC632e2892015-10-19 18:58:41 -0700413 '''
GlennRC475f50d2015-10-23 15:01:09 -0700414
YPZhangacaaf422016-07-26 09:34:03 -0700415 main.case("Bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700416 main.caseExplanation = "Balance masters to make sure " +\
417 "each controller has some devices and " +\
418 "stop ONOS node 3 service. "
419
GlennRC475f50d2015-10-23 15:01:09 -0700420 stepResult = main.FALSE
GlennRCed2122e2015-10-21 14:38:46 -0700421 main.step( "Bringing down node 3" )
GlennRCed2122e2015-10-21 14:38:46 -0700422 # Always bring down the third node
423 main.deadNode = 2
GlennRCed2122e2015-10-21 14:38:46 -0700424 # Printing purposes
GlennRC632e2892015-10-19 18:58:41 -0700425 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700426 main.log.info( "Stopping node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700427 stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] )
GlennRC475f50d2015-10-23 15:01:09 -0700428 main.log.info( "Removing dead node from list of active nodes" )
429 main.activeNodes.pop( main.deadNode )
GlennRC632e2892015-10-19 18:58:41 -0700430
YPZhang77badfc2016-03-09 10:28:59 -0800431 utilities.assert_equals( expect=main.TRUE,
432 actual=stepResult,
433 onpass="Successfully bring down node 3",
434 onfail="Failed to bring down node 3" )
GlennRC632e2892015-10-19 18:58:41 -0700435
GlennRC475f50d2015-10-23 15:01:09 -0700436 def CASE200( self, main ):
GlennRC632e2892015-10-19 18:58:41 -0700437 '''
YPZhangacaaf422016-07-26 09:34:03 -0700438 Bring up onos node
GlennRC632e2892015-10-19 18:58:41 -0700439 '''
GlennRC475f50d2015-10-23 15:01:09 -0700440
YPZhangacaaf422016-07-26 09:34:03 -0700441 main.case("Bring ONOS node 3 up: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700442 main.caseExplanation = "Bring node 3 back up and balance the masters"
GlennRC632e2892015-10-19 18:58:41 -0700443
444 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700445 main.log.info( "Starting node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700446 stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700447 main.log.info( "Starting onos cli" )
GlennRC475f50d2015-10-23 15:01:09 -0700448 stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700449
GlennRC475f50d2015-10-23 15:01:09 -0700450 main.log.info( "Adding previously dead node to list of active nodes" )
GlennRC632e2892015-10-19 18:58:41 -0700451 main.activeNodes.append( main.deadNode )
452
GlennRC632e2892015-10-19 18:58:41 -0700453 utilities.assert_equals( expect=main.TRUE,
454 actual=stepResult,
455 onpass="Successfully brought up onos node %s" % node,
456 onfail="Failed to bring up onos node %s" % node )
457
458
GlennRCe283c4b2016-01-07 13:04:10 -0800459 time.sleep(main.nodeSleep)
460
461 def CASE300( self, main ):
462 '''
463
464 Balancing Masters
465 '''
YPZhang85024fc2016-02-09 16:59:27 -0800466 time.sleep(main.balanceSleep)
GlennRC475f50d2015-10-23 15:01:09 -0700467 main.step( "Balancing Masters" )
GlennRCe283c4b2016-01-07 13:04:10 -0800468
GlennRC475f50d2015-10-23 15:01:09 -0700469 stepResult = main.FALSE
470 if main.activeNodes:
471 controller = main.activeNodes[0]
YPZhang924ccfe2016-01-26 14:17:30 -0800472 stepResult = utilities.retry( main.CLIs[controller].balanceMasters,
473 main.FALSE,
474 [],
475 sleep=3,
476 attempts=3 )
477
GlennRCe283c4b2016-01-07 13:04:10 -0800478 else:
479 main.log.error( "List of active nodes is empty" )
GlennRC475f50d2015-10-23 15:01:09 -0700480 utilities.assert_equals( expect=main.TRUE,
481 actual=stepResult,
482 onpass="Balance masters was successfull",
483 onfail="Failed to balance masters")
GlennRC475f50d2015-10-23 15:01:09 -0700484 time.sleep(main.balanceSleep)
485
GlennRC632e2892015-10-19 18:58:41 -0700486 def CASE1000( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700487 '''
488 Report errors/warnings/exceptions
489 '''
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700490 # Compare the slowest Node through total time of each node
491 slowestNode = 0
492 slowestTotalTime = 0
493 # Second capture
494 for i in range( 3 ):
495 # Calculate total time
496 main.allinfo[ 1 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
497 # Compare the total time
498 if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
499 slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
500 slowestNode = i
501 # Calculate switch connection time
502 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 -0800503 # Calculate the time from last switch connection to the last role request
504 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
505 # Calculate the time from the last role request to the last topology
506 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700507 # Calculate the disconnecti rate
508 main.allinfo[ 1 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ],'num', index=i, funcMode='DR' )
509
510 if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
511 main.log.error( "The results of two capture are different!" )
512 main.log.debug( "The data is " + str( main.allinfo ) )
513 if main.writeData != -1:
514 main.log.info( "Write the date into database" )
515 # write the date into data base
516 with open( main.dbFilePath, "a" ) as dbFile:
517 temp = str( main.currScale )
518 temp += ",'baremetal1'"
519 # put result from second capture into data base
520 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'totalTime' ] )
521 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'swConnection' ] )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800522 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastSwToLastRr' ] )
523 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastRrToLastTopology' ] )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700524 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'disconnectRate' ] )
525 temp += "\n"
526 dbFile.write( temp )
527 else:
528 main.log.error( "The data from log is wrong!" )
529 main.writeData = 1
GlennRC475f50d2015-10-23 15:01:09 -0700530 main.case( "Checking logs for errors, warnings, and exceptions" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700531 main.log.info( "Error report: \n" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700532 main.ONOSbench.logReport( main.ONOSip[ 0 ],
GlennRC475f50d2015-10-23 15:01:09 -0700533 [ "INFO",
534 "FOLLOWER",
535 "WARN",
536 "flow",
537 "ERROR",
538 "Except" ],
Chiyu Cheng899621b2016-11-14 11:14:48 -0800539 "s" )