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