blob: d4740f422ee8c27b0c25a48315e9df7c2690f1a2 [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 Lim58046fa2017-07-05 16:55:00 -070077 if main.hostDiscover == 'True':
78 main.hostDiscover = True
79 else:
80 main.hostDiscover = False
Devin Lim142b5342017-07-20 15:22:39 -070081 main.homeDir = os.path.expanduser( '~' )
Devin Lim58046fa2017-07-05 16:55:00 -070082 main.hostsData = {}
Chiyu Chengb8c2c842016-10-05 12:40:49 -070083
Devin Lim58046fa2017-07-05 16:55:00 -070084 stepResult = main.testSetUp.envSetup()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070085 main.allinfo = {} # The dictionary to record all the data from karaf.log
Chiyu Cheng899621b2016-11-14 11:14:48 -080086
Devin Lim58046fa2017-07-05 16:55:00 -070087 for i in range( 2 ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070088 main.allinfo[ i ] = {}
89 for w in range( 3 ):
Devin Lim58046fa2017-07-05 16:55:00 -070090 # Totaltime: the time from the new switchConnection to its end
91 # swConnection: the time from the first new switchConnection to the last new switchConnection
92 # lastSwToLastRr: the time from the last new switchConnection to the last role request
93 # lastRrToLastTopology: the time form the last role request to the last topology
94 # disconnectRate: the rate that shows how many switch disconnect after connection
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070095 main.allinfo[ i ][ 'info' + str( w ) ] = { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
Chiyu Cheng899621b2016-11-14 11:14:48 -080096
Devin Lim58046fa2017-07-05 16:55:00 -070097 main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
98 main.log.info( "Create Database file " + main.dbFilePath )
Devin Lim142b5342017-07-20 15:22:39 -070099 resultDB = open( main.dbFilePath, 'w+' )
Devin Lim58046fa2017-07-05 16:55:00 -0700100 resultDB.close()
Chiyu Cheng899621b2016-11-14 11:14:48 -0800101
Devin Lim58046fa2017-07-05 16:55:00 -0700102 main.scaleTopoFunction = imp.load_source( wrapperFile2,
103 main.dependencyPath +
104 wrapperFile2 +
105 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700106
Devin Lim58046fa2017-07-05 16:55:00 -0700107 main.topo = imp.load_source( wrapperFile3,
108 main.dependencyPath +
109 wrapperFile3 +
110 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700111
Devin Lim58046fa2017-07-05 16:55:00 -0700112 main.ONOSbench.scp( main.Mininet1,
113 main.dependencyPath +
114 main.multiovs,
115 main.Mininet1.home,
116 direction="to" )
117 except Exception as e:
118 main.testSetUp.envSetupException( e )
119 main.testSetUp.evnSetupConclusion( stepResult )
120 main.commit = main.commit.split( " " )[ 1 ]
GlennRC632e2892015-10-19 18:58:41 -0700121
Devin Lim142b5342017-07-20 15:22:39 -0700122 def CASE2( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700123 """
124 - Set up cell
125 - Create cell file
126 - Set cell file
127 - Verify cell file
128 - Kill ONOS process
129 - Uninstall ONOS cluster
130 - Verify ONOS start up
131 - Install ONOS cluster
132 - Connect to cli
133 """
YPZhangacaaf422016-07-26 09:34:03 -0700134 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700135 try:
136 from tests.dependencies.utils import Utils
137 except ImportError:
138 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700139 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700140 try:
141 main.Utils
142 except ( NameError, AttributeError ):
143 main.Utils = Utils()
144 main.Utils.mininetCleanup( main.Mininet1 )
Devin Lim142b5342017-07-20 15:22:39 -0700145 main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster )
GlennRC632e2892015-10-19 18:58:41 -0700146
147 def CASE10( self, main ):
148 """
YPZhang85024fc2016-02-09 16:59:27 -0800149 Starting up torus topology
GlennRC632e2892015-10-19 18:58:41 -0700150 """
GlennRC475f50d2015-10-23 15:01:09 -0700151 main.case( "Starting up Mininet and verifying topology" )
152 main.caseExplanation = "Starting Mininet with a scalling topology and " +\
153 "comparing topology elements between Mininet and ONOS"
GlennRC475f50d2015-10-23 15:01:09 -0700154 if main.topoScale:
Devin Lim142b5342017-07-20 15:22:39 -0700155 main.currScale = main.topoScale.pop( 0 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700156 else:
157 main.log.error( "topology scale is empty" )
Devin Lim142b5342017-07-20 15:22:39 -0700158 main.step( "Starting up TORUS %sx%s topology" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700159
160 main.log.info( "Constructing Mininet command" )
YPZhangacaaf422016-07-26 09:34:03 -0700161 mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
162 " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
Devin Lim142b5342017-07-20 15:22:39 -0700163 for ctrl in main.Cluster.runningNodes:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700164 mnCmd += " --controller remote,ip=" + ctrl.ipAddress
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700165 stepResult = main.Mininet1.startNet( mnCmd=mnCmd )
GlennRC632e2892015-10-19 18:58:41 -0700166 utilities.assert_equals( expect=main.TRUE,
167 actual=stepResult,
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700168 onpass=main.topoName +
GlennRC632e2892015-10-19 18:58:41 -0700169 " topology started successfully",
170 onfail=main.topoName +
171 " topology failed to start" )
172
GlennRCe283c4b2016-01-07 13:04:10 -0800173 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800174 main.log.info( "Clean up Tshark" )
Devin Lim142b5342017-07-20 15:22:39 -0700175 with open( main.tsharkResultPath, "w" ) as tshark:
Chiyu Cheng899621b2016-11-14 11:14:48 -0800176 tshark.write( "" )
177 main.log.info( "Starting Tshark capture" )
178 main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' )
Devin Lim142b5342017-07-20 15:22:39 -0700179 main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.openflow" )
Chiyu Cheng81499422016-11-09 11:04:23 -0800180 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800181 main.log.info( "Stop Tshark" )
182 main.ONOSbench.tsharkStop()
183 main.log.info( "Get role request time" )
184 with open( main.tsharkResultPath, "r" ) as resultFile:
185 resultText = resultFile.readlines()
186 resultFile.close()
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700187
GlennRC475f50d2015-10-23 15:01:09 -0700188 def CASE11( self, main ):
189 """
YPZhangacaaf422016-07-26 09:34:03 -0700190 Compare topo, and sending Arping package
YPZhang85024fc2016-02-09 16:59:27 -0800191 if the topology is same, then Pass.
GlennRC475f50d2015-10-23 15:01:09 -0700192 """
193 import json
YPZhangacaaf422016-07-26 09:34:03 -0700194 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700195 try:
196 from tests.dependencies.topology import Topology
197 except ImportError:
198 main.log.error( "Topology not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700199 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700200 try:
201 main.topoRelated
202 except ( NameError, AttributeError ):
203 main.topoRelated = Topology()
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700204 # First capture
205 for i in range( 3 ):
206 # Calculate total time
Devin Lim142b5342017-07-20 15:22:39 -0700207 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 -0700208 # Calculate switch connection time
Devin Lim142b5342017-07-20 15:22:39 -0700209 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 -0800210 # Calculate the time from last switch connection to the last role request
Devin Lim142b5342017-07-20 15:22:39 -0700211 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800212 # Calculate the time from the last role request to the last topology
Devin Lim142b5342017-07-20 15:22:39 -0700213 main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700214 # Calculate the disconnecti rate
Devin Lim142b5342017-07-20 15:22:39 -0700215 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 -0700216 main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) )
GlennRC475f50d2015-10-23 15:01:09 -0700217
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700218 main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) )
YPZhang85024fc2016-02-09 16:59:27 -0800219 main.caseExplanation = "Pinging all hosts and comparing topology " +\
GlennRC475f50d2015-10-23 15:01:09 -0700220 "elements between Mininet and ONOS"
GlennRCe283c4b2016-01-07 13:04:10 -0800221
Devin Lim142b5342017-07-20 15:22:39 -0700222 main.log.info( "Gathering topology information" )
YPZhang85024fc2016-02-09 16:59:27 -0800223 time.sleep( main.MNSleep )
YPZhang85024fc2016-02-09 16:59:27 -0800224 stepResult = main.TRUE
GlennRC475f50d2015-10-23 15:01:09 -0700225 main.step( "Comparing MN topology to ONOS topology" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700226 compareRetry = 0
227 while compareRetry < 3:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700228 # While loop for retry
Devin Lim142b5342017-07-20 15:22:39 -0700229 devices = main.topoRelated.getAll( "devices" )
230 ports = main.topoRelated.getAll( "ports" )
231 links = main.topoRelated.getAll( "links" )
YPZhang81a7d4e2016-04-18 13:10:17 -0700232 mnSwitches = main.Mininet1.getSwitches()
Devin Lim142b5342017-07-20 15:22:39 -0700233 mnLinks = main.Mininet1.getLinks( timeout=180 )
GlennRC475f50d2015-10-23 15:01:09 -0700234
Devin Lim142b5342017-07-20 15:22:39 -0700235 for controller in range( len( main.Cluster.active() ) ):
Devin Lim58046fa2017-07-05 16:55:00 -0700236 currentDevicesResult = main.topoRelated.compareDevicePort(
237 main.Mininet1, controller,
238 mnSwitches,
239 devices, ports )
YPZhang81a7d4e2016-04-18 13:10:17 -0700240
Devin Lim58046fa2017-07-05 16:55:00 -0700241 currentLinksResult = main.topoRelated.compareBase( links, controller,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700242 main.Mininet1.compareLinks,
243 [ mnSwitches, mnLinks ] )
YPZhang81a7d4e2016-04-18 13:10:17 -0700244
YPZhangacaaf422016-07-26 09:34:03 -0700245 stepResult = stepResult and currentDevicesResult and currentLinksResult
YPZhang81a7d4e2016-04-18 13:10:17 -0700246 if stepResult:
247 break
248 compareRetry += 1
Devin Lim142b5342017-07-20 15:22:39 -0700249 utilities.assert_equals( expect=main.TRUE,
250 actual=stepResult,
251 onpass=" Topology match Mininet",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700252 onfail="ONOS Topology doesn't match Mininet" )
YPZhang81a7d4e2016-04-18 13:10:17 -0700253
YPZhangacaaf422016-07-26 09:34:03 -0700254 if stepResult:
255 if main.hostDiscover:
256 hostList = []
257 for i in range( 1, int( main.currScale ) + 1 ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700258 for j in range( 1, int( main.currScale ) + 1 ):
YPZhangacaaf422016-07-26 09:34:03 -0700259 # Generate host list
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700260 hoststr = "h" + str( i ) + "x" + str( j )
261 hostList.append( hoststr )
262 for i in range( len( hostList ) ):
263 totalHost = main.topo.sendArpPackage( main, hostList[ i ] )
YPZhangacaaf422016-07-26 09:34:03 -0700264 time.sleep( main.hostDiscoverSleep )
265 if totalHost < 0:
266 # if totalHost less than 0 which means dependence function has exception.
267 main.log.info( "Error when discover host!" )
268 break
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700269 if totalHost == int( main.currScale ) * int( main.currScale ):
YPZhangacaaf422016-07-26 09:34:03 -0700270 main.log.info( "Discovered all hosts" )
You Wang7bb9c462016-08-10 14:18:16 -0700271 stepResult = stepResult and main.TRUE
YPZhangacaaf422016-07-26 09:34:03 -0700272 else:
273 main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
You Wang7bb9c462016-08-10 14:18:16 -0700274 stepResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700275 utilities.assert_equals( expect=main.TRUE,
276 actual=stepResult,
277 onpass=" Topology match Mininet",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700278 onfail="ONOS Topology doesn't match Mininet" )
YPZhangacaaf422016-07-26 09:34:03 -0700279 main.log.info( "Finished this iteration, continue to scale next topology." )
YPZhang81a7d4e2016-04-18 13:10:17 -0700280 else:
YPZhangacaaf422016-07-26 09:34:03 -0700281 main.log.info( "Clean up and exit TestON. Finished this test." )
Devin Lim44075962017-08-11 10:56:37 -0700282 main.cleanAndExit()
GlennRC475f50d2015-10-23 15:01:09 -0700283
GlennRC632e2892015-10-19 18:58:41 -0700284 def CASE100( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700285 """
YPZhang81a7d4e2016-04-18 13:10:17 -0700286 Bring Down node 3
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700287 """
288 main.case( "Bring ONOS node 3 down: TORUS %sx%s" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700289 main.caseExplanation = "Balance masters to make sure " +\
290 "each controller has some devices and " +\
291 "stop ONOS node 3 service. "
292
GlennRC475f50d2015-10-23 15:01:09 -0700293 stepResult = main.FALSE
GlennRCed2122e2015-10-21 14:38:46 -0700294 main.step( "Bringing down node 3" )
GlennRCed2122e2015-10-21 14:38:46 -0700295 # Always bring down the third node
296 main.deadNode = 2
GlennRCed2122e2015-10-21 14:38:46 -0700297 # Printing purposes
GlennRC632e2892015-10-19 18:58:41 -0700298 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700299 main.log.info( "Stopping node %s" % node )
Devin Lim142b5342017-07-20 15:22:39 -0700300 stepResult = main.ONOSbench.onosStop( main.Cluster.active( main.deadNode ).ipAddress )
GlennRC475f50d2015-10-23 15:01:09 -0700301 main.log.info( "Removing dead node from list of active nodes" )
Devin Lim142b5342017-07-20 15:22:39 -0700302 main.Cluster.runningNodes[ main.deadNode ].active = False
GlennRC632e2892015-10-19 18:58:41 -0700303
YPZhang77badfc2016-03-09 10:28:59 -0800304 utilities.assert_equals( expect=main.TRUE,
305 actual=stepResult,
306 onpass="Successfully bring down node 3",
307 onfail="Failed to bring down node 3" )
GlennRC632e2892015-10-19 18:58:41 -0700308
GlennRC475f50d2015-10-23 15:01:09 -0700309 def CASE200( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700310 """
YPZhangacaaf422016-07-26 09:34:03 -0700311 Bring up onos node
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700312 """
313 main.case( "Bring ONOS node 3 up: TORUS %sx%s" % ( main.currScale, main.currScale ) )
GlennRC475f50d2015-10-23 15:01:09 -0700314 main.caseExplanation = "Bring node 3 back up and balance the masters"
Devin Lim142b5342017-07-20 15:22:39 -0700315 ctrl = main.Cluster.runningNodes[ main.deadNode ]
GlennRC632e2892015-10-19 18:58:41 -0700316 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700317 main.log.info( "Starting node %s" % node )
Devin Lim142b5342017-07-20 15:22:39 -0700318 stepResult = main.ONOSbench.onosStart( ctrl.ipAddress )
GlennRC632e2892015-10-19 18:58:41 -0700319 main.log.info( "Starting onos cli" )
Devin Lim142b5342017-07-20 15:22:39 -0700320 stepResult = stepResult and \
321 ctrl.CLI.startOnosCli( ctrl.ipAddress )
GlennRC475f50d2015-10-23 15:01:09 -0700322 main.log.info( "Adding previously dead node to list of active nodes" )
Devin Lim142b5342017-07-20 15:22:39 -0700323 ctrl.active = True
GlennRC632e2892015-10-19 18:58:41 -0700324
GlennRC632e2892015-10-19 18:58:41 -0700325 utilities.assert_equals( expect=main.TRUE,
326 actual=stepResult,
327 onpass="Successfully brought up onos node %s" % node,
328 onfail="Failed to bring up onos node %s" % node )
329
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700330 time.sleep( main.nodeSleep )
GlennRCe283c4b2016-01-07 13:04:10 -0800331
332 def CASE300( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700333 """
GlennRCe283c4b2016-01-07 13:04:10 -0800334 Balancing Masters
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700335 """
336 time.sleep( main.balanceSleep )
GlennRC475f50d2015-10-23 15:01:09 -0700337 main.step( "Balancing Masters" )
GlennRCe283c4b2016-01-07 13:04:10 -0800338
GlennRC475f50d2015-10-23 15:01:09 -0700339 stepResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700340 if main.Cluster.active():
341 stepResult = utilities.retry( main.Cluster.next().CLI.balanceMasters,
YPZhang924ccfe2016-01-26 14:17:30 -0800342 main.FALSE,
343 [],
344 sleep=3,
345 attempts=3 )
GlennRCe283c4b2016-01-07 13:04:10 -0800346 else:
347 main.log.error( "List of active nodes is empty" )
GlennRC475f50d2015-10-23 15:01:09 -0700348 utilities.assert_equals( expect=main.TRUE,
349 actual=stepResult,
350 onpass="Balance masters was successfull",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700351 onfail="Failed to balance masters" )
Devin Lim142b5342017-07-20 15:22:39 -0700352 time.sleep( main.balanceSleep )
GlennRC475f50d2015-10-23 15:01:09 -0700353
GlennRC632e2892015-10-19 18:58:41 -0700354 def CASE1000( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700355 """
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700356 Report errors/warnings/exceptions
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700357 """
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700358 # Compare the slowest Node through total time of each node
359 slowestNode = 0
360 slowestTotalTime = 0
361 # Second capture
362 for i in range( 3 ):
363 # Calculate total time
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700364 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main,
365 main.searchTerm[ 'start' ],
366 'first',
367 main.searchTerm[ 'end' ],
368 'last',
369 index=i,
370 funcMode='TD' )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700371 # Compare the total time
372 if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
373 slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
374 slowestNode = i
375 # Calculate switch connection time
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700376 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main,
377 main.searchTerm[ 'start' ],
378 'first',
379 main.searchTerm[ 'start' ],
380 'last',
381 index=i,
382 funcMode='TD' )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800383 # Calculate the time from last switch connection to the last role request
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700384 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
385 main.searchTerm[ 'start' ],
386 'last',
387 index=i )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800388 # Calculate the time from the last role request to the last topology
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700389 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
390 main.searchTerm[ 'end' ],
391 'last',
392 index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700393 # Calculate the disconnecti rate
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700394 main.allinfo[ 1 ][ 'info' + str( i ) ][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main,
395 main.searchTerm[ 'Disconnect' ],
396 'num',
397 main.searchTerm[ 'start' ],
398 'num',
399 index=i,
400 funcMode='DR' )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700401
402 if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
403 main.log.error( "The results of two capture are different!" )
404 main.log.debug( "The data is " + str( main.allinfo ) )
405 if main.writeData != -1:
406 main.log.info( "Write the date into database" )
407 # write the date into data base
408 with open( main.dbFilePath, "a" ) as dbFile:
409 temp = str( main.currScale )
410 temp += ",'baremetal1'"
411 # put result from second capture into data base
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700412 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'totalTime' ] )
413 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'swConnection' ] )
414 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastSwToLastRr' ] )
415 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastRrToLastTopology' ] )
416 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'disconnectRate' ] )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700417 temp += "\n"
418 dbFile.write( temp )
419 else:
420 main.log.error( "The data from log is wrong!" )
421 main.writeData = 1
GlennRC475f50d2015-10-23 15:01:09 -0700422 main.case( "Checking logs for errors, warnings, and exceptions" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700423 main.log.info( "Error report: \n" )
Devin Lim142b5342017-07-20 15:22:39 -0700424 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
GlennRC475f50d2015-10-23 15:01:09 -0700425 [ "INFO",
426 "FOLLOWER",
427 "WARN",
428 "flow",
429 "ERROR",
430 "Except" ],
Chiyu Cheng899621b2016-11-14 11:14:48 -0800431 "s" )