GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 1 | |
| 2 | # This is a performance scale intent that test onos to see how many intents can |
| 3 | # be installed and rerouted using the null provider and mininet. |
| 4 | |
| 5 | class SCPFmaxIntents: |
| 6 | |
| 7 | def __init__( self ): |
| 8 | self.default = '' |
| 9 | |
| 10 | def CASE0( self, main ): |
| 11 | import time |
| 12 | import os |
| 13 | import imp |
| 14 | |
| 15 | """ |
| 16 | - Construct tests variables |
| 17 | - GIT ( optional ) |
| 18 | - Checkout ONOS master branch |
| 19 | - Pull latest ONOS code |
| 20 | - Building ONOS ( optional ) |
| 21 | - Install ONOS package |
| 22 | - Build ONOS package |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame^] | 23 | - Set up cell |
| 24 | - Create cell file |
| 25 | - Set cell file |
| 26 | - Verify cell file |
| 27 | - Kill ONOS process |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 28 | """ |
| 29 | |
| 30 | main.case( "Constructing test variables and building ONOS package" ) |
| 31 | main.step( "Constructing test variables" ) |
| 32 | stepResult = main.FALSE |
| 33 | |
| 34 | # Test variables |
| 35 | main.testOnDirectory = os.path.dirname( os.getcwd ( ) ) |
| 36 | main.dependencyPath = main.testOnDirectory + \ |
| 37 | main.params['DEPENDENCY']['path'] |
| 38 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 39 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 40 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 41 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 42 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
| 43 | main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] ) |
| 44 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 45 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 46 | main.minIntents = int(main.params['TEST']['min_intents']) |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 47 | main.maxIntents = int(main.params['TEST']['max_intents']) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 48 | main.checkInterval = int(main.params['TEST']['check_interval']) |
| 49 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 50 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 51 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 52 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 53 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
| 54 | main.rerouteSleep = int ( main.params['SLEEP']['reroute'] ) |
| 55 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 56 | main.batchSize = int(main.params['TEST']['batch_size']) |
| 57 | main.cellData = {} # for creating cell file |
| 58 | main.CLIs = [] |
| 59 | main.ONOSip = [] |
| 60 | main.maxNumBatch = 0 |
| 61 | |
| 62 | main.ONOSip = main.ONOSbench.getOnosIps() |
| 63 | main.log.info(main.ONOSip) |
| 64 | |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame^] | 65 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 66 | main.numCtrls = int( main.scale[ 0 ] ) |
| 67 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 68 | # Assigning ONOS cli handles to a list |
| 69 | for i in range( 1, main.maxNodes + 1 ): |
| 70 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 71 | |
| 72 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 73 | main.startUp = imp.load_source( wrapperFile1, |
| 74 | main.dependencyPath + |
| 75 | wrapperFile1 + |
| 76 | ".py" ) |
| 77 | |
| 78 | main.intentFunctions = imp.load_source( wrapperFile2, |
| 79 | main.dependencyPath + |
| 80 | wrapperFile2 + |
| 81 | ".py" ) |
| 82 | |
| 83 | copyResult = main.ONOSbench.copyMininetFile( main.topology, |
| 84 | main.dependencyPath, |
| 85 | main.Mininet1.user_name, |
| 86 | main.Mininet1.ip_address ) |
| 87 | |
| 88 | if main.CLIs: |
| 89 | stepResult = main.TRUE |
| 90 | else: |
| 91 | main.log.error( "Did not properly created list of ONOS CLI handle" ) |
| 92 | stepResult = main.FALSE |
| 93 | |
| 94 | utilities.assert_equals( expect=main.TRUE, |
| 95 | actual=stepResult, |
| 96 | onpass="Successfully construct " + |
| 97 | "test variables ", |
| 98 | onfail="Failed to construct test variables" ) |
| 99 | |
| 100 | if gitPull == 'True': |
| 101 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 102 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 103 | stepResult = onosBuildResult |
| 104 | utilities.assert_equals( expect=main.TRUE, |
| 105 | actual=stepResult, |
| 106 | onpass="Successfully compiled " + |
| 107 | "latest ONOS", |
| 108 | onfail="Failed to compile " + |
| 109 | "latest ONOS" ) |
| 110 | else: |
| 111 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 112 | "clean install" ) |
| 113 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 114 | main.case( "Starting up " + str( main.numCtrls ) + |
| 115 | " node(s) ONOS cluster" ) |
| 116 | |
| 117 | # kill off all onos processes |
| 118 | main.log.info( "Safety check, killing all ONOS processes" + |
| 119 | " before initiating enviornment setup" ) |
| 120 | |
| 121 | for i in range( main.maxNodes ): |
| 122 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 123 | |
| 124 | main.log.info( "NODE COUNT = " + str( main.numCtrls)) |
| 125 | |
| 126 | tempOnosIp = [] |
| 127 | for i in range( main.numCtrls ): |
| 128 | tempOnosIp.append( main.ONOSip[i] ) |
| 129 | |
| 130 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 131 | "temp", |
| 132 | main.Mininet1.ip_address, |
| 133 | main.apps, |
| 134 | tempOnosIp ) |
| 135 | |
| 136 | main.step( "Apply cell to environment" ) |
| 137 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 138 | verifyResult = main.ONOSbench.verifyCell() |
| 139 | stepResult = cellResult and verifyResult |
| 140 | utilities.assert_equals( expect=main.TRUE, |
| 141 | actual=stepResult, |
| 142 | onpass="Successfully applied cell to " + \ |
| 143 | "environment", |
| 144 | onfail="Failed to apply cell to environment " ) |
| 145 | |
| 146 | main.step( "Creating ONOS package" ) |
| 147 | packageResult = main.ONOSbench.onosPackage() |
| 148 | stepResult = packageResult |
| 149 | utilities.assert_equals( expect=main.TRUE, |
| 150 | actual=stepResult, |
| 151 | onpass="Successfully created ONOS package", |
| 152 | onfail="Failed to create ONOS package" ) |
| 153 | |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame^] | 154 | commit = main.ONOSbench.getVersion() |
| 155 | commit = commit.split(" ")[1] |
| 156 | |
| 157 | try: |
| 158 | dbFileName="/tmp/MaxIntentDB" |
| 159 | dbfile = open(dbFileName, "w+") |
| 160 | temp = "'" + commit + "'," |
| 161 | dbfile.write(temp) |
| 162 | dbfile.close() |
| 163 | except IOError: |
| 164 | main.log.warn("Error opening " + dbFileName + " to write results.") |
| 165 | |
| 166 | def CASE1( self, main ): |
| 167 | """ |
| 168 | - Uninstall ONOS cluster |
| 169 | - Verify ONOS start up |
| 170 | - Install ONOS cluster |
| 171 | - Connect to cli |
| 172 | """ |
| 173 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 174 | main.step( "Uninstalling ONOS package" ) |
| 175 | onosUninstallResult = main.TRUE |
| 176 | for i in range( main.maxNodes ): |
| 177 | onosUninstallResult = onosUninstallResult and \ |
| 178 | main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] ) |
| 179 | stepResult = onosUninstallResult |
| 180 | utilities.assert_equals( expect=main.TRUE, |
| 181 | actual=stepResult, |
| 182 | onpass="Successfully uninstalled ONOS package", |
| 183 | onfail="Failed to uninstall ONOS package" ) |
| 184 | |
| 185 | time.sleep( main.startUpSleep ) |
| 186 | main.step( "Installing ONOS package" ) |
| 187 | onosInstallResult = main.TRUE |
| 188 | for i in range( main.numCtrls ): |
| 189 | onosInstallResult = onosInstallResult and \ |
| 190 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 191 | stepResult = onosInstallResult |
| 192 | utilities.assert_equals( expect=main.TRUE, |
| 193 | actual=stepResult, |
| 194 | onpass="Successfully installed ONOS package", |
| 195 | onfail="Failed to install ONOS package" ) |
| 196 | |
| 197 | main.step( "Starting ONOS service" ) |
| 198 | stopResult = main.TRUE |
| 199 | startResult = main.TRUE |
| 200 | onosIsUp = main.TRUE |
| 201 | |
| 202 | for i in range( main.numCtrls ): |
| 203 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 204 | if onosIsUp == main.TRUE: |
| 205 | main.log.report( "ONOS instance is up and ready" ) |
| 206 | else: |
| 207 | main.log.report( "ONOS instance may not be up, stop and " + |
| 208 | "start ONOS again " ) |
| 209 | for i in range( main.numCtrls ): |
| 210 | stopResult = stopResult and \ |
| 211 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 212 | for i in range( main.numCtrls ): |
| 213 | startResult = startResult and \ |
| 214 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 215 | stepResult = onosIsUp and stopResult and startResult |
| 216 | utilities.assert_equals( expect=main.TRUE, |
| 217 | actual=stepResult, |
| 218 | onpass="ONOS service is ready", |
| 219 | onfail="ONOS service did not start properly" ) |
| 220 | |
| 221 | main.step( "Start ONOS cli" ) |
| 222 | cliResult = main.TRUE |
| 223 | for i in range( main.numCtrls ): |
| 224 | cliResult = cliResult and \ |
| 225 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 226 | stepResult = cliResult |
| 227 | utilities.assert_equals( expect=main.TRUE, |
| 228 | actual=stepResult, |
| 229 | onpass="Successfully start ONOS cli", |
| 230 | onfail="Failed to start ONOS cli" ) |
| 231 | |
| 232 | def CASE10( self, main ): |
| 233 | """ |
| 234 | Setting up null-provider |
| 235 | """ |
| 236 | import json |
| 237 | import pexpect |
| 238 | |
| 239 | # Activate apps |
| 240 | main.log.step("Activating apps") |
| 241 | stepResult = main.CLIs[0].activateApp('org.onosproject.null') |
| 242 | utilities.assert_equals( expect=main.TRUE, |
| 243 | actual=stepResult, |
| 244 | onpass="Successfully activated null-provider", |
| 245 | onfail="Failed to activate null-provider") |
| 246 | |
| 247 | # Setup the null-provider |
| 248 | main.log.step("Configuring null-provider") |
| 249 | stepResult = main.FALSE |
| 250 | for i in range(3): |
| 251 | main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 252 | 'org.onosproject.provider.nil.NullProviders', |
| 253 | 'deviceCount 3' ) |
| 254 | main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 255 | 'org.onosproject.provider.nil.NullProviders', |
| 256 | 'topoShape reroute' ) |
| 257 | main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 258 | 'org.onosproject.provider.nil.NullProviders', |
| 259 | 'enabled true' ) |
| 260 | # give onos some time to settle |
| 261 | time.sleep(main.startUpSleep) |
| 262 | jsonSum = json.loads(main.CLIs[0].summary()) |
| 263 | if jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1: |
| 264 | stepResult = main.TRUE |
| 265 | break |
| 266 | utilities.assert_equals( expect=stepResult, |
| 267 | actual=stepResult, |
| 268 | onpass="Successfully configured the null-provider", |
| 269 | onfail="Failed to configure the null-provider") |
| 270 | |
| 271 | |
| 272 | main.log.step("Get default flows") |
| 273 | jsonSum = json.loads(main.CLIs[0].summary()) |
| 274 | |
| 275 | # flows installed by the null-provider |
| 276 | main.defaultFlows = jsonSum["flows"] |
| 277 | main.ingress = ":0000000000000001/3" |
| 278 | main.egress = ":0000000000000003/2" |
| 279 | main.switch = "null" |
| 280 | main.linkUpCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 up" |
| 281 | main.linkDownCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 down" |
| 282 | |
| 283 | def CASE11( self, main ): |
| 284 | ''' |
| 285 | Setting up mininet |
| 286 | ''' |
| 287 | import json |
| 288 | import time |
| 289 | |
| 290 | # Activate apps |
| 291 | main.log.step("Activating apps") |
| 292 | stepResult = main.CLIs[0].activateApp('org.onosproject.openflow') |
| 293 | |
| 294 | utilities.assert_equals( expect=main.TRUE, |
| 295 | actual=stepResult, |
| 296 | onpass="Successfully activated openflow", |
| 297 | onfail="Failed to activate openflow") |
| 298 | # give onos some time settle |
| 299 | time.sleep(main.startUpSleep) |
| 300 | |
| 301 | main.log.step('Starting mininet topology') |
| 302 | main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py') |
| 303 | main.Mininet1.assignSwController(sw='s1', ip=main.ONOSip[0]) |
| 304 | main.Mininet1.assignSwController(sw='s2', ip=main.ONOSip[0]) |
| 305 | main.Mininet1.assignSwController(sw='s3', ip=main.ONOSip[0]) |
| 306 | time.sleep(main.startUpSleep) |
| 307 | |
| 308 | jsonSum = json.loads(main.CLIs[0].summary()) |
| 309 | if jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1: |
| 310 | stepResult = main.TRUE |
| 311 | |
| 312 | utilities.assert_equals( expect=stepResult, |
| 313 | actual=stepResult, |
| 314 | onpass="Successfully assigned switches to their master", |
| 315 | onfail="Failed to assign switches") |
| 316 | |
| 317 | main.log.step("Get default flows") |
| 318 | jsonSum = json.loads(main.CLIs[0].summary()) |
| 319 | |
| 320 | # flows installed by the null-provider |
| 321 | main.defaultFlows = jsonSum["flows"] |
| 322 | main.ingress = ":0000000000000001/3" |
| 323 | main.egress = ":0000000000000003/2" |
| 324 | main.switch = "of" |
| 325 | main.linkDownCmd = 'link s1 s3 down' |
| 326 | main.linkUpCmd = 'link s1 s3 up' |
| 327 | |
| 328 | |
| 329 | def CASE20( self, main ): |
| 330 | import pexpect |
| 331 | ''' |
| 332 | Pushing intents |
| 333 | ''' |
| 334 | # the index where the next intents will be installed |
| 335 | offset = 0 |
| 336 | # the number of intents we expect to be in the installed state |
| 337 | expectedIntents = 0 |
| 338 | # the number of flows we expect to be in the added state |
| 339 | expectedFlows = main.defaultFlows |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 340 | # limit for the number of intents that can be installed |
| 341 | limit = main.maxIntents / main.batchSize |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 342 | try: |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 343 | for i in range(limit): |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 344 | # Push intents |
| 345 | main.log.step("Pushing intents") |
| 346 | stepResult = main.intentFunctions.pushIntents( main, |
| 347 | main.switch, |
| 348 | main.ingress, |
| 349 | main.egress, |
| 350 | main.batchSize, |
| 351 | offset, |
| 352 | sleep=main.installSleep, |
| 353 | timeout=main.timeout, |
| 354 | options="-i" ) |
| 355 | utilities.assert_equals( expect=main.TRUE, |
| 356 | actual=stepResult, |
| 357 | onpass="Successfully pushed intents", |
| 358 | onfail="Failed to push intents") |
| 359 | if stepResult == main.FALSE: |
| 360 | break |
| 361 | |
| 362 | offset += main.batchSize |
| 363 | expectedIntents = offset |
| 364 | expectedFlows += main.batchSize*2 |
| 365 | |
| 366 | if offset >= main.minIntents and offset % main.checkInterval == 0: |
| 367 | # Verifying intents |
| 368 | main.log.step("Verifying intents") |
| 369 | main.log.info("Expected intents: " + str(expectedIntents)) |
| 370 | stepResult = main.intentFunctions.verifyIntents( main, |
| 371 | expectedIntents, |
| 372 | sleep=main.verifySleep, |
| 373 | timeout=main.timeout) |
| 374 | utilities.assert_equals( expect=main.TRUE, |
| 375 | actual=stepResult, |
| 376 | onpass="Successfully verified intents", |
| 377 | onfail="Failed to verify intents") |
| 378 | |
| 379 | if stepResult == main.FALSE: |
| 380 | break |
| 381 | |
| 382 | # Verfying flows |
| 383 | main.log.step("Verifying flows") |
| 384 | main.log.info("Expected Flows: " + str(expectedFlows)) |
| 385 | stepResult = main.intentFunctions.verifyFlows( main, |
| 386 | expectedFlows, |
| 387 | sleep=main.verifySleep, |
| 388 | timeout=main.timeout) |
| 389 | |
| 390 | utilities.assert_equals( expect=main.TRUE, |
| 391 | actual=stepResult, |
| 392 | onpass="Successfully verified flows", |
| 393 | onfail="Failed to verify flows") |
| 394 | |
| 395 | if stepResult == main.FALSE: |
| 396 | break |
| 397 | |
| 398 | except pexpect.TIMEOUT: |
| 399 | main.log.exception("Timeout exception caught") |
| 400 | |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame^] | 401 | maxIntents = main.intentFunctions.getIntents( main ) |
| 402 | maxFlows = main.intentFunctions.getFlows( main ) |
| 403 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 404 | main.log.report("Done pushing intents") |
| 405 | main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame^] | 406 | main.log.info("Installed intents: " + str(maxIntents) + |
| 407 | "\nAdded flows: " + str(maxFlows)) |
| 408 | |
| 409 | try: |
| 410 | dbFileName="/tmp/MaxIntentDB" |
| 411 | dbfile = open(dbFileName, "a+") |
| 412 | temp = "'" + str(maxIntents) + "'," |
| 413 | dbfile.write(temp) |
| 414 | dbfile.close() |
| 415 | except IOError: |
| 416 | main.log.warn("Error opening " + dbFileName + " to write results.") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 417 | |
| 418 | # Stopping mininet |
| 419 | if main.switch == "of": |
| 420 | main.log.info("Stopping mininet") |
| 421 | main.Mininet1.stopNet() |
| 422 | |
| 423 | def CASE21( self, main ): |
| 424 | import pexpect |
| 425 | import time |
| 426 | ''' |
| 427 | Reroute |
| 428 | ''' |
| 429 | # the index where the next intents will be installed |
| 430 | offset = 0 |
| 431 | # the number of intents we expect to be in the installed state |
| 432 | expectedIntents = 0 |
| 433 | # the number of flows we expect to be in the added state |
| 434 | expectedFlows = main.defaultFlows |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 435 | # limit for the number of intents that can be installed |
| 436 | limit = main.maxIntents / main.batchSize |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 437 | try: |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 438 | for i in range(limit): |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 439 | # Push intents |
| 440 | main.log.step("Pushing intents") |
| 441 | stepResult = main.intentFunctions.pushIntents( main, |
| 442 | main.switch, |
| 443 | main.ingress, |
| 444 | main.egress, |
| 445 | main.batchSize, |
| 446 | offset, |
| 447 | sleep=main.installSleep, |
| 448 | options="-i", |
| 449 | timeout=main.timeout ) |
| 450 | utilities.assert_equals( expect=main.TRUE, |
| 451 | actual=stepResult, |
| 452 | onpass="Successfully pushed intents", |
| 453 | onfail="Failed to push intents") |
| 454 | if stepResult == main.FALSE: |
| 455 | break |
| 456 | |
| 457 | offset += main.batchSize |
| 458 | expectedIntents = offset |
| 459 | expectedFlows += main.batchSize*2 |
| 460 | |
| 461 | # Verifying intents |
| 462 | main.log.step("Verifying intents") |
| 463 | main.log.info("Expected intents: " + str(expectedIntents)) |
| 464 | stepResult = main.intentFunctions.verifyIntents( main, |
| 465 | expectedIntents, |
| 466 | sleep=main.verifySleep, |
| 467 | timeout=main.timeout ) |
| 468 | utilities.assert_equals( expect=main.TRUE, |
| 469 | actual=stepResult, |
| 470 | onpass="Successfully verified intents", |
| 471 | onfail="Failed to verify intents") |
| 472 | |
| 473 | if stepResult == main.FALSE: |
| 474 | break |
| 475 | |
| 476 | # Verfying flows |
| 477 | main.log.step("Verifying flows") |
| 478 | main.log.info("Expected Flows: " + str(expectedFlows)) |
| 479 | stepResult = main.intentFunctions.verifyFlows( main, |
| 480 | expectedFlows, |
| 481 | sleep=main.verifySleep, |
| 482 | timeout=main.timeout ) |
| 483 | utilities.assert_equals( expect=main.TRUE, |
| 484 | actual=stepResult, |
| 485 | onpass="Successfully verified flows", |
| 486 | onfail="Failed to verify flows") |
| 487 | |
| 488 | if stepResult == main.FALSE: |
| 489 | break |
| 490 | |
| 491 | # tear down a link |
| 492 | main.log.step("Tearing down link") |
| 493 | if main.switch == "of": |
| 494 | main.log.info("Sending: " + main.linkDownCmd) |
| 495 | main.Mininet1.handle.sendline(main.linkDownCmd) |
| 496 | main.Mininet1.handle.expect('mininet>') |
| 497 | else: |
| 498 | main.log.info("Sending: " + main.linkDownCmd) |
| 499 | main.CLIs[0].handle.sendline(main.linkDownCmd) |
| 500 | main.CLIs[0].handle.expect('onos>') |
| 501 | time.sleep(main.rerouteSleep) |
| 502 | |
| 503 | # rerouting adds a 1000 flows |
| 504 | expectedFlows += 1000 |
| 505 | |
| 506 | # Verfying flows |
| 507 | main.log.step("Verifying flows") |
| 508 | main.log.info("Expected Flows: " + str(expectedFlows)) |
| 509 | stepResult = main.intentFunctions.verifyFlows( main, |
| 510 | expectedFlows, |
| 511 | sleep=main.verifySleep, |
| 512 | timeout=main.timeout) |
| 513 | utilities.assert_equals( expect=main.TRUE, |
| 514 | actual=stepResult, |
| 515 | onpass="Successfully verified flows", |
| 516 | onfail="Failed to verify flows") |
| 517 | |
| 518 | if stepResult == main.FALSE: |
| 519 | break |
| 520 | |
| 521 | # Bring link back up |
| 522 | main.log.step("Tearing down link") |
| 523 | if main.switch == "of": |
| 524 | main.log.info("Sending: " + main.linkUpCmd) |
| 525 | main.Mininet1.handle.sendline(main.linkUpCmd) |
| 526 | main.Mininet1.handle.expect('mininet>') |
| 527 | else: |
| 528 | main.log.info("Sending: " + main.linkUpCmd) |
| 529 | main.CLIs[0].handle.sendline(main.linkUpCmd) |
| 530 | main.CLIs[0].handle.expect('onos>') |
| 531 | time.sleep(main.rerouteSleep) |
| 532 | |
| 533 | except pexpect.TIMEOUT: |
| 534 | main.log.exception("Timeout exception caught") |
| 535 | |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame^] | 536 | maxIntents = main.intentFunctions.getIntents( main ) |
| 537 | maxFlows = main.intentFunctions.getFlows( main ) |
| 538 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 539 | main.log.report("Done pushing intents") |
| 540 | main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame^] | 541 | main.log.info("Installed intents: " + str(maxIntents) + |
| 542 | "\nAdded flows: " + str(maxFlows)) |
| 543 | |
| 544 | try: |
| 545 | dbFileName="/tmp/MaxIntentDB" |
| 546 | dbfile = open(dbFileName, "a+") |
| 547 | temp = "'" + str(maxIntents) + "'," |
| 548 | dbfile.write(temp) |
| 549 | dbfile.close() |
| 550 | except IOError: |
| 551 | main.log.warn("Error opening " + dbFileName + " to write results.") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 552 | |
| 553 | # Stopping mininet |
| 554 | if main.switch == "of": |
| 555 | main.log.info("Stopping mininet") |
| 556 | main.Mininet1.stopNet() |
| 557 | |
| 558 | def CASE100( self, main ): |
| 559 | ''' |
| 560 | Report errors/warnings/exceptions |
| 561 | ''' |
| 562 | main.log.info("Error report: \n") |
| 563 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 564 | [ "INFO", |
| 565 | "FOLLOWER", |
| 566 | "WARN", |
| 567 | "flow", |
| 568 | "ERROR", |
| 569 | "Except" ], |
| 570 | "s" ) |