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