blob: e3a2cd908e5961edf98215c7db7d7a30d93e2449 [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"""
YPZhangcb86c5b2016-01-27 17:38:12 -080021import sys
22import json
23import time
24import os
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070025"""
YPZhangcb86c5b2016-01-27 17:38:12 -080026SCPFscalingMaxIntents
27Push test Intents to onos
28CASE10: set up Null Provider
29CASE11: set up Open Flows
YPZhang14a4aa92016-07-15 13:37:15 -070030Check flows number, if flows number is not as except, finished this test iteration
YPZhangcb86c5b2016-01-27 17:38:12 -080031Scale up when reach the Limited
32Start from 1 nodes, 8 devices. Then Scale up to 3,5,7 nodes
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070033"""
YPZhangcb86c5b2016-01-27 17:38:12 -080034class SCPFscalingMaxIntents:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070035
YPZhangcb86c5b2016-01-27 17:38:12 -080036 def __init__( self ):
37 self.default = ''
38
Devin Lim142b5342017-07-20 15:22:39 -070039 def CASE0( self, main ):
YPZhangcb86c5b2016-01-27 17:38:12 -080040 import sys
41 import json
42 import time
43 import os
44 import imp
Devin Lim58046fa2017-07-05 16:55:00 -070045 try:
46 from tests.dependencies.ONOSSetup import ONOSSetup
47 main.testSetUp = ONOSSetup()
48 except ImportError:
49 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070050 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070051 main.testSetUp.envSetupDescription()
52 stepResult = main.FALSE
53 try:
54 # Test variables
55 main.dependencyPath = main.testOnDirectory + \
56 main.params[ 'DEPENDENCY' ][ 'path' ]
57 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
58 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
59 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
60 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
61 main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
62 main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
63 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
64 main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
65 main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070066 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
Devin Lim142b5342017-07-20 15:22:39 -070067 main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ]
68 main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ]
Devin Lim58046fa2017-07-05 16:55:00 -070069 main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] )
70 main.ingress = main.params[ 'LINK' ][ 'ingress' ]
71 main.egress = main.params[ 'LINK' ][ 'egress' ]
72 main.reroute = main.params[ 'reroute' ]
73 main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
74 if main.flowObj == "True":
75 main.flowObj = True
76 main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
77 else:
78 main.flowObj = False
79 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
80 main.threadID = 0
YPZhangcb86c5b2016-01-27 17:38:12 -080081
Devin Lim58046fa2017-07-05 16:55:00 -070082 if main.reroute == "True":
83 main.reroute = True
84 else:
85 main.reroute = False
86 main.setupSkipped = False
YPZhangcb86c5b2016-01-27 17:38:12 -080087
Devin Lim58046fa2017-07-05 16:55:00 -070088 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
Devin Lim87e12c42017-07-20 13:53:04 -070089 main.nic = main.params[ 'DATABASE' ][ 'nic' ]
Devin Lim58046fa2017-07-05 16:55:00 -070090 node = main.params[ 'DATABASE' ][ 'node' ]
Devin Lim142b5342017-07-20 15:22:39 -070091 stepResult = main.testSetUp.envSetup()
Devin Lim58046fa2017-07-05 16:55:00 -070092 main.log.info( "Cresting DB file" )
93 with open( main.dbFileName, "w+" ) as dbFile:
Devin Lim142b5342017-07-20 15:22:39 -070094 dbFile.write( "" )
Devin Lim58046fa2017-07-05 16:55:00 -070095 except Exception as e:
96 main.testSetUp.envSetupException( e )
Jon Hallaa1d9b82020-07-30 13:49:42 -070097 main.testSetUp.envSetupConclusion( stepResult )
Devin Lim58046fa2017-07-05 16:55:00 -070098 main.commit = main.commit.split( " " )[ 1 ]
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070099
Devin Lim58046fa2017-07-05 16:55:00 -0700100 def CASE1( self ):
YPZhangcb86c5b2016-01-27 17:38:12 -0800101 copyResult = main.ONOSbench.copyMininetFile( main.topology,
102 main.dependencyPath,
103 main.Mininet1.user_name,
104 main.Mininet1.ip_address )
105
YPZhangcb86c5b2016-01-27 17:38:12 -0800106 def CASE2( self, main ):
107 """
108 - Uninstall ONOS cluster
109 - Verify ONOS start up
110 - Install ONOS cluster
111 - Connect to cli
112 """
You Wanga0f6ff62018-01-11 15:46:30 -0800113 main.testSetUp.ONOSSetUp( main.Cluster, True,
Devin Lim142b5342017-07-20 15:22:39 -0700114 killRemoveMax=False )
YPZhangcb86c5b2016-01-27 17:38:12 -0800115
116 def CASE10( self, main ):
117 """
118 Setting up null-provider
119 """
120 import json
121 # Activate apps
Devin Lim142b5342017-07-20 15:22:39 -0700122 main.step( "Activating null-provider" )
123 appStatus = utilities.retry( main.Cluster.active( 0 ).CLI.activateApp,
YPZhangcb86c5b2016-01-27 17:38:12 -0800124 main.FALSE,
Devin Lim58046fa2017-07-05 16:55:00 -0700125 [ 'org.onosproject.null' ],
YPZhangcb86c5b2016-01-27 17:38:12 -0800126 sleep=main.verifySleep,
127 attempts=main.verifyAttempts )
128 utilities.assert_equals( expect=main.TRUE,
129 actual=appStatus,
130 onpass="Successfully activated null-provider",
131 onfail="Failed activate null-provider" )
132
133 # Setup the null-provider
Devin Lim142b5342017-07-20 15:22:39 -0700134 main.step( "Configuring null-provider" )
YPZhangcb86c5b2016-01-27 17:38:12 -0800135 cfgStatus = utilities.retry( main.ONOSbench.onosCfgSet,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700136 main.FALSE,
137 [ main.Cluster.active( 0 ).ipAddress,
138 main.nullProviderCfg, 'deviceCount 8' ],
139 sleep=main.verifySleep,
140 attempts=main.verifyAttempts )
YPZhangcb86c5b2016-01-27 17:38:12 -0800141 cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet,
142 main.FALSE,
Devin Lim142b5342017-07-20 15:22:39 -0700143 [ main.Cluster.active( 0 ).ipAddress,
144 main.nullProviderCfg, 'topoShape reroute' ],
YPZhangcb86c5b2016-01-27 17:38:12 -0800145 sleep=main.verifySleep,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700146 attempts=main.verifyAttempts )
YPZhangcb86c5b2016-01-27 17:38:12 -0800147
148 cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet,
149 main.FALSE,
Devin Lim142b5342017-07-20 15:22:39 -0700150 [ main.Cluster.active( 0 ).ipAddress,
151 main.nullProviderCfg, 'enabled true' ],
YPZhangcb86c5b2016-01-27 17:38:12 -0800152 sleep=main.verifySleep,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700153 attempts=main.verifyAttempts )
YPZhangcb86c5b2016-01-27 17:38:12 -0800154
155 utilities.assert_equals( expect=main.TRUE,
156 actual=cfgStatus,
157 onpass="Successfully configured null-provider",
158 onfail="Failed to configure null-provider" )
159
160 # give onos some time to settle
Devin Lim142b5342017-07-20 15:22:39 -0700161 time.sleep( main.startUpSleep )
YPZhangcb86c5b2016-01-27 17:38:12 -0800162
Devin Lim142b5342017-07-20 15:22:39 -0700163 main.log.info( "Setting default flows to zero" )
YPZhangcb86c5b2016-01-27 17:38:12 -0800164 main.defaultFlows = 0
165
Devin Lim142b5342017-07-20 15:22:39 -0700166 main.step( "Check status of null-provider setup" )
YPZhangcb86c5b2016-01-27 17:38:12 -0800167 caseResult = appStatus and cfgStatus
168 utilities.assert_equals( expect=main.TRUE,
169 actual=caseResult,
170 onpass="Setting up null-provider was successfull",
171 onfail="Failed to setup null-provider" )
172
173 # This tells the following cases if we are using the null-provider or ovs
174 main.switchType = "null:"
175
176 # If the null-provider setup was unsuccessfull, then there is no point to
177 # run the subsequent cases
178
Devin Lim142b5342017-07-20 15:22:39 -0700179 time.sleep( main.startUpSleep )
YPZhangcb86c5b2016-01-27 17:38:12 -0800180 main.step( "Balancing Masters" )
181
182 stepResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700183 stepResult = utilities.retry( main.Cluster.active( 0 ).CLI.balanceMasters,
YPZhangcb86c5b2016-01-27 17:38:12 -0800184 main.FALSE,
185 [],
186 sleep=3,
187 attempts=3 )
188
189 utilities.assert_equals( expect=main.TRUE,
190 actual=stepResult,
191 onpass="Balance masters was successfull",
Devin Lim142b5342017-07-20 15:22:39 -0700192 onfail="Failed to balance masters" )
YPZhangcb86c5b2016-01-27 17:38:12 -0800193
194 time.sleep( 5 )
195 if not caseResult:
196 main.setupSkipped = True
197
Devin Lim142b5342017-07-20 15:22:39 -0700198 def CASE11( self, main ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700199 """
YPZhangcb86c5b2016-01-27 17:38:12 -0800200 Setting up mininet
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700201 """
YPZhangcb86c5b2016-01-27 17:38:12 -0800202 import json
203 import time
YPZhangebf9eb52016-05-12 15:20:24 -0700204 devices = []
Devin Lim142b5342017-07-20 15:22:39 -0700205 devices = main.Cluster.active( 0 ).CLI.getAllDevicesId()
YPZhangebf9eb52016-05-12 15:20:24 -0700206 for d in devices:
Devin Lim142b5342017-07-20 15:22:39 -0700207 main.Cluster.active( 0 ).CLI.deviceRemove( d )
YPZhangcb86c5b2016-01-27 17:38:12 -0800208
Devin Lim142b5342017-07-20 15:22:39 -0700209 time.sleep( main.startUpSleep )
YPZhange6ef82a2016-07-05 16:48:15 -0700210 if main.flowObj:
Devin Lim142b5342017-07-20 15:22:39 -0700211 main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700212 "useFlowObjectives", value="true" )
Devin Lim142b5342017-07-20 15:22:39 -0700213 main.step( 'Starting mininet topology' )
214 mnStatus = main.Mininet1.startNet( topoFile='~/mininet/custom/rerouteTopo.py' )
YPZhangcb86c5b2016-01-27 17:38:12 -0800215 utilities.assert_equals( expect=main.TRUE,
216 actual=mnStatus,
217 onpass="Successfully started Mininet",
218 onfail="Failed to activate Mininet" )
219
Devin Lim142b5342017-07-20 15:22:39 -0700220 main.step( "Assinging masters to switches" )
YPZhangcb86c5b2016-01-27 17:38:12 -0800221 switches = main.Mininet1.getSwitches()
Devin Lim142b5342017-07-20 15:22:39 -0700222 swStatus = main.Mininet1.assignSwController( sw=switches.keys(), ip=main.Cluster.getIps() )
YPZhangcb86c5b2016-01-27 17:38:12 -0800223 utilities.assert_equals( expect=main.TRUE,
224 actual=swStatus,
225 onpass="Successfully assigned switches to masters",
226 onfail="Failed assign switches to masters" )
227
Devin Lim142b5342017-07-20 15:22:39 -0700228 time.sleep( main.startUpSleep )
YPZhangebf9eb52016-05-12 15:20:24 -0700229 # Balancing Masters
230 main.step( "Balancing Masters" )
231 stepResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700232 stepResult = utilities.retry( main.Cluster.active( 0 ).CLI.balanceMasters,
YPZhangebf9eb52016-05-12 15:20:24 -0700233 main.FALSE,
234 [],
235 sleep=3,
236 attempts=3 )
237
238 utilities.assert_equals( expect=main.TRUE,
239 actual=stepResult,
240 onpass="Balance masters was successfull",
241 onfail="Failed to balance masters" )
YPZhangcb86c5b2016-01-27 17:38:12 -0800242
Devin Lim142b5342017-07-20 15:22:39 -0700243 main.log.info( "Getting default flows" )
244 jsonSum = json.loads( main.Cluster.active( 0 ).CLI.summary() )
245 main.defaultFlows = jsonSum[ "flows" ]
YPZhangcb86c5b2016-01-27 17:38:12 -0800246
Devin Lim142b5342017-07-20 15:22:39 -0700247 main.step( "Check status of Mininet setup" )
YPZhangebf9eb52016-05-12 15:20:24 -0700248 caseResult = mnStatus and swStatus
YPZhangcb86c5b2016-01-27 17:38:12 -0800249 utilities.assert_equals( expect=main.TRUE,
250 actual=caseResult,
251 onpass="Successfully setup Mininet",
252 onfail="Failed setup Mininet" )
253
254 # This tells the following cases if we are using the null-provider or ovs
255 main.switchType = "of:"
256
Devin Lim142b5342017-07-20 15:22:39 -0700257 time.sleep( main.startUpSleep )
YPZhangcb86c5b2016-01-27 17:38:12 -0800258 main.step( "Balancing Masters" )
259
260 stepResult = main.FALSE
Devin Lim142b5342017-07-20 15:22:39 -0700261 stepResult = utilities.retry( main.Cluster.active( 0 ).CLI.balanceMasters,
YPZhangcb86c5b2016-01-27 17:38:12 -0800262 main.FALSE,
263 [],
264 sleep=3,
265 attempts=3 )
266
267 utilities.assert_equals( expect=main.TRUE,
268 actual=stepResult,
269 onpass="Balance masters was successfull",
Devin Lim142b5342017-07-20 15:22:39 -0700270 onfail="Failed to balance masters" )
YPZhangcb86c5b2016-01-27 17:38:12 -0800271
Devin Lim142b5342017-07-20 15:22:39 -0700272 time.sleep( 5 )
YPZhangcb86c5b2016-01-27 17:38:12 -0800273 if not caseResult:
274 main.setupSkipped = True
275
YPZhangcb86c5b2016-01-27 17:38:12 -0800276 def CASE20( self, main ):
Devin Lim58046fa2017-07-05 16:55:00 -0700277 try:
278 from tests.dependencies.utils import Utils
279 except ImportError:
280 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700281 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700282 try:
283 main.Utils
284 except ( NameError, AttributeError ):
285 main.Utils = Utils()
YPZhangcb86c5b2016-01-27 17:38:12 -0800286 if main.reroute:
Devin Lim142b5342017-07-20 15:22:39 -0700287 main.minIntents = int( main.params[ 'NULL' ][ 'REROUTE' ][ 'min_intents' ] )
288 main.maxIntents = int( main.params[ 'NULL' ][ 'REROUTE' ][ 'max_intents' ] )
289 main.checkInterval = int( main.params[ 'NULL' ][ 'REROUTE' ][ 'check_interval' ] )
290 main.batchSize = int( main.params[ 'NULL' ][ 'REROUTE' ][ 'batch_size' ] )
YPZhangcb86c5b2016-01-27 17:38:12 -0800291 else:
Devin Lim142b5342017-07-20 15:22:39 -0700292 main.minIntents = int( main.params[ 'NULL' ][ 'PUSH' ][ 'min_intents' ] )
293 main.maxIntents = int( main.params[ 'NULL' ][ 'PUSH' ][ 'max_intents' ] )
294 main.checkInterval = int( main.params[ 'NULL' ][ 'PUSH' ][ 'check_interval' ] )
295 main.batchSize = int( main.params[ 'NULL' ][ 'PUSH' ][ 'batch_size' ] )
YPZhangcb86c5b2016-01-27 17:38:12 -0800296
297 # check if the case needs to be skipped
298 if main.setupSkipped:
299 main.setupSkipped = False
300 main.skipCase()
301
302 # the index where the next intents will be installed
303 offfset = 0
304 # keeps track of how many intents have been installed
305 currIntents = 0
YPZhang3097ba92016-02-16 17:32:32 -0800306 # keeps track of how many flows have been installed, set to 0 at start
307 currFlows = 0
YPZhangcb86c5b2016-01-27 17:38:12 -0800308 # limit for the number of intents that can be installed
Devin Lim142b5342017-07-20 15:22:39 -0700309 main.batchSize = int( int( main.batchSize ) / main.Cluster.numCtrls )
YPZhangcb86c5b2016-01-27 17:38:12 -0800310 limit = main.maxIntents / main.batchSize
311 # total intents installed
312 totalIntents = 0
313
314 intentsState = None
315
316 offtmp = 0
317 main.step( "Pushing intents" )
318 stepResult = main.TRUE
YPZhang47779c22016-03-07 13:03:07 -0800319 # temp variable to contain the number of flows
320 flowsNum = 0
Devin Lim142b5342017-07-20 15:22:39 -0700321 if main.Cluster.numCtrls > 1:
YPZhangebf9eb52016-05-12 15:20:24 -0700322 # if more than one onos nodes, we should check more frequently
Devin Lim142b5342017-07-20 15:22:39 -0700323 main.checkInterval = main.checkInterval / 4
YPZhangcb86c5b2016-01-27 17:38:12 -0800324
YPZhangebf9eb52016-05-12 15:20:24 -0700325 # make sure the checkInterval divisible batchSize
326 main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700327 flowTemp = 0
YPZhang14a4aa92016-07-15 13:37:15 -0700328 intentVerifyTemp = 0
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700329 totalFlows = 0
Devin Lim142b5342017-07-20 15:22:39 -0700330 for i in range( limit ):
YPZhangcb86c5b2016-01-27 17:38:12 -0800331
332 # Threads pool
333 pool = []
334
Devin Lim142b5342017-07-20 15:22:39 -0700335 for j in range( main.Cluster.numCtrls ):
336 if main.Cluster.numCtrls > 1:
YPZhangcb86c5b2016-01-27 17:38:12 -0800337 time.sleep( 1 )
338 offtmp = offfset + main.maxIntents * j
339 # Push intents by using threads
Devin Lim142b5342017-07-20 15:22:39 -0700340 t = main.Thread( target=main.Cluster.active( j ).CLI.pushTestIntents,
YPZhangcb86c5b2016-01-27 17:38:12 -0800341 threadID=main.threadID,
342 name="Push-Test-Intents",
343 args=[ main.switchType + main.ingress,
344 main.switchType + main.egress,
345 main.batchSize ],
346 kwargs={ "offset": offtmp,
347 "options": "-i",
348 "timeout": main.timeout,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700349 "background": False,
350 "noExit": True } )
Devin Lim142b5342017-07-20 15:22:39 -0700351 pool.append( t )
YPZhangcb86c5b2016-01-27 17:38:12 -0800352 t.start()
353 main.threadID = main.threadID + 1
354 for t in pool:
355 t.join()
356 stepResult = stepResult and t.result
357 offfset = offfset + main.batchSize
358
Devin Lim142b5342017-07-20 15:22:39 -0700359 totalIntents = main.batchSize * main.Cluster.numCtrls + totalIntents
YPZhangcb86c5b2016-01-27 17:38:12 -0800360 if totalIntents >= main.minIntents and totalIntents % main.checkInterval == 0:
361 # if reach to minimum number and check interval, verify Intetns and flows
Devin Lim142b5342017-07-20 15:22:39 -0700362 time.sleep( main.verifySleep * main.Cluster.numCtrls )
YPZhangcb86c5b2016-01-27 17:38:12 -0800363
Devin Lim142b5342017-07-20 15:22:39 -0700364 main.log.info( "Verify Intents states" )
YPZhang3097ba92016-02-16 17:32:32 -0800365 # k is a control variable for verify retry attempts
YPZhangcb86c5b2016-01-27 17:38:12 -0800366 k = 1
YPZhang3097ba92016-02-16 17:32:32 -0800367 while k <= main.verifyAttempts:
YPZhang14a4aa92016-07-15 13:37:15 -0700368 # while loop for check intents by using CLI driver
Devin Lim142b5342017-07-20 15:22:39 -0700369 time.sleep( 5 )
370 intentsState = main.Cluster.active( 0 ).CLI.checkIntentSummary( timeout=600, noExit=True )
YPZhangebf9eb52016-05-12 15:20:24 -0700371 if intentsState:
Devin Lim142b5342017-07-20 15:22:39 -0700372 verifyTotalIntents = main.Cluster.active( 0 ).CLI.getTotalIntentsNum( timeout=600, noExit=True )
YPZhang14a4aa92016-07-15 13:37:15 -0700373 if intentVerifyTemp < verifyTotalIntents:
374 intentVerifyTemp = verifyTotalIntents
YPZhangebf9eb52016-05-12 15:20:24 -0700375 else:
YPZhang14a4aa92016-07-15 13:37:15 -0700376 verifyTotalIntents = intentVerifyTemp
YPZhang6e758fb2016-07-26 09:20:55 -0700377 intentsState = False
Devin Lim142b5342017-07-20 15:22:39 -0700378 main.log.info( "Total Installed Intents: {}".format( verifyTotalIntents ) )
YPZhangcb86c5b2016-01-27 17:38:12 -0800379 break
Devin Lim142b5342017-07-20 15:22:39 -0700380 k = k + 1
YPZhangac53ebf2016-05-13 16:26:19 -0700381
YPZhang14a4aa92016-07-15 13:37:15 -0700382 k = 1
383 flowVerify = True
384 while k <= main.verifyAttempts:
Devin Lim142b5342017-07-20 15:22:39 -0700385 time.sleep( 5 )
386 totalFlows = main.Cluster.active( 0 ).CLI.getTotalFlowsNum( timeout=600, noExit=True )
YPZhang14a4aa92016-07-15 13:37:15 -0700387 expectFlows = totalIntents * 7 + main.defaultFlows
388 if totalFlows == expectFlows:
Devin Lim142b5342017-07-20 15:22:39 -0700389 main.log.info( "Total Flows Added: {}".format( totalFlows ) )
YPZhang14a4aa92016-07-15 13:37:15 -0700390 break
391 else:
Devin Lim142b5342017-07-20 15:22:39 -0700392 main.log.info( "Some Flows are not added, retry..." )
393 main.log.info( "Total Flows Added: {} Expect Flows: {}".format( totalFlows, expectFlows ) )
YPZhang14a4aa92016-07-15 13:37:15 -0700394 flowVerify = False
YPZhangac53ebf2016-05-13 16:26:19 -0700395
YPZhang14a4aa92016-07-15 13:37:15 -0700396 k += 1
397 if flowTemp < totalFlows:
398 flowTemp = totalFlows
399 else:
400 totalFlows = flowTemp
401
402 if not intentsState or not flowVerify:
YPZhanga4acbb82016-03-02 17:28:25 -0800403 # If some intents are not installed, grep the previous flows list, and finished this test case
YPZhang14a4aa92016-07-15 13:37:15 -0700404 main.log.warn( "Intents or flows are not installed" )
Devin Lim142b5342017-07-20 15:22:39 -0700405 verifyTotalIntents = main.Cluster.active( 0 ).CLI.getTotalIntentsNum( timeout=600, noExit=True )
YPZhang14a4aa92016-07-15 13:37:15 -0700406 if intentVerifyTemp < verifyTotalIntents:
407 intentVerifyTemp = verifyTotalIntents
408 else:
409 verifyTotalIntents = intentVerifyTemp
410 if flowTemp < totalFlows:
411 flowTemp = totalFlows
412 else:
413 totalFlows = flowTemp
Devin Lim142b5342017-07-20 15:22:39 -0700414 main.log.info( "Total Intents: {}".format( verifyTotalIntents ) )
YPZhangcb86c5b2016-01-27 17:38:12 -0800415 break
YPZhange96a3062016-05-12 16:18:35 -0700416
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700417 utilities.assert_equals( expect=main.TRUE,
418 actual=intentsState,
419 onpass="Successfully pushed and verified intents",
420 onfail="Failed to push and verify intents" )
YPZhangcb86c5b2016-01-27 17:38:12 -0800421
YPZhangcb86c5b2016-01-27 17:38:12 -0800422 main.log.info( "Total Intents Installed before crash: {}".format( totalIntents ) )
423 main.log.info( "Total Flows ADDED before crash: {}".format( totalFlows ) )
424
Devin Lim58046fa2017-07-05 16:55:00 -0700425 main.Utils.mininetCleanup( main.Mininet1 )
426
Devin Lim142b5342017-07-20 15:22:39 -0700427 main.log.info( "Writing results to DS file" )
428 with open( main.dbFileName, "a" ) as dbFile:
YPZhangcb86c5b2016-01-27 17:38:12 -0800429 # Scale number
Devin Lim87e12c42017-07-20 13:53:04 -0700430 temp = "'" + main.commit + "',"
431 temp += "'" + main.nic + "',"
Devin Lim142b5342017-07-20 15:22:39 -0700432 temp += str( main.Cluster.numCtrls )
YPZhangcb86c5b2016-01-27 17:38:12 -0800433 temp += ",'" + "baremetal1" + "'"
434 # how many intents we installed before crash
Devin Lim142b5342017-07-20 15:22:39 -0700435 temp += "," + str( verifyTotalIntents )
YPZhangcb86c5b2016-01-27 17:38:12 -0800436 # how many flows we installed before crash
Devin Lim142b5342017-07-20 15:22:39 -0700437 temp += "," + str( totalFlows )
YPZhangcb86c5b2016-01-27 17:38:12 -0800438 # other columns in database, but we didn't use in this test
Devin Lima16d8942017-11-15 16:48:37 -0800439 temp += "," + "0,0,0,0,0,0,0,0"
YPZhangcb86c5b2016-01-27 17:38:12 -0800440 temp += "\n"
441 dbFile.write( temp )