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