blob: b5a46f77568a126adcd3e3f137aa7bc837d16c7f [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' ] )
You Wangb2043922020-10-28 18:45:24 -070083 main.tsharkInterface = main.params[ 'TSHARK' ][ 'tsharkInterface' ]
Devin Lima7cfdbd2017-09-29 15:02:22 -070084 main.currScale = None
You Wangaa7bc722019-02-21 17:55:39 -080085 main.maxScale = 1
Devin Lima7cfdbd2017-09-29 15:02:22 -070086 main.threadID = 0
Devin Lim58046fa2017-07-05 16:55:00 -070087 if main.hostDiscover == 'True':
88 main.hostDiscover = True
89 else:
90 main.hostDiscover = False
Devin Lim142b5342017-07-20 15:22:39 -070091 main.homeDir = os.path.expanduser( '~' )
Devin Lim58046fa2017-07-05 16:55:00 -070092 main.hostsData = {}
Chiyu Chengb8c2c842016-10-05 12:40:49 -070093
Devin Lim58046fa2017-07-05 16:55:00 -070094 stepResult = main.testSetUp.envSetup()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070095 main.allinfo = {} # The dictionary to record all the data from karaf.log
Chiyu Cheng899621b2016-11-14 11:14:48 -080096
Devin Lim58046fa2017-07-05 16:55:00 -070097 for i in range( 2 ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070098 main.allinfo[ i ] = {}
99 for w in range( 3 ):
Devin Lim58046fa2017-07-05 16:55:00 -0700100 # Totaltime: the time from the new switchConnection to its end
101 # swConnection: the time from the first new switchConnection to the last new switchConnection
102 # lastSwToLastRr: the time from the last new switchConnection to the last role request
103 # lastRrToLastTopology: the time form the last role request to the last topology
104 # disconnectRate: the rate that shows how many switch disconnect after connection
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700105 main.allinfo[ i ][ 'info' + str( w ) ] = { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
Chiyu Cheng899621b2016-11-14 11:14:48 -0800106
Devin Lim58046fa2017-07-05 16:55:00 -0700107 main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
108 main.log.info( "Create Database file " + main.dbFilePath )
Devin Lim142b5342017-07-20 15:22:39 -0700109 resultDB = open( main.dbFilePath, 'w+' )
Devin Lim58046fa2017-07-05 16:55:00 -0700110 resultDB.close()
Chiyu Cheng899621b2016-11-14 11:14:48 -0800111
Devin Lim58046fa2017-07-05 16:55:00 -0700112 main.scaleTopoFunction = imp.load_source( wrapperFile2,
113 main.dependencyPath +
114 wrapperFile2 +
115 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700116
Devin Lim58046fa2017-07-05 16:55:00 -0700117 main.topo = imp.load_source( wrapperFile3,
118 main.dependencyPath +
119 wrapperFile3 +
120 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700121
Devin Lim58046fa2017-07-05 16:55:00 -0700122 main.ONOSbench.scp( main.Mininet1,
123 main.dependencyPath +
124 main.multiovs,
125 main.Mininet1.home,
126 direction="to" )
127 except Exception as e:
128 main.testSetUp.envSetupException( e )
Jon Hallaa1d9b82020-07-30 13:49:42 -0700129 main.testSetUp.envSetupConclusion( stepResult )
Devin Lim58046fa2017-07-05 16:55:00 -0700130 main.commit = main.commit.split( " " )[ 1 ]
GlennRC632e2892015-10-19 18:58:41 -0700131
Devin Lim142b5342017-07-20 15:22:39 -0700132 def CASE2( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700133 """
134 - Set up cell
135 - Create cell file
136 - Set cell file
137 - Verify cell file
138 - Kill ONOS process
139 - Uninstall ONOS cluster
140 - Verify ONOS start up
141 - Install ONOS cluster
142 - Connect to cli
143 """
YPZhangacaaf422016-07-26 09:34:03 -0700144 import time
You Wanga0f6ff62018-01-11 15:46:30 -0800145 main.testSetUp.ONOSSetUp( main.Cluster )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700146
147 def CASE3( self, main ):
148 """
149 cleanup mininet.
150 """
Devin Lim58046fa2017-07-05 16:55:00 -0700151 try:
152 from tests.dependencies.utils import Utils
153 except ImportError:
154 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700155 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700156 try:
157 main.Utils
158 except ( NameError, AttributeError ):
159 main.Utils = Utils()
Devin Lima7cfdbd2017-09-29 15:02:22 -0700160 main.Utils.mininetCleanup( main.Mininet1, exitTimeout=main.basicMNTime + ( int( main.currScale ) if main.currScale is not None
161 else 1 ) * main.stopNetTime )
GlennRC632e2892015-10-19 18:58:41 -0700162
163 def CASE10( self, main ):
164 """
YPZhang85024fc2016-02-09 16:59:27 -0800165 Starting up torus topology
GlennRC632e2892015-10-19 18:58:41 -0700166 """
GlennRC475f50d2015-10-23 15:01:09 -0700167 main.case( "Starting up Mininet and verifying topology" )
168 main.caseExplanation = "Starting Mininet with a scalling topology and " +\
169 "comparing topology elements between Mininet and ONOS"
GlennRC475f50d2015-10-23 15:01:09 -0700170 if main.topoScale:
Devin Lim142b5342017-07-20 15:22:39 -0700171 main.currScale = main.topoScale.pop( 0 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700172 else:
173 main.log.error( "topology scale is empty" )
Devin Lim142b5342017-07-20 15:22:39 -0700174 main.step( "Starting up TORUS %sx%s topology" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700175
176 main.log.info( "Constructing Mininet command" )
YPZhangacaaf422016-07-26 09:34:03 -0700177 mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
178 " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
Devin Lim142b5342017-07-20 15:22:39 -0700179 for ctrl in main.Cluster.runningNodes:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700180 mnCmd += " --controller remote,ip=" + ctrl.ipAddress
Devin Lima7cfdbd2017-09-29 15:02:22 -0700181 stepResult = main.Mininet1.startNet( mnCmd=mnCmd, timeout=( main.basicMNTime + int( main.currScale ) * main.startNetTime ) )
GlennRC632e2892015-10-19 18:58:41 -0700182 utilities.assert_equals( expect=main.TRUE,
183 actual=stepResult,
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700184 onpass=main.topoName +
GlennRC632e2892015-10-19 18:58:41 -0700185 " topology started successfully",
186 onfail=main.topoName +
187 " topology failed to start" )
188
GlennRCe283c4b2016-01-07 13:04:10 -0800189 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800190 main.log.info( "Clean up Tshark" )
Devin Lim142b5342017-07-20 15:22:39 -0700191 with open( main.tsharkResultPath, "w" ) as tshark:
Chiyu Cheng899621b2016-11-14 11:14:48 -0800192 tshark.write( "" )
193 main.log.info( "Starting Tshark capture" )
You Wangb2043922020-10-28 18:45:24 -0700194 main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, interface=main.tsharkInterface, grepOptions='-E' )
Devin Lim142b5342017-07-20 15:22:39 -0700195 main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.openflow" )
Chiyu Cheng81499422016-11-09 11:04:23 -0800196 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800197 main.log.info( "Stop Tshark" )
198 main.ONOSbench.tsharkStop()
199 main.log.info( "Get role request time" )
200 with open( main.tsharkResultPath, "r" ) as resultFile:
201 resultText = resultFile.readlines()
202 resultFile.close()
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700203
GlennRC475f50d2015-10-23 15:01:09 -0700204 def CASE11( self, main ):
205 """
YPZhangacaaf422016-07-26 09:34:03 -0700206 Compare topo, and sending Arping package
YPZhang85024fc2016-02-09 16:59:27 -0800207 if the topology is same, then Pass.
GlennRC475f50d2015-10-23 15:01:09 -0700208 """
209 import json
YPZhangacaaf422016-07-26 09:34:03 -0700210 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700211 try:
212 from tests.dependencies.topology import Topology
213 except ImportError:
214 main.log.error( "Topology not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700215 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700216 try:
217 main.topoRelated
218 except ( NameError, AttributeError ):
219 main.topoRelated = Topology()
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700220 # First capture
Devin Lima7cfdbd2017-09-29 15:02:22 -0700221
222 main.postResult = True
Devin Lim4a87b2a2017-10-11 18:23:12 -0700223 main.step( "Grep information from the ONOS log" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700224 for i in range( 3 ):
225 # Calculate total time
Devin Lim142b5342017-07-20 15:22:39 -0700226 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 -0700227 # Calculate switch connection time
Devin Lim142b5342017-07-20 15:22:39 -0700228 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 -0800229 # Calculate the time from last switch connection to the last role request
Devin Lim142b5342017-07-20 15:22:39 -0700230 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800231 # Calculate the time from the last role request to the last topology
Devin Lim142b5342017-07-20 15:22:39 -0700232 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700233 # Calculate the disconnecti rate
Devin Lim142b5342017-07-20 15:22:39 -0700234 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 -0700235 main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700236 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 -0700237 utilities.assert_equals( expect=main.TRUE,
238 actual=main.FALSE,
239 onpass="Everything installed properly to the ONOS.",
240 onfail="Something happened to ONOS. Skip the rest of the steps." )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700241 main.postResult = False
YPZhang81a7d4e2016-04-18 13:10:17 -0700242 else:
Devin Lima7cfdbd2017-09-29 15:02:22 -0700243 main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) )
244 main.caseExplanation = "Pinging all hosts and comparing topology " +\
245 "elements between Mininet and ONOS"
246
247 main.log.info( "Gathering topology information" )
248 time.sleep( main.MNSleep )
Devin Lim4a87b2a2017-10-11 18:23:12 -0700249
Devin Lima7cfdbd2017-09-29 15:02:22 -0700250 compareRetry = 0
Devin Lim4a87b2a2017-10-11 18:23:12 -0700251 main.step( "Checking if ONOS is stable" )
252 main.scaleTopoFunction.checkingONOSStablility( main )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700253
Devin Lim4a87b2a2017-10-11 18:23:12 -0700254 if main.postResult:
255 main.step( "Comparing MN topology to ONOS topology" )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700256
Devin Lim4a87b2a2017-10-11 18:23:12 -0700257 compareRetry = 0
258 while compareRetry < 2:
259 stepResult = main.TRUE
260 currentDevicesResult = main.TRUE
261 currentLinksResult = main.TRUE
262 # While loop for retry
You Wang3b7b5562018-11-01 16:31:41 -0700263 devices = main.topoRelated.getAll( "devices", kwargs={ 'timeout': main.getTopoTime } )
264 ports = main.topoRelated.getAll( "ports", kwargs={ 'timeout': main.getTopoTime } )
265 links = main.topoRelated.getAll( "links", kwargs={ 'timeout': main.getTopoTime } )
Devin Lim4a87b2a2017-10-11 18:23:12 -0700266 if None in devices or None in ports or None in links:
267 main.log.warn( "Something went wrong. Retrying..." )
268 time.sleep( 20 )
Devin Lima7cfdbd2017-09-29 15:02:22 -0700269 stepResult = main.FALSE
Devin Lim4a87b2a2017-10-11 18:23:12 -0700270 compareRetry += 1
271 continue
272 mnSwitches = main.Mininet1.getSwitches( updateTimeout=main.basicMNTime + int( main.currScale ) * main.MNupdateTime )
273 main.log.info( "Comparing switches..." )
274 devicePool = []
275 for controller in range( len( main.Cluster.active() ) ):
276 t = main.Thread( target=main.topoRelated.compareDevicePort,
277 threadID=main.threadID,
278 name="Compare-Device-Port",
279 args=[ main.Mininet1, controller,
280 mnSwitches,
281 devices, ports ] )
282 devicePool.append( t )
283 t.start()
284 main.threadID = main.threadID + 1
285
286 mnLinks = main.Mininet1.getLinks( timeout=main.basicMNTime + int( main.currScale ) * main.MNLinksTime,
287 updateTimeout=main.basicMNTime + int(main.currScale) * main.MNupdateTime )
288 main.log.info( "Comparing links..." )
289 linkPool = []
290 for controller in range( len( main.Cluster.active() ) ):
291 t = main.Thread( target=main.topoRelated.compareBase,
292 threadID=main.threadID,
293 name="Compare-Link-Result",
294 args=[ links, controller,
295 main.Mininet1.compareLinks,
296 [ mnSwitches, mnLinks ] ] )
297 linkPool.append( t )
298 t.start()
299 main.threadID = main.threadID + 1
300
301 for t in devicePool:
302 t.join()
303 currentDevicesResult = currentDevicesResult and t.result
304 for t in linkPool:
305 t.join()
306 currentLinksResult = currentLinksResult and t.result
307 stepResult = stepResult and currentDevicesResult and currentLinksResult
308 if stepResult:
309 break
310 compareRetry += 1
311 utilities.assert_equals( expect=main.TRUE,
312 actual=stepResult,
313 onpass=" Topology match Mininet",
314 onfail="ONOS Topology doesn't match Mininet" )
315 main.scaleTopoFunction.checkingONOSStablility( main )
316 if stepResult and main.postResult:
317 if main.hostDiscover:
318 hostList = []
319 for i in range( 1, int( main.currScale ) + 1 ):
320 for j in range( 1, int( main.currScale ) + 1 ):
321 # Generate host list
322 hoststr = "h" + str( i ) + "x" + str( j )
323 hostList.append( hoststr )
324 for i in range( len( hostList ) ):
325 main.topo.sendArpPackage( main, hostList[ i ] )
326 time.sleep( 20 )
327 totalHost = main.topo.getHostNum( main )
328 if totalHost == int( main.currScale ) * int( main.currScale ):
329 main.log.info( "Discovered all hosts" )
330 stepResult = stepResult and main.TRUE
331 else:
332 main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
333 stepResult = main.FALSE
334 utilities.assert_equals( expect=main.TRUE,
335 actual=stepResult,
336 onpass=" Topology match Mininet",
337 onfail="ONOS Topology doesn't match Mininet" )
338 main.log.info( "Finished this iteration, continue to scale next topology." )
339 else:
Devin Lima7cfdbd2017-09-29 15:02:22 -0700340 utilities.assert_equals( expect=main.TRUE,
Devin Lim4a87b2a2017-10-11 18:23:12 -0700341 actual=main.FALSE,
342 onpass="ONOS is stable.",
343 onfail="Something happened to ONOS. Skip the rest of the steps." )
344 main.postResult = False
GlennRC475f50d2015-10-23 15:01:09 -0700345
GlennRC632e2892015-10-19 18:58:41 -0700346 def CASE100( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700347 """
YPZhang81a7d4e2016-04-18 13:10:17 -0700348 Bring Down node 3
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700349 """
350 main.case( "Bring ONOS node 3 down: TORUS %sx%s" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700351 main.caseExplanation = "Balance masters to make sure " +\
352 "each controller has some devices and " +\
353 "stop ONOS node 3 service. "
354
GlennRC475f50d2015-10-23 15:01:09 -0700355 stepResult = main.FALSE
GlennRCed2122e2015-10-21 14:38:46 -0700356 main.step( "Bringing down node 3" )
GlennRCed2122e2015-10-21 14:38:46 -0700357 # Always bring down the third node
358 main.deadNode = 2
GlennRCed2122e2015-10-21 14:38:46 -0700359 # Printing purposes
GlennRC632e2892015-10-19 18:58:41 -0700360 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700361 main.log.info( "Stopping node %s" % node )
Devin Lim142b5342017-07-20 15:22:39 -0700362 stepResult = main.ONOSbench.onosStop( main.Cluster.active( main.deadNode ).ipAddress )
GlennRC475f50d2015-10-23 15:01:09 -0700363 main.log.info( "Removing dead node from list of active nodes" )
Devin Lim142b5342017-07-20 15:22:39 -0700364 main.Cluster.runningNodes[ main.deadNode ].active = False
GlennRC632e2892015-10-19 18:58:41 -0700365
YPZhang77badfc2016-03-09 10:28:59 -0800366 utilities.assert_equals( expect=main.TRUE,
367 actual=stepResult,
368 onpass="Successfully bring down node 3",
369 onfail="Failed to bring down node 3" )
GlennRC632e2892015-10-19 18:58:41 -0700370
GlennRC475f50d2015-10-23 15:01:09 -0700371 def CASE200( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700372 """
YPZhangacaaf422016-07-26 09:34:03 -0700373 Bring up onos node
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700374 """
375 main.case( "Bring ONOS node 3 up: TORUS %sx%s" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700376 main.caseExplanation = "Bring node 3 back up and balance the masters"
Devin Lim142b5342017-07-20 15:22:39 -0700377 ctrl = main.Cluster.runningNodes[ main.deadNode ]
GlennRC632e2892015-10-19 18:58:41 -0700378 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700379 main.log.info( "Starting node %s" % node )
Devin Lim142b5342017-07-20 15:22:39 -0700380 stepResult = main.ONOSbench.onosStart( ctrl.ipAddress )
GlennRC632e2892015-10-19 18:58:41 -0700381 main.log.info( "Starting onos cli" )
Devin Lim142b5342017-07-20 15:22:39 -0700382 stepResult = stepResult and \
383 ctrl.CLI.startOnosCli( ctrl.ipAddress )
GlennRC475f50d2015-10-23 15:01:09 -0700384 main.log.info( "Adding previously dead node to list of active nodes" )
Devin Lim142b5342017-07-20 15:22:39 -0700385 ctrl.active = True
GlennRC632e2892015-10-19 18:58:41 -0700386
GlennRC632e2892015-10-19 18:58:41 -0700387 utilities.assert_equals( expect=main.TRUE,
388 actual=stepResult,
389 onpass="Successfully brought up onos node %s" % node,
390 onfail="Failed to bring up onos node %s" % node )
391
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700392 time.sleep( main.nodeSleep )
GlennRCe283c4b2016-01-07 13:04:10 -0800393
394 def CASE300( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700395 """
GlennRCe283c4b2016-01-07 13:04:10 -0800396 Balancing Masters
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700397 """
398 time.sleep( main.balanceSleep )
GlennRC475f50d2015-10-23 15:01:09 -0700399 main.step( "Balancing Masters" )
GlennRCe283c4b2016-01-07 13:04:10 -0800400
GlennRC475f50d2015-10-23 15:01:09 -0700401 stepResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700402 if main.Cluster.active():
403 stepResult = utilities.retry( main.Cluster.next().CLI.balanceMasters,
YPZhang924ccfe2016-01-26 14:17:30 -0800404 main.FALSE,
405 [],
406 sleep=3,
407 attempts=3 )
GlennRCe283c4b2016-01-07 13:04:10 -0800408 else:
409 main.log.error( "List of active nodes is empty" )
GlennRC475f50d2015-10-23 15:01:09 -0700410 utilities.assert_equals( expect=main.TRUE,
411 actual=stepResult,
412 onpass="Balance masters was successfull",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700413 onfail="Failed to balance masters" )
Devin Lim142b5342017-07-20 15:22:39 -0700414 time.sleep( main.balanceSleep )
GlennRC475f50d2015-10-23 15:01:09 -0700415
GlennRC632e2892015-10-19 18:58:41 -0700416 def CASE1000( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700417 """
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700418 Report errors/warnings/exceptions
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700419 """
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700420 # Compare the slowest Node through total time of each node
Devin Lima7cfdbd2017-09-29 15:02:22 -0700421 if main.postResult:
422 slowestNode = 0
423 slowestTotalTime = 0
424 # Second capture
425 for i in range( 3 ):
426 # Calculate total time
427 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main,
428 main.searchTerm[ 'start' ],
429 'first',
430 main.searchTerm[ 'end' ],
431 'last',
432 index=i,
433 funcMode='TD' )
434 # Compare the total time
435 if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
436 slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
437 slowestNode = i
438 # Calculate switch connection time
439 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main,
440 main.searchTerm[ 'start' ],
441 'first',
442 main.searchTerm[ 'start' ],
443 'last',
444 index=i,
445 funcMode='TD' )
446 # Calculate the time from last switch connection to the last role request
447 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
448 main.searchTerm[ 'start' ],
449 'last',
450 index=i )
451 # Calculate the time from the last role request to the last topology
452 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
453 main.searchTerm[ 'end' ],
454 'last',
455 index=i )
456 # Calculate the disconnecti rate
457 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main,
458 main.searchTerm[ 'Disconnect' ],
459 'num',
460 main.searchTerm[ 'start' ],
461 'num',
462 index=i,
463 funcMode='DR' )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700464
Devin Lima7cfdbd2017-09-29 15:02:22 -0700465 if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
466 main.log.error( "The results of two capture are different!" )
467 main.log.debug( "The data is " + str( main.allinfo ) )
468 if main.writeData != -1:
You Wangaa7bc722019-02-21 17:55:39 -0800469 main.maxScale = main.currScale
Devin Lima7cfdbd2017-09-29 15:02:22 -0700470 main.log.info( "Write the date into database" )
471 # write the date into data base
472 with open( main.dbFilePath, "a" ) as dbFile:
473 temp = str( main.currScale )
474 temp += ",'baremetal1'"
475 # put result from second capture into data base
476 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'totalTime' ] )
477 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'swConnection' ] )
478 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastSwToLastRr' ] )
479 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastRrToLastTopology' ] )
480 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'disconnectRate' ] )
481 temp += "\n"
482 dbFile.write( temp )
483 else:
484 main.log.error( "The data from log is wrong!" )
485 main.writeData = 1
486 main.case( "Checking logs for errors, warnings, and exceptions" )
487 main.log.info( "Error report: \n" )
488 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
489 [ "INFO",
490 "FOLLOWER",
491 "WARN",
492 "flow",
493 "ERROR",
494 "Except" ],
495 "s" )
You Wangaa7bc722019-02-21 17:55:39 -0800496
497 def CASE1001( self, main ):
498 """
499 Write abnormal test results to alarm log
500 """
501 threshold = int( main.params[ 'ALARM' ][ 'minMaxScale' ] )
502 if int( main.maxScale ) < threshold:
503 main.log.alarm( "Max scale: {}x{} < {}x{}".format( main.maxScale, main.maxScale,
504 threshold, threshold ) )