blob: 1ad81ad30fa0a6cbb145d3e631ed13d1cb6d935a [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 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"""
suibin zhang17308622016-04-14 15:45:30 -070021class SCPFbatchFlowResp:
Jon Hall5c3ff722017-05-24 17:24:59 -070022
23 """
suibin zhang17308622016-04-14 15:45:30 -070024 Testing end-to-end ONOS response time from POST of batched flows to when ONOS returns
25 response confirmation of all flows ADDED; subsequently testing the response time from when REST DELETE to
26 ONOS confirmation of all flows REMOVED.
Jon Hall5c3ff722017-05-24 17:24:59 -070027 """
suibin zhang17308622016-04-14 15:45:30 -070028 def __init__( self ):
29 self.default = ''
30
31 def CASE1( self, main ):
32 import time
33 import os
34 import imp
35
36 """
37 - Construct tests variables
38 - GIT ( optional )
39 - Checkout ONOS master branch
40 - Pull latest ONOS code
suibin zhang17308622016-04-14 15:45:30 -070041 """
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()
49 stepResult = main.FALSE
50 try:
51 # Test variables
52 main.testOnDirectory = os.path.dirname( os.getcwd() )
53 main.cellName = main.params[ 'CASE1' ][ 'cellName' ]
54 main.apps = main.params[ 'CASE1' ][ 'cellApps' ]
55 main.maxNodes = int( main.params[ 'GLOBAL' ][ 'maxNodes' ] )
56 main.startUpSleep = float( main.params[ 'GLOBAL' ][ 'SLEEP' ][ 'startup' ] )
57 main.startMNSleep = float( main.params[ 'GLOBAL' ][ 'SLEEP' ][ 'startMN' ] )
58 main.addFlowSleep = float( main.params[ 'GLOBAL' ][ 'SLEEP' ][ 'addFlow' ] )
59 main.delFlowSleep = float( main.params[ 'GLOBAL' ][ 'SLEEP' ][ 'delFlow' ] )
60 main.chkFlowSleep = float( main.params[ 'GLOBAL' ][ 'SLEEP' ][ 'chkFlow' ] )
You Wanga3cbc052017-07-27 12:22:12 -070061 main.skipPackaging = main.params[ 'CASE2' ][ 'skipPackaging' ]
62 if main.skipPackaging.lower() == "true":
63 main.skipPackaging = True
64 else:
65 main.skipPackaging = False
Devin Lim58046fa2017-07-05 16:55:00 -070066 main.cfgSleep = float( main.params[ 'GLOBAL' ][ 'SLEEP' ][ 'cfg' ] )
67 main.numSw = int( main.params[ 'GLOBAL' ][ 'numSw' ] )
68 main.numThreads = int( main.params[ 'GLOBAL' ][ 'numThreads' ] )
69 main.cluster = main.params[ 'GLOBAL' ][ 'cluster' ]
suibin zhang17308622016-04-14 15:45:30 -070070
Devin Lim58046fa2017-07-05 16:55:00 -070071 stepResult = main.testSetUp.envSetup()
72 except Exception as e:
73 main.testSetUp.envSetupException( e )
74 main.testSetUp.evnSetupConclusion( stepResult )
Jon Hall5c3ff722017-05-24 17:24:59 -070075 main.commit = main.commit.split( " " )[ 1 ]
YPZhang28909bc2016-06-20 13:29:11 -070076
suibin zhang17308622016-04-14 15:45:30 -070077 def CASE2( self, main ):
78 """
79 - Set up cell
80 - Create cell file
81 - Set cell file
82 - Verify cell file
83 - Kill ONOS process
84 - Uninstall ONOS cluster
85 - Verify ONOS start up
86 - Install ONOS cluster
87 - Connect to cli
88 """
Devin Lim142b5342017-07-20 15:22:39 -070089 main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster,
90 skipPack=main.skipPackaging )
suibin zhang17308622016-04-14 15:45:30 -070091
suibin zhang17308622016-04-14 15:45:30 -070092 def CASE10( self, main ):
Jon Hall5c3ff722017-05-24 17:24:59 -070093 """
suibin zhang17308622016-04-14 15:45:30 -070094 Start Mininet
Jon Hall5c3ff722017-05-24 17:24:59 -070095 """
suibin zhang17308622016-04-14 15:45:30 -070096 import time
97
98 main.case( "Enable openflow-base on onos and start Mininet." )
99
Jon Hall5c3ff722017-05-24 17:24:59 -0700100 main.step( "Activate openflow-base App" )
101 app = main.params[ 'CASE10' ][ 'app' ]
Devin Lim142b5342017-07-20 15:22:39 -0700102 stepResult = main.Cluster.active( 0 ).CLI.activateApp( app )
Jon Hall5c3ff722017-05-24 17:24:59 -0700103 time.sleep( main.cfgSleep )
104 main.log.info( stepResult )
suibin zhang17308622016-04-14 15:45:30 -0700105 utilities.assert_equals( expect=main.TRUE,
106 actual=stepResult,
107 onpass="Successfully activate " + app,
108 onfail="Failed to activate app " + app )
109
Jon Hall5c3ff722017-05-24 17:24:59 -0700110 time.sleep( main.cfgSleep )
suibin zhang17308622016-04-14 15:45:30 -0700111
Jon Hall5c3ff722017-05-24 17:24:59 -0700112 main.step( "Configure AdaptiveFlowSampling " )
Devin Lim142b5342017-07-20 15:22:39 -0700113 stepResult = main.Cluster.active( 0 ).CLI.setCfg( component=main.params[ 'CASE10' ][ 'cfg' ],
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700114 propName="adaptiveFlowSampling ", value=main.params[ 'CASE10' ][ 'adaptiveFlowenabled' ] )
suibin zhang17308622016-04-14 15:45:30 -0700115 utilities.assert_equals( expect=main.TRUE,
116 actual=stepResult,
117 onpass="App Configuration Succeeded! ",
118 onfail="App Configuration Failed!" )
Jon Hall5c3ff722017-05-24 17:24:59 -0700119 time.sleep( main.cfgSleep )
suibin zhang17308622016-04-14 15:45:30 -0700120
Jon Hall5c3ff722017-05-24 17:24:59 -0700121 main.step( "Setup Mininet Linear Topology with " + str( main.numSw ) + " switches" )
122 argStr = main.params[ 'CASE10' ][ 'mnArgs' ].format( main.numSw )
123 stepResult = main.Mininet1.startNet( args=argStr )
suibin zhang17308622016-04-14 15:45:30 -0700124
125 utilities.assert_equals( expect=main.TRUE,
126 actual=stepResult,
127 onpass="Successfully loaded topology",
128 onfail="Failed to load topology" )
129
130 time.sleep( main.startMNSleep )
131
132 main.step( "Assign switches to controller" )
Jon Hall5c3ff722017-05-24 17:24:59 -0700133 for i in range( 1, main.numSw + 1 ):
Devin Lim142b5342017-07-20 15:22:39 -0700134 main.Mininet1.assignSwController( "s" + str( i ),
135 main.Cluster.active( 0 ).ipAddress )
suibin zhang17308622016-04-14 15:45:30 -0700136
137 utilities.assert_equals( expect=main.TRUE,
138 actual=stepResult,
139 onpass="Successfully assigned switch to controller",
140 onfail="Failed to assign switch to controller" )
141
142 main.deviceIdPrefix = "of:"
143
144 time.sleep( main.startMNSleep )
145
146 def CASE11( self, main ):
Jon Hall5c3ff722017-05-24 17:24:59 -0700147 """
suibin zhang17308622016-04-14 15:45:30 -0700148 Start Null Provider
Jon Hall5c3ff722017-05-24 17:24:59 -0700149 """
suibin zhang17308622016-04-14 15:45:30 -0700150 import time
151
152 main.case( "Setup Null Provider for linear Topology" )
153
Jon Hall5c3ff722017-05-24 17:24:59 -0700154 main.step( "Activate Null Provider App" )
Devin Lim142b5342017-07-20 15:22:39 -0700155 stepResult = main.ONOSbench.onosCli( ONOSIp=main.Cluster.active( 0 ).ipAddress,
Jon Hall5c3ff722017-05-24 17:24:59 -0700156 cmdstr="app activate org.onosproject.null" )
suibin zhang17308622016-04-14 15:45:30 -0700157 utilities.assert_equals( expect=main.TRUE,
158 actual=stepResult,
159 onpass="Successfully activated org.onosproject.null",
160 onfail="Failed to activate org.onosproject.null" )
Jon Hall5c3ff722017-05-24 17:24:59 -0700161 time.sleep( main.cfgSleep )
Devin Lim142b5342017-07-20 15:22:39 -0700162 cfgs = main.params[ 'CASE11' ][ 'cfg' ]
Jon Hall5c3ff722017-05-24 17:24:59 -0700163 main.step( "Setup Null Provider Linear Topology with " + str( main.numSw ) + " devices." )
Devin Lim142b5342017-07-20 15:22:39 -0700164 r1 = main.ONOSbench.onosCfgSet( main.Cluster.active( 0 ).ipAddress,
165 cfgs,
166 "deviceCount " + str( main.numSw ) )
167 r2 = main.ONOSbench.onosCfgSet( main.Cluster.active( 0 ).ipAddress,
168 cfgs,
169 "topoShape " + main.params[ 'CASE11' ][ 'nullTopo' ] )
170 r3 = main.ONOSbench.onosCfgSet( main.Cluster.active( 0 ).ipAddress,
171 cfgs,
172 "enabled " + main.params[ 'CASE11' ][ 'nullStart' ] )
suibin zhang17308622016-04-14 15:45:30 -0700173 stepResult = r1 & r2 & r3
174 utilities.assert_equals( expect=main.TRUE,
175 actual=stepResult,
176 onpass="App Configuration Succeeded! ",
177 onfail="App Configuration Failed!" )
178 time.sleep( main.cfgSleep )
179
Jon Hall5c3ff722017-05-24 17:24:59 -0700180 main.log.info( "Check to make sure null providers are configured correctly." )
181 main.ONOSbench.handle.sendline( "onos $OC1 summary" )
182 stepResult = main.ONOSbench.handle.expect( ":~" )
183 main.log.info( "ONOS Summary: " + main.ONOSbench.handle.before )
suibin zhang17308622016-04-14 15:45:30 -0700184
185 main.deviceIdPrefix = "null:"
186
187 time.sleep( main.startMNSleep )
188
suibin zhang17308622016-04-14 15:45:30 -0700189 def CASE1000( self, main ):
Jon Hall5c3ff722017-05-24 17:24:59 -0700190 """
suibin zhang17308622016-04-14 15:45:30 -0700191 create JSON object with batched flows
Jon Hall5c3ff722017-05-24 17:24:59 -0700192 """
suibin zhang17308622016-04-14 15:45:30 -0700193 import numpy
194 import time
195 from pprint import pprint
196
197 main.case( "Create a json object for the batched flows" )
198
199 main.step( "Parse batch creation information" )
Jon Hall5c3ff722017-05-24 17:24:59 -0700200 main.batchSize = int( main.params[ 'CASE1000' ][ 'batchSize' ] )
201 main.log.info( "Number of flows in a batch is:" + str( main.batchSize ) )
suibin zhang17308622016-04-14 15:45:30 -0700202
203 main.flowJsonBatchList = []
204 startSw = 1
205
Jon Hall5c3ff722017-05-24 17:24:59 -0700206 main.step( "Creating a full list of batches" )
207 for index in range( 1, int( main.params[ 'CASE1000' ][ 'batches' ] ) + 1 ):
suibin zhang17308622016-04-14 15:45:30 -0700208 if startSw <= main.numSw:
209 ind = startSw
210 else:
211 startSw = 1
212 ind = startSw
213
Jon Hall5c3ff722017-05-24 17:24:59 -0700214 main.log.info( "Creating batch: " + str( index ) )
Devin Lim142b5342017-07-20 15:22:39 -0700215 flowJsonBatch = main.Cluster.active( 0 ).REST.createFlowBatch( numSw=main.numSw,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700216 swIndex=ind,
217 batchSize=main.batchSize,
218 batchIndex=index,
219 deviceIdpreFix=main.deviceIdPrefix,
220 ingressPort=2,
221 egressPort=3 )
Jon Hall5c3ff722017-05-24 17:24:59 -0700222 main.flowJsonBatchList.append( flowJsonBatch )
suibin zhang17308622016-04-14 15:45:30 -0700223
224 startSw += 1
Jon Hall5c3ff722017-05-24 17:24:59 -0700225 main.log.info( "Number of items created in the batch list is: " + str( len( main.flowJsonBatchList ) ) )
suibin zhang17308622016-04-14 15:45:30 -0700226
Jon Hall5c3ff722017-05-24 17:24:59 -0700227 def CASE2100( self, main ):
228 """
suibin zhang17308622016-04-14 15:45:30 -0700229 Posting flow batches using threads
Jon Hall5c3ff722017-05-24 17:24:59 -0700230 """
231 main.case( "Using REST API /flows/{} to post flow batch - multi-threads" )
232 main.step( "Using REST API /flows/{} to post flow batch - multi-threads" )
suibin zhang17308622016-04-14 15:45:30 -0700233
234 from Queue import Queue
235 from threading import Thread
236 import time
237 import json
238
239 main.threadID = 0
240 main.addedBatchList = []
241 q = Queue()
242 tAllAdded = 0
You Wang7b5b2262016-11-10 13:54:56 -0800243 main.postFailed = False
suibin zhang17308622016-04-14 15:45:30 -0700244
Jon Hall5c3ff722017-05-24 17:24:59 -0700245 def postWorker( id ):
suibin zhang17308622016-04-14 15:45:30 -0700246 while True:
247 item = q.get()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700248 # print json.dumps( item )
Devin Lim142b5342017-07-20 15:22:39 -0700249 status, response = main.Cluster.active( 0 ).REST.sendFlowBatch( batch=item )
You Wang7b5b2262016-11-10 13:54:56 -0800250 if status == main.TRUE:
Jon Hall5c3ff722017-05-24 17:24:59 -0700251 main.log.info( "Thread {} is working on posting. ".format( id ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700252 # print json.dumps( response )
Jon Hall5c3ff722017-05-24 17:24:59 -0700253 main.addedBatchList.append( response[ 1 ] )
You Wang7b5b2262016-11-10 13:54:56 -0800254 else:
Jon Hall5c3ff722017-05-24 17:24:59 -0700255 main.log.error( "Thread {} failed to post.".format( id ) )
You Wang7b5b2262016-11-10 13:54:56 -0800256 main.postFailed = True
suibin zhang17308622016-04-14 15:45:30 -0700257 q.task_done()
258
Jon Hall5c3ff722017-05-24 17:24:59 -0700259 for i in range( int( main.params[ 'CASE2100' ][ 'numThreads' ] ) ):
260 threadID = "ThreadID-" + str( i )
261 t = Thread( target=postWorker, name=threadID, args=( threadID, ) )
suibin zhang17308622016-04-14 15:45:30 -0700262 t.daemon = True
263 t.start()
264
265 tStartPost = time.time()
266 for item in main.flowJsonBatchList:
Jon Hall5c3ff722017-05-24 17:24:59 -0700267 q.put( item )
suibin zhang17308622016-04-14 15:45:30 -0700268
269 q.join()
270 tLastPostEnd = time.time()
You Wang7b5b2262016-11-10 13:54:56 -0800271 if main.postFailed:
272 main.log.error( "Flow batch posting failed, exit test" )
Devin Lim44075962017-08-11 10:56:37 -0700273 main.cleanAndExit()
suibin zhang17308622016-04-14 15:45:30 -0700274
Jon Hall5c3ff722017-05-24 17:24:59 -0700275 main.step( "Check to ensure all flows are in added state." )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700276 # pprint( main.addedBatchList )
suibin zhang17308622016-04-14 15:45:30 -0700277 resp = main.FALSE
Jon Hall5c3ff722017-05-24 17:24:59 -0700278 while resp != main.TRUE and ( tAllAdded - tLastPostEnd < int( main.params[ 'CASE2100' ][ 'chkFlowTO' ] ) ):
279 if main.params[ 'CASE2100' ][ 'RESTchkFlow' ] == 'main.TRUE':
Devin Lim142b5342017-07-20 15:22:39 -0700280 resp = main.Cluster.active( 0 ).REST.checkFlowsState()
suibin zhang17308622016-04-14 15:45:30 -0700281 else:
Devin Lim142b5342017-07-20 15:22:39 -0700282 handle = main.Cluster.active( 0 ).CLI.flows( state=" |grep PEND|wc -l", jsonFormat=False )
Jon Hall5c3ff722017-05-24 17:24:59 -0700283 main.log.info( "handle returns PENDING flows: " + handle )
suibin zhang17308622016-04-14 15:45:30 -0700284 if handle == "0":
285 resp = main.TRUE
286
287 time.sleep( main.chkFlowSleep )
288 tAllAdded = time.time()
289
Jon Hall5c3ff722017-05-24 17:24:59 -0700290 if tAllAdded - tLastPostEnd >= int( main.params[ 'CASE2100' ][ 'chkFlowTO' ] ):
291 main.log.warn( "ONOS Flows still in pending state after: {} seconds.".format( tAllAdded - tLastPostEnd ) )
suibin zhang17308622016-04-14 15:45:30 -0700292
Jon Hall5c3ff722017-05-24 17:24:59 -0700293 main.numFlows = int( main.params[ 'CASE1000' ][ 'batches' ] ) *\
294 int( main.params[ 'CASE1000' ][ 'batchSize' ] )
295 main.log.info( "Total number of flows: " + str( main.numFlows ) )
296 main.elapsePOST = tLastPostEnd - tStartPost
297 main.log.info( "Total POST elapse time: " + str( main.elapsePOST ) )
298 main.log.info( "Rate of ADD Controller response: " + str( main.numFlows / ( main.elapsePOST ) ) )
suibin zhang17308622016-04-14 15:45:30 -0700299
300 main.POSTtoCONFRM = tAllAdded - tLastPostEnd
Jon Hall5c3ff722017-05-24 17:24:59 -0700301 main.log.info( "Elapse time from end of last REST POST to Flows in ADDED state: " +
302 str( main.POSTtoCONFRM ) )
303 main.log.info( "Rate of Confirmed Batch Flow ADD is ( flows/sec ): " +
304 str( main.numFlows / main.POSTtoCONFRM ) )
305 main.log.info( "Number of flow Batches in the addedBatchList is: " +
306 str( len( main.addedBatchList ) ) )
suibin zhang17308622016-04-14 15:45:30 -0700307
Jon Hall5c3ff722017-05-24 17:24:59 -0700308 def CASE3100( self, main ):
309 """
suibin zhang17308622016-04-14 15:45:30 -0700310 DELETE flow batches using threads
Jon Hall5c3ff722017-05-24 17:24:59 -0700311 """
312 main.case( "Using REST API /flows/{} to delete flow batch - multi-threads" )
313 main.step( "Using REST API /flows/{} to delete flow batch - multi-threads" )
suibin zhang17308622016-04-14 15:45:30 -0700314
315 from Queue import Queue
316 from threading import Thread
317 import time
318 import json
319
320 main.threadID = 0
321 q = Queue()
322 tAllRemoved = 0
323
Jon Hall5c3ff722017-05-24 17:24:59 -0700324 main.log.info( "Number of flow batches at start of remove: " + str( len( main.addedBatchList ) ) )
325
326 def removeWorker( id ):
suibin zhang17308622016-04-14 15:45:30 -0700327 while True:
328 item = q.get()
Devin Lim142b5342017-07-20 15:22:39 -0700329 response = main.Cluster.active( 0 ).REST.removeFlowBatch( batch=json.loads( item ) )
Jon Hall5c3ff722017-05-24 17:24:59 -0700330 main.log.info( "Thread {} is working on deleting. ".format( id ) )
suibin zhang17308622016-04-14 15:45:30 -0700331 q.task_done()
332
Jon Hall5c3ff722017-05-24 17:24:59 -0700333 for i in range( int( main.params[ 'CASE2100' ][ 'numThreads' ] ) ):
334 threadID = "ThreadID-" + str( i )
335 t = Thread( target=removeWorker, name=threadID, args=( threadID, ) )
suibin zhang17308622016-04-14 15:45:30 -0700336 t.daemon = True
337 t.start()
338
339 tStartDelete = time.time()
340 for item in main.addedBatchList:
Jon Hall5c3ff722017-05-24 17:24:59 -0700341 q.put( item )
suibin zhang17308622016-04-14 15:45:30 -0700342
343 q.join()
344 tLastDeleteEnd = time.time()
Jon Hall5c3ff722017-05-24 17:24:59 -0700345 main.log.info( "Number of flow batches at end of remove: " + str( len( main.addedBatchList ) ) )
suibin zhang17308622016-04-14 15:45:30 -0700346
Jon Hall5c3ff722017-05-24 17:24:59 -0700347 main.step( "Check to ensure all flows are in added state." )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700348 # pprint( main.addedBatchList )
suibin zhang17308622016-04-14 15:45:30 -0700349 resp = main.FALSE
Jon Hall5c3ff722017-05-24 17:24:59 -0700350 while resp != main.TRUE and ( tAllRemoved - tLastDeleteEnd < int( main.params[ 'CASE3100' ][ 'chkFlowTO' ] ) ):
351 if main.params[ 'CASE3100' ][ 'RESTchkFlow' ] == 'main.TRUE':
Devin Lim142b5342017-07-20 15:22:39 -0700352 resp = main.Cluster.active( 0 ).REST.checkFlowsState()
suibin zhang17308622016-04-14 15:45:30 -0700353 else:
Devin Lim142b5342017-07-20 15:22:39 -0700354 handle = main.Cluster.active( 0 ).CLI.flows( state=" |grep PEND|wc -l", jsonFormat=False )
Jon Hall5c3ff722017-05-24 17:24:59 -0700355 main.log.info( "handle returns PENDING flows: " + handle )
suibin zhang17308622016-04-14 15:45:30 -0700356 if handle == "0":
357 resp = main.TRUE
358 time.sleep( main.chkFlowSleep )
359 tAllRemoved = time.time()
360
Jon Hall5c3ff722017-05-24 17:24:59 -0700361 if tLastDeleteEnd - tLastDeleteEnd >= int( main.params[ 'CASE2100' ][ 'chkFlowTO' ] ):
362 main.log.warn( "ONOS Flows still in pending state after: {} seconds.".format( tAllRemoved - tLastDeleteEnd ) )
suibin zhang17308622016-04-14 15:45:30 -0700363
Jon Hall5c3ff722017-05-24 17:24:59 -0700364 main.numFlows = int( main.params[ 'CASE1000' ][ 'batches' ] ) *\
365 int( main.params[ 'CASE1000' ][ 'batchSize' ] )
366 main.log.info( "Total number of flows: " + str( main.numFlows ) )
367 main.elapseDELETE = tLastDeleteEnd - tStartDelete
368 main.log.info( "Total DELETE elapse time: " + str( main.elapseDELETE ) )
369 main.log.info( "Rate of DELETE Controller response: " + str( main.numFlows / ( main.elapseDELETE ) ) )
suibin zhang17308622016-04-14 15:45:30 -0700370
371 main.DELtoCONFRM = tAllRemoved - tLastDeleteEnd
Jon Hall5c3ff722017-05-24 17:24:59 -0700372 main.log.info( "Elapse time from end of last REST DELETE to Flows in REMOVED state: " +
373 str( main.DELtoCONFRM ) )
374 main.log.info( "Rate of Confirmed Batch Flow REMOVED is ( flows/sec ): " + str( main.numFlows / main.DELtoCONFRM ) )
suibin zhang17308622016-04-14 15:45:30 -0700375
Jon Hall5c3ff722017-05-24 17:24:59 -0700376 def CASE100( self, main ):
suibin zhang17308622016-04-14 15:45:30 -0700377 from pprint import pprint
378
379 main.case( "Check to ensure onos flows." )
380
Devin Lim142b5342017-07-20 15:22:39 -0700381 resp = main.Cluster.active( 0 ).REST.checkFlowsState()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700382 # pprint( resp )
suibin zhang17308622016-04-14 15:45:30 -0700383
Jon Hall5c3ff722017-05-24 17:24:59 -0700384 def CASE210( self, main ):
385 main.case( "Log test results to a data file" )
386 main.step( "Write test resulted data to a data file" )
suibin zhang17308622016-04-14 15:45:30 -0700387 main.scale = main.maxNodes
388
389 try:
Jon Hall5c3ff722017-05-24 17:24:59 -0700390 dbFileName = "/tmp/SCPFbatchFlowRespData"
391 dbfile = open( dbFileName, "w+" )
suibin zhang17308622016-04-14 15:45:30 -0700392 temp = "'" + main.commit + "',"
YPZhang28909bc2016-06-20 13:29:11 -0700393 temp += "'1gig',"
suibin zhang17308622016-04-14 15:45:30 -0700394 temp += "'" + str( main.scale ) + "',"
395 temp += "'" + main.cluster + "',"
396 temp += "'" + str( main.elapsePOST ) + "',"
397 temp += "'" + str( main.POSTtoCONFRM ) + "',"
YPZhang28909bc2016-06-20 13:29:11 -0700398 temp += "'" + str( main.numFlows / main.POSTtoCONFRM ) + "',"
Jon Hall5c3ff722017-05-24 17:24:59 -0700399 temp += "'" + str( main.elapseDELETE ) + "',"
400 temp += "'" + str( main.DELtoCONFRM ) + "',"
YPZhang28909bc2016-06-20 13:29:11 -0700401 temp += "'" + str( main.numFlows / main.DELtoCONFRM ) + "',"
402 temp += "'" + str( main.numSw ) + "'\n"
suibin zhang17308622016-04-14 15:45:30 -0700403 dbfile.write( temp )
404 dbfile.close()
405 stepResult = main.TRUE
406 except IOError:
Jon Hall5c3ff722017-05-24 17:24:59 -0700407 main.log.warn( "Error opening " + dbFileName + " to write results." )
suibin zhang17308622016-04-14 15:45:30 -0700408 stepResult = main.FALSE
409
410 utilities.assert_equals( expect=main.TRUE,
411 actual=stepResult,
412 onpass="Succeeded to write results to datafile",
413 onfail="Failed to write results to datafile " )
Jon Hall5c3ff722017-05-24 17:24:59 -0700414
suibin zhang17308622016-04-14 15:45:30 -0700415 def CASE110( self, main ):
Jon Hall5c3ff722017-05-24 17:24:59 -0700416 """
suibin zhang17308622016-04-14 15:45:30 -0700417 Report errors/warnings/exceptions
Jon Hall5c3ff722017-05-24 17:24:59 -0700418 """
419 main.log.info( "Error report: \n" )
Devin Lim142b5342017-07-20 15:22:39 -0700420 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
suibin zhang17308622016-04-14 15:45:30 -0700421 [ "INFO",
422 "FOLLOWER",
423 "WARN",
424 "flow",
425 "ERROR",
426 "Except" ],
427 "s" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700428 # main.stop()