blob: 923f056e647ba7ff04e0ad42539e79408991d718 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
kelvin-onlab1d381fe2015-07-14 16:24:56 -070021# Testing network scalability, this test suite scales up a network topology
22# using mininet and verifies ONOS stability
23
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070024
GlennRC1c5df3c2015-08-27 16:12:09 -070025class SCPFscaleTopo:
kelvin-onlab1d381fe2015-07-14 16:24:56 -070026
27 def __init__( self ):
28 self.default = ''
29
30 def CASE1( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -070031 import os
32 import imp
kelvin-onlab1d381fe2015-07-14 16:24:56 -070033 """
34 - Construct tests variables
35 - GIT ( optional )
36 - Checkout ONOS master branch
37 - Pull latest ONOS code
38 - Building ONOS ( optional )
39 - Install ONOS package
40 - Build ONOS package
41 """
Devin Lim58046fa2017-07-05 16:55:00 -070042 try:
43 from tests.dependencies.ONOSSetup import ONOSSetup
44 main.testSetUp = ONOSSetup()
45 except ImportError:
46 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070047 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070048 main.testSetUp.envSetupDescription()
kelvin-onlab1d381fe2015-07-14 16:24:56 -070049 stepResult = main.FALSE
Devin Lim58046fa2017-07-05 16:55:00 -070050 try:
51 # The variable to decide if the data should be written into data base.
52 # 1 means Yes and -1 means No.
53 main.writeData = 1
54 main.searchTerm = main.params[ 'SearchTerm' ]
55 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
56 main.dependencyPath = main.testOnDirectory + \
57 main.params[ 'DEPENDENCY' ][ 'path' ]
58 main.tsharkResultPath = main.params[ 'TsharkPath' ]
Devin Lim142b5342017-07-20 15:22:39 -070059 main.roleRequest = main.params[ 'SearchTerm' ][ 'roleRequest' ]
Devin Lim58046fa2017-07-05 16:55:00 -070060 main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
61 main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ]
Devin Lim58046fa2017-07-05 16:55:00 -070062 main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," )
63 main.topoScaleSize = len( main.topoScale )
64 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
65 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
66 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
67 main.topoCmpAttempts = int( main.params[ 'ATTEMPTS' ][ 'topoCmp' ] )
68 main.pingallAttempts = int( main.params[ 'ATTEMPTS' ][ 'pingall' ] )
69 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
70 main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] )
71 main.nodeSleep = int( main.params[ 'SLEEP' ][ 'nodeSleep' ] )
72 main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] )
73 main.MNSleep = int( main.params[ 'SLEEP' ][ 'MNsleep' ] )
74 main.pingTimeout = float( main.params[ 'TIMEOUT' ][ 'pingall' ] )
75 main.hostDiscover = main.params[ 'TOPOLOGY' ][ 'host' ]
Devin Lim142b5342017-07-20 15:22:39 -070076 main.hostDiscoverSleep = float( main.params[ 'SLEEP' ][ 'host' ] )
Devin Lima7cfdbd2017-09-29 15:02:22 -070077 main.basicMNTime = int( main.params[ 'TIMEOUT' ][ 'basicMininet' ] )
78 main.startNetTime = int( main.params[ 'TIMEOUT' ][ 'startNet' ] )
79 main.stopNetTime = int( main.params[ 'TIMEOUT' ][ 'stopNet' ] )
80 main.MNupdateTime = int( main.params[ 'TIMEOUT' ][ 'update' ] )
81 main.MNLinksTime = int( main.params[ 'TIMEOUT' ][ 'links' ] )
82 main.currScale = None
83 main.threadID = 0
Devin Lim58046fa2017-07-05 16:55:00 -070084 if main.hostDiscover == 'True':
85 main.hostDiscover = True
86 else:
87 main.hostDiscover = False
Devin Lim142b5342017-07-20 15:22:39 -070088 main.homeDir = os.path.expanduser( '~' )
Devin Lim58046fa2017-07-05 16:55:00 -070089 main.hostsData = {}
Chiyu Chengb8c2c842016-10-05 12:40:49 -070090
Devin Lim58046fa2017-07-05 16:55:00 -070091 stepResult = main.testSetUp.envSetup()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070092 main.allinfo = {} # The dictionary to record all the data from karaf.log
Chiyu Cheng899621b2016-11-14 11:14:48 -080093
Devin Lim58046fa2017-07-05 16:55:00 -070094 for i in range( 2 ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070095 main.allinfo[ i ] = {}
96 for w in range( 3 ):
Devin Lim58046fa2017-07-05 16:55:00 -070097 # Totaltime: the time from the new switchConnection to its end
98 # swConnection: the time from the first new switchConnection to the last new switchConnection
99 # lastSwToLastRr: the time from the last new switchConnection to the last role request
100 # lastRrToLastTopology: the time form the last role request to the last topology
101 # disconnectRate: the rate that shows how many switch disconnect after connection
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700102 main.allinfo[ i ][ 'info' + str( w ) ] = { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
Chiyu Cheng899621b2016-11-14 11:14:48 -0800103
Devin Lim58046fa2017-07-05 16:55:00 -0700104 main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
105 main.log.info( "Create Database file " + main.dbFilePath )
Devin Lim142b5342017-07-20 15:22:39 -0700106 resultDB = open( main.dbFilePath, 'w+' )
Devin Lim58046fa2017-07-05 16:55:00 -0700107 resultDB.close()
Chiyu Cheng899621b2016-11-14 11:14:48 -0800108
Devin Lim58046fa2017-07-05 16:55:00 -0700109 main.scaleTopoFunction = imp.load_source( wrapperFile2,
110 main.dependencyPath +
111 wrapperFile2 +
112 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700113
Devin Lim58046fa2017-07-05 16:55:00 -0700114 main.topo = imp.load_source( wrapperFile3,
115 main.dependencyPath +
116 wrapperFile3 +
117 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700118
Devin Lim58046fa2017-07-05 16:55:00 -0700119 main.ONOSbench.scp( main.Mininet1,
120 main.dependencyPath +
121 main.multiovs,
122 main.Mininet1.home,
123 direction="to" )
124 except Exception as e:
125 main.testSetUp.envSetupException( e )
126 main.testSetUp.evnSetupConclusion( stepResult )
127 main.commit = main.commit.split( " " )[ 1 ]
GlennRC632e2892015-10-19 18:58:41 -0700128
Devin Lim142b5342017-07-20 15:22:39 -0700129 def CASE2( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700130 """
131 - Set up cell
132 - Create cell file
133 - Set cell file
134 - Verify cell file
135 - Kill ONOS process
136 - Uninstall ONOS cluster
137 - Verify ONOS start up
138 - Install ONOS cluster
139 - Connect to cli
140 """
YPZhangacaaf422016-07-26 09:34:03 -0700141 import time
Devin Lima7cfdbd2017-09-29 15:02:22 -0700142 main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster )
143
144 def CASE3( self, main ):
145 """
146 cleanup mininet.
147 """
Devin Lim58046fa2017-07-05 16:55:00 -0700148 try:
149 from tests.dependencies.utils import Utils
150 except ImportError:
151 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700152 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700153 try:
154 main.Utils
155 except ( NameError, AttributeError ):
156 main.Utils = Utils()
Devin Lima7cfdbd2017-09-29 15:02:22 -0700157 main.Utils.mininetCleanup( main.Mininet1, exitTimeout=main.basicMNTime + ( int( main.currScale ) if main.currScale is not None
158 else 1 ) * main.stopNetTime )
GlennRC632e2892015-10-19 18:58:41 -0700159
160 def CASE10( self, main ):
161 """
YPZhang85024fc2016-02-09 16:59:27 -0800162 Starting up torus topology
GlennRC632e2892015-10-19 18:58:41 -0700163 """
GlennRC475f50d2015-10-23 15:01:09 -0700164 main.case( "Starting up Mininet and verifying topology" )
165 main.caseExplanation = "Starting Mininet with a scalling topology and " +\
166 "comparing topology elements between Mininet and ONOS"
GlennRC475f50d2015-10-23 15:01:09 -0700167 if main.topoScale:
Devin Lim142b5342017-07-20 15:22:39 -0700168 main.currScale = main.topoScale.pop( 0 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700169 else:
170 main.log.error( "topology scale is empty" )
Devin Lim142b5342017-07-20 15:22:39 -0700171 main.step( "Starting up TORUS %sx%s topology" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700172
173 main.log.info( "Constructing Mininet command" )
YPZhangacaaf422016-07-26 09:34:03 -0700174 mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
175 " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
Devin Lim142b5342017-07-20 15:22:39 -0700176 for ctrl in main.Cluster.runningNodes:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700177 mnCmd += " --controller remote,ip=" + ctrl.ipAddress
Devin Lima7cfdbd2017-09-29 15:02:22 -0700178 stepResult = main.Mininet1.startNet( mnCmd=mnCmd, timeout=( main.basicMNTime + int( main.currScale ) * main.startNetTime ) )
GlennRC632e2892015-10-19 18:58:41 -0700179 utilities.assert_equals( expect=main.TRUE,
180 actual=stepResult,
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700181 onpass=main.topoName +
GlennRC632e2892015-10-19 18:58:41 -0700182 " topology started successfully",
183 onfail=main.topoName +
184 " topology failed to start" )
185
GlennRCe283c4b2016-01-07 13:04:10 -0800186 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800187 main.log.info( "Clean up Tshark" )
Devin Lim142b5342017-07-20 15:22:39 -0700188 with open( main.tsharkResultPath, "w" ) as tshark:
Chiyu Cheng899621b2016-11-14 11:14:48 -0800189 tshark.write( "" )
190 main.log.info( "Starting Tshark capture" )
191 main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' )
Devin Lim142b5342017-07-20 15:22:39 -0700192 main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.openflow" )
Chiyu Cheng81499422016-11-09 11:04:23 -0800193 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800194 main.log.info( "Stop Tshark" )
195 main.ONOSbench.tsharkStop()
196 main.log.info( "Get role request time" )
197 with open( main.tsharkResultPath, "r" ) as resultFile:
198 resultText = resultFile.readlines()
199 resultFile.close()
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700200
GlennRC475f50d2015-10-23 15:01:09 -0700201 def CASE11( self, main ):
202 """
YPZhangacaaf422016-07-26 09:34:03 -0700203 Compare topo, and sending Arping package
YPZhang85024fc2016-02-09 16:59:27 -0800204 if the topology is same, then Pass.
GlennRC475f50d2015-10-23 15:01:09 -0700205 """
206 import json
YPZhangacaaf422016-07-26 09:34:03 -0700207 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700208 try:
209 from tests.dependencies.topology import Topology
210 except ImportError:
211 main.log.error( "Topology not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700212 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700213 try:
214 main.topoRelated
215 except ( NameError, AttributeError ):
216 main.topoRelated = Topology()
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700217 # First capture
Devin Lima7cfdbd2017-09-29 15:02:22 -0700218
219 main.postResult = True
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700220 for i in range( 3 ):
221 # Calculate total time
Devin Lim142b5342017-07-20 15:22:39 -0700222 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700223 # Calculate switch connection time
Devin Lim142b5342017-07-20 15:22:39 -0700224 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 -0800225 # Calculate the time from last switch connection to the last role request
Devin Lim142b5342017-07-20 15:22:39 -0700226 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800227 # Calculate the time from the last role request to the last topology
Devin Lim142b5342017-07-20 15:22:39 -0700228 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700229 # Calculate the disconnecti rate
Devin Lim142b5342017-07-20 15:22:39 -0700230 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ], 'num', index=i, funcMode='DR' )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700231 main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700232 if -1 in main.allinfo[ 0 ][ 'info0' ].values() or -1 in main.allinfo[ 0 ][ 'info1' ].values() or -1 in main.allinfo[ 0 ][ 'info2' ].values():
233 main.log.warn( "Something happened to ONOS. Skip the rest of the steps" )
234 main.postResult = False
YPZhang81a7d4e2016-04-18 13:10:17 -0700235 else:
Devin Lima7cfdbd2017-09-29 15:02:22 -0700236 main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) )
237 main.caseExplanation = "Pinging all hosts and comparing topology " +\
238 "elements between Mininet and ONOS"
239
240 main.log.info( "Gathering topology information" )
241 time.sleep( main.MNSleep )
242 stepResult = main.TRUE
243 main.step( "Comparing MN topology to ONOS topology" )
244 compareRetry = 0
245
246 while compareRetry < 3:
247 currentDevicesResult = main.TRUE
248 currentLinksResult = main.TRUE
249 # While loop for retry
250 devices = main.topoRelated.getAll( "devices" )
251 ports = main.topoRelated.getAll( "ports" )
252 links = main.topoRelated.getAll( "links" )
253 mnSwitches = main.Mininet1.getSwitches( updateTimeout=main.basicMNTime + int( main.currScale ) * main.MNupdateTime )
254 main.log.info( "Comparing switches..." )
255 devicePool = []
256 for controller in range( len( main.Cluster.active() ) ):
257 t = main.Thread( target=main.topoRelated.compareDevicePort,
258 threadID=main.threadID,
259 name="Compare-Device-Port",
260 args=[ main.Mininet1, controller,
261 mnSwitches,
262 devices, ports ] )
263 devicePool.append( t )
264 t.start()
265 main.threadID = main.threadID + 1
266
267 mnLinks = main.Mininet1.getLinks( timeout=main.basicMNTime + int( main.currScale ) * main.MNLinksTime,
268 updateTimeout=main.basicMNTime + int(main.currScale) * main.MNupdateTime )
269 main.log.info( "Comparing links..." )
270 linkPool = []
271 for controller in range( len( main.Cluster.active() ) ):
272 t = main.Thread( target=main.topoRelated.compareBase,
273 threadID=main.threadID,
274 name="Compare-Link-Result",
275 args=[ links, controller,
276 main.Mininet1.compareLinks,
277 [ mnSwitches, mnLinks ] ] )
278 linkPool.append( t )
279 t.start()
280 main.threadID = main.threadID + 1
281
282 for t in devicePool:
283 t.join()
284 currentDevicesResult = currentDevicesResult and t.result
285 for t in linkPool:
286 t.join()
287 currentLinksResult = currentLinksResult and t.result
288 stepResult = stepResult and currentDevicesResult and currentLinksResult
289 if stepResult:
290 break
291 compareRetry += 1
292 utilities.assert_equals( expect=main.TRUE,
293 actual=stepResult,
294 onpass=" Topology match Mininet",
295 onfail="ONOS Topology doesn't match Mininet" )
296
297 if stepResult:
298 if main.hostDiscover:
299 hostList = []
300 for i in range( 1, int( main.currScale ) + 1 ):
301 for j in range( 1, int( main.currScale ) + 1 ):
302 # Generate host list
303 hoststr = "h" + str( i ) + "x" + str( j )
304 hostList.append( hoststr )
305 for i in range( len( hostList ) ):
306 main.topo.sendArpPackage( main, hostList[ i ] )
307 time.sleep( 20 )
308 totalHost = main.topo.getHostNum( main )
309 if totalHost == int( main.currScale ) * int( main.currScale ):
310 main.log.info( "Discovered all hosts" )
311 stepResult = stepResult and main.TRUE
312 else:
313 main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
314 stepResult = main.FALSE
315 utilities.assert_equals( expect=main.TRUE,
316 actual=stepResult,
317 onpass=" Topology match Mininet",
318 onfail="ONOS Topology doesn't match Mininet" )
319 main.log.info( "Finished this iteration, continue to scale next topology." )
320 else:
321 main.log.info( "Clean up and exit TestON. Finished this test." )
322 main.cleanAndExit()
GlennRC475f50d2015-10-23 15:01:09 -0700323
GlennRC632e2892015-10-19 18:58:41 -0700324 def CASE100( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700325 """
YPZhang81a7d4e2016-04-18 13:10:17 -0700326 Bring Down node 3
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700327 """
328 main.case( "Bring ONOS node 3 down: TORUS %sx%s" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700329 main.caseExplanation = "Balance masters to make sure " +\
330 "each controller has some devices and " +\
331 "stop ONOS node 3 service. "
332
GlennRC475f50d2015-10-23 15:01:09 -0700333 stepResult = main.FALSE
GlennRCed2122e2015-10-21 14:38:46 -0700334 main.step( "Bringing down node 3" )
GlennRCed2122e2015-10-21 14:38:46 -0700335 # Always bring down the third node
336 main.deadNode = 2
GlennRCed2122e2015-10-21 14:38:46 -0700337 # Printing purposes
GlennRC632e2892015-10-19 18:58:41 -0700338 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700339 main.log.info( "Stopping node %s" % node )
Devin Lim142b5342017-07-20 15:22:39 -0700340 stepResult = main.ONOSbench.onosStop( main.Cluster.active( main.deadNode ).ipAddress )
GlennRC475f50d2015-10-23 15:01:09 -0700341 main.log.info( "Removing dead node from list of active nodes" )
Devin Lim142b5342017-07-20 15:22:39 -0700342 main.Cluster.runningNodes[ main.deadNode ].active = False
GlennRC632e2892015-10-19 18:58:41 -0700343
YPZhang77badfc2016-03-09 10:28:59 -0800344 utilities.assert_equals( expect=main.TRUE,
345 actual=stepResult,
346 onpass="Successfully bring down node 3",
347 onfail="Failed to bring down node 3" )
GlennRC632e2892015-10-19 18:58:41 -0700348
GlennRC475f50d2015-10-23 15:01:09 -0700349 def CASE200( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700350 """
YPZhangacaaf422016-07-26 09:34:03 -0700351 Bring up onos node
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700352 """
353 main.case( "Bring ONOS node 3 up: TORUS %sx%s" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700354 main.caseExplanation = "Bring node 3 back up and balance the masters"
Devin Lim142b5342017-07-20 15:22:39 -0700355 ctrl = main.Cluster.runningNodes[ main.deadNode ]
GlennRC632e2892015-10-19 18:58:41 -0700356 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700357 main.log.info( "Starting node %s" % node )
Devin Lim142b5342017-07-20 15:22:39 -0700358 stepResult = main.ONOSbench.onosStart( ctrl.ipAddress )
GlennRC632e2892015-10-19 18:58:41 -0700359 main.log.info( "Starting onos cli" )
Devin Lim142b5342017-07-20 15:22:39 -0700360 stepResult = stepResult and \
361 ctrl.CLI.startOnosCli( ctrl.ipAddress )
GlennRC475f50d2015-10-23 15:01:09 -0700362 main.log.info( "Adding previously dead node to list of active nodes" )
Devin Lim142b5342017-07-20 15:22:39 -0700363 ctrl.active = True
GlennRC632e2892015-10-19 18:58:41 -0700364
GlennRC632e2892015-10-19 18:58:41 -0700365 utilities.assert_equals( expect=main.TRUE,
366 actual=stepResult,
367 onpass="Successfully brought up onos node %s" % node,
368 onfail="Failed to bring up onos node %s" % node )
369
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700370 time.sleep( main.nodeSleep )
GlennRCe283c4b2016-01-07 13:04:10 -0800371
372 def CASE300( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700373 """
GlennRCe283c4b2016-01-07 13:04:10 -0800374 Balancing Masters
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700375 """
376 time.sleep( main.balanceSleep )
GlennRC475f50d2015-10-23 15:01:09 -0700377 main.step( "Balancing Masters" )
GlennRCe283c4b2016-01-07 13:04:10 -0800378
GlennRC475f50d2015-10-23 15:01:09 -0700379 stepResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700380 if main.Cluster.active():
381 stepResult = utilities.retry( main.Cluster.next().CLI.balanceMasters,
YPZhang924ccfe2016-01-26 14:17:30 -0800382 main.FALSE,
383 [],
384 sleep=3,
385 attempts=3 )
GlennRCe283c4b2016-01-07 13:04:10 -0800386 else:
387 main.log.error( "List of active nodes is empty" )
GlennRC475f50d2015-10-23 15:01:09 -0700388 utilities.assert_equals( expect=main.TRUE,
389 actual=stepResult,
390 onpass="Balance masters was successfull",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700391 onfail="Failed to balance masters" )
Devin Lim142b5342017-07-20 15:22:39 -0700392 time.sleep( main.balanceSleep )
GlennRC475f50d2015-10-23 15:01:09 -0700393
GlennRC632e2892015-10-19 18:58:41 -0700394 def CASE1000( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700395 """
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700396 Report errors/warnings/exceptions
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700397 """
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700398 # Compare the slowest Node through total time of each node
Devin Lima7cfdbd2017-09-29 15:02:22 -0700399 if main.postResult:
400 slowestNode = 0
401 slowestTotalTime = 0
402 # Second capture
403 for i in range( 3 ):
404 # Calculate total time
405 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main,
406 main.searchTerm[ 'start' ],
407 'first',
408 main.searchTerm[ 'end' ],
409 'last',
410 index=i,
411 funcMode='TD' )
412 # Compare the total time
413 if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
414 slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
415 slowestNode = i
416 # Calculate switch connection time
417 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main,
418 main.searchTerm[ 'start' ],
419 'first',
420 main.searchTerm[ 'start' ],
421 'last',
422 index=i,
423 funcMode='TD' )
424 # Calculate the time from last switch connection to the last role request
425 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
426 main.searchTerm[ 'start' ],
427 'last',
428 index=i )
429 # Calculate the time from the last role request to the last topology
430 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
431 main.searchTerm[ 'end' ],
432 'last',
433 index=i )
434 # Calculate the disconnecti rate
435 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main,
436 main.searchTerm[ 'Disconnect' ],
437 'num',
438 main.searchTerm[ 'start' ],
439 'num',
440 index=i,
441 funcMode='DR' )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700442
Devin Lima7cfdbd2017-09-29 15:02:22 -0700443 if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
444 main.log.error( "The results of two capture are different!" )
445 main.log.debug( "The data is " + str( main.allinfo ) )
446 if main.writeData != -1:
447 main.log.info( "Write the date into database" )
448 # write the date into data base
449 with open( main.dbFilePath, "a" ) as dbFile:
450 temp = str( main.currScale )
451 temp += ",'baremetal1'"
452 # put result from second capture into data base
453 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'totalTime' ] )
454 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'swConnection' ] )
455 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastSwToLastRr' ] )
456 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastRrToLastTopology' ] )
457 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'disconnectRate' ] )
458 temp += "\n"
459 dbFile.write( temp )
460 else:
461 main.log.error( "The data from log is wrong!" )
462 main.writeData = 1
463 main.case( "Checking logs for errors, warnings, and exceptions" )
464 main.log.info( "Error report: \n" )
465 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
466 [ "INFO",
467 "FOLLOWER",
468 "WARN",
469 "flow",
470 "ERROR",
471 "Except" ],
472 "s" )