Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2016 Open Networking Foundation (ONF) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 | """ |
| 21 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 22 | import sys |
| 23 | import json |
| 24 | import time |
| 25 | import os |
| 26 | ''' |
| 27 | SCPFscalingMaxIntents |
| 28 | Push test Intents to onos |
| 29 | CASE10: set up Null Provider |
| 30 | CASE11: set up Open Flows |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 31 | Check flows number, if flows number is not as except, finished this test iteration |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 32 | Scale up when reach the Limited |
| 33 | Start from 1 nodes, 8 devices. Then Scale up to 3,5,7 nodes |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 34 | ''' |
| 35 | class SCPFscalingMaxIntents: |
| 36 | def __init__( self ): |
| 37 | self.default = '' |
| 38 | |
| 39 | def CASE0( self, main): |
| 40 | import sys |
| 41 | import json |
| 42 | import time |
| 43 | import os |
| 44 | import imp |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 45 | 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" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 50 | main.exit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 51 | 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' ] ) |
| 66 | main.rerouteSleep = int ( main.params[ 'SLEEP' ][ 'reroute' ] ) |
| 67 | main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] ) |
| 68 | main.ingress = main.params[ 'LINK' ][ 'ingress' ] |
| 69 | main.egress = main.params[ 'LINK' ][ 'egress' ] |
| 70 | main.reroute = main.params[ 'reroute' ] |
| 71 | main.flowObj = main.params[ 'TEST' ][ 'flowObj' ] |
| 72 | if main.flowObj == "True": |
| 73 | main.flowObj = True |
| 74 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ] |
| 75 | else: |
| 76 | main.flowObj = False |
| 77 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ] |
| 78 | main.threadID = 0 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 79 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 80 | if main.reroute == "True": |
| 81 | main.reroute = True |
| 82 | else: |
| 83 | main.reroute = False |
| 84 | main.setupSkipped = False |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 85 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 86 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
Devin Lim | 87e12c4 | 2017-07-20 13:53:04 -0700 | [diff] [blame] | 87 | main.nic = main.params[ 'DATABASE' ][ 'nic' ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 88 | node = main.params[ 'DATABASE' ][ 'node' ] |
| 89 | stepResult = main.testSetUp.gitPulling() |
| 90 | main.log.info( "Cresting DB file" ) |
| 91 | with open( main.dbFileName, "w+" ) as dbFile: |
| 92 | dbFile.write("") |
| 93 | except Exception as e: |
| 94 | main.testSetUp.envSetupException( e ) |
| 95 | main.testSetUp.evnSetupConclusion( stepResult ) |
| 96 | main.commit = main.commit.split( " " )[ 1 ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 97 | def CASE1( self ): |
| 98 | main.testSetUp.getNumCtrls( True ) |
| 99 | main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 100 | copyResult = main.ONOSbench.copyMininetFile( main.topology, |
| 101 | main.dependencyPath, |
| 102 | main.Mininet1.user_name, |
| 103 | main.Mininet1.ip_address ) |
| 104 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 105 | def CASE2( self, main ): |
| 106 | """ |
| 107 | - Uninstall ONOS cluster |
| 108 | - Verify ONOS start up |
| 109 | - Install ONOS cluster |
| 110 | - Connect to cli |
| 111 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 112 | main.testSetUp.ONOSSetUp( main.Mininet1, True, |
| 113 | killRemoveMax=False, CtrlsSet=False ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 114 | |
| 115 | def CASE10( self, main ): |
| 116 | """ |
| 117 | Setting up null-provider |
| 118 | """ |
| 119 | import json |
| 120 | # Activate apps |
| 121 | main.step("Activating null-provider") |
| 122 | appStatus = utilities.retry( main.CLIs[0].activateApp, |
| 123 | main.FALSE, |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 124 | [ 'org.onosproject.null' ], |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 125 | sleep=main.verifySleep, |
| 126 | attempts=main.verifyAttempts ) |
| 127 | utilities.assert_equals( expect=main.TRUE, |
| 128 | actual=appStatus, |
| 129 | onpass="Successfully activated null-provider", |
| 130 | onfail="Failed activate null-provider" ) |
| 131 | |
| 132 | # Setup the null-provider |
| 133 | main.step("Configuring null-provider") |
| 134 | cfgStatus = utilities.retry( main.ONOSbench.onosCfgSet, |
| 135 | main.FALSE, |
| 136 | [ main.ONOSip[0], |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 137 | 'org.onosproject.provider.nil.NullProviders', 'deviceCount 8' ], |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 138 | sleep=main.verifySleep, |
| 139 | attempts = main.verifyAttempts ) |
| 140 | cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet, |
| 141 | main.FALSE, |
| 142 | [ main.ONOSip[0], |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 143 | 'org.onosproject.provider.nil.NullProviders', 'topoShape reroute' ], |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 144 | sleep=main.verifySleep, |
| 145 | attempts = main.verifyAttempts ) |
| 146 | |
| 147 | cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet, |
| 148 | main.FALSE, |
| 149 | [ main.ONOSip[0], |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 150 | 'org.onosproject.provider.nil.NullProviders', 'enabled true' ], |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 151 | sleep=main.verifySleep, |
| 152 | attempts = main.verifyAttempts ) |
| 153 | |
| 154 | |
| 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 |
| 161 | time.sleep(main.startUpSleep) |
| 162 | |
| 163 | main.log.info("Setting default flows to zero") |
| 164 | main.defaultFlows = 0 |
| 165 | |
| 166 | main.step("Check status of null-provider setup") |
| 167 | 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 | |
| 179 | time.sleep(main.startUpSleep) |
| 180 | main.step( "Balancing Masters" ) |
| 181 | |
| 182 | stepResult = main.FALSE |
| 183 | stepResult = utilities.retry( main.CLIs[0].balanceMasters, |
| 184 | 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", |
| 192 | onfail="Failed to balance masters") |
| 193 | |
| 194 | time.sleep( 5 ) |
| 195 | if not caseResult: |
| 196 | main.setupSkipped = True |
| 197 | |
| 198 | def CASE11( self, main): |
| 199 | ''' |
| 200 | Setting up mininet |
| 201 | ''' |
| 202 | import json |
| 203 | import time |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 204 | |
| 205 | devices = [] |
| 206 | devices = main.CLIs[0].getAllDevicesId() |
| 207 | for d in devices: |
| 208 | main.CLIs[0].deviceRemove( d ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 209 | |
| 210 | time.sleep(main.startUpSleep) |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 211 | if main.flowObj: |
| 212 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 213 | "useFlowObjectives", value="true") |
You Wang | 106d0fa | 2017-05-15 17:22:15 -0700 | [diff] [blame] | 214 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 215 | "defaultFlowObjectiveCompiler", |
| 216 | value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler') |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 217 | main.step('Starting mininet topology') |
| 218 | mnStatus = main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py') |
| 219 | utilities.assert_equals( expect=main.TRUE, |
| 220 | actual=mnStatus, |
| 221 | onpass="Successfully started Mininet", |
| 222 | onfail="Failed to activate Mininet" ) |
| 223 | |
| 224 | main.step("Assinging masters to switches") |
| 225 | switches = main.Mininet1.getSwitches() |
| 226 | swStatus = main.Mininet1.assignSwController( sw=switches.keys(), ip=main.ONOSip ) |
| 227 | utilities.assert_equals( expect=main.TRUE, |
| 228 | actual=swStatus, |
| 229 | onpass="Successfully assigned switches to masters", |
| 230 | onfail="Failed assign switches to masters" ) |
| 231 | |
| 232 | time.sleep(main.startUpSleep) |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 233 | # Balancing Masters |
| 234 | main.step( "Balancing Masters" ) |
| 235 | stepResult = main.FALSE |
| 236 | stepResult = utilities.retry( main.CLIs[0].balanceMasters, |
| 237 | main.FALSE, |
| 238 | [], |
| 239 | sleep=3, |
| 240 | attempts=3 ) |
| 241 | |
| 242 | utilities.assert_equals( expect=main.TRUE, |
| 243 | actual=stepResult, |
| 244 | onpass="Balance masters was successfull", |
| 245 | onfail="Failed to balance masters" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 246 | |
| 247 | main.log.info("Getting default flows") |
| 248 | jsonSum = json.loads(main.CLIs[0].summary()) |
| 249 | main.defaultFlows = jsonSum["flows"] |
| 250 | |
| 251 | main.step("Check status of Mininet setup") |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 252 | caseResult = mnStatus and swStatus |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 253 | utilities.assert_equals( expect=main.TRUE, |
| 254 | actual=caseResult, |
| 255 | onpass="Successfully setup Mininet", |
| 256 | onfail="Failed setup Mininet" ) |
| 257 | |
| 258 | # This tells the following cases if we are using the null-provider or ovs |
| 259 | main.switchType = "of:" |
| 260 | |
| 261 | time.sleep(main.startUpSleep) |
| 262 | main.step( "Balancing Masters" ) |
| 263 | |
| 264 | stepResult = main.FALSE |
| 265 | stepResult = utilities.retry( main.CLIs[0].balanceMasters, |
| 266 | main.FALSE, |
| 267 | [], |
| 268 | sleep=3, |
| 269 | attempts=3 ) |
| 270 | |
| 271 | utilities.assert_equals( expect=main.TRUE, |
| 272 | actual=stepResult, |
| 273 | onpass="Balance masters was successfull", |
| 274 | onfail="Failed to balance masters") |
| 275 | |
| 276 | time.sleep(5) |
| 277 | if not caseResult: |
| 278 | main.setupSkipped = True |
| 279 | |
| 280 | |
| 281 | |
| 282 | def CASE20( self, main ): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 283 | try: |
| 284 | from tests.dependencies.utils import Utils |
| 285 | except ImportError: |
| 286 | main.log.error( "Utils not found exiting the test" ) |
| 287 | main.exit() |
| 288 | try: |
| 289 | main.Utils |
| 290 | except ( NameError, AttributeError ): |
| 291 | main.Utils = Utils() |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 292 | if main.reroute: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 293 | main.minIntents = int(main.params[ 'NULL' ][ 'REROUTE' ][ 'min_intents' ] ) |
| 294 | main.maxIntents = int(main.params[ 'NULL' ][ 'REROUTE' ][ 'max_intents' ] ) |
| 295 | main.checkInterval = int(main.params[ 'NULL' ][ 'REROUTE' ][ 'check_interval' ] ) |
| 296 | main.batchSize = int(main.params[ 'NULL' ][ 'REROUTE' ][ 'batch_size' ] ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 297 | else: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 298 | main.minIntents = int(main.params[ 'NULL' ][ 'PUSH' ][ 'min_intents' ] ) |
| 299 | main.maxIntents = int(main.params[ 'NULL' ][ 'PUSH' ][ 'max_intents' ] ) |
| 300 | main.checkInterval = int(main.params[ 'NULL' ][ 'PUSH' ][ 'check_interval' ] ) |
| 301 | main.batchSize = int(main.params[ 'NULL' ][ 'PUSH' ][ 'batch_size' ] ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 302 | |
| 303 | # check if the case needs to be skipped |
| 304 | if main.setupSkipped: |
| 305 | main.setupSkipped = False |
| 306 | main.skipCase() |
| 307 | |
| 308 | # the index where the next intents will be installed |
| 309 | offfset = 0 |
| 310 | # keeps track of how many intents have been installed |
| 311 | currIntents = 0 |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 312 | # keeps track of how many flows have been installed, set to 0 at start |
| 313 | currFlows = 0 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 314 | # limit for the number of intents that can be installed |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 315 | main.batchSize = int( int(main.batchSize)/int(main.numCtrls)) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 316 | limit = main.maxIntents / main.batchSize |
| 317 | # total intents installed |
| 318 | totalIntents = 0 |
| 319 | |
| 320 | intentsState = None |
| 321 | |
| 322 | offtmp = 0 |
| 323 | main.step( "Pushing intents" ) |
| 324 | stepResult = main.TRUE |
YPZhang | 47779c2 | 2016-03-07 13:03:07 -0800 | [diff] [blame] | 325 | # temp variable to contain the number of flows |
| 326 | flowsNum = 0 |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 327 | if main.numCtrls > 1: |
| 328 | # if more than one onos nodes, we should check more frequently |
| 329 | main.checkInterval = main.checkInterval/4 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 330 | |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 331 | # make sure the checkInterval divisible batchSize |
| 332 | main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize ) |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 333 | flowTemp=0 |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 334 | intentVerifyTemp = 0 |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 335 | totalFlows=0 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 336 | for i in range(limit): |
| 337 | |
| 338 | # Threads pool |
| 339 | pool = [] |
| 340 | |
| 341 | for j in range( int( main.numCtrls) ): |
| 342 | if main.numCtrls > 1: |
| 343 | time.sleep( 1 ) |
| 344 | offtmp = offfset + main.maxIntents * j |
| 345 | # Push intents by using threads |
| 346 | t = main.Thread( target=main.CLIs[j].pushTestIntents, |
| 347 | threadID=main.threadID, |
| 348 | name="Push-Test-Intents", |
| 349 | args=[ main.switchType + main.ingress, |
| 350 | main.switchType + main.egress, |
| 351 | main.batchSize ], |
| 352 | kwargs={ "offset": offtmp, |
| 353 | "options": "-i", |
| 354 | "timeout": main.timeout, |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 355 | "background":False, |
| 356 | "noExit":True} ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 357 | pool.append(t) |
| 358 | t.start() |
| 359 | main.threadID = main.threadID + 1 |
| 360 | for t in pool: |
| 361 | t.join() |
| 362 | stepResult = stepResult and t.result |
| 363 | offfset = offfset + main.batchSize |
| 364 | |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 365 | totalIntents = main.batchSize * main.numCtrls + totalIntents |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 366 | if totalIntents >= main.minIntents and totalIntents % main.checkInterval == 0: |
| 367 | # if reach to minimum number and check interval, verify Intetns and flows |
| 368 | time.sleep( main.verifySleep * main.numCtrls ) |
| 369 | |
| 370 | main.log.info("Verify Intents states") |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 371 | # k is a control variable for verify retry attempts |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 372 | k = 1 |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 373 | while k <= main.verifyAttempts: |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 374 | # while loop for check intents by using CLI driver |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 375 | time.sleep(5) |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 376 | intentsState = main.CLIs[0].checkIntentSummary(timeout=600, noExit=True) |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 377 | if intentsState: |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 378 | verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600, noExit=True) |
| 379 | if intentVerifyTemp < verifyTotalIntents: |
| 380 | intentVerifyTemp = verifyTotalIntents |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 381 | else: |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 382 | verifyTotalIntents = intentVerifyTemp |
YPZhang | 6e758fb | 2016-07-26 09:20:55 -0700 | [diff] [blame] | 383 | intentsState = False |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 384 | main.log.info("Total Installed Intents: {}".format( verifyTotalIntents ) ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 385 | break |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 386 | k = k+1 |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 387 | |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 388 | k = 1 |
| 389 | flowVerify = True |
| 390 | while k <= main.verifyAttempts: |
| 391 | time.sleep(5) |
| 392 | totalFlows = main.CLIs[0].getTotalFlowsNum( timeout=600, noExit=True ) |
| 393 | expectFlows = totalIntents * 7 + main.defaultFlows |
| 394 | if totalFlows == expectFlows: |
| 395 | main.log.info("Total Flows Added: {}".format(totalFlows)) |
| 396 | break |
| 397 | else: |
| 398 | main.log.info("Some Flows are not added, retry...") |
| 399 | main.log.info("Total Flows Added: {} Expect Flows: {}".format(totalFlows, expectFlows)) |
| 400 | flowVerify = False |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 401 | |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 402 | k += 1 |
| 403 | if flowTemp < totalFlows: |
| 404 | flowTemp = totalFlows |
| 405 | else: |
| 406 | totalFlows = flowTemp |
| 407 | |
| 408 | if not intentsState or not flowVerify: |
YPZhang | a4acbb8 | 2016-03-02 17:28:25 -0800 | [diff] [blame] | 409 | # If some intents are not installed, grep the previous flows list, and finished this test case |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 410 | main.log.warn( "Intents or flows are not installed" ) |
| 411 | verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600, noExit=True) |
| 412 | if intentVerifyTemp < verifyTotalIntents: |
| 413 | intentVerifyTemp = verifyTotalIntents |
| 414 | else: |
| 415 | verifyTotalIntents = intentVerifyTemp |
| 416 | if flowTemp < totalFlows: |
| 417 | flowTemp = totalFlows |
| 418 | else: |
| 419 | totalFlows = flowTemp |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 420 | main.log.info("Total Intents: {}".format( verifyTotalIntents) ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 421 | break |
YPZhang | e96a306 | 2016-05-12 16:18:35 -0700 | [diff] [blame] | 422 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 423 | utilities.assert_equals( expect = main.TRUE, |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 424 | actual = intentsState, |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 425 | onpass = "Successfully pushed and verified intents", |
| 426 | onfail = "Failed to push and verify intents" ) |
| 427 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 428 | main.log.info( "Total Intents Installed before crash: {}".format( totalIntents ) ) |
| 429 | main.log.info( "Total Flows ADDED before crash: {}".format( totalFlows ) ) |
| 430 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 431 | main.Utils.mininetCleanup( main.Mininet1 ) |
| 432 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 433 | main.log.info("Writing results to DS file") |
| 434 | with open(main.dbFileName, "a") as dbFile: |
| 435 | # Scale number |
Devin Lim | 87e12c4 | 2017-07-20 13:53:04 -0700 | [diff] [blame] | 436 | temp = "'" + main.commit + "'," |
| 437 | temp += "'" + main.nic + "'," |
| 438 | temp += str(main.numCtrls) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 439 | temp += ",'" + "baremetal1" + "'" |
| 440 | # how many intents we installed before crash |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 441 | temp += "," + str(verifyTotalIntents) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 442 | # how many flows we installed before crash |
| 443 | temp += "," + str(totalFlows) |
| 444 | # other columns in database, but we didn't use in this test |
| 445 | temp += "," + "0,0,0,0,0,0" |
| 446 | temp += "\n" |
| 447 | dbFile.write( temp ) |