blob: 6e45f816ab48cbd93403c60d63259472f10dfa7e [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2015 Open Networking Foundation (ONF)
3
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
11 (at your option) any later version.
12
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
22# Testing network scalability, this test suite scales up a network topology
23# using mininet and verifies ONOS stability
24
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" )
47 main.exit()
48 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' ]
59 main.roleRequest = main.params[ 'SearchTerm' ]['roleRequest']
60 main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
61 main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ]
62 main.numCtrls = int( main.params[ 'CTRL' ][ 'numCtrls' ] )
63 main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," )
64 main.topoScaleSize = len( main.topoScale )
65 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
66 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
67 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
68 main.topoCmpAttempts = int( main.params[ 'ATTEMPTS' ][ 'topoCmp' ] )
69 main.pingallAttempts = int( main.params[ 'ATTEMPTS' ][ 'pingall' ] )
70 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
71 main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] )
72 main.nodeSleep = int( main.params[ 'SLEEP' ][ 'nodeSleep' ] )
73 main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] )
74 main.MNSleep = int( main.params[ 'SLEEP' ][ 'MNsleep' ] )
75 main.pingTimeout = float( main.params[ 'TIMEOUT' ][ 'pingall' ] )
76 main.hostDiscover = main.params[ 'TOPOLOGY' ][ 'host' ]
77 main.hostDiscoverSleep = float( main.params['SLEEP']['host'] )
78 if main.hostDiscover == 'True':
79 main.hostDiscover = True
80 else:
81 main.hostDiscover = False
82 main.homeDir = os.path.expanduser('~')
83 main.hostsData = {}
84 main.activeNodes = []
Chiyu Chengb8c2c842016-10-05 12:40:49 -070085
Chiyu Cheng899621b2016-11-14 11:14:48 -080086
Devin Lim58046fa2017-07-05 16:55:00 -070087 stepResult = main.testSetUp.envSetup()
88 main.allinfo = {} # The dictionary to record all the data from karaf.log
Chiyu Cheng899621b2016-11-14 11:14:48 -080089
Devin Lim58046fa2017-07-05 16:55:00 -070090 for i in range( 2 ):
91 main.allinfo[ i ]={}
92 for w in range ( 3 ):
93 # Totaltime: the time from the new switchConnection to its end
94 # swConnection: the time from the first new switchConnection to the last new switchConnection
95 # lastSwToLastRr: the time from the last new switchConnection to the last role request
96 # lastRrToLastTopology: the time form the last role request to the last topology
97 # disconnectRate: the rate that shows how many switch disconnect after connection
98 main.allinfo[ i ][ 'info' + str( w ) ]= { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
Chiyu Cheng899621b2016-11-14 11:14:48 -080099
Devin Lim58046fa2017-07-05 16:55:00 -0700100 main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
101 main.log.info( "Create Database file " + main.dbFilePath )
102 resultDB = open(main.dbFilePath, 'w+' )
103 resultDB.close()
Chiyu Cheng899621b2016-11-14 11:14:48 -0800104
Devin Lim58046fa2017-07-05 16:55:00 -0700105 main.scaleTopoFunction = imp.load_source( wrapperFile2,
106 main.dependencyPath +
107 wrapperFile2 +
108 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700109
Devin Lim58046fa2017-07-05 16:55:00 -0700110 main.topo = imp.load_source( wrapperFile3,
111 main.dependencyPath +
112 wrapperFile3 +
113 ".py" )
GlennRC632e2892015-10-19 18:58:41 -0700114
Devin Lim58046fa2017-07-05 16:55:00 -0700115 main.ONOSbench.scp( main.Mininet1,
116 main.dependencyPath +
117 main.multiovs,
118 main.Mininet1.home,
119 direction="to" )
120 except Exception as e:
121 main.testSetUp.envSetupException( e )
122 main.testSetUp.evnSetupConclusion( stepResult )
123 main.commit = main.commit.split( " " )[ 1 ]
GlennRC632e2892015-10-19 18:58:41 -0700124
125 def CASE2( self, main):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700126 """
127 - Set up cell
128 - Create cell file
129 - Set cell file
130 - Verify cell file
131 - Kill ONOS process
132 - Uninstall ONOS cluster
133 - Verify ONOS start up
134 - Install ONOS cluster
135 - Connect to cli
136 """
YPZhangacaaf422016-07-26 09:34:03 -0700137 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700138 try:
139 from tests.dependencies.utils import Utils
140 except ImportError:
141 main.log.error( "Utils not found exiting the test" )
142 main.exit()
143 try:
144 main.Utils
145 except ( NameError, AttributeError ):
146 main.Utils = Utils()
147 main.Utils.mininetCleanup( main.Mininet1 )
148 main.testSetUp.ONOSSetUp( main.Mininet1 )
YPZhang29c2d642016-06-22 16:15:19 -0700149 main.activeNodes = []
GlennRC632e2892015-10-19 18:58:41 -0700150 for i in range( main.numCtrls ):
GlennRC632e2892015-10-19 18:58:41 -0700151 main.activeNodes.append( i )
GlennRC632e2892015-10-19 18:58:41 -0700152
153 def CASE10( self, main ):
154 """
YPZhang85024fc2016-02-09 16:59:27 -0800155 Starting up torus topology
GlennRC632e2892015-10-19 18:58:41 -0700156 """
GlennRC475f50d2015-10-23 15:01:09 -0700157
158 main.case( "Starting up Mininet and verifying topology" )
159 main.caseExplanation = "Starting Mininet with a scalling topology and " +\
160 "comparing topology elements between Mininet and ONOS"
GlennRC475f50d2015-10-23 15:01:09 -0700161 if main.topoScale:
GlennRC90d43952015-10-27 11:36:15 -0700162 main.currScale = main.topoScale.pop(0)
GlennRC475f50d2015-10-23 15:01:09 -0700163 else: main.log.error( "topology scale is empty" )
GlennRC90d43952015-10-27 11:36:15 -0700164 main.step( "Starting up TORUS %sx%s topology" % (main.currScale, main.currScale) )
GlennRC475f50d2015-10-23 15:01:09 -0700165
166 main.log.info( "Constructing Mininet command" )
YPZhangacaaf422016-07-26 09:34:03 -0700167 mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
168 " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
GlennRC475f50d2015-10-23 15:01:09 -0700169 for i in range( main.numCtrls ):
170 mnCmd += " --controller remote,ip=" + main.ONOSip[ i ]
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700171 stepResult = main.Mininet1.startNet( mnCmd=mnCmd )
GlennRC632e2892015-10-19 18:58:41 -0700172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700174 onpass=main.topoName +
GlennRC632e2892015-10-19 18:58:41 -0700175 " topology started successfully",
176 onfail=main.topoName +
177 " topology failed to start" )
178
GlennRCe283c4b2016-01-07 13:04:10 -0800179 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800180 main.log.info( "Clean up Tshark" )
181 with open(main.tsharkResultPath, "w" ) as tshark:
182 tshark.write( "" )
183 main.log.info( "Starting Tshark capture" )
184 main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' )
Chiyu Cheng81499422016-11-09 11:04:23 -0800185 main.CLIs[ 0 ].activateApp( "org.onosproject.openflow" )
186 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800187 main.log.info( "Stop Tshark" )
188 main.ONOSbench.tsharkStop()
189 main.log.info( "Get role request time" )
190 with open( main.tsharkResultPath, "r" ) as resultFile:
191 resultText = resultFile.readlines()
192 resultFile.close()
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700193
GlennRC475f50d2015-10-23 15:01:09 -0700194 def CASE11( self, main ):
195 """
YPZhangacaaf422016-07-26 09:34:03 -0700196 Compare topo, and sending Arping package
YPZhang85024fc2016-02-09 16:59:27 -0800197 if the topology is same, then Pass.
GlennRC475f50d2015-10-23 15:01:09 -0700198 """
199 import json
YPZhangacaaf422016-07-26 09:34:03 -0700200 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700201 try:
202 from tests.dependencies.topology import Topology
203 except ImportError:
204 main.log.error( "Topology not found exiting the test" )
205 main.exit()
206 try:
207 main.topoRelated
208 except ( NameError, AttributeError ):
209 main.topoRelated = Topology()
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700210 # First capture
211 for i in range( 3 ):
212 # Calculate total time
213 main.allinfo[ 0 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
214 # Calculate switch connection time
215 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 -0800216 # Calculate the time from last switch connection to the last role request
217 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
218 # Calculate the time from the last role request to the last topology
219 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700220 # Calculate the disconnecti rate
221 main.allinfo[ 0 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ], 'num', index=i, funcMode='DR' )
222 main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) )
GlennRC475f50d2015-10-23 15:01:09 -0700223
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700224 main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) )
YPZhang85024fc2016-02-09 16:59:27 -0800225 main.caseExplanation = "Pinging all hosts and comparing topology " +\
GlennRC475f50d2015-10-23 15:01:09 -0700226 "elements between Mininet and ONOS"
GlennRCe283c4b2016-01-07 13:04:10 -0800227
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700228 main.log.info( "Gathering topology information")
YPZhang85024fc2016-02-09 16:59:27 -0800229 time.sleep( main.MNSleep )
YPZhang85024fc2016-02-09 16:59:27 -0800230 stepResult = main.TRUE
GlennRC475f50d2015-10-23 15:01:09 -0700231 main.step( "Comparing MN topology to ONOS topology" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700232 compareRetry = 0
233 while compareRetry < 3:
YPZhang81a7d4e2016-04-18 13:10:17 -0700234 #While loop for retry
Devin Lim58046fa2017-07-05 16:55:00 -0700235 devices = main.topoRelated.getAllDevices( main.numCtrls, False )
236 ports = main.topoRelated.getAllPorts( main.numCtrls, False )
237 links = main.topoRelated.getAllLinks( main.numCtrls, False)
YPZhang81a7d4e2016-04-18 13:10:17 -0700238 mnSwitches = main.Mininet1.getSwitches()
239 mnLinks = main.Mininet1.getLinks(timeout=180)
GlennRC475f50d2015-10-23 15:01:09 -0700240
YPZhang81a7d4e2016-04-18 13:10:17 -0700241 for controller in range(len(main.activeNodes)):
YPZhangacaaf422016-07-26 09:34:03 -0700242 # controllerStr = str( main.activeNodes[controller] + 1 )
Devin Lim58046fa2017-07-05 16:55:00 -0700243 currentDevicesResult = main.topoRelated.compareDevicePort(
244 main.Mininet1, controller,
245 mnSwitches,
246 devices, ports )
YPZhang81a7d4e2016-04-18 13:10:17 -0700247
Devin Lim58046fa2017-07-05 16:55:00 -0700248 currentLinksResult = main.topoRelated.compareBase( links, controller,
249 main.Mininet1.compareLinks,
250 [ mnSwitches, mnLinks ] )
YPZhang81a7d4e2016-04-18 13:10:17 -0700251
YPZhangacaaf422016-07-26 09:34:03 -0700252 stepResult = stepResult and currentDevicesResult and currentLinksResult
YPZhang81a7d4e2016-04-18 13:10:17 -0700253 if stepResult:
254 break
255 compareRetry += 1
YPZhangacaaf422016-07-26 09:34:03 -0700256 utilities.assert_equals(expect=main.TRUE,
257 actual=stepResult,
258 onpass=" Topology match Mininet",
259 onfail="ONOS Topology doesn't match Mininet")
YPZhang81a7d4e2016-04-18 13:10:17 -0700260
YPZhangacaaf422016-07-26 09:34:03 -0700261 if stepResult:
262 if main.hostDiscover:
263 hostList = []
264 for i in range( 1, int( main.currScale ) + 1 ):
265 for j in range( 1, int( main.currScale ) + 1) :
266 # Generate host list
267 hoststr = "h" + str(i) + "x" + str(j)
268 hostList.append(hoststr)
269 for i in range( len(hostList) ):
270 totalHost = main.topo.sendArpPackage( main, hostList[i] )
271 time.sleep( main.hostDiscoverSleep )
272 if totalHost < 0:
273 # if totalHost less than 0 which means dependence function has exception.
274 main.log.info( "Error when discover host!" )
275 break
276 if totalHost == int( main.currScale ) * int( main.currScale ):
277 main.log.info( "Discovered all hosts" )
You Wang7bb9c462016-08-10 14:18:16 -0700278 stepResult = stepResult and main.TRUE
YPZhangacaaf422016-07-26 09:34:03 -0700279 else:
280 main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
You Wang7bb9c462016-08-10 14:18:16 -0700281 stepResult = main.FALSE
YPZhangacaaf422016-07-26 09:34:03 -0700282 utilities.assert_equals(expect=main.TRUE,
283 actual=stepResult,
284 onpass=" Topology match Mininet",
285 onfail="ONOS Topology doesn't match Mininet")
286 main.log.info( "Finished this iteration, continue to scale next topology." )
YPZhang81a7d4e2016-04-18 13:10:17 -0700287 else:
YPZhangacaaf422016-07-26 09:34:03 -0700288 main.log.info( "Clean up and exit TestON. Finished this test." )
289 main.cleanup()
290 main.exit()
GlennRC475f50d2015-10-23 15:01:09 -0700291
GlennRC632e2892015-10-19 18:58:41 -0700292 def CASE100( self, main ):
293 '''
YPZhang81a7d4e2016-04-18 13:10:17 -0700294 Bring Down node 3
GlennRC632e2892015-10-19 18:58:41 -0700295 '''
GlennRC475f50d2015-10-23 15:01:09 -0700296
YPZhangacaaf422016-07-26 09:34:03 -0700297 main.case("Bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700298 main.caseExplanation = "Balance masters to make sure " +\
299 "each controller has some devices and " +\
300 "stop ONOS node 3 service. "
301
GlennRC475f50d2015-10-23 15:01:09 -0700302 stepResult = main.FALSE
GlennRCed2122e2015-10-21 14:38:46 -0700303 main.step( "Bringing down node 3" )
GlennRCed2122e2015-10-21 14:38:46 -0700304 # Always bring down the third node
305 main.deadNode = 2
GlennRCed2122e2015-10-21 14:38:46 -0700306 # Printing purposes
GlennRC632e2892015-10-19 18:58:41 -0700307 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700308 main.log.info( "Stopping node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700309 stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] )
GlennRC475f50d2015-10-23 15:01:09 -0700310 main.log.info( "Removing dead node from list of active nodes" )
311 main.activeNodes.pop( main.deadNode )
GlennRC632e2892015-10-19 18:58:41 -0700312
YPZhang77badfc2016-03-09 10:28:59 -0800313 utilities.assert_equals( expect=main.TRUE,
314 actual=stepResult,
315 onpass="Successfully bring down node 3",
316 onfail="Failed to bring down node 3" )
GlennRC632e2892015-10-19 18:58:41 -0700317
GlennRC475f50d2015-10-23 15:01:09 -0700318 def CASE200( self, main ):
GlennRC632e2892015-10-19 18:58:41 -0700319 '''
YPZhangacaaf422016-07-26 09:34:03 -0700320 Bring up onos node
GlennRC632e2892015-10-19 18:58:41 -0700321 '''
GlennRC475f50d2015-10-23 15:01:09 -0700322
YPZhangacaaf422016-07-26 09:34:03 -0700323 main.case("Bring ONOS node 3 up: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700324 main.caseExplanation = "Bring node 3 back up and balance the masters"
GlennRC632e2892015-10-19 18:58:41 -0700325
326 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700327 main.log.info( "Starting node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700328 stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700329 main.log.info( "Starting onos cli" )
GlennRC475f50d2015-10-23 15:01:09 -0700330 stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700331
GlennRC475f50d2015-10-23 15:01:09 -0700332 main.log.info( "Adding previously dead node to list of active nodes" )
GlennRC632e2892015-10-19 18:58:41 -0700333 main.activeNodes.append( main.deadNode )
334
GlennRC632e2892015-10-19 18:58:41 -0700335 utilities.assert_equals( expect=main.TRUE,
336 actual=stepResult,
337 onpass="Successfully brought up onos node %s" % node,
338 onfail="Failed to bring up onos node %s" % node )
339
340
GlennRCe283c4b2016-01-07 13:04:10 -0800341 time.sleep(main.nodeSleep)
342
343 def CASE300( self, main ):
344 '''
345
346 Balancing Masters
347 '''
YPZhang85024fc2016-02-09 16:59:27 -0800348 time.sleep(main.balanceSleep)
GlennRC475f50d2015-10-23 15:01:09 -0700349 main.step( "Balancing Masters" )
GlennRCe283c4b2016-01-07 13:04:10 -0800350
GlennRC475f50d2015-10-23 15:01:09 -0700351 stepResult = main.FALSE
352 if main.activeNodes:
353 controller = main.activeNodes[0]
YPZhang924ccfe2016-01-26 14:17:30 -0800354 stepResult = utilities.retry( main.CLIs[controller].balanceMasters,
355 main.FALSE,
356 [],
357 sleep=3,
358 attempts=3 )
359
GlennRCe283c4b2016-01-07 13:04:10 -0800360 else:
361 main.log.error( "List of active nodes is empty" )
GlennRC475f50d2015-10-23 15:01:09 -0700362 utilities.assert_equals( expect=main.TRUE,
363 actual=stepResult,
364 onpass="Balance masters was successfull",
365 onfail="Failed to balance masters")
GlennRC475f50d2015-10-23 15:01:09 -0700366 time.sleep(main.balanceSleep)
367
GlennRC632e2892015-10-19 18:58:41 -0700368 def CASE1000( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700369 '''
370 Report errors/warnings/exceptions
371 '''
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700372 # Compare the slowest Node through total time of each node
373 slowestNode = 0
374 slowestTotalTime = 0
375 # Second capture
376 for i in range( 3 ):
377 # Calculate total time
378 main.allinfo[ 1 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
379 # Compare the total time
380 if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
381 slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
382 slowestNode = i
383 # Calculate switch connection time
384 main.allinfo[ 1 ][ 'info' + str( i )][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'start' ], 'last', index=i, funcMode='TD' )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800385 # Calculate the time from last switch connection to the last role request
386 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
387 # Calculate the time from the last role request to the last topology
388 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700389 # Calculate the disconnecti rate
390 main.allinfo[ 1 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ],'num', index=i, funcMode='DR' )
391
392 if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
393 main.log.error( "The results of two capture are different!" )
394 main.log.debug( "The data is " + str( main.allinfo ) )
395 if main.writeData != -1:
396 main.log.info( "Write the date into database" )
397 # write the date into data base
398 with open( main.dbFilePath, "a" ) as dbFile:
399 temp = str( main.currScale )
400 temp += ",'baremetal1'"
401 # put result from second capture into data base
402 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'totalTime' ] )
403 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'swConnection' ] )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800404 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastSwToLastRr' ] )
405 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastRrToLastTopology' ] )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700406 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'disconnectRate' ] )
407 temp += "\n"
408 dbFile.write( temp )
409 else:
410 main.log.error( "The data from log is wrong!" )
411 main.writeData = 1
GlennRC475f50d2015-10-23 15:01:09 -0700412 main.case( "Checking logs for errors, warnings, and exceptions" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700413 main.log.info( "Error report: \n" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700414 main.ONOSbench.logReport( main.ONOSip[ 0 ],
GlennRC475f50d2015-10-23 15:01:09 -0700415 [ "INFO",
416 "FOLLOWER",
417 "WARN",
418 "flow",
419 "ERROR",
420 "Except" ],
Chiyu Cheng899621b2016-11-14 11:14:48 -0800421 "s" )