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) + "," |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 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 |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 346 | # keeps track of how many intents have been installed |
| 347 | maxIntents = 0 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 348 | # the number of flows we expect to be in the added state |
| 349 | expectedFlows = main.defaultFlows |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 350 | # keeps track of how many flows have been installed |
| 351 | maxFlows = main.defaultFlows |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 352 | # limit for the number of intents that can be installed |
| 353 | limit = main.maxIntents / main.batchSize |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 354 | |
| 355 | for i in range(limit): |
| 356 | # Push intents |
| 357 | main.log.step("Pushing intents") |
| 358 | stepResult = main.intentFunctions.pushIntents( main, |
| 359 | main.switch, |
| 360 | main.ingress, |
| 361 | main.egress, |
| 362 | main.batchSize, |
| 363 | offset, |
| 364 | sleep=main.installSleep, |
| 365 | timeout=main.timeout, |
| 366 | options="-i" ) |
| 367 | utilities.assert_equals( expect=main.TRUE, |
| 368 | actual=stepResult, |
| 369 | onpass="Successfully pushed intents", |
| 370 | onfail="Failed to push intents") |
| 371 | if stepResult == main.FALSE: |
| 372 | break |
| 373 | |
| 374 | offset += main.batchSize |
| 375 | expectedIntents = offset |
| 376 | expectedFlows += main.batchSize*2 |
| 377 | |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 378 | maxIntents = main.intentFunctions.getIntents( main ) |
| 379 | maxFlows = main.intentFunctions.getFlows( main ) |
| 380 | |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 381 | if offset >= main.minIntents and offset % main.checkInterval == 0 or expectedIntents == main.maxIntents: |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 382 | # Verifying intents |
| 383 | main.log.step("Verifying intents") |
| 384 | main.log.info("Expected intents: " + str(expectedIntents)) |
| 385 | stepResult = main.intentFunctions.verifyIntents( main, |
| 386 | expectedIntents, |
| 387 | sleep=main.verifySleep, |
| 388 | timeout=main.timeout) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 389 | utilities.assert_equals( expect=main.TRUE, |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 390 | actual=stepResult, |
| 391 | onpass="Successfully verified intents", |
| 392 | onfail="Failed to verify intents") |
| 393 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 394 | if stepResult == main.FALSE: |
| 395 | break |
| 396 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 397 | # Verfying flows |
| 398 | main.log.step("Verifying flows") |
| 399 | main.log.info("Expected Flows: " + str(expectedFlows)) |
| 400 | stepResult = main.intentFunctions.verifyFlows( main, |
| 401 | expectedFlows, |
| 402 | sleep=main.verifySleep, |
| 403 | timeout=main.timeout) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 404 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 405 | utilities.assert_equals( expect=main.TRUE, |
| 406 | actual=stepResult, |
| 407 | onpass="Successfully verified flows", |
| 408 | onfail="Failed to verify flows") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 409 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 410 | if stepResult == main.FALSE: |
| 411 | break |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 412 | |
| 413 | main.log.report("Done pushing intents") |
| 414 | main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 415 | main.log.info("Installed intents: " + str(maxIntents) + |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 416 | " Added flows: " + str(maxFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 417 | |
GlennRC | 58ea254 | 2015-09-02 14:23:34 -0700 | [diff] [blame] | 418 | main.log.info("Writing results to DB file") |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 419 | try: |
| 420 | dbFileName="/tmp/MaxIntentDB" |
GlennRC | 58ea254 | 2015-09-02 14:23:34 -0700 | [diff] [blame] | 421 | dbfile = open(dbFileName, "a") |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 422 | temp = "," + str(maxIntents) |
| 423 | temp += "," + str(maxFlows) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 424 | dbfile.write(temp) |
| 425 | dbfile.close() |
| 426 | except IOError: |
| 427 | main.log.warn("Error opening " + dbFileName + " to write results.") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 428 | |
| 429 | # Stopping mininet |
| 430 | if main.switch == "of": |
| 431 | main.log.info("Stopping mininet") |
| 432 | main.Mininet1.stopNet() |
| 433 | |
| 434 | def CASE21( self, main ): |
| 435 | import pexpect |
| 436 | import time |
| 437 | ''' |
| 438 | Reroute |
| 439 | ''' |
| 440 | # the index where the next intents will be installed |
| 441 | offset = 0 |
| 442 | # the number of intents we expect to be in the installed state |
| 443 | expectedIntents = 0 |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 444 | # keeps track of how many intents have been installed |
| 445 | maxIntents = 0 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 446 | # the number of flows we expect to be in the added state |
| 447 | expectedFlows = main.defaultFlows |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 448 | # keeps track of how many flows have been installed |
| 449 | maxFlows = main.defaultFlows |
GlennRC | 9882f35 | 2015-08-27 18:03:28 -0700 | [diff] [blame] | 450 | # limit for the number of intents that can be installed |
| 451 | limit = main.maxIntents / main.batchSize |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 452 | |
| 453 | for i in range(limit): |
| 454 | # Push intents |
| 455 | main.log.step("Pushing intents") |
| 456 | stepResult = main.intentFunctions.pushIntents( main, |
| 457 | main.switch, |
| 458 | main.ingress, |
| 459 | main.egress, |
| 460 | main.batchSize, |
| 461 | offset, |
| 462 | sleep=main.installSleep, |
| 463 | options="-i", |
| 464 | timeout=main.timeout ) |
| 465 | utilities.assert_equals( expect=main.TRUE, |
| 466 | actual=stepResult, |
| 467 | onpass="Successfully pushed intents", |
| 468 | onfail="Failed to push intents") |
| 469 | if stepResult == main.FALSE: |
| 470 | break |
| 471 | |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 472 | maxIntents = main.intentFunctions.getIntents( main ) |
| 473 | maxFlows = main.intentFunctions.getFlows( main ) |
| 474 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 475 | offset += main.batchSize |
| 476 | expectedIntents = offset |
| 477 | expectedFlows += main.batchSize*2 |
| 478 | |
| 479 | # Verifying intents |
| 480 | main.log.step("Verifying intents") |
| 481 | main.log.info("Expected intents: " + str(expectedIntents)) |
| 482 | stepResult = main.intentFunctions.verifyIntents( main, |
| 483 | expectedIntents, |
| 484 | sleep=main.verifySleep, |
| 485 | timeout=main.timeout ) |
| 486 | utilities.assert_equals( expect=main.TRUE, |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 487 | actual=stepResult, |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 488 | onpass="Successfully verified intents", |
| 489 | onfail="Failed to verify intents") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 490 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 491 | if stepResult == main.FALSE: |
| 492 | break |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 493 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 494 | # Verfying flows |
| 495 | main.log.step("Verifying flows") |
| 496 | main.log.info("Expected Flows: " + str(expectedFlows)) |
| 497 | stepResult = main.intentFunctions.verifyFlows( main, |
| 498 | expectedFlows, |
| 499 | sleep=main.verifySleep, |
| 500 | timeout=main.timeout ) |
| 501 | utilities.assert_equals( expect=main.TRUE, |
| 502 | actual=stepResult, |
| 503 | onpass="Successfully verified flows", |
| 504 | onfail="Failed to verify flows") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 505 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 506 | if stepResult == main.FALSE: |
| 507 | break |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 508 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 509 | # tear down a link |
| 510 | main.log.step("Tearing down link") |
| 511 | if main.switch == "of": |
| 512 | main.log.info("Sending: " + main.linkDownCmd) |
| 513 | main.Mininet1.handle.sendline(main.linkDownCmd) |
| 514 | main.Mininet1.handle.expect('mininet>') |
| 515 | else: |
| 516 | main.log.info("Sending: " + main.linkDownCmd) |
| 517 | main.CLIs[0].handle.sendline(main.linkDownCmd) |
| 518 | main.CLIs[0].handle.expect('onos>') |
| 519 | time.sleep(main.rerouteSleep) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 520 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 521 | # rerouting adds a 1000 flows |
| 522 | expectedFlows += 1000 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 523 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 524 | # Verfying flows |
| 525 | main.log.step("Verifying flows") |
| 526 | main.log.info("Expected Flows: " + str(expectedFlows)) |
| 527 | stepResult = main.intentFunctions.verifyFlows( main, |
| 528 | expectedFlows, |
| 529 | sleep=main.verifySleep, |
| 530 | timeout=main.timeout) |
| 531 | utilities.assert_equals( expect=main.TRUE, |
| 532 | actual=stepResult, |
| 533 | onpass="Successfully verified flows", |
| 534 | onfail="Failed to verify flows") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 535 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 536 | if stepResult == main.FALSE: |
| 537 | break |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 538 | |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 539 | # Bring link back up |
| 540 | main.log.step("Tearing down link") |
| 541 | if main.switch == "of": |
| 542 | main.log.info("Sending: " + main.linkUpCmd) |
| 543 | main.Mininet1.handle.sendline(main.linkUpCmd) |
| 544 | main.Mininet1.handle.expect('mininet>') |
| 545 | else: |
| 546 | main.log.info("Sending: " + main.linkUpCmd) |
| 547 | main.CLIs[0].handle.sendline(main.linkUpCmd) |
| 548 | main.CLIs[0].handle.expect('onos>') |
| 549 | time.sleep(main.rerouteSleep) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 550 | |
| 551 | main.log.report("Done pushing intents") |
| 552 | main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 553 | main.log.info("Installed intents: " + str(maxIntents) + |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 554 | " Added flows: " + str(maxFlows)) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 555 | |
GlennRC | 14d54f7 | 2015-09-03 10:51:37 -0700 | [diff] [blame] | 556 | try: |
| 557 | dbFileName="/tmp/MaxIntentDB" |
| 558 | dbfile = open(dbFileName, "a") |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 559 | temp = "," + str(maxIntents) |
| 560 | temp += "," + str(maxFlows) |
GlennRC | 14d54f7 | 2015-09-03 10:51:37 -0700 | [diff] [blame] | 561 | dbfile.write(temp) |
| 562 | dbfile.close() |
| 563 | except IOError: |
| 564 | main.log.warn("Error opening " + dbFileName + " to write results.") |
| 565 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 566 | # Stopping mininet |
| 567 | if main.switch == "of": |
| 568 | main.log.info("Stopping mininet") |
| 569 | main.Mininet1.stopNet() |
| 570 | |
| 571 | def CASE100( self, main ): |
| 572 | ''' |
| 573 | Report errors/warnings/exceptions |
| 574 | ''' |
| 575 | main.log.info("Error report: \n") |
| 576 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 577 | [ "INFO", |
| 578 | "FOLLOWER", |
| 579 | "WARN", |
| 580 | "flow", |
| 581 | "ERROR", |
| 582 | "Except" ], |
| 583 | "s" ) |