blob: 5ac38e6e399a2caf7aef0a3fe56f555cf65ef69c [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' ] )
You Wang3b7b5562018-11-01 16:31:41 -070082 main.getTopoTime = int( main.params[ 'TIMEOUT' ][ 'getTopo' ] )
Devin Lima7cfdbd2017-09-29 15:02:22 -070083 main.currScale = None
84 main.threadID = 0
Devin Lim58046fa2017-07-05 16:55:00 -070085 if main.hostDiscover == 'True':
86 main.hostDiscover = True
87 else:
88 main.hostDiscover = False
Devin Lim142b5342017-07-20 15:22:39 -070089 main.homeDir = os.path.expanduser( '~' )
Devin Lim58046fa2017-07-05 16:55:00 -070090 main.hostsData = {}
Chiyu Chengb8c2c842016-10-05 12:40:49 -070091
Devin Lim58046fa2017-07-05 16:55:00 -070092 stepResult = main.testSetUp.envSetup()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070093 main.allinfo = {} # The dictionary to record all the data from karaf.log
Chiyu Cheng899621b2016-11-14 11:14:48 -080094
Devin Lim58046fa2017-07-05 16:55:00 -070095 for i in range( 2 ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070096 main.allinfo[ i ] = {}
97 for w in range( 3 ):
Devin Lim58046fa2017-07-05 16:55:00 -070098 # Totaltime: the time from the new switchConnection to its end
99 # swConnection: the time from the first new switchConnection to the last new switchConnection
100 # lastSwToLastRr: the time from the last new switchConnection to the last role request
101 # lastRrToLastTopology: the time form the last role request to the last topology
102 # disconnectRate: the rate that shows how many switch disconnect after connection
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700103 main.allinfo[ i ][ 'info' + str( w ) ] = { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
Chiyu Cheng899621b2016-11-14 11:14:48 -0800104
Devin Lim58046fa2017-07-05 16:55:00 -0700105 main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
106 main.log.info( "Create Database file " + main.dbFilePath )
Devin Lim142b5342017-07-20 15:22:39 -0700107 resultDB = open( main.dbFilePath, 'w+' )
Devin Lim58046fa2017-07-05 16:55:00 -0700108 resultDB.close()
Chiyu Cheng899621b2016-11-14 11:14:48 -0800109
Devin Lim58046fa2017-07-05 16:55:00 -0700110 main.scaleTopoFunction = imp.load_source( wrapperFile2,
111 main.dependencyPath +
112 wrapperFile2 +
113 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700114
Devin Lim58046fa2017-07-05 16:55:00 -0700115 main.topo = imp.load_source( wrapperFile3,
116 main.dependencyPath +
117 wrapperFile3 +
118 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700119
Devin Lim58046fa2017-07-05 16:55:00 -0700120 main.ONOSbench.scp( main.Mininet1,
121 main.dependencyPath +
122 main.multiovs,
123 main.Mininet1.home,
124 direction="to" )
125 except Exception as e:
126 main.testSetUp.envSetupException( e )
127 main.testSetUp.evnSetupConclusion( stepResult )
128 main.commit = main.commit.split( " " )[ 1 ]
GlennRC632e2892015-10-19 18:58:41 -0700129
Devin Lim142b5342017-07-20 15:22:39 -0700130 def CASE2( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700131 """
132 - Set up cell
133 - Create cell file
134 - Set cell file
135 - Verify cell file
136 - Kill ONOS process
137 - Uninstall ONOS cluster
138 - Verify ONOS start up
139 - Install ONOS cluster
140 - Connect to cli
141 """
YPZhangacaaf422016-07-26 09:34:03 -0700142 import time
You Wanga0f6ff62018-01-11 15:46:30 -0800143 main.testSetUp.ONOSSetUp( main.Cluster )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700144
145 def CASE3( self, main ):
146 """
147 cleanup mininet.
148 """
Devin Lim58046fa2017-07-05 16:55:00 -0700149 try:
150 from tests.dependencies.utils import Utils
151 except ImportError:
152 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700153 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700154 try:
155 main.Utils
156 except ( NameError, AttributeError ):
157 main.Utils = Utils()
Devin Lima7cfdbd2017-09-29 15:02:22 -0700158 main.Utils.mininetCleanup( main.Mininet1, exitTimeout=main.basicMNTime + ( int( main.currScale ) if main.currScale is not None
159 else 1 ) * main.stopNetTime )
GlennRC632e2892015-10-19 18:58:41 -0700160
161 def CASE10( self, main ):
162 """
YPZhang85024fc2016-02-09 16:59:27 -0800163 Starting up torus topology
GlennRC632e2892015-10-19 18:58:41 -0700164 """
GlennRC475f50d2015-10-23 15:01:09 -0700165 main.case( "Starting up Mininet and verifying topology" )
166 main.caseExplanation = "Starting Mininet with a scalling topology and " +\
167 "comparing topology elements between Mininet and ONOS"
GlennRC475f50d2015-10-23 15:01:09 -0700168 if main.topoScale:
Devin Lim142b5342017-07-20 15:22:39 -0700169 main.currScale = main.topoScale.pop( 0 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700170 else:
171 main.log.error( "topology scale is empty" )
Devin Lim142b5342017-07-20 15:22:39 -0700172 main.step( "Starting up TORUS %sx%s topology" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700173
174 main.log.info( "Constructing Mininet command" )
YPZhangacaaf422016-07-26 09:34:03 -0700175 mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
176 " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
Devin Lim142b5342017-07-20 15:22:39 -0700177 for ctrl in main.Cluster.runningNodes:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700178 mnCmd += " --controller remote,ip=" + ctrl.ipAddress
Devin Lima7cfdbd2017-09-29 15:02:22 -0700179 stepResult = main.Mininet1.startNet( mnCmd=mnCmd, timeout=( main.basicMNTime + int( main.currScale ) * main.startNetTime ) )
GlennRC632e2892015-10-19 18:58:41 -0700180 utilities.assert_equals( expect=main.TRUE,
181 actual=stepResult,
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700182 onpass=main.topoName +
GlennRC632e2892015-10-19 18:58:41 -0700183 " topology started successfully",
184 onfail=main.topoName +
185 " topology failed to start" )
186
GlennRCe283c4b2016-01-07 13:04:10 -0800187 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800188 main.log.info( "Clean up Tshark" )
Devin Lim142b5342017-07-20 15:22:39 -0700189 with open( main.tsharkResultPath, "w" ) as tshark:
Chiyu Cheng899621b2016-11-14 11:14:48 -0800190 tshark.write( "" )
191 main.log.info( "Starting Tshark capture" )
192 main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' )
Devin Lim142b5342017-07-20 15:22:39 -0700193 main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.openflow" )
Chiyu Cheng81499422016-11-09 11:04:23 -0800194 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800195 main.log.info( "Stop Tshark" )
196 main.ONOSbench.tsharkStop()
197 main.log.info( "Get role request time" )
198 with open( main.tsharkResultPath, "r" ) as resultFile:
199 resultText = resultFile.readlines()
200 resultFile.close()
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700201
GlennRC475f50d2015-10-23 15:01:09 -0700202 def CASE11( self, main ):
203 """
YPZhangacaaf422016-07-26 09:34:03 -0700204 Compare topo, and sending Arping package
YPZhang85024fc2016-02-09 16:59:27 -0800205 if the topology is same, then Pass.
GlennRC475f50d2015-10-23 15:01:09 -0700206 """
207 import json
YPZhangacaaf422016-07-26 09:34:03 -0700208 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700209 try:
210 from tests.dependencies.topology import Topology
211 except ImportError:
212 main.log.error( "Topology not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700213 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700214 try:
215 main.topoRelated
216 except ( NameError, AttributeError ):
217 main.topoRelated = Topology()
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700218 # First capture
Devin Lima7cfdbd2017-09-29 15:02:22 -0700219
220 main.postResult = True
Devin Lim4a87b2a2017-10-11 18:23:12 -0700221 main.step( "Grep information from the ONOS log" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700222 for i in range( 3 ):
223 # Calculate total time
Devin Lim142b5342017-07-20 15:22:39 -0700224 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 -0700225 # Calculate switch connection time
Devin Lim142b5342017-07-20 15:22:39 -0700226 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 -0800227 # Calculate the time from last switch connection to the last role request
Devin Lim142b5342017-07-20 15:22:39 -0700228 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800229 # Calculate the time from the last role request to the last topology
Devin Lim142b5342017-07-20 15:22:39 -0700230 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700231 # Calculate the disconnecti rate
Devin Lim142b5342017-07-20 15:22:39 -0700232 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 -0700233 main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700234 if -1 in main.allinfo[ 0 ][ 'info0' ].values() or -1 in main.allinfo[ 0 ][ 'info1' ].values() or -1 in main.allinfo[ 0 ][ 'info2' ].values():
Devin Lim4a87b2a2017-10-11 18:23:12 -0700235 utilities.assert_equals( expect=main.TRUE,
236 actual=main.FALSE,
237 onpass="Everything installed properly to the ONOS.",
238 onfail="Something happened to ONOS. Skip the rest of the steps." )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700239 main.postResult = False
YPZhang81a7d4e2016-04-18 13:10:17 -0700240 else:
Devin Lima7cfdbd2017-09-29 15:02:22 -0700241 main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) )
242 main.caseExplanation = "Pinging all hosts and comparing topology " +\
243 "elements between Mininet and ONOS"
244
245 main.log.info( "Gathering topology information" )
246 time.sleep( main.MNSleep )
Devin Lim4a87b2a2017-10-11 18:23:12 -0700247
Devin Lima7cfdbd2017-09-29 15:02:22 -0700248 compareRetry = 0
Devin Lim4a87b2a2017-10-11 18:23:12 -0700249 main.step( "Checking if ONOS is stable" )
250 main.scaleTopoFunction.checkingONOSStablility( main )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700251
Devin Lim4a87b2a2017-10-11 18:23:12 -0700252 if main.postResult:
253 main.step( "Comparing MN topology to ONOS topology" )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700254
Devin Lim4a87b2a2017-10-11 18:23:12 -0700255 compareRetry = 0
256 while compareRetry < 2:
257 stepResult = main.TRUE
258 currentDevicesResult = main.TRUE
259 currentLinksResult = main.TRUE
260 # While loop for retry
You Wang3b7b5562018-11-01 16:31:41 -0700261 devices = main.topoRelated.getAll( "devices", kwargs={ 'timeout': main.getTopoTime } )
262 ports = main.topoRelated.getAll( "ports", kwargs={ 'timeout': main.getTopoTime } )
263 links = main.topoRelated.getAll( "links", kwargs={ 'timeout': main.getTopoTime } )
Devin Lim4a87b2a2017-10-11 18:23:12 -0700264 if None in devices or None in ports or None in links:
265 main.log.warn( "Something went wrong. Retrying..." )
266 time.sleep( 20 )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700267 stepResult = main.FALSE
Devin Lim4a87b2a2017-10-11 18:23:12 -0700268 compareRetry += 1
269 continue
270 mnSwitches = main.Mininet1.getSwitches( updateTimeout=main.basicMNTime + int( main.currScale ) * main.MNupdateTime )
271 main.log.info( "Comparing switches..." )
272 devicePool = []
273 for controller in range( len( main.Cluster.active() ) ):
274 t = main.Thread( target=main.topoRelated.compareDevicePort,
275 threadID=main.threadID,
276 name="Compare-Device-Port",
277 args=[ main.Mininet1, controller,
278 mnSwitches,
279 devices, ports ] )
280 devicePool.append( t )
281 t.start()
282 main.threadID = main.threadID + 1
283
284 mnLinks = main.Mininet1.getLinks( timeout=main.basicMNTime + int( main.currScale ) * main.MNLinksTime,
285 updateTimeout=main.basicMNTime + int(main.currScale) * main.MNupdateTime )
286 main.log.info( "Comparing links..." )
287 linkPool = []
288 for controller in range( len( main.Cluster.active() ) ):
289 t = main.Thread( target=main.topoRelated.compareBase,
290 threadID=main.threadID,
291 name="Compare-Link-Result",
292 args=[ links, controller,
293 main.Mininet1.compareLinks,
294 [ mnSwitches, mnLinks ] ] )
295 linkPool.append( t )
296 t.start()
297 main.threadID = main.threadID + 1
298
299 for t in devicePool:
300 t.join()
301 currentDevicesResult = currentDevicesResult and t.result
302 for t in linkPool:
303 t.join()
304 currentLinksResult = currentLinksResult and t.result
305 stepResult = stepResult and currentDevicesResult and currentLinksResult
306 if stepResult:
307 break
308 compareRetry += 1
309 utilities.assert_equals( expect=main.TRUE,
310 actual=stepResult,
311 onpass=" Topology match Mininet",
312 onfail="ONOS Topology doesn't match Mininet" )
313 main.scaleTopoFunction.checkingONOSStablility( main )
314 if stepResult and main.postResult:
315 if main.hostDiscover:
316 hostList = []
317 for i in range( 1, int( main.currScale ) + 1 ):
318 for j in range( 1, int( main.currScale ) + 1 ):
319 # Generate host list
320 hoststr = "h" + str( i ) + "x" + str( j )
321 hostList.append( hoststr )
322 for i in range( len( hostList ) ):
323 main.topo.sendArpPackage( main, hostList[ i ] )
324 time.sleep( 20 )
325 totalHost = main.topo.getHostNum( main )
326 if totalHost == int( main.currScale ) * int( main.currScale ):
327 main.log.info( "Discovered all hosts" )
328 stepResult = stepResult and main.TRUE
329 else:
330 main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
331 stepResult = main.FALSE
332 utilities.assert_equals( expect=main.TRUE,
333 actual=stepResult,
334 onpass=" Topology match Mininet",
335 onfail="ONOS Topology doesn't match Mininet" )
336 main.log.info( "Finished this iteration, continue to scale next topology." )
337 else:
Devin Lima7cfdbd2017-09-29 15:02:22 -0700338 utilities.assert_equals( expect=main.TRUE,
Devin Lim4a87b2a2017-10-11 18:23:12 -0700339 actual=main.FALSE,
340 onpass="ONOS is stable.",
341 onfail="Something happened to ONOS. Skip the rest of the steps." )
342 main.postResult = False
GlennRC475f50d2015-10-23 15:01:09 -0700343
GlennRC632e2892015-10-19 18:58:41 -0700344 def CASE100( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700345 """
YPZhang81a7d4e2016-04-18 13:10:17 -0700346 Bring Down node 3
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700347 """
348 main.case( "Bring ONOS node 3 down: TORUS %sx%s" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700349 main.caseExplanation = "Balance masters to make sure " +\
350 "each controller has some devices and " +\
351 "stop ONOS node 3 service. "
352
GlennRC475f50d2015-10-23 15:01:09 -0700353 stepResult = main.FALSE
GlennRCed2122e2015-10-21 14:38:46 -0700354 main.step( "Bringing down node 3" )
GlennRCed2122e2015-10-21 14:38:46 -0700355 # Always bring down the third node
356 main.deadNode = 2
GlennRCed2122e2015-10-21 14:38:46 -0700357 # Printing purposes
GlennRC632e2892015-10-19 18:58:41 -0700358 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700359 main.log.info( "Stopping node %s" % node )
Devin Lim142b5342017-07-20 15:22:39 -0700360 stepResult = main.ONOSbench.onosStop( main.Cluster.active( main.deadNode ).ipAddress )
GlennRC475f50d2015-10-23 15:01:09 -0700361 main.log.info( "Removing dead node from list of active nodes" )
Devin Lim142b5342017-07-20 15:22:39 -0700362 main.Cluster.runningNodes[ main.deadNode ].active = False
GlennRC632e2892015-10-19 18:58:41 -0700363
YPZhang77badfc2016-03-09 10:28:59 -0800364 utilities.assert_equals( expect=main.TRUE,
365 actual=stepResult,
366 onpass="Successfully bring down node 3",
367 onfail="Failed to bring down node 3" )
GlennRC632e2892015-10-19 18:58:41 -0700368
GlennRC475f50d2015-10-23 15:01:09 -0700369 def CASE200( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700370 """
YPZhangacaaf422016-07-26 09:34:03 -0700371 Bring up onos node
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700372 """
373 main.case( "Bring ONOS node 3 up: TORUS %sx%s" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700374 main.caseExplanation = "Bring node 3 back up and balance the masters"
Devin Lim142b5342017-07-20 15:22:39 -0700375 ctrl = main.Cluster.runningNodes[ main.deadNode ]
GlennRC632e2892015-10-19 18:58:41 -0700376 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700377 main.log.info( "Starting node %s" % node )
Devin Lim142b5342017-07-20 15:22:39 -0700378 stepResult = main.ONOSbench.onosStart( ctrl.ipAddress )
GlennRC632e2892015-10-19 18:58:41 -0700379 main.log.info( "Starting onos cli" )
Devin Lim142b5342017-07-20 15:22:39 -0700380 stepResult = stepResult and \
381 ctrl.CLI.startOnosCli( ctrl.ipAddress )
GlennRC475f50d2015-10-23 15:01:09 -0700382 main.log.info( "Adding previously dead node to list of active nodes" )
Devin Lim142b5342017-07-20 15:22:39 -0700383 ctrl.active = True
GlennRC632e2892015-10-19 18:58:41 -0700384
GlennRC632e2892015-10-19 18:58:41 -0700385 utilities.assert_equals( expect=main.TRUE,
386 actual=stepResult,
387 onpass="Successfully brought up onos node %s" % node,
388 onfail="Failed to bring up onos node %s" % node )
389
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700390 time.sleep( main.nodeSleep )
GlennRCe283c4b2016-01-07 13:04:10 -0800391
392 def CASE300( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700393 """
GlennRCe283c4b2016-01-07 13:04:10 -0800394 Balancing Masters
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700395 """
396 time.sleep( main.balanceSleep )
GlennRC475f50d2015-10-23 15:01:09 -0700397 main.step( "Balancing Masters" )
GlennRCe283c4b2016-01-07 13:04:10 -0800398
GlennRC475f50d2015-10-23 15:01:09 -0700399 stepResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700400 if main.Cluster.active():
401 stepResult = utilities.retry( main.Cluster.next().CLI.balanceMasters,
YPZhang924ccfe2016-01-26 14:17:30 -0800402 main.FALSE,
403 [],
404 sleep=3,
405 attempts=3 )
GlennRCe283c4b2016-01-07 13:04:10 -0800406 else:
407 main.log.error( "List of active nodes is empty" )
GlennRC475f50d2015-10-23 15:01:09 -0700408 utilities.assert_equals( expect=main.TRUE,
409 actual=stepResult,
410 onpass="Balance masters was successfull",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700411 onfail="Failed to balance masters" )
Devin Lim142b5342017-07-20 15:22:39 -0700412 time.sleep( main.balanceSleep )
GlennRC475f50d2015-10-23 15:01:09 -0700413
GlennRC632e2892015-10-19 18:58:41 -0700414 def CASE1000( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700415 """
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700416 Report errors/warnings/exceptions
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700417 """
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700418 # Compare the slowest Node through total time of each node
Devin Lima7cfdbd2017-09-29 15:02:22 -0700419 if main.postResult:
420 slowestNode = 0
421 slowestTotalTime = 0
422 # Second capture
423 for i in range( 3 ):
424 # Calculate total time
425 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main,
426 main.searchTerm[ 'start' ],
427 'first',
428 main.searchTerm[ 'end' ],
429 'last',
430 index=i,
431 funcMode='TD' )
432 # Compare the total time
433 if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
434 slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
435 slowestNode = i
436 # Calculate switch connection time
437 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main,
438 main.searchTerm[ 'start' ],
439 'first',
440 main.searchTerm[ 'start' ],
441 'last',
442 index=i,
443 funcMode='TD' )
444 # Calculate the time from last switch connection to the last role request
445 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
446 main.searchTerm[ 'start' ],
447 'last',
448 index=i )
449 # Calculate the time from the last role request to the last topology
450 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
451 main.searchTerm[ 'end' ],
452 'last',
453 index=i )
454 # Calculate the disconnecti rate
455 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main,
456 main.searchTerm[ 'Disconnect' ],
457 'num',
458 main.searchTerm[ 'start' ],
459 'num',
460 index=i,
461 funcMode='DR' )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700462
Devin Lima7cfdbd2017-09-29 15:02:22 -0700463 if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
464 main.log.error( "The results of two capture are different!" )
465 main.log.debug( "The data is " + str( main.allinfo ) )
466 if main.writeData != -1:
467 main.log.info( "Write the date into database" )
468 # write the date into data base
469 with open( main.dbFilePath, "a" ) as dbFile:
470 temp = str( main.currScale )
471 temp += ",'baremetal1'"
472 # put result from second capture into data base
473 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'totalTime' ] )
474 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'swConnection' ] )
475 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastSwToLastRr' ] )
476 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastRrToLastTopology' ] )
477 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'disconnectRate' ] )
478 temp += "\n"
479 dbFile.write( temp )
480 else:
481 main.log.error( "The data from log is wrong!" )
482 main.writeData = 1
483 main.case( "Checking logs for errors, warnings, and exceptions" )
484 main.log.info( "Error report: \n" )
485 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
486 [ "INFO",
487 "FOLLOWER",
488 "WARN",
489 "flow",
490 "ERROR",
491 "Except" ],
492 "s" )