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 ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 37 | """ |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 38 | - GIT |
| 39 | - BUILDING ONOS |
| 40 | Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| 41 | This step is usually skipped. Because in a Jenkins driven automated |
| 42 | test env. We want Jenkins jobs to pull&build for flexibility to handle |
| 43 | different versions of ONOS. |
| 44 | - Construct tests variables |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 45 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 46 | try: |
| 47 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 48 | main.testSetUp = ONOSSetup() |
| 49 | except ImportError: |
| 50 | main.log.error( "ONOSSetup not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 51 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 52 | main.testSetUp.envSetupDescription() |
| 53 | stepResult = main.FALSE |
| 54 | try: |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 55 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 56 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 57 | main.BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 58 | main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 59 | main.MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 60 | main.maxNodes = int( main.params[ 'max' ] ) |
| 61 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 62 | main.scale = ( main.params[ 'SCALE' ] ).split( "," ) |
| 63 | main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] ) |
| 64 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 65 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 66 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 67 | main.intentManagerCfg = main.params[ 'CFG' ][ 'intentManager' ] |
| 68 | main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ] |
| 69 | main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ] |
| 70 | main.linkCollectionIntentCfg = main.params[ 'CFG' ][ 'linkCollectionIntent' ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 71 | main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] ) |
| 72 | main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] ) |
| 73 | main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] ) |
| 74 | main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," ) |
| 75 | main.ingress = main.params[ 'TEST' ][ 'ingress' ] |
| 76 | main.egress = main.params[ 'TEST' ][ 'egress' ] |
| 77 | main.debug = main.params[ 'TEST' ][ 'debug' ] |
| 78 | main.flowObj = main.params[ 'TEST' ][ 'flowObj' ] |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 79 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 80 | if main.flowObj == "True": |
| 81 | main.flowObj = True |
| 82 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ] |
| 83 | else: |
| 84 | main.flowObj = False |
| 85 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ] |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 86 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 87 | for i in range( 0, len( main.intentsList ) ): |
| 88 | main.intentsList[ i ] = int( main.intentsList[ i ] ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 89 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 90 | stepResult = main.testSetUp.envSetup() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 91 | # Create DataBase file |
| 92 | main.log.info( "Create Database file " + main.dbFileName ) |
| 93 | resultsDB = open( main.dbFileName, "w+" ) |
| 94 | resultsDB.close() |
| 95 | except Exception as e: |
| 96 | main.testSetUp.envSetupException( e ) |
| 97 | main.testSetUp.evnSetupConclusion( stepResult ) |
| 98 | main.commit = main.commit.split( " " )[ 1 ] |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 99 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 100 | def CASE1( self, main ): |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 101 | # Clean up test environment and set up |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 102 | import time |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 103 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 104 | main.maxNumBatch = 0 |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 105 | main.testSetUp.ONOSSetUp( main.MN1Ip, main.Cluster, True, |
| 106 | cellName=main.cellName, killRemoveMax=False ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 107 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 108 | # configure apps |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 109 | main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, |
| 110 | "deviceCount", value=7 ) |
| 111 | main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, |
| 112 | "topoShape", value="linear" ) |
| 113 | main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, |
| 114 | "enabled", value="true" ) |
| 115 | main.Cluster.active( 0 ).CLI.setCfg( main.intentManagerCfg, |
| 116 | "skipReleaseResourcesOnWithdrawal", |
| 117 | value="true" ) |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 118 | if main.flowObj: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 119 | main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg, |
| 120 | "useFlowObjectives", value="true" ) |
| 121 | main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg, |
| 122 | "defaultFlowObjectiveCompiler", |
| 123 | value=main.linkCollectionIntentCfg ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 124 | time.sleep( main.startUpSleep ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 125 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 126 | # balanceMasters |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 127 | main.Cluster.active( 0 ).CLI.balanceMasters() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 128 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 129 | |
| 130 | def CASE2( self, main ): |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 131 | import time |
| 132 | import numpy |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 133 | import json |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 134 | print( main.intentsList ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 135 | for batchSize in main.intentsList: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 136 | main.log.report( "Intent Batch size: {}".format( batchSize ) ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 137 | main.installLatList = [] |
| 138 | main.withdrawLatList = [] |
| 139 | validrun = 0 |
| 140 | invalidrun = 0 |
| 141 | # we use two variables to control the iteration |
| 142 | while validrun <= main.warmUp + main.sampleSize and invalidrun < 20: |
| 143 | if validrun >= main.warmUp: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 144 | main.log.info( "================================================" ) |
| 145 | main.log.info( "Starting test iteration " + str( validrun - main.warmUp ) ) |
| 146 | main.log.info( "Total test iteration: " + str( invalidrun + validrun ) ) |
| 147 | main.log.info( "================================================" ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 148 | else: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 149 | main.log.info( "====================Warm Up=====================" ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 150 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 151 | # push intents |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 152 | installResult = main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress, |
| 153 | main.egress, |
| 154 | batchSize, |
| 155 | offset=1, |
| 156 | options="-i", |
| 157 | timeout=main.timeout, |
| 158 | getResponse=True ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 159 | if isinstance( installResult, str ): |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 160 | if "Failure" in installResult: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 161 | main.log.error( "Install Intents failure, ignore this iteration." ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 162 | if validrun < main.warmUp: |
| 163 | validrun += 1 |
| 164 | continue |
| 165 | else: |
| 166 | invalidrun += 1 |
| 167 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 168 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 169 | try: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 170 | latency = int( installResult.split()[ 5 ] ) |
| 171 | main.log.info( installResult ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 172 | except: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 173 | main.log.error( "Failed to get latency, ignore this iteration." ) |
| 174 | main.log.error( "Response from ONOS:" ) |
| 175 | print( installResult ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 176 | if validrun < main.warmUp: |
| 177 | validrun += 1 |
| 178 | continue |
| 179 | else: |
| 180 | invalidrun += 1 |
| 181 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 182 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 183 | if validrun >= main.warmUp: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 184 | main.installLatList.append( latency ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 185 | else: |
| 186 | invalidrun += 1 |
| 187 | continue |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 188 | time.sleep( 2 ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 189 | # Withdraw Intents |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 190 | withdrawResult = main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress, |
| 191 | main.egress, |
| 192 | batchSize, |
| 193 | offset=1, |
| 194 | options="-w", |
| 195 | timeout=main.timeout, |
| 196 | getResponse=True ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 197 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 198 | if isinstance( withdrawResult, str ): |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 199 | if "Failure" in withdrawResult: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 200 | main.log.error( "withdraw Intents failure, ignore this iteration." ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 201 | if validrun < main.warmUp: |
| 202 | validrun += 1 |
| 203 | continue |
| 204 | else: |
| 205 | invalidrun += 1 |
| 206 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 207 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 208 | try: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 209 | latency = int( withdrawResult.split()[ 5 ] ) |
| 210 | main.log.info( withdrawResult ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 211 | except: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 212 | main.log.error( "Failed to get latency, ignore this iteration." ) |
| 213 | main.log.error( "Response from ONOS:" ) |
| 214 | print( withdrawResult ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 215 | if validrun < main.warmUp: |
| 216 | validrun += 1 |
| 217 | continue |
| 218 | else: |
| 219 | invalidrun += 1 |
| 220 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 221 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 222 | if validrun >= main.warmUp: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 223 | main.withdrawLatList.append( latency ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 224 | else: |
| 225 | invalidrun += 1 |
| 226 | continue |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 227 | time.sleep( 2 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 228 | main.Cluster.active( 0 ).CLI.purgeWithdrawnIntents() |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 229 | validrun += 1 |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 230 | installave = numpy.average( main.installLatList ) |
| 231 | installstd = numpy.std( main.installLatList ) |
| 232 | withdrawave = numpy.average( main.withdrawLatList ) |
| 233 | withdrawstd = numpy.std( main.withdrawLatList ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 234 | # log report |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 235 | main.log.report( "----------------------------------------------------" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 236 | main.log.report( "Scale: " + str( main.Cluster.numCtrls ) ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 237 | main.log.report( "Intent batch: " + str( batchSize ) ) |
| 238 | main.log.report( "Install average: {} std: {}".format( installave, installstd ) ) |
| 239 | main.log.report( "Withdraw average: {} std: {}".format( withdrawave, withdrawstd ) ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 240 | # write result to database file |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 241 | if not ( numpy.isnan( installave ) or numpy.isnan( installstd ) or |
| 242 | numpy.isnan( withdrawstd ) or numpy.isnan( withdrawave ) ): |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 243 | databaseString = "'" + main.commit + "'," |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 244 | databaseString += str( main.Cluster.numCtrls ) + "," |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 245 | databaseString += str( batchSize ) + "," |
| 246 | databaseString += str( installave ) + "," |
| 247 | databaseString += str( installstd ) + "," |
| 248 | databaseString += str( withdrawave ) + "," |
| 249 | databaseString += str( withdrawstd ) + "\n" |
| 250 | resultsDB = open( main.dbFileName, "a" ) |
| 251 | resultsDB.write( databaseString ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 252 | resultsDB.close() |