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