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. |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 4 | ''' |
| 5 | This test will not test on reroute and OVS!!! |
| 6 | If you need test on reroute or OVS, change the params file |
| 7 | |
| 8 | Test information: |
| 9 | - BatchSize: 1000 |
| 10 | - Minimum intents: 10,000 |
| 11 | - Maximum Intents: 1,000,000 |
| 12 | - Check Interval: 10,000 |
| 13 | - Link: |
| 14 | - ingress: 0000000000000001/9 |
| 15 | - egress: 0000000000000002/9 |
| 16 | - Timeout: 120 Seconds |
| 17 | ''' |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 18 | |
| 19 | class SCPFmaxIntents: |
| 20 | |
| 21 | def __init__( self ): |
| 22 | self.default = '' |
| 23 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 24 | def CASE1( self, main ): |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 25 | import time |
| 26 | import os |
| 27 | import imp |
| 28 | |
| 29 | """ |
| 30 | - Construct tests variables |
| 31 | - GIT ( optional ) |
| 32 | - Checkout ONOS master branch |
| 33 | - Pull latest ONOS code |
| 34 | - Building ONOS ( optional ) |
| 35 | - Install ONOS package |
| 36 | - Build ONOS package |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 37 | - Set up cell |
| 38 | - Create cell file |
| 39 | - Set cell file |
| 40 | - Verify cell file |
| 41 | - Kill ONOS process |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 42 | """ |
| 43 | |
| 44 | main.case( "Constructing test variables and building ONOS package" ) |
| 45 | main.step( "Constructing test variables" ) |
| 46 | stepResult = main.FALSE |
| 47 | |
| 48 | # Test variables |
| 49 | main.testOnDirectory = os.path.dirname( os.getcwd ( ) ) |
| 50 | main.dependencyPath = main.testOnDirectory + \ |
| 51 | main.params['DEPENDENCY']['path'] |
| 52 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 53 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 54 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 55 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
| 56 | main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] ) |
| 57 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 58 | main.timeout = int(main.params['SLEEP']['timeout']) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 59 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 60 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 61 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
| 62 | main.rerouteSleep = int ( main.params['SLEEP']['reroute'] ) |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 63 | main.verifyAttempts = int( main.params['ATTEMPTS']['verify'] ) |
| 64 | main.ingress = main.params['LINK']['ingress'] |
| 65 | main.egress = main.params['LINK']['egress'] |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 66 | main.dbFileName = main.params['DATABASE']['file'] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 67 | main.cellData = {} # for creating cell file |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 68 | main.reroute = main.params['reroute'] |
| 69 | if main.reroute == "True": |
| 70 | main.reroute = True |
| 71 | else: |
| 72 | main.reroute = False |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 73 | main.CLIs = [] |
| 74 | main.ONOSip = [] |
| 75 | main.maxNumBatch = 0 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 76 | main.ONOSip = main.ONOSbench.getOnosIps() |
| 77 | main.log.info(main.ONOSip) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 78 | main.setupSkipped = False |
| 79 | |
| 80 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 81 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 82 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 83 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 84 | nic = main.params['DATABASE']['nic'] |
| 85 | node = main.params['DATABASE']['node'] |
| 86 | nic = main.params['DATABASE']['nic'] |
| 87 | node = main.params['DATABASE']['node'] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 88 | |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 89 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 90 | main.numCtrls = int( main.scale[ 0 ] ) |
| 91 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 92 | main.log.info("Creating list of ONOS cli handles") |
| 93 | for i in range(main.maxNodes): |
| 94 | main.CLIs.append( getattr( main, 'ONOScli' + str( i+1 ))) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 95 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 96 | if not main.CLIs: |
| 97 | main.log.error("Failed to create the list of ONOS cli handles") |
| 98 | main.cleanup() |
| 99 | main.exit() |
| 100 | |
| 101 | main.log.info("Loading wrapper files") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 102 | main.startUp = imp.load_source( wrapperFile1, |
| 103 | main.dependencyPath + |
| 104 | wrapperFile1 + |
| 105 | ".py" ) |
| 106 | |
| 107 | main.intentFunctions = imp.load_source( wrapperFile2, |
| 108 | main.dependencyPath + |
| 109 | wrapperFile2 + |
| 110 | ".py" ) |
| 111 | |
| 112 | copyResult = main.ONOSbench.copyMininetFile( main.topology, |
| 113 | main.dependencyPath, |
| 114 | main.Mininet1.user_name, |
| 115 | main.Mininet1.ip_address ) |
| 116 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 117 | commit = main.ONOSbench.getVersion(report=True) |
| 118 | commit = commit.split(" ")[1] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 119 | |
| 120 | if gitPull == 'True': |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 121 | if not main.startUp.onosBuild( main, gitBranch ): |
| 122 | main.log.error("Failed to build ONOS") |
| 123 | main.cleanup() |
| 124 | main.exit() |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 125 | else: |
| 126 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 127 | "clean install" ) |
| 128 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 129 | main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 130 | main.log.info( "Safety check, killing all ONOS processes" + |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame] | 131 | " before initiating environment setup" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 132 | |
| 133 | for i in range( main.maxNodes ): |
| 134 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 135 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 136 | main.log.info( "NODE COUNT = %s" % main.numCtrls) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 137 | |
| 138 | tempOnosIp = [] |
| 139 | for i in range( main.numCtrls ): |
| 140 | tempOnosIp.append( main.ONOSip[i] ) |
| 141 | |
| 142 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 143 | "temp", |
| 144 | main.Mininet1.ip_address, |
| 145 | main.apps, |
| 146 | tempOnosIp ) |
| 147 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 148 | main.step( "Apply cell to environment" ) |
| 149 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 150 | verifyResult = main.ONOSbench.verifyCell() |
| 151 | stepResult = cellResult and verifyResult |
| 152 | utilities.assert_equals( expect=main.TRUE, |
| 153 | actual=stepResult, |
| 154 | onpass="Successfully applied cell to " + \ |
| 155 | "environment", |
| 156 | onfail="Failed to apply cell to environment " ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 157 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 158 | main.step( "Creating ONOS package" ) |
| 159 | packageResult = main.ONOSbench.onosPackage() |
| 160 | stepResult = packageResult |
| 161 | utilities.assert_equals( expect=main.TRUE, |
| 162 | actual=stepResult, |
| 163 | onpass="Successfully created ONOS package", |
| 164 | onfail="Failed to create ONOS package" ) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 165 | |
GlennRC | 58ea254 | 2015-09-02 14:23:34 -0700 | [diff] [blame] | 166 | main.log.info("Creating DB file") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 167 | with open(main.dbFileName, "w+") as dbFile: |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 168 | temp = "'" + commit + "'," |
GlennRC | 58ea254 | 2015-09-02 14:23:34 -0700 | [diff] [blame] | 169 | temp += "'" + nic + "'," |
| 170 | temp += str(main.numCtrls) + "," |
GlennRC | 5719ff0 | 2015-09-08 17:25:30 -0700 | [diff] [blame] | 171 | temp += "'" + node + "1" + "'" |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 172 | dbFile.write(temp) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 173 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 174 | def CASE2( self, main ): |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 175 | """ |
| 176 | - Uninstall ONOS cluster |
| 177 | - Verify ONOS start up |
| 178 | - Install ONOS cluster |
| 179 | - Connect to cli |
| 180 | """ |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 181 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 182 | main.step( "Installing ONOS with -f" ) |
| 183 | onosInstallResult = main.TRUE |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 184 | for i in range( main.numCtrls ): |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 185 | onosInstallResult = onosInstallResult and \ |
| 186 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 187 | stepResult = onosInstallResult |
| 188 | utilities.assert_equals( expect=main.TRUE, |
| 189 | actual=stepResult, |
| 190 | onpass="Successfully installed ONOS package", |
| 191 | onfail="Failed to install ONOS package" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 192 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 193 | time.sleep( main.startUpSleep ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 194 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 195 | main.step( "Start ONOS cli" ) |
| 196 | cliResult = main.TRUE |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 197 | for i in range( main.numCtrls ): |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 198 | cliResult = cliResult and \ |
| 199 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 200 | stepResult = cliResult |
| 201 | utilities.assert_equals( expect=main.TRUE, |
| 202 | actual=stepResult, |
| 203 | onpass="Successfully start ONOS cli", |
| 204 | onfail="Failed to start ONOS cli" ) |
| 205 | |
| 206 | time.sleep( main.startUpSleep ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 207 | |
| 208 | def CASE10( self, main ): |
| 209 | """ |
| 210 | Setting up null-provider |
| 211 | """ |
| 212 | import json |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 213 | |
| 214 | # Activate apps |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 215 | main.step("Activating null-provider") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 216 | appStatus = main.CLIs[0].activateApp('org.onosproject.null') |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 217 | utilities.assert_equals( expect=main.TRUE, |
| 218 | actual=appStatus, |
| 219 | onpass="Successfully activated null-provider", |
| 220 | onfail="Failed activate null-provider" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 221 | |
| 222 | # Setup the null-provider |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 223 | main.step("Configuring null-provider") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 224 | cfgStatus = main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 225 | 'org.onosproject.provider.nil.NullProviders', 'deviceCount 3' ) |
| 226 | cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 227 | 'org.onosproject.provider.nil.NullProviders', 'topoShape reroute' ) |
| 228 | cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 229 | 'org.onosproject.provider.nil.NullProviders', 'enabled true' ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 230 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 231 | utilities.assert_equals( expect=main.TRUE, |
| 232 | actual=cfgStatus, |
| 233 | onpass="Successfully configured null-provider", |
| 234 | onfail="Failed to configure null-provider" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 235 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 236 | # give onos some time to settle |
| 237 | time.sleep(main.startUpSleep) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 238 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 239 | main.log.info("Setting default flows to zero") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 240 | main.defaultFlows = 0 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 241 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 242 | main.step("Check status of null-provider setup") |
| 243 | caseResult = appStatus and cfgStatus |
| 244 | utilities.assert_equals( expect=main.TRUE, |
| 245 | actual=caseResult, |
| 246 | onpass="Setting up null-provider was successfull", |
| 247 | onfail="Failed to setup null-provider" ) |
| 248 | |
| 249 | # This tells the following cases if we are using the null-provider or ovs |
| 250 | main.switchType = "null:" |
| 251 | |
| 252 | # If the null-provider setup was unsuccessfull, then there is no point to |
| 253 | # run the subsequent cases |
| 254 | if not caseResult: |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 255 | main.setupSkipped = True |
| 256 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 257 | def CASE11( self, main ): |
| 258 | ''' |
| 259 | Setting up mininet |
| 260 | ''' |
| 261 | import json |
| 262 | import time |
| 263 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 264 | time.sleep(main.startUpSleep) |
| 265 | |
| 266 | main.step("Activating openflow") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 267 | appStatus = main.CLIs[0].activateApp('org.onosproject.openflow') |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 268 | utilities.assert_equals( expect=main.TRUE, |
| 269 | actual=appStatus, |
| 270 | onpass="Successfully activated openflow", |
| 271 | onfail="Failed activate openflow" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 272 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 273 | time.sleep(main.startUpSleep) |
| 274 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 275 | main.step('Starting mininet topology') |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 276 | mnStatus = main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py') |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 277 | utilities.assert_equals( expect=main.TRUE, |
| 278 | actual=mnStatus, |
| 279 | onpass="Successfully started Mininet", |
| 280 | onfail="Failed to activate Mininet" ) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 281 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 282 | main.step("Assinging masters to switches") |
| 283 | switches = main.Mininet1.getSwitches() |
| 284 | swStatus = main.Mininet1.assignSwController( sw=switches.keys(), ip=main.ONOSip ) |
| 285 | utilities.assert_equals( expect=main.TRUE, |
| 286 | actual=swStatus, |
| 287 | onpass="Successfully assigned switches to masters", |
| 288 | onfail="Failed assign switches to masters" ) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 289 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 290 | time.sleep(main.startUpSleep) |
| 291 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 292 | main.log.info("Getting default flows") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 293 | jsonSum = json.loads(main.CLIs[0].summary()) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 294 | main.defaultFlows = jsonSum["flows"] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 295 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 296 | main.step("Check status of Mininet setup") |
| 297 | caseResult = appStatus and mnStatus and swStatus |
| 298 | utilities.assert_equals( expect=main.TRUE, |
| 299 | actual=caseResult, |
| 300 | onpass="Successfully setup Mininet", |
| 301 | onfail="Failed setup Mininet" ) |
| 302 | |
| 303 | # This tells the following cases if we are using the null-provider or ovs |
| 304 | main.switchType = "of:" |
| 305 | |
| 306 | if not caseResult: |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 307 | main.setupSkipped = True |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 308 | |
| 309 | def CASE20( self, main ): |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 310 | ''' |
| 311 | Pushing intents |
| 312 | ''' |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 313 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 314 | if main.reroute: |
| 315 | if main.switchType == "of:": |
| 316 | main.minIntents = int(main.params['OVS']['REROUTE']['min_intents']) |
| 317 | main.maxIntents = int(main.params['OVS']['REROUTE']['max_intents']) |
| 318 | main.checkInterval = int(main.params['OVS']['REROUTE']['check_interval']) |
| 319 | main.batchSize = int(main.params['OVS']['REROUTE']['batch_size']) |
| 320 | else: |
| 321 | main.minIntents = int(main.params['NULL']['REROUTE']['min_intents']) |
| 322 | main.maxIntents = int(main.params['NULL']['REROUTE']['max_intents']) |
| 323 | main.checkInterval = int(main.params['NULL']['REROUTE']['check_interval']) |
| 324 | main.batchSize = int(main.params['NULL']['REROUTE']['batch_size']) |
| 325 | else: |
| 326 | if main.switchType == "of:": |
| 327 | main.minIntents = int(main.params['OVS']['PUSH']['min_intents']) |
| 328 | main.maxIntents = int(main.params['OVS']['PUSH']['max_intents']) |
| 329 | main.checkInterval = int(main.params['OVS']['PUSH']['check_interval']) |
| 330 | main.batchSize = int(main.params['OVS']['PUSH']['batch_size']) |
| 331 | else: |
| 332 | main.minIntents = int(main.params['NULL']['PUSH']['min_intents']) |
| 333 | main.maxIntents = int(main.params['NULL']['PUSH']['max_intents']) |
| 334 | main.checkInterval = int(main.params['NULL']['PUSH']['check_interval']) |
| 335 | main.batchSize = int(main.params['NULL']['PUSH']['batch_size']) |
| 336 | |
| 337 | # check if the case needs to be skipped |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 338 | if main.setupSkipped: |
| 339 | main.setupSkipped = False |
| 340 | main.skipCase() |
| 341 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 342 | # the index where the next intents will be installed |
| 343 | offset = 0 |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 344 | # keeps track of how many intents have been installed |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 345 | currIntents = 0 |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 346 | # keeps track of how many flows have been installed |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 347 | currFlows = 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 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 351 | main.step( "Pushing intents" ) |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 352 | for i in range(limit): |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 353 | pushResult = main.ONOScli1.pushTestIntents( main.switchType + main.ingress, |
| 354 | main.switchType + main.egress, |
| 355 | main.batchSize, |
| 356 | offset = offset, |
| 357 | options = "-i", |
| 358 | timeout = main.timeout ) |
| 359 | if pushResult == None: |
| 360 | main.log.info( "Timeout!" ) |
| 361 | main.skipCase() |
| 362 | time.sleep(1) |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 363 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 364 | # Update offset |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 365 | offset += main.batchSize |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 366 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 367 | if offset >= main.minIntents and offset % main.checkInterval == 0: |
| 368 | intentVerify = utilities.retry( main.ONOScli1.checkIntentSummary, |
| 369 | main.FALSE, |
| 370 | [main.timeout], |
| 371 | sleep=main.verifySleep, |
| 372 | attempts=main.verifyAttempts ) |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 373 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 374 | flowVerify = utilities.retry( main.ONOScli1.checkFlowsState, |
| 375 | main.FALSE, |
| 376 | [False,main.timeout], |
| 377 | sleep=main.verifySleep, |
| 378 | attempts=main.verifyAttempts ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 379 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 380 | if not intentVerify: |
| 381 | main.log.error( "Failed to install intents" ) |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 382 | break |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 383 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 384 | if main.reroute: |
| 385 | main.step( "Reroute" ) |
| 386 | # tear down a link |
| 387 | main.log.info("Tearing down link") |
| 388 | if main.switchType == "of:": |
| 389 | downlink = main.Mininet1.link( END1 = "s1", END2 = "s3", OPTION = "down" ) |
| 390 | else: |
| 391 | downlink = main.ONOScli1.link( main.ingress, main.egress, "down") |
| 392 | |
| 393 | if downlink: |
| 394 | main.log.info( "Successfully tear down link" ) |
| 395 | else: |
| 396 | main.log.warn( "Failed to tear down link" ) |
| 397 | |
| 398 | time.sleep(main.rerouteSleep) |
| 399 | |
| 400 | # Verifying intents |
| 401 | main.step( "Checking intents and flows" ) |
| 402 | intentVerify = utilities.retry( main.ONOScli1.checkIntentSummary, |
| 403 | main.FALSE, |
| 404 | [main.timeout], |
| 405 | sleep=main.verifySleep, |
| 406 | attempts=main.verifyAttempts ) |
| 407 | # Verfying flows |
| 408 | flowVerify = utilities.retry( main.ONOScli1.checkFlowsState, |
| 409 | main.FALSE, |
| 410 | [False, main.timeout], |
| 411 | sleep = main.verifySleep, |
| 412 | attempts = main.verifyAttempts ) |
| 413 | |
| 414 | if not intentVerify: |
| 415 | main.log.error( "Failed to install intents" ) |
| 416 | # Bring link back up |
| 417 | main.log.info("Bringing link back up") |
| 418 | if main.switchType == "of:": |
| 419 | uplink = main.Mininet1.link( END1 = "s1", END2 = "s3", OPTION = "up" ) |
| 420 | else: |
| 421 | uplink = main.ONOScli1.link( main.ingress, main.egress, "up" ) |
| 422 | |
| 423 | if uplink: |
| 424 | main.log.info( "Successfully bring link back up" ) |
| 425 | else: |
| 426 | main.log.warn( "Failed to bring link back up" ) |
| 427 | |
| 428 | time.sleep(main.rerouteSleep) |
| 429 | |
| 430 | # Verifying intents |
| 431 | main.step( "Checking intents and flows" ) |
| 432 | intentVerify = utilities.retry( main.ONOScli1.checkIntentSummary, |
| 433 | main.FALSE, |
| 434 | [main.timeout], |
| 435 | sleep=main.verifySleep, |
| 436 | attempts=main.verifyAttempts ) |
| 437 | # Verfying flows |
| 438 | flowVerify = utilities.retry( main.ONOScli1.checkFlowsState, |
| 439 | main.FALSE, |
| 440 | [False, main.timeout], |
| 441 | sleep = main.verifySleep, |
| 442 | attempts = main.verifyAttempts ) |
| 443 | |
| 444 | if not intentVerify: |
| 445 | main.log.error( "Failed to install intents" ) |
| 446 | |
| 447 | rerouteResult = downlink and uplink |
| 448 | utilities.assert_equals( expect = main.TRUE, |
| 449 | actual = rerouteResult, |
| 450 | onpass = "Successfully reroute", |
| 451 | onfail = "Failed to reroute" ) |
| 452 | |
| 453 | utilities.assert_equals( expect = main.TRUE, |
| 454 | actual = intentVerify, |
| 455 | onpass = "Successfully pushed and verified intents", |
| 456 | onfail = "Failed to push and verify intents" ) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 457 | |
GlennRC | 58ea254 | 2015-09-02 14:23:34 -0700 | [diff] [blame] | 458 | main.log.info("Writing results to DB file") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 459 | with open(main.dbFileName, "a") as dbFile: |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 460 | temp = "," + str(currIntents) |
| 461 | temp += "," + str(currFlows) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 462 | dbFile.write(temp) |
GlennRC | 14d54f7 | 2015-09-03 10:51:37 -0700 | [diff] [blame] | 463 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 464 | if main.switchType == "of:": |
| 465 | main.step( "Stopping mininet" ) |
| 466 | stepResult = main.Mininet1.stopNet() |
| 467 | utilities.assert_equals( expect = main.TRUE, |
| 468 | actual = stepResult, |
| 469 | oppass = "Successfully stop Mininet", |
| 470 | opfail = "Failed stop Mininet" ) |
| 471 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 472 | |
| 473 | def CASE100( self, main ): |
| 474 | ''' |
| 475 | Report errors/warnings/exceptions |
| 476 | ''' |
| 477 | main.log.info("Error report: \n") |
| 478 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 479 | [ "INFO", |
| 480 | "FOLLOWER", |
| 481 | "WARN", |
| 482 | "flow", |
| 483 | "ERROR", |
| 484 | "Except" ], |
| 485 | "s" ) |