Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2016 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 21 | import sys |
| 22 | import json |
| 23 | import time |
| 24 | import os |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 25 | """ |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 26 | SCPFscalingMaxIntents |
| 27 | Push test Intents to onos |
| 28 | CASE10: set up Null Provider |
| 29 | CASE11: set up Open Flows |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 30 | Check flows number, if flows number is not as except, finished this test iteration |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 31 | Scale up when reach the Limited |
| 32 | Start from 1 nodes, 8 devices. Then Scale up to 3,5,7 nodes |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 33 | """ |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 34 | class SCPFscalingMaxIntents: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 35 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 36 | def __init__( self ): |
| 37 | self.default = '' |
| 38 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 39 | def CASE0( self, main ): |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 40 | import sys |
| 41 | import json |
| 42 | import time |
| 43 | import os |
| 44 | import imp |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 45 | try: |
| 46 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 47 | main.testSetUp = ONOSSetup() |
| 48 | except ImportError: |
| 49 | main.log.error( "ONOSSetup not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 50 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 51 | main.testSetUp.envSetupDescription() |
| 52 | stepResult = main.FALSE |
| 53 | try: |
| 54 | # Test variables |
| 55 | main.dependencyPath = main.testOnDirectory + \ |
| 56 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 57 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 58 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 59 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 60 | main.scale = ( main.params[ 'SCALE' ] ).split( "," ) |
| 61 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 62 | main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] ) |
| 63 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 64 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 65 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 66 | main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 67 | main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ] |
| 68 | main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ] |
| 69 | main.linkCollectionIntentCfg = main.params[ 'CFG' ][ 'linkCollectionIntent' ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 70 | main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] ) |
| 71 | main.ingress = main.params[ 'LINK' ][ 'ingress' ] |
| 72 | main.egress = main.params[ 'LINK' ][ 'egress' ] |
| 73 | main.reroute = main.params[ 'reroute' ] |
| 74 | main.flowObj = main.params[ 'TEST' ][ 'flowObj' ] |
| 75 | if main.flowObj == "True": |
| 76 | main.flowObj = True |
| 77 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ] |
| 78 | else: |
| 79 | main.flowObj = False |
| 80 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ] |
| 81 | main.threadID = 0 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 82 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 83 | if main.reroute == "True": |
| 84 | main.reroute = True |
| 85 | else: |
| 86 | main.reroute = False |
| 87 | main.setupSkipped = False |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 88 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 89 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
Devin Lim | 87e12c4 | 2017-07-20 13:53:04 -0700 | [diff] [blame] | 90 | main.nic = main.params[ 'DATABASE' ][ 'nic' ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 91 | node = main.params[ 'DATABASE' ][ 'node' ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 92 | stepResult = main.testSetUp.envSetup() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 93 | main.log.info( "Cresting DB file" ) |
| 94 | with open( main.dbFileName, "w+" ) as dbFile: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 95 | dbFile.write( "" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 96 | except Exception as e: |
| 97 | main.testSetUp.envSetupException( e ) |
| 98 | main.testSetUp.evnSetupConclusion( stepResult ) |
| 99 | main.commit = main.commit.split( " " )[ 1 ] |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 100 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 101 | def CASE1( self ): |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 102 | copyResult = main.ONOSbench.copyMininetFile( main.topology, |
| 103 | main.dependencyPath, |
| 104 | main.Mininet1.user_name, |
| 105 | main.Mininet1.ip_address ) |
| 106 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 107 | def CASE2( self, main ): |
| 108 | """ |
| 109 | - Uninstall ONOS cluster |
| 110 | - Verify ONOS start up |
| 111 | - Install ONOS cluster |
| 112 | - Connect to cli |
| 113 | """ |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame^] | 114 | main.testSetUp.ONOSSetUp( main.Cluster, True, |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 115 | killRemoveMax=False ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 116 | |
| 117 | def CASE10( self, main ): |
| 118 | """ |
| 119 | Setting up null-provider |
| 120 | """ |
| 121 | import json |
| 122 | # Activate apps |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 123 | main.step( "Activating null-provider" ) |
| 124 | appStatus = utilities.retry( main.Cluster.active( 0 ).CLI.activateApp, |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 125 | main.FALSE, |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 126 | [ 'org.onosproject.null' ], |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 127 | sleep=main.verifySleep, |
| 128 | attempts=main.verifyAttempts ) |
| 129 | utilities.assert_equals( expect=main.TRUE, |
| 130 | actual=appStatus, |
| 131 | onpass="Successfully activated null-provider", |
| 132 | onfail="Failed activate null-provider" ) |
| 133 | |
| 134 | # Setup the null-provider |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 135 | main.step( "Configuring null-provider" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 136 | cfgStatus = utilities.retry( main.ONOSbench.onosCfgSet, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 137 | main.FALSE, |
| 138 | [ main.Cluster.active( 0 ).ipAddress, |
| 139 | main.nullProviderCfg, 'deviceCount 8' ], |
| 140 | sleep=main.verifySleep, |
| 141 | attempts=main.verifyAttempts ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 142 | cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet, |
| 143 | main.FALSE, |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 144 | [ main.Cluster.active( 0 ).ipAddress, |
| 145 | main.nullProviderCfg, 'topoShape reroute' ], |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 146 | sleep=main.verifySleep, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 147 | attempts=main.verifyAttempts ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 148 | |
| 149 | cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet, |
| 150 | main.FALSE, |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 151 | [ main.Cluster.active( 0 ).ipAddress, |
| 152 | main.nullProviderCfg, 'enabled true' ], |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 153 | sleep=main.verifySleep, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 154 | attempts=main.verifyAttempts ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 155 | |
| 156 | utilities.assert_equals( expect=main.TRUE, |
| 157 | actual=cfgStatus, |
| 158 | onpass="Successfully configured null-provider", |
| 159 | onfail="Failed to configure null-provider" ) |
| 160 | |
| 161 | # give onos some time to settle |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 162 | time.sleep( main.startUpSleep ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 163 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 164 | main.log.info( "Setting default flows to zero" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 165 | main.defaultFlows = 0 |
| 166 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 167 | main.step( "Check status of null-provider setup" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 168 | caseResult = appStatus and cfgStatus |
| 169 | utilities.assert_equals( expect=main.TRUE, |
| 170 | actual=caseResult, |
| 171 | onpass="Setting up null-provider was successfull", |
| 172 | onfail="Failed to setup null-provider" ) |
| 173 | |
| 174 | # This tells the following cases if we are using the null-provider or ovs |
| 175 | main.switchType = "null:" |
| 176 | |
| 177 | # If the null-provider setup was unsuccessfull, then there is no point to |
| 178 | # run the subsequent cases |
| 179 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 180 | time.sleep( main.startUpSleep ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 181 | main.step( "Balancing Masters" ) |
| 182 | |
| 183 | stepResult = main.FALSE |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 184 | stepResult = utilities.retry( main.Cluster.active( 0 ).CLI.balanceMasters, |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 185 | main.FALSE, |
| 186 | [], |
| 187 | sleep=3, |
| 188 | attempts=3 ) |
| 189 | |
| 190 | utilities.assert_equals( expect=main.TRUE, |
| 191 | actual=stepResult, |
| 192 | onpass="Balance masters was successfull", |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 193 | onfail="Failed to balance masters" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 194 | |
| 195 | time.sleep( 5 ) |
| 196 | if not caseResult: |
| 197 | main.setupSkipped = True |
| 198 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 199 | def CASE11( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 200 | """ |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 201 | Setting up mininet |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 202 | """ |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 203 | import json |
| 204 | import time |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 205 | devices = [] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 206 | devices = main.Cluster.active( 0 ).CLI.getAllDevicesId() |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 207 | for d in devices: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 208 | main.Cluster.active( 0 ).CLI.deviceRemove( d ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 209 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 210 | time.sleep( main.startUpSleep ) |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 211 | if main.flowObj: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 212 | main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 213 | "useFlowObjectives", value="true" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 214 | main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 215 | "defaultFlowObjectiveCompiler", |
| 216 | value=main.linkCollectionIntentCfg ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 217 | main.step( 'Starting mininet topology' ) |
| 218 | mnStatus = main.Mininet1.startNet( topoFile='~/mininet/custom/rerouteTopo.py' ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 219 | utilities.assert_equals( expect=main.TRUE, |
| 220 | actual=mnStatus, |
| 221 | onpass="Successfully started Mininet", |
| 222 | onfail="Failed to activate Mininet" ) |
| 223 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 224 | main.step( "Assinging masters to switches" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 225 | switches = main.Mininet1.getSwitches() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 226 | swStatus = main.Mininet1.assignSwController( sw=switches.keys(), ip=main.Cluster.getIps() ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 227 | utilities.assert_equals( expect=main.TRUE, |
| 228 | actual=swStatus, |
| 229 | onpass="Successfully assigned switches to masters", |
| 230 | onfail="Failed assign switches to masters" ) |
| 231 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 232 | time.sleep( main.startUpSleep ) |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 233 | # Balancing Masters |
| 234 | main.step( "Balancing Masters" ) |
| 235 | stepResult = main.FALSE |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 236 | stepResult = utilities.retry( main.Cluster.active( 0 ).CLI.balanceMasters, |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 237 | main.FALSE, |
| 238 | [], |
| 239 | sleep=3, |
| 240 | attempts=3 ) |
| 241 | |
| 242 | utilities.assert_equals( expect=main.TRUE, |
| 243 | actual=stepResult, |
| 244 | onpass="Balance masters was successfull", |
| 245 | onfail="Failed to balance masters" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 246 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 247 | main.log.info( "Getting default flows" ) |
| 248 | jsonSum = json.loads( main.Cluster.active( 0 ).CLI.summary() ) |
| 249 | main.defaultFlows = jsonSum[ "flows" ] |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 250 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 251 | main.step( "Check status of Mininet setup" ) |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 252 | caseResult = mnStatus and swStatus |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 253 | utilities.assert_equals( expect=main.TRUE, |
| 254 | actual=caseResult, |
| 255 | onpass="Successfully setup Mininet", |
| 256 | onfail="Failed setup Mininet" ) |
| 257 | |
| 258 | # This tells the following cases if we are using the null-provider or ovs |
| 259 | main.switchType = "of:" |
| 260 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 261 | time.sleep( main.startUpSleep ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 262 | main.step( "Balancing Masters" ) |
| 263 | |
| 264 | stepResult = main.FALSE |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 265 | stepResult = utilities.retry( main.Cluster.active( 0 ).CLI.balanceMasters, |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 266 | main.FALSE, |
| 267 | [], |
| 268 | sleep=3, |
| 269 | attempts=3 ) |
| 270 | |
| 271 | utilities.assert_equals( expect=main.TRUE, |
| 272 | actual=stepResult, |
| 273 | onpass="Balance masters was successfull", |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 274 | onfail="Failed to balance masters" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 275 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 276 | time.sleep( 5 ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 277 | if not caseResult: |
| 278 | main.setupSkipped = True |
| 279 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 280 | def CASE20( self, main ): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 281 | try: |
| 282 | from tests.dependencies.utils import Utils |
| 283 | except ImportError: |
| 284 | main.log.error( "Utils not found exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 285 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 286 | try: |
| 287 | main.Utils |
| 288 | except ( NameError, AttributeError ): |
| 289 | main.Utils = Utils() |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 290 | if main.reroute: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 291 | main.minIntents = int( main.params[ 'NULL' ][ 'REROUTE' ][ 'min_intents' ] ) |
| 292 | main.maxIntents = int( main.params[ 'NULL' ][ 'REROUTE' ][ 'max_intents' ] ) |
| 293 | main.checkInterval = int( main.params[ 'NULL' ][ 'REROUTE' ][ 'check_interval' ] ) |
| 294 | main.batchSize = int( main.params[ 'NULL' ][ 'REROUTE' ][ 'batch_size' ] ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 295 | else: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 296 | main.minIntents = int( main.params[ 'NULL' ][ 'PUSH' ][ 'min_intents' ] ) |
| 297 | main.maxIntents = int( main.params[ 'NULL' ][ 'PUSH' ][ 'max_intents' ] ) |
| 298 | main.checkInterval = int( main.params[ 'NULL' ][ 'PUSH' ][ 'check_interval' ] ) |
| 299 | main.batchSize = int( main.params[ 'NULL' ][ 'PUSH' ][ 'batch_size' ] ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 300 | |
| 301 | # check if the case needs to be skipped |
| 302 | if main.setupSkipped: |
| 303 | main.setupSkipped = False |
| 304 | main.skipCase() |
| 305 | |
| 306 | # the index where the next intents will be installed |
| 307 | offfset = 0 |
| 308 | # keeps track of how many intents have been installed |
| 309 | currIntents = 0 |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 310 | # keeps track of how many flows have been installed, set to 0 at start |
| 311 | currFlows = 0 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 312 | # limit for the number of intents that can be installed |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 313 | main.batchSize = int( int( main.batchSize ) / main.Cluster.numCtrls ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 314 | limit = main.maxIntents / main.batchSize |
| 315 | # total intents installed |
| 316 | totalIntents = 0 |
| 317 | |
| 318 | intentsState = None |
| 319 | |
| 320 | offtmp = 0 |
| 321 | main.step( "Pushing intents" ) |
| 322 | stepResult = main.TRUE |
YPZhang | 47779c2 | 2016-03-07 13:03:07 -0800 | [diff] [blame] | 323 | # temp variable to contain the number of flows |
| 324 | flowsNum = 0 |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 325 | if main.Cluster.numCtrls > 1: |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 326 | # if more than one onos nodes, we should check more frequently |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 327 | main.checkInterval = main.checkInterval / 4 |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 328 | |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 329 | # make sure the checkInterval divisible batchSize |
| 330 | main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 331 | flowTemp = 0 |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 332 | intentVerifyTemp = 0 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 333 | totalFlows = 0 |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 334 | for i in range( limit ): |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 335 | |
| 336 | # Threads pool |
| 337 | pool = [] |
| 338 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 339 | for j in range( main.Cluster.numCtrls ): |
| 340 | if main.Cluster.numCtrls > 1: |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 341 | time.sleep( 1 ) |
| 342 | offtmp = offfset + main.maxIntents * j |
| 343 | # Push intents by using threads |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 344 | t = main.Thread( target=main.Cluster.active( j ).CLI.pushTestIntents, |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 345 | threadID=main.threadID, |
| 346 | name="Push-Test-Intents", |
| 347 | args=[ main.switchType + main.ingress, |
| 348 | main.switchType + main.egress, |
| 349 | main.batchSize ], |
| 350 | kwargs={ "offset": offtmp, |
| 351 | "options": "-i", |
| 352 | "timeout": main.timeout, |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 353 | "background": False, |
| 354 | "noExit": True } ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 355 | pool.append( t ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 356 | t.start() |
| 357 | main.threadID = main.threadID + 1 |
| 358 | for t in pool: |
| 359 | t.join() |
| 360 | stepResult = stepResult and t.result |
| 361 | offfset = offfset + main.batchSize |
| 362 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 363 | totalIntents = main.batchSize * main.Cluster.numCtrls + totalIntents |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 364 | if totalIntents >= main.minIntents and totalIntents % main.checkInterval == 0: |
| 365 | # if reach to minimum number and check interval, verify Intetns and flows |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 366 | time.sleep( main.verifySleep * main.Cluster.numCtrls ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 367 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 368 | main.log.info( "Verify Intents states" ) |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 369 | # k is a control variable for verify retry attempts |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 370 | k = 1 |
YPZhang | 3097ba9 | 2016-02-16 17:32:32 -0800 | [diff] [blame] | 371 | while k <= main.verifyAttempts: |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 372 | # while loop for check intents by using CLI driver |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 373 | time.sleep( 5 ) |
| 374 | intentsState = main.Cluster.active( 0 ).CLI.checkIntentSummary( timeout=600, noExit=True ) |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 375 | if intentsState: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 376 | verifyTotalIntents = main.Cluster.active( 0 ).CLI.getTotalIntentsNum( timeout=600, noExit=True ) |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 377 | if intentVerifyTemp < verifyTotalIntents: |
| 378 | intentVerifyTemp = verifyTotalIntents |
YPZhang | ebf9eb5 | 2016-05-12 15:20:24 -0700 | [diff] [blame] | 379 | else: |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 380 | verifyTotalIntents = intentVerifyTemp |
YPZhang | 6e758fb | 2016-07-26 09:20:55 -0700 | [diff] [blame] | 381 | intentsState = False |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 382 | main.log.info( "Total Installed Intents: {}".format( verifyTotalIntents ) ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 383 | break |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 384 | k = k + 1 |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 385 | |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 386 | k = 1 |
| 387 | flowVerify = True |
| 388 | while k <= main.verifyAttempts: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 389 | time.sleep( 5 ) |
| 390 | totalFlows = main.Cluster.active( 0 ).CLI.getTotalFlowsNum( timeout=600, noExit=True ) |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 391 | expectFlows = totalIntents * 7 + main.defaultFlows |
| 392 | if totalFlows == expectFlows: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 393 | main.log.info( "Total Flows Added: {}".format( totalFlows ) ) |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 394 | break |
| 395 | else: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 396 | main.log.info( "Some Flows are not added, retry..." ) |
| 397 | main.log.info( "Total Flows Added: {} Expect Flows: {}".format( totalFlows, expectFlows ) ) |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 398 | flowVerify = False |
YPZhang | ac53ebf | 2016-05-13 16:26:19 -0700 | [diff] [blame] | 399 | |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 400 | k += 1 |
| 401 | if flowTemp < totalFlows: |
| 402 | flowTemp = totalFlows |
| 403 | else: |
| 404 | totalFlows = flowTemp |
| 405 | |
| 406 | if not intentsState or not flowVerify: |
YPZhang | a4acbb8 | 2016-03-02 17:28:25 -0800 | [diff] [blame] | 407 | # If some intents are not installed, grep the previous flows list, and finished this test case |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 408 | main.log.warn( "Intents or flows are not installed" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 409 | verifyTotalIntents = main.Cluster.active( 0 ).CLI.getTotalIntentsNum( timeout=600, noExit=True ) |
YPZhang | 14a4aa9 | 2016-07-15 13:37:15 -0700 | [diff] [blame] | 410 | if intentVerifyTemp < verifyTotalIntents: |
| 411 | intentVerifyTemp = verifyTotalIntents |
| 412 | else: |
| 413 | verifyTotalIntents = intentVerifyTemp |
| 414 | if flowTemp < totalFlows: |
| 415 | flowTemp = totalFlows |
| 416 | else: |
| 417 | totalFlows = flowTemp |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 418 | main.log.info( "Total Intents: {}".format( verifyTotalIntents ) ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 419 | break |
YPZhang | e96a306 | 2016-05-12 16:18:35 -0700 | [diff] [blame] | 420 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 421 | utilities.assert_equals( expect=main.TRUE, |
| 422 | actual=intentsState, |
| 423 | onpass="Successfully pushed and verified intents", |
| 424 | onfail="Failed to push and verify intents" ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 425 | |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 426 | main.log.info( "Total Intents Installed before crash: {}".format( totalIntents ) ) |
| 427 | main.log.info( "Total Flows ADDED before crash: {}".format( totalFlows ) ) |
| 428 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 429 | main.Utils.mininetCleanup( main.Mininet1 ) |
| 430 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 431 | main.log.info( "Writing results to DS file" ) |
| 432 | with open( main.dbFileName, "a" ) as dbFile: |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 433 | # Scale number |
Devin Lim | 87e12c4 | 2017-07-20 13:53:04 -0700 | [diff] [blame] | 434 | temp = "'" + main.commit + "'," |
| 435 | temp += "'" + main.nic + "'," |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 436 | temp += str( main.Cluster.numCtrls ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 437 | temp += ",'" + "baremetal1" + "'" |
| 438 | # how many intents we installed before crash |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 439 | temp += "," + str( verifyTotalIntents ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 440 | # how many flows we installed before crash |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 441 | temp += "," + str( totalFlows ) |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 442 | # other columns in database, but we didn't use in this test |
Devin Lim | a16d894 | 2017-11-15 16:48:37 -0800 | [diff] [blame] | 443 | temp += "," + "0,0,0,0,0,0,0,0" |
YPZhang | cb86c5b | 2016-01-27 17:38:12 -0800 | [diff] [blame] | 444 | temp += "\n" |
| 445 | dbFile.write( temp ) |