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 |
| 10 | Scale up when reach the Limited |
| 11 | Start from 1 nodes, 8 devices. Then Scale up to 3,5,7 nodes |
| 12 | Recommand batch size: 100, check interval: 100 |
| 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 |
| 24 | |
| 25 | main.case( "Constructing test variables and building ONOS package" ) |
| 26 | main.step( "Constructing test variables" ) |
| 27 | stepResult = main.FALSE |
| 28 | |
| 29 | # Test variables |
| 30 | main.testOnDirectory = os.path.dirname( os.getcwd ( ) ) |
| 31 | main.dependencyPath = main.testOnDirectory + \ |
| 32 | main.params['DEPENDENCY']['path'] |
| 33 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 34 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 35 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 36 | main.scale = ( main.params[ 'SCALE' ] ).split( "," ) |
| 37 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 38 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 39 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 40 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 41 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
| 42 | main.rerouteSleep = int ( main.params['SLEEP']['reroute'] ) |
| 43 | main.verifyAttempts = int( main.params['ATTEMPTS']['verify'] ) |
| 44 | main.ingress = main.params['LINK']['ingress'] |
| 45 | main.egress = main.params['LINK']['egress'] |
| 46 | main.dbFileName = main.params['DATABASE']['file'] |
| 47 | main.cellData = {} # for creating cell file |
| 48 | main.reroute = main.params['reroute'] |
| 49 | main.threadID = 0 |
| 50 | |
| 51 | if main.reroute == "True": |
| 52 | main.reroute = True |
| 53 | else: |
| 54 | main.reroute = False |
| 55 | |
| 56 | main.CLIs = [] |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 57 | main.setupSkipped = False |
| 58 | |
| 59 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 60 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 61 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 62 | nic = main.params['DATABASE']['nic'] |
| 63 | node = main.params['DATABASE']['node'] |
| 64 | nic = main.params['DATABASE']['nic'] |
| 65 | node = main.params['DATABASE']['node'] |
| 66 | stepResult = main.TRUE |
| 67 | |
| 68 | main.log.info("Cresting DB file") |
| 69 | with open(main.dbFileName, "w+") as dbFile: |
| 70 | dbFile.write("") |
| 71 | |
| 72 | utilities.assert_equals( expect=main.TRUE, |
| 73 | actual=stepResult, |
| 74 | onpass="environment set up successfull", |
| 75 | onfail="environment set up Failed" ) |
| 76 | |
| 77 | def CASE1( self ): |
| 78 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 79 | main.CLIs = [] |
| 80 | main.numCtrls = int( main.scale[ 0 ] ) |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 81 | main.ONOSip = [] |
| 82 | main.maxNumBatch = 0 |
| 83 | main.AllONOSip = main.ONOSbench.getOnosIps() |
| 84 | for i in range(main.numCtrls): |
| 85 | main.ONOSip.append(main.AllONOSip[i]) |
| 86 | main.log.info(main.ONOSip) |
| 87 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 88 | main.log.info( "Creating list of ONOS cli handles" ) |
| 89 | for i in range(main.numCtrls): |
| 90 | main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) ) |
| 91 | |
| 92 | main.log.info(main.CLIs) |
| 93 | if not main.CLIs: |
| 94 | main.log.error( "Failed to create the list of ONOS cli handles" ) |
| 95 | main.cleanup() |
| 96 | main.exit() |
| 97 | |
| 98 | main.log.info( "Loading wrapper files" ) |
| 99 | main.startUp = imp.load_source( wrapperFile1, |
| 100 | main.dependencyPath + |
| 101 | wrapperFile1 + |
| 102 | ".py" ) |
| 103 | |
| 104 | copyResult = main.ONOSbench.copyMininetFile( main.topology, |
| 105 | main.dependencyPath, |
| 106 | main.Mininet1.user_name, |
| 107 | main.Mininet1.ip_address ) |
| 108 | |
| 109 | commit = main.ONOSbench.getVersion(report=True) |
| 110 | commit = commit.split(" ")[1] |
| 111 | |
| 112 | if gitPull == 'True': |
| 113 | if not main.startUp.onosBuild( main, gitBranch ): |
| 114 | main.log.error( "Failed to build ONOS" ) |
| 115 | main.cleanup() |
| 116 | main.exit() |
| 117 | else: |
| 118 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 119 | "clean install" ) |
| 120 | with open(main.dbFileName, "a") as dbFile: |
| 121 | temp = "'" + commit + "'," |
| 122 | temp += "'" + nic + "'," |
| 123 | dbFile.write(temp) |
| 124 | |
| 125 | def CASE2( self, main ): |
| 126 | """ |
| 127 | - Uninstall ONOS cluster |
| 128 | - Verify ONOS start up |
| 129 | - Install ONOS cluster |
| 130 | - Connect to cli |
| 131 | """ |
| 132 | main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls) |
| 133 | main.log.info( "Safety check, killing all ONOS processes" + |
| 134 | " before initiating environment setup" ) |
| 135 | |
| 136 | for i in range( main.numCtrls ): |
| 137 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 138 | |
| 139 | main.log.info( "NODE COUNT = %s" % main.numCtrls) |
| 140 | |
| 141 | tempOnosIp = [] |
| 142 | for i in range( main.numCtrls ): |
| 143 | tempOnosIp.append( main.ONOSip[i] ) |
| 144 | |
| 145 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 146 | "temp", |
| 147 | main.Mininet1.ip_address, |
| 148 | main.apps, |
| 149 | tempOnosIp ) |
| 150 | |
| 151 | main.step( "Apply cell to environment" ) |
| 152 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 153 | verifyResult = main.ONOSbench.verifyCell() |
| 154 | stepResult = cellResult and verifyResult |
| 155 | utilities.assert_equals( expect=main.TRUE, |
| 156 | actual=stepResult, |
| 157 | onpass="Successfully applied cell to " + \ |
| 158 | "environment", |
| 159 | onfail="Failed to apply cell to environment " ) |
| 160 | |
| 161 | main.step( "Creating ONOS package" ) |
| 162 | packageResult = main.ONOSbench.onosPackage() |
| 163 | stepResult = packageResult |
| 164 | utilities.assert_equals( expect=main.TRUE, |
| 165 | actual=stepResult, |
| 166 | onpass="Successfully created ONOS package", |
| 167 | onfail="Failed to create ONOS package" ) |
| 168 | |
| 169 | main.step( "Uninstall ONOS package on all Nodes" ) |
| 170 | uninstallResult = main.TRUE |
| 171 | for i in range( int( main.numCtrls ) ): |
| 172 | main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] ) |
| 173 | u_result = main.ONOSbench.onosUninstall( main.ONOSip[i] ) |
| 174 | utilities.assert_equals( expect=main.TRUE, actual=u_result, |
| 175 | onpass="Test step PASS", |
| 176 | onfail="Test step FAIL" ) |
| 177 | uninstallResult = ( uninstallResult and u_result ) |
| 178 | |
| 179 | main.step( "Install ONOS package on all Nodes" ) |
| 180 | installResult = main.TRUE |
| 181 | for i in range( int( main.numCtrls ) ): |
| 182 | main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] ) |
| 183 | i_result = main.ONOSbench.onosInstall( node=main.ONOSip[i] ) |
| 184 | utilities.assert_equals( expect=main.TRUE, actual=i_result, |
| 185 | onpass="Test step PASS", |
| 186 | onfail="Test step FAIL" ) |
| 187 | installResult = installResult and i_result |
| 188 | |
| 189 | main.step( "Verify ONOS nodes UP status" ) |
| 190 | statusResult = main.TRUE |
| 191 | for i in range( int( main.numCtrls ) ): |
| 192 | main.log.info( "ONOS Node " + main.ONOSip[i] + " status:" ) |
| 193 | onos_status = main.ONOSbench.onosStatus( node=main.ONOSip[i] ) |
| 194 | utilities.assert_equals( expect=main.TRUE, actual=onos_status, |
| 195 | onpass="Test step PASS", |
| 196 | onfail="Test step FAIL" ) |
| 197 | statusResult = ( statusResult and onos_status ) |
| 198 | |
| 199 | main.step( "Start ONOS CLI on all nodes" ) |
| 200 | cliResult = main.TRUE |
| 201 | main.log.step(" Start ONOS cli using thread ") |
| 202 | startCliResult = main.TRUE |
| 203 | pool = [] |
| 204 | |
| 205 | for i in range( int( main.numCtrls) ): |
| 206 | t = main.Thread( target=main.CLIs[i].startOnosCli, |
| 207 | threadID=main.threadID, |
| 208 | name="startOnosCli", |
| 209 | args=[ main.ONOSip[i] ], |
| 210 | kwargs = {"onosStartTimeout":main.timeout} ) |
| 211 | pool.append(t) |
| 212 | t.start() |
| 213 | main.threadID = main.threadID + 1 |
| 214 | for t in pool: |
| 215 | t.join() |
| 216 | startCliResult = startCliResult and t.result |
| 217 | time.sleep( main.startUpSleep ) |
| 218 | |
| 219 | def CASE10( self, main ): |
| 220 | """ |
| 221 | Setting up null-provider |
| 222 | """ |
| 223 | import json |
| 224 | # Activate apps |
| 225 | main.step("Activating null-provider") |
| 226 | appStatus = utilities.retry( main.CLIs[0].activateApp, |
| 227 | main.FALSE, |
| 228 | ['org.onosproject.null'], |
| 229 | sleep=main.verifySleep, |
| 230 | attempts=main.verifyAttempts ) |
| 231 | utilities.assert_equals( expect=main.TRUE, |
| 232 | actual=appStatus, |
| 233 | onpass="Successfully activated null-provider", |
| 234 | onfail="Failed activate null-provider" ) |
| 235 | |
| 236 | # Setup the null-provider |
| 237 | main.step("Configuring null-provider") |
| 238 | cfgStatus = utilities.retry( main.ONOSbench.onosCfgSet, |
| 239 | main.FALSE, |
| 240 | [ main.ONOSip[0], |
| 241 | 'org.onosproject.provider.nil.NullProviders', 'deviceCount 8'], |
| 242 | sleep=main.verifySleep, |
| 243 | attempts = main.verifyAttempts ) |
| 244 | cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet, |
| 245 | main.FALSE, |
| 246 | [ main.ONOSip[0], |
| 247 | 'org.onosproject.provider.nil.NullProviders', 'topoShape reroute'], |
| 248 | sleep=main.verifySleep, |
| 249 | attempts = main.verifyAttempts ) |
| 250 | |
| 251 | cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet, |
| 252 | main.FALSE, |
| 253 | [ main.ONOSip[0], |
| 254 | 'org.onosproject.provider.nil.NullProviders', 'enabled true'], |
| 255 | sleep=main.verifySleep, |
| 256 | attempts = main.verifyAttempts ) |
| 257 | |
| 258 | |
| 259 | utilities.assert_equals( expect=main.TRUE, |
| 260 | actual=cfgStatus, |
| 261 | onpass="Successfully configured null-provider", |
| 262 | onfail="Failed to configure null-provider" ) |
| 263 | |
| 264 | # give onos some time to settle |
| 265 | time.sleep(main.startUpSleep) |
| 266 | |
| 267 | main.log.info("Setting default flows to zero") |
| 268 | main.defaultFlows = 0 |
| 269 | |
| 270 | main.step("Check status of null-provider setup") |
| 271 | caseResult = appStatus and cfgStatus |
| 272 | utilities.assert_equals( expect=main.TRUE, |
| 273 | actual=caseResult, |
| 274 | onpass="Setting up null-provider was successfull", |
| 275 | onfail="Failed to setup null-provider" ) |
| 276 | |
| 277 | # This tells the following cases if we are using the null-provider or ovs |
| 278 | main.switchType = "null:" |
| 279 | |
| 280 | # If the null-provider setup was unsuccessfull, then there is no point to |
| 281 | # run the subsequent cases |
| 282 | |
| 283 | time.sleep(main.startUpSleep) |
| 284 | main.step( "Balancing Masters" ) |
| 285 | |
| 286 | stepResult = main.FALSE |
| 287 | stepResult = utilities.retry( main.CLIs[0].balanceMasters, |
| 288 | main.FALSE, |
| 289 | [], |
| 290 | sleep=3, |
| 291 | attempts=3 ) |
| 292 | |
| 293 | utilities.assert_equals( expect=main.TRUE, |
| 294 | actual=stepResult, |
| 295 | onpass="Balance masters was successfull", |
| 296 | onfail="Failed to balance masters") |
| 297 | |
| 298 | time.sleep( 5 ) |
| 299 | if not caseResult: |
| 300 | main.setupSkipped = True |
| 301 | |
| 302 | def CASE11( self, main): |
| 303 | ''' |
| 304 | Setting up mininet |
| 305 | ''' |
| 306 | import json |
| 307 | import time |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 308 | |
| 309 | devices = [] |
| 310 | devices = main.CLIs[0].getAllDevicesId() |
| 311 | for d in devices: |
| 312 | main.CLIs[0].deviceRemove( d ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 313 | |
| 314 | time.sleep(main.startUpSleep) |
| 315 | main.step('Starting mininet topology') |
| 316 | mnStatus = main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py') |
| 317 | utilities.assert_equals( expect=main.TRUE, |
| 318 | actual=mnStatus, |
| 319 | onpass="Successfully started Mininet", |
| 320 | onfail="Failed to activate Mininet" ) |
| 321 | |
| 322 | main.step("Assinging masters to switches") |
| 323 | switches = main.Mininet1.getSwitches() |
| 324 | swStatus = main.Mininet1.assignSwController( sw=switches.keys(), ip=main.ONOSip ) |
| 325 | utilities.assert_equals( expect=main.TRUE, |
| 326 | actual=swStatus, |
| 327 | onpass="Successfully assigned switches to masters", |
| 328 | onfail="Failed assign switches to masters" ) |
| 329 | |
| 330 | time.sleep(main.startUpSleep) |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 331 | # Balancing Masters |
| 332 | main.step( "Balancing Masters" ) |
| 333 | stepResult = main.FALSE |
| 334 | stepResult = utilities.retry( main.CLIs[0].balanceMasters, |
| 335 | main.FALSE, |
| 336 | [], |
| 337 | sleep=3, |
| 338 | attempts=3 ) |
| 339 | |
| 340 | utilities.assert_equals( expect=main.TRUE, |
| 341 | actual=stepResult, |
| 342 | onpass="Balance masters was successfull", |
| 343 | onfail="Failed to balance masters" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 344 | |
| 345 | main.log.info("Getting default flows") |
| 346 | jsonSum = json.loads(main.CLIs[0].summary()) |
| 347 | main.defaultFlows = jsonSum["flows"] |
| 348 | |
| 349 | main.step("Check status of Mininet setup") |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 350 | caseResult = mnStatus and swStatus |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 351 | utilities.assert_equals( expect=main.TRUE, |
| 352 | actual=caseResult, |
| 353 | onpass="Successfully setup Mininet", |
| 354 | onfail="Failed setup Mininet" ) |
| 355 | |
| 356 | # This tells the following cases if we are using the null-provider or ovs |
| 357 | main.switchType = "of:" |
| 358 | |
| 359 | time.sleep(main.startUpSleep) |
| 360 | main.step( "Balancing Masters" ) |
| 361 | |
| 362 | stepResult = main.FALSE |
| 363 | stepResult = utilities.retry( main.CLIs[0].balanceMasters, |
| 364 | main.FALSE, |
| 365 | [], |
| 366 | sleep=3, |
| 367 | attempts=3 ) |
| 368 | |
| 369 | utilities.assert_equals( expect=main.TRUE, |
| 370 | actual=stepResult, |
| 371 | onpass="Balance masters was successfull", |
| 372 | onfail="Failed to balance masters") |
| 373 | |
| 374 | time.sleep(5) |
| 375 | if not caseResult: |
| 376 | main.setupSkipped = True |
| 377 | |
| 378 | |
| 379 | |
| 380 | def CASE20( self, main ): |
| 381 | if main.reroute: |
| 382 | main.minIntents = int(main.params['NULL']['REROUTE']['min_intents']) |
| 383 | main.maxIntents = int(main.params['NULL']['REROUTE']['max_intents']) |
| 384 | main.checkInterval = int(main.params['NULL']['REROUTE']['check_interval']) |
| 385 | main.batchSize = int(main.params['NULL']['REROUTE']['batch_size']) |
| 386 | else: |
| 387 | main.minIntents = int(main.params['NULL']['PUSH']['min_intents']) |
| 388 | main.maxIntents = int(main.params['NULL']['PUSH']['max_intents']) |
| 389 | main.checkInterval = int(main.params['NULL']['PUSH']['check_interval']) |
| 390 | main.batchSize = int(main.params['NULL']['PUSH']['batch_size']) |
| 391 | |
| 392 | # check if the case needs to be skipped |
| 393 | if main.setupSkipped: |
| 394 | main.setupSkipped = False |
| 395 | main.skipCase() |
| 396 | |
| 397 | # the index where the next intents will be installed |
| 398 | offfset = 0 |
| 399 | # keeps track of how many intents have been installed |
| 400 | currIntents = 0 |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 401 | # keeps track of how many flows have been installed, set to 0 at start |
| 402 | currFlows = 0 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 403 | # limit for the number of intents that can be installed |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 404 | main.batchSize = int( int(main.batchSize)/int(main.numCtrls)) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 405 | limit = main.maxIntents / main.batchSize |
| 406 | # total intents installed |
| 407 | totalIntents = 0 |
| 408 | |
| 409 | intentsState = None |
| 410 | |
| 411 | offtmp = 0 |
| 412 | main.step( "Pushing intents" ) |
| 413 | stepResult = main.TRUE |
YPZhang | 47779c2 | 2016-03-07 13:03:07 -0800 | [diff] [blame] | 414 | # temp variable to contain the number of flows |
| 415 | flowsNum = 0 |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 416 | if main.numCtrls > 1: |
| 417 | # if more than one onos nodes, we should check more frequently |
| 418 | main.checkInterval = main.checkInterval/4 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 419 | |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 420 | # make sure the checkInterval divisible batchSize |
| 421 | main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize ) |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 422 | flowTemp=0 |
| 423 | totalFlows=0 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 424 | for i in range(limit): |
| 425 | |
| 426 | # Threads pool |
| 427 | pool = [] |
| 428 | |
| 429 | for j in range( int( main.numCtrls) ): |
| 430 | if main.numCtrls > 1: |
| 431 | time.sleep( 1 ) |
| 432 | offtmp = offfset + main.maxIntents * j |
| 433 | # Push intents by using threads |
| 434 | t = main.Thread( target=main.CLIs[j].pushTestIntents, |
| 435 | threadID=main.threadID, |
| 436 | name="Push-Test-Intents", |
| 437 | args=[ main.switchType + main.ingress, |
| 438 | main.switchType + main.egress, |
| 439 | main.batchSize ], |
| 440 | kwargs={ "offset": offtmp, |
| 441 | "options": "-i", |
| 442 | "timeout": main.timeout, |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 443 | "background":False, |
| 444 | "noExit":True} ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 445 | pool.append(t) |
| 446 | t.start() |
| 447 | main.threadID = main.threadID + 1 |
| 448 | for t in pool: |
| 449 | t.join() |
| 450 | stepResult = stepResult and t.result |
| 451 | offfset = offfset + main.batchSize |
| 452 | |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 453 | totalIntents = main.batchSize * main.numCtrls + totalIntents |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 454 | if totalIntents >= main.minIntents and totalIntents % main.checkInterval == 0: |
| 455 | # if reach to minimum number and check interval, verify Intetns and flows |
| 456 | time.sleep( main.verifySleep * main.numCtrls ) |
| 457 | |
| 458 | main.log.info("Verify Intents states") |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 459 | # k is a control variable for verify retry attempts |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 460 | k = 1 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 461 | |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 462 | while k <= main.verifyAttempts: |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 463 | # while loop for check intents by using REST api |
| 464 | time.sleep(5) |
| 465 | temp = 0 |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 466 | intentsState = main.CLIs[0].checkIntentSummary(timeout=600) |
| 467 | if intentsState: |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 468 | verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600) |
| 469 | if temp < verifyTotalIntents: |
| 470 | temp = verifyTotalIntents |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 471 | else: |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 472 | verifytotalIntents = temp |
| 473 | main.log.info("Total Intents: {}".format( verifyTotalIntents ) ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 474 | break |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 475 | k = k+1 |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 476 | |
| 477 | totalFlows = main.CLIs[0].getTotalFlowsNum( timeout=600, noExit=True ) |
| 478 | if flowTemp < totalFlows: |
| 479 | flowTemp = totalFlows |
| 480 | else: |
| 481 | totalFlows = flowTemp |
| 482 | |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 483 | if not intentsState: |
YPZhang | a4acbb8 | 2016-03-02 17:28:25 -0800 | [diff] [blame] | 484 | # If some intents are not installed, grep the previous flows list, and finished this test case |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 485 | main.log.warn( "Some intens did not install" ) |
YPZhang | f9f0fa9 | 2016-05-23 15:44:44 -0700 | [diff] [blame] | 486 | verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600) |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 487 | main.log.info("Total Intents: {}".format( verifyTotalIntents) ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 488 | break |
YPZhang | e96a306 | 2016-05-12 16:18:35 -0700 | [diff] [blame] | 489 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 490 | del main.scale[0] |
| 491 | utilities.assert_equals( expect = main.TRUE, |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 492 | actual = intentsState, |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 493 | onpass = "Successfully pushed and verified intents", |
| 494 | onfail = "Failed to push and verify intents" ) |
| 495 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 496 | main.log.info( "Total Intents Installed before crash: {}".format( totalIntents ) ) |
| 497 | main.log.info( "Total Flows ADDED before crash: {}".format( totalFlows ) ) |
| 498 | |
| 499 | main.step('clean up Mininet') |
| 500 | main.Mininet1.stopNet() |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 501 | main.log.info("Writing results to DS file") |
| 502 | with open(main.dbFileName, "a") as dbFile: |
| 503 | # Scale number |
| 504 | temp = str(main.numCtrls) |
| 505 | temp += ",'" + "baremetal1" + "'" |
| 506 | # how many intents we installed before crash |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 507 | temp += "," + str(verifyTotalIntents) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 508 | # how many flows we installed before crash |
| 509 | temp += "," + str(totalFlows) |
| 510 | # other columns in database, but we didn't use in this test |
| 511 | temp += "," + "0,0,0,0,0,0" |
| 512 | temp += "\n" |
| 513 | dbFile.write( temp ) |