blob: 5fd051cd597e4a1076c927f1ecf78fd4f2c2b0d3 [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
GlennRC632e2892015-10-19 18:58:41 -0700122
123 def CASE2( self, main):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700124 """
125 - Set up cell
126 - Create cell file
127 - Set cell file
128 - Verify cell file
129 - Kill ONOS process
130 - Uninstall ONOS cluster
131 - Verify ONOS start up
132 - Install ONOS cluster
133 - Connect to cli
134 """
YPZhangacaaf422016-07-26 09:34:03 -0700135 import time
YPZhang29c2d642016-06-22 16:15:19 -0700136 main.log.info( "Checking if mininet is already running" )
137 if len( main.topoScale ) < main.topoScaleSize:
138 main.log.info( "Mininet is already running. Stopping mininet." )
139 main.Mininet1.stopNet()
140 time.sleep(main.MNSleep)
141 else:
142 main.log.info( "Mininet was not running" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700143
You Wang5fa68182017-04-17 13:08:13 -0700144 main.commit = main.ONOSbench.getVersion(report=True)
145 main.commit = main.commit.split(" ")[1]
146
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700147 main.case( "Starting up " + str( main.numCtrls ) +
148 " node(s) ONOS cluster" )
GlennRC632e2892015-10-19 18:58:41 -0700149 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
150 " node(s) ONOS cluster"
151
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700152 #kill off all onos processes
153 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800154 " before initiating environment setup" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700155
GlennRC632e2892015-10-19 18:58:41 -0700156 for i in range( main.numCtrls ):
You Wangb98a9fa2017-02-15 17:27:42 -0800157 main.ONOSbench.onosStop( main.ONOSip[ i ] )
158 main.ONOSbench.onosKill( main.ONOSip[ i ] )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700159
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700160 tempOnosIp = []
161 for i in range( main.numCtrls ):
162 tempOnosIp.append( main.ONOSip[i] )
163
164 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
165 "temp", main.Mininet1.ip_address,
Devin Lim461f0872017-06-05 16:49:33 -0700166 main.apps, tempOnosIp, main.ONOScli1.user_name )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700167
168 main.step( "Apply cell to environment" )
169 cellResult = main.ONOSbench.setCell( "temp" )
170 verifyResult = main.ONOSbench.verifyCell()
171 stepResult = cellResult and verifyResult
172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
174 onpass="Successfully applied cell to " + \
175 "environment",
176 onfail="Failed to apply cell to environment " )
177
178 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700179 packageResult = main.ONOSbench.buckBuild()
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700180 stepResult = packageResult
181 utilities.assert_equals( expect=main.TRUE,
182 actual=stepResult,
183 onpass="Successfully created ONOS package",
184 onfail="Failed to create ONOS package" )
185
GlennRC632e2892015-10-19 18:58:41 -0700186 time.sleep( main.startUpSleep )
187 main.step( "Uninstalling ONOS package" )
188 onosUninstallResult = main.TRUE
189 for ip in main.ONOSip:
190 onosUninstallResult = onosUninstallResult and \
191 main.ONOSbench.onosUninstall( nodeIp=ip )
192 stepResult = onosUninstallResult
193 utilities.assert_equals( expect=main.TRUE,
194 actual=stepResult,
195 onpass="Successfully uninstalled ONOS package",
196 onfail="Failed to uninstall ONOS package" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700197
GlennRC632e2892015-10-19 18:58:41 -0700198 time.sleep( main.startUpSleep )
199 main.step( "Installing ONOS package" )
200 onosInstallResult = main.TRUE
201 for i in range( main.numCtrls ):
202 onosInstallResult = onosInstallResult and \
203 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
204 stepResult = onosInstallResult
205 utilities.assert_equals( expect=main.TRUE,
206 actual=stepResult,
207 onpass="Successfully installed ONOS package",
208 onfail="Failed to install ONOS package" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700209
You Wangf5de25b2017-01-06 15:13:01 -0800210 main.step( "Set up ONOS secure SSH" )
211 secureSshResult = main.TRUE
212 for i in range( int( main.numCtrls ) ):
213 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
214 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
215 onpass="Test step PASS",
216 onfail="Test step FAIL" )
217
GlennRC632e2892015-10-19 18:58:41 -0700218 time.sleep( main.startUpSleep )
219 main.step( "Starting ONOS service" )
220 stopResult = main.TRUE
221 startResult = main.TRUE
222 onosIsUp = main.TRUE
223
224 for i in range( main.numCtrls ):
225 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
226 if onosIsUp == main.TRUE:
227 main.log.report( "ONOS instance is up and ready" )
228 else:
229 main.log.report( "ONOS instance may not be up, stop and " +
230 "start ONOS again " )
231
232 for i in range( main.numCtrls ):
233 stopResult = stopResult and \
234 main.ONOSbench.onosStop( main.ONOSip[ i ] )
235 for i in range( main.numCtrls ):
236 startResult = startResult and \
237 main.ONOSbench.onosStart( main.ONOSip[ i ] )
238 stepResult = onosIsUp and stopResult and startResult
239 utilities.assert_equals( expect=main.TRUE,
240 actual=stepResult,
241 onpass="ONOS service is ready",
242 onfail="ONOS service did not start properly" )
243
244 main.step( "Start ONOS cli" )
245 cliResult = main.TRUE
YPZhang29c2d642016-06-22 16:15:19 -0700246 main.activeNodes = []
GlennRC632e2892015-10-19 18:58:41 -0700247 for i in range( main.numCtrls ):
248 cliResult = cliResult and \
249 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
250 main.activeNodes.append( i )
251 stepResult = cliResult
252 utilities.assert_equals( expect=main.TRUE,
253 actual=stepResult,
254 onpass="Successfully start ONOS cli",
255 onfail="Failed to start ONOS cli" )
YPZhang29c2d642016-06-22 16:15:19 -0700256 time.sleep( main.startUpSleep )
GlennRC632e2892015-10-19 18:58:41 -0700257
258 def CASE10( self, main ):
259 """
YPZhang85024fc2016-02-09 16:59:27 -0800260 Starting up torus topology
GlennRC632e2892015-10-19 18:58:41 -0700261 """
GlennRC475f50d2015-10-23 15:01:09 -0700262
263 main.case( "Starting up Mininet and verifying topology" )
264 main.caseExplanation = "Starting Mininet with a scalling topology and " +\
265 "comparing topology elements between Mininet and ONOS"
GlennRC475f50d2015-10-23 15:01:09 -0700266 if main.topoScale:
GlennRC90d43952015-10-27 11:36:15 -0700267 main.currScale = main.topoScale.pop(0)
GlennRC475f50d2015-10-23 15:01:09 -0700268 else: main.log.error( "topology scale is empty" )
GlennRC90d43952015-10-27 11:36:15 -0700269 main.step( "Starting up TORUS %sx%s topology" % (main.currScale, main.currScale) )
GlennRC475f50d2015-10-23 15:01:09 -0700270
271 main.log.info( "Constructing Mininet command" )
YPZhangacaaf422016-07-26 09:34:03 -0700272 mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
273 " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
GlennRC475f50d2015-10-23 15:01:09 -0700274 for i in range( main.numCtrls ):
275 mnCmd += " --controller remote,ip=" + main.ONOSip[ i ]
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700276 stepResult = main.Mininet1.startNet( mnCmd=mnCmd )
GlennRC632e2892015-10-19 18:58:41 -0700277 utilities.assert_equals( expect=main.TRUE,
278 actual=stepResult,
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700279 onpass=main.topoName +
GlennRC632e2892015-10-19 18:58:41 -0700280 " topology started successfully",
281 onfail=main.topoName +
282 " topology failed to start" )
283
GlennRCe283c4b2016-01-07 13:04:10 -0800284 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800285 main.log.info( "Clean up Tshark" )
286 with open(main.tsharkResultPath, "w" ) as tshark:
287 tshark.write( "" )
288 main.log.info( "Starting Tshark capture" )
289 main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' )
Chiyu Cheng81499422016-11-09 11:04:23 -0800290 main.CLIs[ 0 ].activateApp( "org.onosproject.openflow" )
291 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800292 main.log.info( "Stop Tshark" )
293 main.ONOSbench.tsharkStop()
294 main.log.info( "Get role request time" )
295 with open( main.tsharkResultPath, "r" ) as resultFile:
296 resultText = resultFile.readlines()
297 resultFile.close()
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700298
GlennRC475f50d2015-10-23 15:01:09 -0700299 def CASE11( self, main ):
300 """
YPZhangacaaf422016-07-26 09:34:03 -0700301 Compare topo, and sending Arping package
YPZhang85024fc2016-02-09 16:59:27 -0800302 if the topology is same, then Pass.
GlennRC475f50d2015-10-23 15:01:09 -0700303 """
304 import json
YPZhangacaaf422016-07-26 09:34:03 -0700305 import time
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700306 # First capture
307 for i in range( 3 ):
308 # Calculate total time
309 main.allinfo[ 0 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
310 # Calculate switch connection time
311 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 -0800312 # Calculate the time from last switch connection to the last role request
313 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
314 # Calculate the time from the last role request to the last topology
315 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700316 # Calculate the disconnecti rate
317 main.allinfo[ 0 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ], 'num', index=i, funcMode='DR' )
318 main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) )
GlennRC475f50d2015-10-23 15:01:09 -0700319
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700320 main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) )
YPZhang85024fc2016-02-09 16:59:27 -0800321 main.caseExplanation = "Pinging all hosts and comparing topology " +\
GlennRC475f50d2015-10-23 15:01:09 -0700322 "elements between Mininet and ONOS"
GlennRCe283c4b2016-01-07 13:04:10 -0800323
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700324 main.log.info( "Gathering topology information")
YPZhang85024fc2016-02-09 16:59:27 -0800325 time.sleep( main.MNSleep )
YPZhang85024fc2016-02-09 16:59:27 -0800326 stepResult = main.TRUE
GlennRC475f50d2015-10-23 15:01:09 -0700327 main.step( "Comparing MN topology to ONOS topology" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700328 compareRetry = 0
329 while compareRetry < 3:
YPZhang81a7d4e2016-04-18 13:10:17 -0700330 #While loop for retry
331 devices = main.topo.getAllDevices( main )
YPZhang81a7d4e2016-04-18 13:10:17 -0700332 ports = main.topo.getAllPorts( main )
333 links = main.topo.getAllLinks( main)
YPZhang81a7d4e2016-04-18 13:10:17 -0700334 mnSwitches = main.Mininet1.getSwitches()
335 mnLinks = main.Mininet1.getLinks(timeout=180)
GlennRC475f50d2015-10-23 15:01:09 -0700336
YPZhang81a7d4e2016-04-18 13:10:17 -0700337 for controller in range(len(main.activeNodes)):
YPZhangacaaf422016-07-26 09:34:03 -0700338 # controllerStr = str( main.activeNodes[controller] + 1 )
339 if devices[ controller ] and ports[ controller ] and \
340 "Error" not in devices[ controller ] and \
341 "Error" not in ports[ controller ]:
YPZhang81a7d4e2016-04-18 13:10:17 -0700342 currentDevicesResult = main.Mininet1.compareSwitches(
343 mnSwitches,
344 json.loads( devices[ controller ] ),
345 json.loads( ports[ controller ] ) )
346 else:
347 currentDevicesResult = main.FALSE
348
349 if links[ controller ] and "Error" not in links[ controller ]:
350 currentLinksResult = main.Mininet1.compareLinks(
351 mnSwitches, mnLinks,
352 json.loads( links[ controller ] ) )
353 else:
354 currentLinksResult = main.FALSE
355
YPZhangacaaf422016-07-26 09:34:03 -0700356 stepResult = stepResult and currentDevicesResult and currentLinksResult
YPZhang81a7d4e2016-04-18 13:10:17 -0700357 if stepResult:
358 break
359 compareRetry += 1
YPZhangacaaf422016-07-26 09:34:03 -0700360 utilities.assert_equals(expect=main.TRUE,
361 actual=stepResult,
362 onpass=" Topology match Mininet",
363 onfail="ONOS Topology doesn't match Mininet")
YPZhang81a7d4e2016-04-18 13:10:17 -0700364
YPZhangacaaf422016-07-26 09:34:03 -0700365 if stepResult:
366 if main.hostDiscover:
367 hostList = []
368 for i in range( 1, int( main.currScale ) + 1 ):
369 for j in range( 1, int( main.currScale ) + 1) :
370 # Generate host list
371 hoststr = "h" + str(i) + "x" + str(j)
372 hostList.append(hoststr)
373 for i in range( len(hostList) ):
374 totalHost = main.topo.sendArpPackage( main, hostList[i] )
375 time.sleep( main.hostDiscoverSleep )
376 if totalHost < 0:
377 # if totalHost less than 0 which means dependence function has exception.
378 main.log.info( "Error when discover host!" )
379 break
380 if totalHost == int( main.currScale ) * int( main.currScale ):
381 main.log.info( "Discovered all hosts" )
You Wang7bb9c462016-08-10 14:18:16 -0700382 stepResult = stepResult and main.TRUE
YPZhangacaaf422016-07-26 09:34:03 -0700383 else:
384 main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
You Wang7bb9c462016-08-10 14:18:16 -0700385 stepResult = main.FALSE
YPZhangacaaf422016-07-26 09:34:03 -0700386 utilities.assert_equals(expect=main.TRUE,
387 actual=stepResult,
388 onpass=" Topology match Mininet",
389 onfail="ONOS Topology doesn't match Mininet")
390 main.log.info( "Finished this iteration, continue to scale next topology." )
YPZhang81a7d4e2016-04-18 13:10:17 -0700391 else:
YPZhangacaaf422016-07-26 09:34:03 -0700392 main.log.info( "Clean up and exit TestON. Finished this test." )
393 main.cleanup()
394 main.exit()
GlennRC475f50d2015-10-23 15:01:09 -0700395
GlennRC632e2892015-10-19 18:58:41 -0700396 def CASE100( self, main ):
397 '''
YPZhang81a7d4e2016-04-18 13:10:17 -0700398 Bring Down node 3
GlennRC632e2892015-10-19 18:58:41 -0700399 '''
GlennRC475f50d2015-10-23 15:01:09 -0700400
YPZhangacaaf422016-07-26 09:34:03 -0700401 main.case("Bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700402 main.caseExplanation = "Balance masters to make sure " +\
403 "each controller has some devices and " +\
404 "stop ONOS node 3 service. "
405
GlennRC475f50d2015-10-23 15:01:09 -0700406 stepResult = main.FALSE
GlennRCed2122e2015-10-21 14:38:46 -0700407 main.step( "Bringing down node 3" )
GlennRCed2122e2015-10-21 14:38:46 -0700408 # Always bring down the third node
409 main.deadNode = 2
GlennRCed2122e2015-10-21 14:38:46 -0700410 # Printing purposes
GlennRC632e2892015-10-19 18:58:41 -0700411 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700412 main.log.info( "Stopping node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700413 stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] )
GlennRC475f50d2015-10-23 15:01:09 -0700414 main.log.info( "Removing dead node from list of active nodes" )
415 main.activeNodes.pop( main.deadNode )
GlennRC632e2892015-10-19 18:58:41 -0700416
YPZhang77badfc2016-03-09 10:28:59 -0800417 utilities.assert_equals( expect=main.TRUE,
418 actual=stepResult,
419 onpass="Successfully bring down node 3",
420 onfail="Failed to bring down node 3" )
GlennRC632e2892015-10-19 18:58:41 -0700421
GlennRC475f50d2015-10-23 15:01:09 -0700422 def CASE200( self, main ):
GlennRC632e2892015-10-19 18:58:41 -0700423 '''
YPZhangacaaf422016-07-26 09:34:03 -0700424 Bring up onos node
GlennRC632e2892015-10-19 18:58:41 -0700425 '''
GlennRC475f50d2015-10-23 15:01:09 -0700426
YPZhangacaaf422016-07-26 09:34:03 -0700427 main.case("Bring ONOS node 3 up: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700428 main.caseExplanation = "Bring node 3 back up and balance the masters"
GlennRC632e2892015-10-19 18:58:41 -0700429
430 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700431 main.log.info( "Starting node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700432 stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700433 main.log.info( "Starting onos cli" )
GlennRC475f50d2015-10-23 15:01:09 -0700434 stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700435
GlennRC475f50d2015-10-23 15:01:09 -0700436 main.log.info( "Adding previously dead node to list of active nodes" )
GlennRC632e2892015-10-19 18:58:41 -0700437 main.activeNodes.append( main.deadNode )
438
GlennRC632e2892015-10-19 18:58:41 -0700439 utilities.assert_equals( expect=main.TRUE,
440 actual=stepResult,
441 onpass="Successfully brought up onos node %s" % node,
442 onfail="Failed to bring up onos node %s" % node )
443
444
GlennRCe283c4b2016-01-07 13:04:10 -0800445 time.sleep(main.nodeSleep)
446
447 def CASE300( self, main ):
448 '''
449
450 Balancing Masters
451 '''
YPZhang85024fc2016-02-09 16:59:27 -0800452 time.sleep(main.balanceSleep)
GlennRC475f50d2015-10-23 15:01:09 -0700453 main.step( "Balancing Masters" )
GlennRCe283c4b2016-01-07 13:04:10 -0800454
GlennRC475f50d2015-10-23 15:01:09 -0700455 stepResult = main.FALSE
456 if main.activeNodes:
457 controller = main.activeNodes[0]
YPZhang924ccfe2016-01-26 14:17:30 -0800458 stepResult = utilities.retry( main.CLIs[controller].balanceMasters,
459 main.FALSE,
460 [],
461 sleep=3,
462 attempts=3 )
463
GlennRCe283c4b2016-01-07 13:04:10 -0800464 else:
465 main.log.error( "List of active nodes is empty" )
GlennRC475f50d2015-10-23 15:01:09 -0700466 utilities.assert_equals( expect=main.TRUE,
467 actual=stepResult,
468 onpass="Balance masters was successfull",
469 onfail="Failed to balance masters")
GlennRC475f50d2015-10-23 15:01:09 -0700470 time.sleep(main.balanceSleep)
471
GlennRC632e2892015-10-19 18:58:41 -0700472 def CASE1000( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700473 '''
474 Report errors/warnings/exceptions
475 '''
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700476 # Compare the slowest Node through total time of each node
477 slowestNode = 0
478 slowestTotalTime = 0
479 # Second capture
480 for i in range( 3 ):
481 # Calculate total time
482 main.allinfo[ 1 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
483 # Compare the total time
484 if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
485 slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
486 slowestNode = i
487 # Calculate switch connection time
488 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 -0800489 # Calculate the time from last switch connection to the last role request
490 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
491 # Calculate the time from the last role request to the last topology
492 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700493 # Calculate the disconnecti rate
494 main.allinfo[ 1 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ],'num', index=i, funcMode='DR' )
495
496 if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
497 main.log.error( "The results of two capture are different!" )
498 main.log.debug( "The data is " + str( main.allinfo ) )
499 if main.writeData != -1:
500 main.log.info( "Write the date into database" )
501 # write the date into data base
502 with open( main.dbFilePath, "a" ) as dbFile:
503 temp = str( main.currScale )
504 temp += ",'baremetal1'"
505 # put result from second capture into data base
506 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'totalTime' ] )
507 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'swConnection' ] )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800508 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastSwToLastRr' ] )
509 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastRrToLastTopology' ] )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700510 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'disconnectRate' ] )
511 temp += "\n"
512 dbFile.write( temp )
513 else:
514 main.log.error( "The data from log is wrong!" )
515 main.writeData = 1
GlennRC475f50d2015-10-23 15:01:09 -0700516 main.case( "Checking logs for errors, warnings, and exceptions" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700517 main.log.info( "Error report: \n" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700518 main.ONOSbench.logReport( main.ONOSip[ 0 ],
GlennRC475f50d2015-10-23 15:01:09 -0700519 [ "INFO",
520 "FOLLOWER",
521 "WARN",
522 "flow",
523 "ERROR",
524 "Except" ],
Chiyu Cheng899621b2016-11-14 11:14:48 -0800525 "s" )