blob: 58505e9198ac2880949f8925a45edad142fa1b6e [file] [log] [blame]
kelvin-onlab1d381fe2015-07-14 16:24:56 -07001
2# Testing network scalability, this test suite scales up a network topology
3# using mininet and verifies ONOS stability
4
GlennRC1c5df3c2015-08-27 16:12:09 -07005class SCPFscaleTopo:
kelvin-onlab1d381fe2015-07-14 16:24:56 -07006
7 def __init__( self ):
8 self.default = ''
9
10 def CASE1( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -070011 import os
12 import imp
kelvin-onlab1d381fe2015-07-14 16:24:56 -070013 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
Devin Lim58046fa2017-07-05 16:55:00 -070022 try:
23 from tests.dependencies.ONOSSetup import ONOSSetup
24 main.testSetUp = ONOSSetup()
25 except ImportError:
26 main.log.error( "ONOSSetup not found. exiting the test" )
27 main.exit()
28 main.testSetUp.envSetupDescription()
kelvin-onlab1d381fe2015-07-14 16:24:56 -070029 stepResult = main.FALSE
Devin Lim58046fa2017-07-05 16:55:00 -070030 try:
31 # The variable to decide if the data should be written into data base.
32 # 1 means Yes and -1 means No.
33 main.writeData = 1
34 main.searchTerm = main.params[ 'SearchTerm' ]
35 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
36 main.dependencyPath = main.testOnDirectory + \
37 main.params[ 'DEPENDENCY' ][ 'path' ]
38 main.tsharkResultPath = main.params[ 'TsharkPath' ]
39 main.roleRequest = main.params[ 'SearchTerm' ]['roleRequest']
40 main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
41 main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ]
42 main.numCtrls = int( main.params[ 'CTRL' ][ 'numCtrls' ] )
43 main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," )
44 main.topoScaleSize = len( main.topoScale )
45 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
46 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
47 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
48 main.topoCmpAttempts = int( main.params[ 'ATTEMPTS' ][ 'topoCmp' ] )
49 main.pingallAttempts = int( main.params[ 'ATTEMPTS' ][ 'pingall' ] )
50 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
51 main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] )
52 main.nodeSleep = int( main.params[ 'SLEEP' ][ 'nodeSleep' ] )
53 main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] )
54 main.MNSleep = int( main.params[ 'SLEEP' ][ 'MNsleep' ] )
55 main.pingTimeout = float( main.params[ 'TIMEOUT' ][ 'pingall' ] )
56 main.hostDiscover = main.params[ 'TOPOLOGY' ][ 'host' ]
57 main.hostDiscoverSleep = float( main.params['SLEEP']['host'] )
58 if main.hostDiscover == 'True':
59 main.hostDiscover = True
60 else:
61 main.hostDiscover = False
62 main.homeDir = os.path.expanduser('~')
63 main.hostsData = {}
64 main.activeNodes = []
Chiyu Chengb8c2c842016-10-05 12:40:49 -070065
Chiyu Cheng899621b2016-11-14 11:14:48 -080066
Devin Lim58046fa2017-07-05 16:55:00 -070067 stepResult = main.testSetUp.envSetup()
68 main.allinfo = {} # The dictionary to record all the data from karaf.log
Chiyu Cheng899621b2016-11-14 11:14:48 -080069
Devin Lim58046fa2017-07-05 16:55:00 -070070 for i in range( 2 ):
71 main.allinfo[ i ]={}
72 for w in range ( 3 ):
73 # Totaltime: the time from the new switchConnection to its end
74 # swConnection: the time from the first new switchConnection to the last new switchConnection
75 # lastSwToLastRr: the time from the last new switchConnection to the last role request
76 # lastRrToLastTopology: the time form the last role request to the last topology
77 # disconnectRate: the rate that shows how many switch disconnect after connection
78 main.allinfo[ i ][ 'info' + str( w ) ]= { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
Chiyu Cheng899621b2016-11-14 11:14:48 -080079
Devin Lim58046fa2017-07-05 16:55:00 -070080 main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
81 main.log.info( "Create Database file " + main.dbFilePath )
82 resultDB = open(main.dbFilePath, 'w+' )
83 resultDB.close()
Chiyu Cheng899621b2016-11-14 11:14:48 -080084
Devin Lim58046fa2017-07-05 16:55:00 -070085 main.scaleTopoFunction = imp.load_source( wrapperFile2,
86 main.dependencyPath +
87 wrapperFile2 +
88 ".py" )
GlennRC632e2892015-10-19 18:58:41 -070089
Devin Lim58046fa2017-07-05 16:55:00 -070090 main.topo = imp.load_source( wrapperFile3,
91 main.dependencyPath +
92 wrapperFile3 +
93 ".py" )
GlennRC632e2892015-10-19 18:58:41 -070094
Devin Lim58046fa2017-07-05 16:55:00 -070095 main.ONOSbench.scp( main.Mininet1,
96 main.dependencyPath +
97 main.multiovs,
98 main.Mininet1.home,
99 direction="to" )
100 except Exception as e:
101 main.testSetUp.envSetupException( e )
102 main.testSetUp.evnSetupConclusion( stepResult )
103 main.commit = main.commit.split( " " )[ 1 ]
GlennRC632e2892015-10-19 18:58:41 -0700104
105 def CASE2( self, main):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700106 """
107 - Set up cell
108 - Create cell file
109 - Set cell file
110 - Verify cell file
111 - Kill ONOS process
112 - Uninstall ONOS cluster
113 - Verify ONOS start up
114 - Install ONOS cluster
115 - Connect to cli
116 """
YPZhangacaaf422016-07-26 09:34:03 -0700117 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700118 try:
119 from tests.dependencies.utils import Utils
120 except ImportError:
121 main.log.error( "Utils not found exiting the test" )
122 main.exit()
123 try:
124 main.Utils
125 except ( NameError, AttributeError ):
126 main.Utils = Utils()
127 main.Utils.mininetCleanup( main.Mininet1 )
128 main.testSetUp.ONOSSetUp( main.Mininet1 )
YPZhang29c2d642016-06-22 16:15:19 -0700129 main.activeNodes = []
GlennRC632e2892015-10-19 18:58:41 -0700130 for i in range( main.numCtrls ):
GlennRC632e2892015-10-19 18:58:41 -0700131 main.activeNodes.append( i )
GlennRC632e2892015-10-19 18:58:41 -0700132
133 def CASE10( self, main ):
134 """
YPZhang85024fc2016-02-09 16:59:27 -0800135 Starting up torus topology
GlennRC632e2892015-10-19 18:58:41 -0700136 """
GlennRC475f50d2015-10-23 15:01:09 -0700137
138 main.case( "Starting up Mininet and verifying topology" )
139 main.caseExplanation = "Starting Mininet with a scalling topology and " +\
140 "comparing topology elements between Mininet and ONOS"
GlennRC475f50d2015-10-23 15:01:09 -0700141 if main.topoScale:
GlennRC90d43952015-10-27 11:36:15 -0700142 main.currScale = main.topoScale.pop(0)
GlennRC475f50d2015-10-23 15:01:09 -0700143 else: main.log.error( "topology scale is empty" )
GlennRC90d43952015-10-27 11:36:15 -0700144 main.step( "Starting up TORUS %sx%s topology" % (main.currScale, main.currScale) )
GlennRC475f50d2015-10-23 15:01:09 -0700145
146 main.log.info( "Constructing Mininet command" )
YPZhangacaaf422016-07-26 09:34:03 -0700147 mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
148 " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
GlennRC475f50d2015-10-23 15:01:09 -0700149 for i in range( main.numCtrls ):
150 mnCmd += " --controller remote,ip=" + main.ONOSip[ i ]
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700151 stepResult = main.Mininet1.startNet( mnCmd=mnCmd )
GlennRC632e2892015-10-19 18:58:41 -0700152 utilities.assert_equals( expect=main.TRUE,
153 actual=stepResult,
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700154 onpass=main.topoName +
GlennRC632e2892015-10-19 18:58:41 -0700155 " topology started successfully",
156 onfail=main.topoName +
157 " topology failed to start" )
158
GlennRCe283c4b2016-01-07 13:04:10 -0800159 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800160 main.log.info( "Clean up Tshark" )
161 with open(main.tsharkResultPath, "w" ) as tshark:
162 tshark.write( "" )
163 main.log.info( "Starting Tshark capture" )
164 main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' )
Chiyu Cheng81499422016-11-09 11:04:23 -0800165 main.CLIs[ 0 ].activateApp( "org.onosproject.openflow" )
166 time.sleep( main.MNSleep )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800167 main.log.info( "Stop Tshark" )
168 main.ONOSbench.tsharkStop()
169 main.log.info( "Get role request time" )
170 with open( main.tsharkResultPath, "r" ) as resultFile:
171 resultText = resultFile.readlines()
172 resultFile.close()
kelvin-onlabd9e23de2015-08-06 10:34:44 -0700173
GlennRC475f50d2015-10-23 15:01:09 -0700174 def CASE11( self, main ):
175 """
YPZhangacaaf422016-07-26 09:34:03 -0700176 Compare topo, and sending Arping package
YPZhang85024fc2016-02-09 16:59:27 -0800177 if the topology is same, then Pass.
GlennRC475f50d2015-10-23 15:01:09 -0700178 """
179 import json
YPZhangacaaf422016-07-26 09:34:03 -0700180 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700181 try:
182 from tests.dependencies.topology import Topology
183 except ImportError:
184 main.log.error( "Topology not found exiting the test" )
185 main.exit()
186 try:
187 main.topoRelated
188 except ( NameError, AttributeError ):
189 main.topoRelated = Topology()
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700190 # First capture
191 for i in range( 3 ):
192 # Calculate total time
193 main.allinfo[ 0 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
194 # Calculate switch connection time
195 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 -0800196 # Calculate the time from last switch connection to the last role request
197 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
198 # Calculate the time from the last role request to the last topology
199 main.allinfo[ 0 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700200 # Calculate the disconnecti rate
201 main.allinfo[ 0 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ], 'num', index=i, funcMode='DR' )
202 main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) )
GlennRC475f50d2015-10-23 15:01:09 -0700203
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700204 main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) )
YPZhang85024fc2016-02-09 16:59:27 -0800205 main.caseExplanation = "Pinging all hosts and comparing topology " +\
GlennRC475f50d2015-10-23 15:01:09 -0700206 "elements between Mininet and ONOS"
GlennRCe283c4b2016-01-07 13:04:10 -0800207
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700208 main.log.info( "Gathering topology information")
YPZhang85024fc2016-02-09 16:59:27 -0800209 time.sleep( main.MNSleep )
YPZhang85024fc2016-02-09 16:59:27 -0800210 stepResult = main.TRUE
GlennRC475f50d2015-10-23 15:01:09 -0700211 main.step( "Comparing MN topology to ONOS topology" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700212 compareRetry = 0
213 while compareRetry < 3:
YPZhang81a7d4e2016-04-18 13:10:17 -0700214 #While loop for retry
Devin Lim58046fa2017-07-05 16:55:00 -0700215 devices = main.topoRelated.getAllDevices( main.numCtrls, False )
216 ports = main.topoRelated.getAllPorts( main.numCtrls, False )
217 links = main.topoRelated.getAllLinks( main.numCtrls, False)
YPZhang81a7d4e2016-04-18 13:10:17 -0700218 mnSwitches = main.Mininet1.getSwitches()
219 mnLinks = main.Mininet1.getLinks(timeout=180)
GlennRC475f50d2015-10-23 15:01:09 -0700220
YPZhang81a7d4e2016-04-18 13:10:17 -0700221 for controller in range(len(main.activeNodes)):
YPZhangacaaf422016-07-26 09:34:03 -0700222 # controllerStr = str( main.activeNodes[controller] + 1 )
Devin Lim58046fa2017-07-05 16:55:00 -0700223 currentDevicesResult = main.topoRelated.compareDevicePort(
224 main.Mininet1, controller,
225 mnSwitches,
226 devices, ports )
YPZhang81a7d4e2016-04-18 13:10:17 -0700227
Devin Lim58046fa2017-07-05 16:55:00 -0700228 currentLinksResult = main.topoRelated.compareBase( links, controller,
229 main.Mininet1.compareLinks,
230 [ mnSwitches, mnLinks ] )
YPZhang81a7d4e2016-04-18 13:10:17 -0700231
YPZhangacaaf422016-07-26 09:34:03 -0700232 stepResult = stepResult and currentDevicesResult and currentLinksResult
YPZhang81a7d4e2016-04-18 13:10:17 -0700233 if stepResult:
234 break
235 compareRetry += 1
YPZhangacaaf422016-07-26 09:34:03 -0700236 utilities.assert_equals(expect=main.TRUE,
237 actual=stepResult,
238 onpass=" Topology match Mininet",
239 onfail="ONOS Topology doesn't match Mininet")
YPZhang81a7d4e2016-04-18 13:10:17 -0700240
YPZhangacaaf422016-07-26 09:34:03 -0700241 if stepResult:
242 if main.hostDiscover:
243 hostList = []
244 for i in range( 1, int( main.currScale ) + 1 ):
245 for j in range( 1, int( main.currScale ) + 1) :
246 # Generate host list
247 hoststr = "h" + str(i) + "x" + str(j)
248 hostList.append(hoststr)
249 for i in range( len(hostList) ):
250 totalHost = main.topo.sendArpPackage( main, hostList[i] )
251 time.sleep( main.hostDiscoverSleep )
252 if totalHost < 0:
253 # if totalHost less than 0 which means dependence function has exception.
254 main.log.info( "Error when discover host!" )
255 break
256 if totalHost == int( main.currScale ) * int( main.currScale ):
257 main.log.info( "Discovered all hosts" )
You Wang7bb9c462016-08-10 14:18:16 -0700258 stepResult = stepResult and main.TRUE
YPZhangacaaf422016-07-26 09:34:03 -0700259 else:
260 main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
You Wang7bb9c462016-08-10 14:18:16 -0700261 stepResult = main.FALSE
YPZhangacaaf422016-07-26 09:34:03 -0700262 utilities.assert_equals(expect=main.TRUE,
263 actual=stepResult,
264 onpass=" Topology match Mininet",
265 onfail="ONOS Topology doesn't match Mininet")
266 main.log.info( "Finished this iteration, continue to scale next topology." )
YPZhang81a7d4e2016-04-18 13:10:17 -0700267 else:
YPZhangacaaf422016-07-26 09:34:03 -0700268 main.log.info( "Clean up and exit TestON. Finished this test." )
269 main.cleanup()
270 main.exit()
GlennRC475f50d2015-10-23 15:01:09 -0700271
GlennRC632e2892015-10-19 18:58:41 -0700272 def CASE100( self, main ):
273 '''
YPZhang81a7d4e2016-04-18 13:10:17 -0700274 Bring Down node 3
GlennRC632e2892015-10-19 18:58:41 -0700275 '''
GlennRC475f50d2015-10-23 15:01:09 -0700276
YPZhangacaaf422016-07-26 09:34:03 -0700277 main.case("Bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700278 main.caseExplanation = "Balance masters to make sure " +\
279 "each controller has some devices and " +\
280 "stop ONOS node 3 service. "
281
GlennRC475f50d2015-10-23 15:01:09 -0700282 stepResult = main.FALSE
GlennRCed2122e2015-10-21 14:38:46 -0700283 main.step( "Bringing down node 3" )
GlennRCed2122e2015-10-21 14:38:46 -0700284 # Always bring down the third node
285 main.deadNode = 2
GlennRCed2122e2015-10-21 14:38:46 -0700286 # Printing purposes
GlennRC632e2892015-10-19 18:58:41 -0700287 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700288 main.log.info( "Stopping node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700289 stepResult = main.ONOSbench.onosStop( main.ONOSip[ main.deadNode ] )
GlennRC475f50d2015-10-23 15:01:09 -0700290 main.log.info( "Removing dead node from list of active nodes" )
291 main.activeNodes.pop( main.deadNode )
GlennRC632e2892015-10-19 18:58:41 -0700292
YPZhang77badfc2016-03-09 10:28:59 -0800293 utilities.assert_equals( expect=main.TRUE,
294 actual=stepResult,
295 onpass="Successfully bring down node 3",
296 onfail="Failed to bring down node 3" )
GlennRC632e2892015-10-19 18:58:41 -0700297
GlennRC475f50d2015-10-23 15:01:09 -0700298 def CASE200( self, main ):
GlennRC632e2892015-10-19 18:58:41 -0700299 '''
YPZhangacaaf422016-07-26 09:34:03 -0700300 Bring up onos node
GlennRC632e2892015-10-19 18:58:41 -0700301 '''
GlennRC475f50d2015-10-23 15:01:09 -0700302
YPZhangacaaf422016-07-26 09:34:03 -0700303 main.case("Bring ONOS node 3 up: TORUS %sx%s" % (main.currScale, main.currScale))
GlennRC475f50d2015-10-23 15:01:09 -0700304 main.caseExplanation = "Bring node 3 back up and balance the masters"
GlennRC632e2892015-10-19 18:58:41 -0700305
306 node = main.deadNode + 1
GlennRC632e2892015-10-19 18:58:41 -0700307 main.log.info( "Starting node %s" % node )
GlennRC475f50d2015-10-23 15:01:09 -0700308 stepResult = main.ONOSbench.onosStart( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700309 main.log.info( "Starting onos cli" )
GlennRC475f50d2015-10-23 15:01:09 -0700310 stepResult = stepResult and main.CLIs[ main.deadNode ].startOnosCli( main.ONOSip[ main.deadNode ] )
GlennRC632e2892015-10-19 18:58:41 -0700311
GlennRC475f50d2015-10-23 15:01:09 -0700312 main.log.info( "Adding previously dead node to list of active nodes" )
GlennRC632e2892015-10-19 18:58:41 -0700313 main.activeNodes.append( main.deadNode )
314
GlennRC632e2892015-10-19 18:58:41 -0700315 utilities.assert_equals( expect=main.TRUE,
316 actual=stepResult,
317 onpass="Successfully brought up onos node %s" % node,
318 onfail="Failed to bring up onos node %s" % node )
319
320
GlennRCe283c4b2016-01-07 13:04:10 -0800321 time.sleep(main.nodeSleep)
322
323 def CASE300( self, main ):
324 '''
325
326 Balancing Masters
327 '''
YPZhang85024fc2016-02-09 16:59:27 -0800328 time.sleep(main.balanceSleep)
GlennRC475f50d2015-10-23 15:01:09 -0700329 main.step( "Balancing Masters" )
GlennRCe283c4b2016-01-07 13:04:10 -0800330
GlennRC475f50d2015-10-23 15:01:09 -0700331 stepResult = main.FALSE
332 if main.activeNodes:
333 controller = main.activeNodes[0]
YPZhang924ccfe2016-01-26 14:17:30 -0800334 stepResult = utilities.retry( main.CLIs[controller].balanceMasters,
335 main.FALSE,
336 [],
337 sleep=3,
338 attempts=3 )
339
GlennRCe283c4b2016-01-07 13:04:10 -0800340 else:
341 main.log.error( "List of active nodes is empty" )
GlennRC475f50d2015-10-23 15:01:09 -0700342 utilities.assert_equals( expect=main.TRUE,
343 actual=stepResult,
344 onpass="Balance masters was successfull",
345 onfail="Failed to balance masters")
GlennRC475f50d2015-10-23 15:01:09 -0700346 time.sleep(main.balanceSleep)
347
GlennRC632e2892015-10-19 18:58:41 -0700348 def CASE1000( self, main ):
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700349 '''
350 Report errors/warnings/exceptions
351 '''
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700352 # Compare the slowest Node through total time of each node
353 slowestNode = 0
354 slowestTotalTime = 0
355 # Second capture
356 for i in range( 3 ):
357 # Calculate total time
358 main.allinfo[ 1 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' )
359 # Compare the total time
360 if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
361 slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
362 slowestNode = i
363 # Calculate switch connection time
364 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 -0800365 # Calculate the time from last switch connection to the last role request
366 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i )
367 # Calculate the time from the last role request to the last topology
368 main.allinfo[ 1 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700369 # Calculate the disconnecti rate
370 main.allinfo[ 1 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ],'num', index=i, funcMode='DR' )
371
372 if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
373 main.log.error( "The results of two capture are different!" )
374 main.log.debug( "The data is " + str( main.allinfo ) )
375 if main.writeData != -1:
376 main.log.info( "Write the date into database" )
377 # write the date into data base
378 with open( main.dbFilePath, "a" ) as dbFile:
379 temp = str( main.currScale )
380 temp += ",'baremetal1'"
381 # put result from second capture into data base
382 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'totalTime' ] )
383 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'swConnection' ] )
Chiyu Cheng899621b2016-11-14 11:14:48 -0800384 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastSwToLastRr' ] )
385 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastRrToLastTopology' ] )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700386 temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'disconnectRate' ] )
387 temp += "\n"
388 dbFile.write( temp )
389 else:
390 main.log.error( "The data from log is wrong!" )
391 main.writeData = 1
GlennRC475f50d2015-10-23 15:01:09 -0700392 main.case( "Checking logs for errors, warnings, and exceptions" )
Chiyu Chengb8c2c842016-10-05 12:40:49 -0700393 main.log.info( "Error report: \n" )
kelvin-onlab1d381fe2015-07-14 16:24:56 -0700394 main.ONOSbench.logReport( main.ONOSip[ 0 ],
GlennRC475f50d2015-10-23 15:01:09 -0700395 [ "INFO",
396 "FOLLOWER",
397 "WARN",
398 "flow",
399 "ERROR",
400 "Except" ],
Chiyu Cheng899621b2016-11-14 11:14:48 -0800401 "s" )