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" + "'" |
YPZhang | b5d3f83 | 2016-01-23 22:54:26 -0800 | [diff] [blame] | 172 | temp += ",0" |
| 173 | temp += ",0" |
| 174 | temp += ",0" |
| 175 | temp += ",0" |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 176 | dbFile.write(temp) |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 177 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 178 | def CASE2( self, main ): |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 179 | """ |
| 180 | - Uninstall ONOS cluster |
| 181 | - Verify ONOS start up |
| 182 | - Install ONOS cluster |
| 183 | - Connect to cli |
| 184 | """ |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 185 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 186 | main.step( "Installing ONOS with -f" ) |
| 187 | onosInstallResult = main.TRUE |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 188 | for i in range( main.numCtrls ): |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 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" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 196 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 197 | time.sleep( main.startUpSleep ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 198 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 199 | main.step( "Start ONOS cli" ) |
| 200 | cliResult = main.TRUE |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 201 | for i in range( main.numCtrls ): |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 202 | cliResult = cliResult and \ |
| 203 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 204 | stepResult = cliResult |
| 205 | utilities.assert_equals( expect=main.TRUE, |
| 206 | actual=stepResult, |
| 207 | onpass="Successfully start ONOS cli", |
| 208 | onfail="Failed to start ONOS cli" ) |
| 209 | |
| 210 | time.sleep( main.startUpSleep ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 211 | |
| 212 | def CASE10( self, main ): |
| 213 | """ |
| 214 | Setting up null-provider |
| 215 | """ |
| 216 | import json |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 217 | |
| 218 | # Activate apps |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 219 | main.step("Activating null-provider") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 220 | appStatus = main.CLIs[0].activateApp('org.onosproject.null') |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 221 | utilities.assert_equals( expect=main.TRUE, |
| 222 | actual=appStatus, |
| 223 | onpass="Successfully activated null-provider", |
| 224 | onfail="Failed activate null-provider" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 225 | |
| 226 | # Setup the null-provider |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 227 | main.step("Configuring null-provider") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 228 | cfgStatus = main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 229 | 'org.onosproject.provider.nil.NullProviders', 'deviceCount 3' ) |
| 230 | cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 231 | 'org.onosproject.provider.nil.NullProviders', 'topoShape reroute' ) |
| 232 | cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0], |
| 233 | 'org.onosproject.provider.nil.NullProviders', 'enabled true' ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 234 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 235 | utilities.assert_equals( expect=main.TRUE, |
| 236 | actual=cfgStatus, |
| 237 | onpass="Successfully configured null-provider", |
| 238 | onfail="Failed to configure null-provider" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 239 | |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 240 | # give onos some time to settle |
| 241 | time.sleep(main.startUpSleep) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 242 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 243 | main.log.info("Setting default flows to zero") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 244 | main.defaultFlows = 0 |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 245 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 246 | main.step("Check status of null-provider setup") |
| 247 | caseResult = appStatus and cfgStatus |
| 248 | utilities.assert_equals( expect=main.TRUE, |
| 249 | actual=caseResult, |
| 250 | onpass="Setting up null-provider was successfull", |
| 251 | onfail="Failed to setup null-provider" ) |
| 252 | |
| 253 | # This tells the following cases if we are using the null-provider or ovs |
| 254 | main.switchType = "null:" |
| 255 | |
| 256 | # If the null-provider setup was unsuccessfull, then there is no point to |
| 257 | # run the subsequent cases |
| 258 | if not caseResult: |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 259 | main.setupSkipped = True |
| 260 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 261 | def CASE11( self, main ): |
| 262 | ''' |
| 263 | Setting up mininet |
| 264 | ''' |
| 265 | import json |
| 266 | import time |
| 267 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 268 | time.sleep(main.startUpSleep) |
| 269 | |
| 270 | main.step("Activating openflow") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 271 | appStatus = main.CLIs[0].activateApp('org.onosproject.openflow') |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 272 | utilities.assert_equals( expect=main.TRUE, |
| 273 | actual=appStatus, |
| 274 | onpass="Successfully activated openflow", |
| 275 | onfail="Failed activate openflow" ) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 276 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 277 | time.sleep(main.startUpSleep) |
| 278 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 279 | main.step('Starting mininet topology') |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 280 | mnStatus = main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py') |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 281 | utilities.assert_equals( expect=main.TRUE, |
| 282 | actual=mnStatus, |
| 283 | onpass="Successfully started Mininet", |
| 284 | onfail="Failed to activate Mininet" ) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 285 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 286 | main.step("Assinging masters to switches") |
| 287 | switches = main.Mininet1.getSwitches() |
| 288 | swStatus = main.Mininet1.assignSwController( sw=switches.keys(), ip=main.ONOSip ) |
| 289 | utilities.assert_equals( expect=main.TRUE, |
| 290 | actual=swStatus, |
| 291 | onpass="Successfully assigned switches to masters", |
| 292 | onfail="Failed assign switches to masters" ) |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 293 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 294 | time.sleep(main.startUpSleep) |
| 295 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 296 | main.log.info("Getting default flows") |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 297 | jsonSum = json.loads(main.CLIs[0].summary()) |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 298 | main.defaultFlows = jsonSum["flows"] |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 299 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 300 | main.step("Check status of Mininet setup") |
| 301 | caseResult = appStatus and mnStatus and swStatus |
| 302 | utilities.assert_equals( expect=main.TRUE, |
| 303 | actual=caseResult, |
| 304 | onpass="Successfully setup Mininet", |
| 305 | onfail="Failed setup Mininet" ) |
| 306 | |
| 307 | # This tells the following cases if we are using the null-provider or ovs |
| 308 | main.switchType = "of:" |
| 309 | |
| 310 | if not caseResult: |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 311 | main.setupSkipped = True |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 312 | |
| 313 | def CASE20( self, main ): |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 314 | ''' |
| 315 | Pushing intents |
| 316 | ''' |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 317 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 318 | if main.reroute: |
| 319 | if main.switchType == "of:": |
| 320 | main.minIntents = int(main.params['OVS']['REROUTE']['min_intents']) |
| 321 | main.maxIntents = int(main.params['OVS']['REROUTE']['max_intents']) |
| 322 | main.checkInterval = int(main.params['OVS']['REROUTE']['check_interval']) |
| 323 | main.batchSize = int(main.params['OVS']['REROUTE']['batch_size']) |
| 324 | else: |
| 325 | main.minIntents = int(main.params['NULL']['REROUTE']['min_intents']) |
| 326 | main.maxIntents = int(main.params['NULL']['REROUTE']['max_intents']) |
| 327 | main.checkInterval = int(main.params['NULL']['REROUTE']['check_interval']) |
| 328 | main.batchSize = int(main.params['NULL']['REROUTE']['batch_size']) |
| 329 | else: |
| 330 | if main.switchType == "of:": |
| 331 | main.minIntents = int(main.params['OVS']['PUSH']['min_intents']) |
| 332 | main.maxIntents = int(main.params['OVS']['PUSH']['max_intents']) |
| 333 | main.checkInterval = int(main.params['OVS']['PUSH']['check_interval']) |
| 334 | main.batchSize = int(main.params['OVS']['PUSH']['batch_size']) |
| 335 | else: |
| 336 | main.minIntents = int(main.params['NULL']['PUSH']['min_intents']) |
| 337 | main.maxIntents = int(main.params['NULL']['PUSH']['max_intents']) |
| 338 | main.checkInterval = int(main.params['NULL']['PUSH']['check_interval']) |
| 339 | main.batchSize = int(main.params['NULL']['PUSH']['batch_size']) |
| 340 | |
| 341 | # check if the case needs to be skipped |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 342 | if main.setupSkipped: |
| 343 | main.setupSkipped = False |
| 344 | main.skipCase() |
| 345 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 346 | # the index where the next intents will be installed |
| 347 | offset = 0 |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 348 | # keeps track of how many intents have been installed |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 349 | currIntents = 0 |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 350 | # keeps track of how many flows have been installed |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 351 | currFlows = 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 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 355 | main.step( "Pushing intents" ) |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 356 | for i in range(limit): |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 357 | pushResult = main.ONOScli1.pushTestIntents( main.switchType + main.ingress, |
| 358 | main.switchType + main.egress, |
| 359 | main.batchSize, |
| 360 | offset = offset, |
| 361 | options = "-i", |
| 362 | timeout = main.timeout ) |
| 363 | if pushResult == None: |
| 364 | main.log.info( "Timeout!" ) |
| 365 | main.skipCase() |
| 366 | time.sleep(1) |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 367 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 368 | # Update offset |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 369 | offset += main.batchSize |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 370 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 371 | if offset >= main.minIntents and offset % main.checkInterval == 0: |
| 372 | intentVerify = utilities.retry( main.ONOScli1.checkIntentSummary, |
| 373 | main.FALSE, |
| 374 | [main.timeout], |
| 375 | sleep=main.verifySleep, |
| 376 | attempts=main.verifyAttempts ) |
GlennRC | 33a4207 | 2015-09-11 11:32:44 -0700 | [diff] [blame] | 377 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 378 | flowVerify = utilities.retry( main.ONOScli1.checkFlowsState, |
| 379 | main.FALSE, |
| 380 | [False,main.timeout], |
| 381 | sleep=main.verifySleep, |
| 382 | attempts=main.verifyAttempts ) |
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 not intentVerify: |
| 385 | main.log.error( "Failed to install intents" ) |
GlennRC | d0e5ed2 | 2015-09-03 11:54:27 -0700 | [diff] [blame] | 386 | break |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 387 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 388 | if main.reroute: |
| 389 | main.step( "Reroute" ) |
| 390 | # tear down a link |
| 391 | main.log.info("Tearing down link") |
| 392 | if main.switchType == "of:": |
| 393 | downlink = main.Mininet1.link( END1 = "s1", END2 = "s3", OPTION = "down" ) |
| 394 | else: |
| 395 | downlink = main.ONOScli1.link( main.ingress, main.egress, "down") |
| 396 | |
| 397 | if downlink: |
| 398 | main.log.info( "Successfully tear down link" ) |
| 399 | else: |
| 400 | main.log.warn( "Failed to tear down link" ) |
| 401 | |
| 402 | time.sleep(main.rerouteSleep) |
| 403 | |
| 404 | # Verifying intents |
| 405 | main.step( "Checking intents and flows" ) |
| 406 | intentVerify = utilities.retry( main.ONOScli1.checkIntentSummary, |
| 407 | main.FALSE, |
| 408 | [main.timeout], |
| 409 | sleep=main.verifySleep, |
| 410 | attempts=main.verifyAttempts ) |
| 411 | # Verfying flows |
| 412 | flowVerify = utilities.retry( main.ONOScli1.checkFlowsState, |
| 413 | main.FALSE, |
| 414 | [False, main.timeout], |
| 415 | sleep = main.verifySleep, |
| 416 | attempts = main.verifyAttempts ) |
| 417 | |
| 418 | if not intentVerify: |
| 419 | main.log.error( "Failed to install intents" ) |
| 420 | # Bring link back up |
| 421 | main.log.info("Bringing link back up") |
| 422 | if main.switchType == "of:": |
| 423 | uplink = main.Mininet1.link( END1 = "s1", END2 = "s3", OPTION = "up" ) |
| 424 | else: |
| 425 | uplink = main.ONOScli1.link( main.ingress, main.egress, "up" ) |
| 426 | |
| 427 | if uplink: |
| 428 | main.log.info( "Successfully bring link back up" ) |
| 429 | else: |
| 430 | main.log.warn( "Failed to bring link back up" ) |
| 431 | |
| 432 | time.sleep(main.rerouteSleep) |
| 433 | |
| 434 | # Verifying intents |
| 435 | main.step( "Checking intents and flows" ) |
| 436 | intentVerify = utilities.retry( main.ONOScli1.checkIntentSummary, |
| 437 | main.FALSE, |
| 438 | [main.timeout], |
| 439 | sleep=main.verifySleep, |
| 440 | attempts=main.verifyAttempts ) |
| 441 | # Verfying flows |
| 442 | flowVerify = utilities.retry( main.ONOScli1.checkFlowsState, |
| 443 | main.FALSE, |
| 444 | [False, main.timeout], |
| 445 | sleep = main.verifySleep, |
| 446 | attempts = main.verifyAttempts ) |
| 447 | |
| 448 | if not intentVerify: |
| 449 | main.log.error( "Failed to install intents" ) |
| 450 | |
| 451 | rerouteResult = downlink and uplink |
| 452 | utilities.assert_equals( expect = main.TRUE, |
| 453 | actual = rerouteResult, |
| 454 | onpass = "Successfully reroute", |
| 455 | onfail = "Failed to reroute" ) |
| 456 | |
| 457 | utilities.assert_equals( expect = main.TRUE, |
| 458 | actual = intentVerify, |
| 459 | onpass = "Successfully pushed and verified intents", |
| 460 | onfail = "Failed to push and verify intents" ) |
YPZhang | b5d3f83 | 2016-01-23 22:54:26 -0800 | [diff] [blame] | 461 | currIntents = main.ONOScli1.getTotalIntentsNum() |
| 462 | currFlows = main.ONOScli1.getTotalFlowsNum() |
GlennRC | ec6c761 | 2015-08-31 14:52:10 -0700 | [diff] [blame] | 463 | |
GlennRC | 58ea254 | 2015-09-02 14:23:34 -0700 | [diff] [blame] | 464 | main.log.info("Writing results to DB file") |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 465 | with open(main.dbFileName, "a") as dbFile: |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 466 | temp = "," + str(currIntents) |
| 467 | temp += "," + str(currFlows) |
YPZhang | b5d3f83 | 2016-01-23 22:54:26 -0800 | [diff] [blame] | 468 | temp += ",0" |
| 469 | temp += ",0\n" |
GlennRC | 4c74543 | 2015-09-17 17:09:13 -0700 | [diff] [blame] | 470 | dbFile.write(temp) |
GlennRC | 14d54f7 | 2015-09-03 10:51:37 -0700 | [diff] [blame] | 471 | |
GlennRC | ed77124 | 2016-01-13 17:02:47 -0800 | [diff] [blame] | 472 | if main.switchType == "of:": |
| 473 | main.step( "Stopping mininet" ) |
| 474 | stepResult = main.Mininet1.stopNet() |
| 475 | utilities.assert_equals( expect = main.TRUE, |
| 476 | actual = stepResult, |
| 477 | oppass = "Successfully stop Mininet", |
| 478 | opfail = "Failed stop Mininet" ) |
| 479 | |
GlennRC | b3202c5 | 2015-08-24 14:43:30 -0700 | [diff] [blame] | 480 | |
| 481 | def CASE100( self, main ): |
| 482 | ''' |
| 483 | Report errors/warnings/exceptions |
| 484 | ''' |
| 485 | main.log.info("Error report: \n") |
| 486 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 487 | [ "INFO", |
| 488 | "FOLLOWER", |
| 489 | "WARN", |
| 490 | "flow", |
| 491 | "ERROR", |
| 492 | "Except" ], |
| 493 | "s" ) |