YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2015 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 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 21 | """ |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 22 | SCPFintentInstallWithdrawLat: |
| 23 | - Test the latency of intent installed and withdrawn |
| 24 | - Use Push-test-intents command to push intents |
| 25 | - Use Null provider with 7 devices and linear topology |
| 26 | - Always push intents between 1/6 and 7/5 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 27 | - The batch size is defined in parm file. ( default 1,100,1000 ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 28 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 29 | yunpeng@onlab.us |
| 30 | """ |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 31 | class SCPFintentInstallWithdrawLat: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 32 | |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 33 | def __init__( self ): |
| 34 | self.default = '' |
| 35 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 36 | def CASE0( self, main ): |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 37 | import imp |
| 38 | import os |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 39 | """ |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 40 | - GIT |
| 41 | - BUILDING ONOS |
| 42 | Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| 43 | This step is usually skipped. Because in a Jenkins driven automated |
| 44 | test env. We want Jenkins jobs to pull&build for flexibility to handle |
| 45 | different versions of ONOS. |
| 46 | - Construct tests variables |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 47 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 48 | try: |
| 49 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 50 | main.testSetUp = ONOSSetup() |
| 51 | except ImportError: |
| 52 | main.log.error( "ONOSSetup not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 53 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 54 | main.testSetUp.envSetupDescription() |
| 55 | stepResult = main.FALSE |
| 56 | try: |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 57 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 58 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 59 | main.BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 60 | main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 61 | main.MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 62 | main.maxNodes = int( main.params[ 'max' ] ) |
| 63 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 64 | main.scale = ( main.params[ 'SCALE' ] ).split( "," ) |
| 65 | main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] ) |
| 66 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 67 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 68 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 69 | main.intentManagerCfg = main.params[ 'CFG' ][ 'intentManager' ] |
| 70 | main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ] |
| 71 | main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 72 | main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] ) |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 73 | main.cfgRetry = int( main.params[ 'ATTEMPTS' ][ 'cfg' ] ) |
| 74 | main.maxInvalidRun = int( main.params[ 'ATTEMPTS' ][ 'maxInvalidRun' ] ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 75 | main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] ) |
| 76 | main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] ) |
| 77 | main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," ) |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 78 | main.deviceCount = int( main.params[ 'TEST' ][ 'deviceCount' ] ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 79 | main.ingress = main.params[ 'TEST' ][ 'ingress' ] |
| 80 | main.egress = main.params[ 'TEST' ][ 'egress' ] |
| 81 | main.debug = main.params[ 'TEST' ][ 'debug' ] |
| 82 | main.flowObj = main.params[ 'TEST' ][ 'flowObj' ] |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 83 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 84 | if main.flowObj == "True": |
| 85 | main.flowObj = True |
| 86 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ] |
| 87 | else: |
| 88 | main.flowObj = False |
| 89 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ] |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 90 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 91 | for i in range( 0, len( main.intentsList ) ): |
| 92 | main.intentsList[ i ] = int( main.intentsList[ i ] ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 93 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 94 | stepResult = main.testSetUp.envSetup() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 95 | # Create DataBase file |
| 96 | main.log.info( "Create Database file " + main.dbFileName ) |
| 97 | resultsDB = open( main.dbFileName, "w+" ) |
| 98 | resultsDB.close() |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 99 | file1 = main.params[ "DEPENDENCY" ][ "FILE1" ] |
| 100 | main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ] |
| 101 | main.intentFuncs = imp.load_source( file1, main.dependencyPath + file1 + ".py" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 102 | except Exception as e: |
| 103 | main.testSetUp.envSetupException( e ) |
| 104 | main.testSetUp.evnSetupConclusion( stepResult ) |
| 105 | main.commit = main.commit.split( " " )[ 1 ] |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 106 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 107 | def CASE1( self, main ): |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 108 | # Clean up test environment and set up |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 109 | import time |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 110 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 111 | main.maxNumBatch = 0 |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 112 | main.testSetUp.ONOSSetUp( main.Cluster, True, |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 113 | cellName=main.cellName, killRemoveMax=False ) |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 114 | configRetry = 0 |
| 115 | main.cfgCheck = False |
| 116 | while configRetry < main.cfgRetry: |
| 117 | # configure apps |
| 118 | stepResult = main.TRUE |
| 119 | stepResult = stepResult and \ |
| 120 | main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, |
| 121 | "deviceCount", value=main.deviceCount ) |
| 122 | stepResult = stepResult and \ |
| 123 | main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, |
| 124 | "topoShape", value="linear" ) |
| 125 | stepResult = stepResult and \ |
| 126 | main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, |
| 127 | "enabled", value="true" ) |
| 128 | stepResult = stepResult and \ |
| 129 | main.Cluster.active( 0 ).CLI.setCfg( main.intentManagerCfg, |
| 130 | "skipReleaseResourcesOnWithdrawal", |
| 131 | value="true" ) |
| 132 | if main.flowObj: |
| 133 | stepResult = stepResult and \ |
| 134 | main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg, |
| 135 | "useFlowObjectives", value="true" ) |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 136 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 137 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 138 | # balanceMasters |
| 139 | stepResult = stepResult and \ |
| 140 | main.Cluster.active( 0 ).CLI.balanceMasters() |
| 141 | if stepResult: |
| 142 | main.cfgCheck = True |
| 143 | break |
| 144 | configRetry += 1 |
| 145 | time.sleep( main.verifySleep ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 146 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 147 | time.sleep( main.startUpSleep ) |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 148 | if not main.cfgCheck: |
| 149 | main.log.error( "Setting configuration to the ONOS failed. Skip the rest of the steps" ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 150 | |
| 151 | def CASE2( self, main ): |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 152 | import time |
| 153 | import numpy |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 154 | import json |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 155 | testResult = main.TRUE |
| 156 | main.case( "Installing/Withdrawing intents start" ) |
| 157 | main.step( "Checking starts" ) |
| 158 | if main.cfgCheck: |
| 159 | print( main.intentsList ) |
| 160 | for batchSize in main.intentsList: |
| 161 | main.log.report( "Intent Batch size: {}".format( batchSize ) ) |
| 162 | main.batchSize = batchSize |
| 163 | main.installLatList = [] |
| 164 | main.withdrawLatList = [] |
| 165 | main.validrun = 0 |
| 166 | main.invalidrun = 0 |
| 167 | # we use two variables to control the iteration |
| 168 | while main.validrun <= main.warmUp + main.sampleSize and main.invalidrun <= main.maxInvalidRun: |
| 169 | if main.validrun >= main.warmUp: |
| 170 | main.log.info( "================================================" ) |
| 171 | main.log.info( "Starting test iteration " + str( main.validrun - main.warmUp ) ) |
| 172 | main.log.info( "Total test iteration: " + str( main.invalidrun + main.validrun ) ) |
| 173 | main.log.info( "================================================" ) |
| 174 | else: |
| 175 | main.log.info( "====================Warm Up=====================" ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 176 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 177 | # push intents |
| 178 | installResult = main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress, |
| 179 | main.egress, |
| 180 | batchSize, |
| 181 | offset=1, |
| 182 | options="-i", |
| 183 | timeout=main.timeout, |
| 184 | getResponse=True ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 185 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 186 | time.sleep( 2 ) |
| 187 | main.intentFuncs.sanityCheck( main, |
| 188 | ( main.deviceCount - 1 ) * 2, |
| 189 | batchSize * main.deviceCount, |
| 190 | main.batchSize ) |
| 191 | if not main.verify: |
| 192 | main.log.warn( "Sanity check failed, skipping this iteration..." ) |
| 193 | continue |
| 194 | if isinstance( installResult, str ): |
| 195 | if "Failure" in installResult: |
| 196 | main.log.error( "Install Intents failure, ignore this iteration." ) |
| 197 | if main.validrun < main.warmUp: |
| 198 | main.validrun += 1 |
| 199 | continue |
| 200 | else: |
| 201 | main.invalidrun += 1 |
| 202 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 203 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 204 | try: |
| 205 | latency = int( installResult.split()[ 5 ] ) |
| 206 | main.log.info( installResult ) |
| 207 | except: |
| 208 | main.log.error( "Failed to get latency, ignore this iteration." ) |
| 209 | main.log.error( "Response from ONOS:" ) |
| 210 | print( installResult ) |
| 211 | if main.validrun < main.warmUp: |
| 212 | main.validrun += 1 |
| 213 | continue |
| 214 | else: |
| 215 | main.invalidrun += 1 |
| 216 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 217 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 218 | if main.validrun >= main.warmUp: |
| 219 | main.installLatList.append( latency ) |
| 220 | else: |
| 221 | main.invalidrun += 1 |
| 222 | continue |
| 223 | # Withdraw Intents |
| 224 | withdrawResult = main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress, |
| 225 | main.egress, |
| 226 | batchSize, |
| 227 | offset=1, |
| 228 | options="-w", |
| 229 | timeout=main.timeout, |
| 230 | getResponse=True ) |
| 231 | time.sleep( 5 ) |
| 232 | main.Cluster.active( 0 ).CLI.purgeWithdrawnIntents() |
| 233 | main.intentFuncs.sanityCheck( main, ( main.deviceCount - 1 ) * 2, 0, 0 ) |
| 234 | if not main.verify: |
| 235 | main.log.warn( "Sanity check failed, skipping this iteration..." ) |
| 236 | continue |
| 237 | if isinstance( withdrawResult, str ): |
| 238 | if "Failure" in withdrawResult: |
| 239 | main.log.error( "withdraw Intents failure, ignore this iteration." ) |
| 240 | if main.validrun < main.warmUp: |
| 241 | main.validrun += 1 |
| 242 | continue |
| 243 | else: |
| 244 | main.invalidrun += 1 |
| 245 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 246 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 247 | try: |
| 248 | latency = int( withdrawResult.split()[ 5 ] ) |
| 249 | main.log.info( withdrawResult ) |
| 250 | except: |
| 251 | main.log.error( "Failed to get latency, ignore this iteration." ) |
| 252 | main.log.error( "Response from ONOS:" ) |
| 253 | print( withdrawResult ) |
| 254 | if main.validrun < main.warmUp: |
| 255 | main.validrun += 1 |
| 256 | continue |
| 257 | else: |
| 258 | main.invalidrun += 1 |
| 259 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 260 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 261 | if main.validrun >= main.warmUp: |
| 262 | main.withdrawLatList.append( latency ) |
| 263 | else: |
| 264 | main.invalidrun += 1 |
| 265 | continue |
| 266 | main.validrun += 1 |
| 267 | result = ( main.TRUE if main.invalidrun <= main.maxInvalidRun else main.FALSE ) |
| 268 | installave = numpy.average( main.installLatList ) if main.installLatList and result else 0 |
| 269 | installstd = numpy.std( main.installLatList ) if main.installLatList and result else 0 |
| 270 | withdrawave = numpy.average( main.withdrawLatList ) if main.withdrawLatList and result else 0 |
| 271 | withdrawstd = numpy.std( main.withdrawLatList ) if main.withdrawLatList and result else 0 |
| 272 | testResult = testResult and result |
| 273 | # log report |
| 274 | main.log.report( "----------------------------------------------------" ) |
| 275 | main.log.report( "Scale: " + str( main.Cluster.numCtrls ) ) |
| 276 | main.log.report( "Intent batch: " + str( batchSize ) ) |
| 277 | main.log.report( "Install average: {} std: {}".format( installave, installstd ) ) |
| 278 | main.log.report( "Withdraw average: {} std: {}".format( withdrawave, withdrawstd ) ) |
You Wang | 012300d | 2019-02-21 17:55:39 -0800 | [diff] [blame^] | 279 | |
| 280 | # Check test results |
| 281 | index = len( main.intentsList ) * ( main.cycle - 1 ) + main.intentsList.index( batchSize ) |
| 282 | # Check installation results |
| 283 | if main.flowObj: |
| 284 | threshold = float( main.params[ 'ALARM' ][ 'maxInstallLatFlowObj' ].split( ',' )[ index ]) |
| 285 | else: |
| 286 | threshold = float( main.params[ 'ALARM' ][ 'maxInstallLat' ].split( ',' )[ index ]) |
| 287 | if installave > threshold: |
| 288 | main.log.alarm( "{}-node install avg: {} ms > {} ms".format( main.Cluster.numCtrls, |
| 289 | installave, threshold ) ) |
| 290 | # Check withdrawal results |
| 291 | if main.flowObj: |
| 292 | threshold = float( main.params[ 'ALARM' ][ 'maxWithdrawLatFlowObj' ].split( ',' )[ index ]) |
| 293 | else: |
| 294 | threshold = float( main.params[ 'ALARM' ][ 'maxWithdrawLat' ].split( ',' )[ index ]) |
| 295 | if withdrawave > threshold: |
| 296 | main.log.alarm( "{}-node withdraw avg: {} ms > {} ms".format( main.Cluster.numCtrls, |
| 297 | withdrawave, threshold ) ) |
| 298 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 299 | # write result to database file |
| 300 | if not ( numpy.isnan( installave ) or numpy.isnan( installstd ) or |
| 301 | numpy.isnan( withdrawstd ) or numpy.isnan( withdrawave ) ): |
| 302 | databaseString = "'" + main.commit + "'," |
| 303 | databaseString += str( main.Cluster.numCtrls ) + "," |
| 304 | databaseString += str( batchSize ) + "," |
| 305 | databaseString += str( installave ) + "," |
| 306 | databaseString += str( installstd ) + "," |
| 307 | databaseString += str( withdrawave ) + "," |
| 308 | databaseString += str( withdrawstd ) + "\n" |
| 309 | resultsDB = open( main.dbFileName, "a" ) |
| 310 | resultsDB.write( databaseString ) |
| 311 | resultsDB.close() |
| 312 | else: |
| 313 | testResult = main.FALSE |
| 314 | utilities.assert_equals( expect=main.TRUE, |
| 315 | actual=testResult, |
| 316 | onpass="Installing and withdrawing intents properly", |
| 317 | onfail="There was something wrong installing and withdrawing intents" ) |