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