YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 1 | """ |
| 2 | SCPFintentInstallWithdrawLat: |
| 3 | - Test the latency of intent installed and withdrawn |
| 4 | - Use Push-test-intents command to push intents |
| 5 | - Use Null provider with 7 devices and linear topology |
| 6 | - Always push intents between 1/6 and 7/5 |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 7 | - 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] | 8 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 9 | yunpeng@onlab.us |
| 10 | """ |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 11 | class SCPFintentInstallWithdrawLat: |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 12 | def __init__( self ): |
| 13 | self.default = '' |
| 14 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 15 | def CASE0( self, main ): |
| 16 | ''' |
| 17 | - GIT |
| 18 | - BUILDING ONOS |
| 19 | Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| 20 | This step is usually skipped. Because in a Jenkins driven automated |
| 21 | test env. We want Jenkins jobs to pull&build for flexibility to handle |
| 22 | different versions of ONOS. |
| 23 | - Construct tests variables |
| 24 | ''' |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 25 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 26 | try: |
| 27 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 28 | main.testSetUp = ONOSSetup() |
| 29 | except ImportError: |
| 30 | main.log.error( "ONOSSetup not found. exiting the test" ) |
| 31 | main.exit() |
| 32 | main.testSetUp.envSetupDescription() |
| 33 | stepResult = main.FALSE |
| 34 | try: |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 35 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 36 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 37 | main.BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 38 | main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 39 | main.MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 40 | main.maxNodes = int( main.params[ 'max' ] ) |
| 41 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 42 | main.scale = ( main.params[ 'SCALE' ] ).split( "," ) |
| 43 | main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] ) |
| 44 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 45 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 46 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
| 47 | main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] ) |
| 48 | main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] ) |
| 49 | main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] ) |
| 50 | main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," ) |
| 51 | main.ingress = main.params[ 'TEST' ][ 'ingress' ] |
| 52 | main.egress = main.params[ 'TEST' ][ 'egress' ] |
| 53 | main.debug = main.params[ 'TEST' ][ 'debug' ] |
| 54 | main.flowObj = main.params[ 'TEST' ][ 'flowObj' ] |
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 | if main.flowObj == "True": |
| 57 | main.flowObj = True |
| 58 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ] |
| 59 | else: |
| 60 | main.flowObj = False |
| 61 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ] |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 62 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 63 | for i in range( 0, len( main.intentsList ) ): |
| 64 | main.intentsList[ i ] = int( main.intentsList[ i ] ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 65 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 66 | stepResult = main.testSetUp.gitPulling() |
| 67 | # Create DataBase file |
| 68 | main.log.info( "Create Database file " + main.dbFileName ) |
| 69 | resultsDB = open( main.dbFileName, "w+" ) |
| 70 | resultsDB.close() |
| 71 | except Exception as e: |
| 72 | main.testSetUp.envSetupException( e ) |
| 73 | main.testSetUp.evnSetupConclusion( stepResult ) |
| 74 | main.commit = main.commit.split( " " )[ 1 ] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 75 | def CASE1( self, main ): |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 76 | # Clean up test environment and set up |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 77 | import time |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 78 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 79 | main.maxNumBatch = 0 |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 80 | main.testSetUp.getNumCtrls( True ) |
| 81 | main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False ) |
| 82 | main.testSetUp.ONOSSetUp( main.MN1Ip, True, |
| 83 | cellName=main.cellName, killRemoveMax=False, |
| 84 | CtrlsSet=False ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 85 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 86 | # configure apps |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 87 | main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount", value=7 ) |
| 88 | main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "topoShape", value="linear" ) |
| 89 | main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled", value="true" ) |
| 90 | main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.IntentManager", "skipReleaseResourcesOnWithdrawal", value="true" ) |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 91 | if main.flowObj: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 92 | main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 93 | "useFlowObjectives", value="true" ) |
| 94 | main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
You Wang | 106d0fa | 2017-05-15 17:22:15 -0700 | [diff] [blame] | 95 | "defaultFlowObjectiveCompiler", |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 96 | value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' ) |
| 97 | time.sleep( main.startUpSleep ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 98 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 99 | # balanceMasters |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 100 | main.CLIs[ 0 ].balanceMasters() |
| 101 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 102 | |
| 103 | def CASE2( self, main ): |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 104 | import time |
| 105 | import numpy |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 106 | import json |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 107 | print( main.intentsList ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 108 | for batchSize in main.intentsList: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 109 | main.log.report( "Intent Batch size: {}".format( batchSize ) ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 110 | main.installLatList = [] |
| 111 | main.withdrawLatList = [] |
| 112 | validrun = 0 |
| 113 | invalidrun = 0 |
| 114 | # we use two variables to control the iteration |
| 115 | while validrun <= main.warmUp + main.sampleSize and invalidrun < 20: |
| 116 | if validrun >= main.warmUp: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 117 | main.log.info( "================================================" ) |
| 118 | main.log.info( "Starting test iteration " + str( validrun - main.warmUp ) ) |
| 119 | main.log.info( "Total test iteration: " + str( invalidrun + validrun ) ) |
| 120 | main.log.info( "================================================" ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 121 | else: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 122 | main.log.info( "====================Warm Up=====================" ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 123 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 124 | # push intents |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 125 | installResult = main.CLIs[ 0 ].pushTestIntents( main.ingress, main.egress, batchSize, |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 126 | offset=1, options="-i", timeout=main.timeout, |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 127 | getResponse=True ) |
| 128 | if type( installResult ) is str: |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 129 | if "Failure" in installResult: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 130 | main.log.error( "Install Intents failure, ignore this iteration." ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 131 | if validrun < main.warmUp: |
| 132 | validrun += 1 |
| 133 | continue |
| 134 | else: |
| 135 | invalidrun += 1 |
| 136 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 137 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 138 | try: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 139 | latency = int( installResult.split()[ 5 ] ) |
| 140 | main.log.info( installResult ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 141 | except: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 142 | main.log.error( "Failed to get latency, ignore this iteration." ) |
| 143 | main.log.error( "Response from ONOS:" ) |
| 144 | print( installResult ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 145 | if validrun < main.warmUp: |
| 146 | validrun += 1 |
| 147 | continue |
| 148 | else: |
| 149 | invalidrun += 1 |
| 150 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 151 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 152 | if validrun >= main.warmUp: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 153 | main.installLatList.append( latency ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 154 | else: |
| 155 | invalidrun += 1 |
| 156 | continue |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 157 | time.sleep( 2 ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 158 | # Withdraw Intents |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 159 | withdrawResult = main.CLIs[ 0 ].pushTestIntents( main.ingress, main.egress, batchSize, |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 160 | offset=1, options="-w", timeout=main.timeout, |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 161 | getResponse=True ) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 162 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 163 | if type( withdrawResult ) is str: |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 164 | if "Failure" in withdrawResult: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 165 | main.log.error( "withdraw Intents failure, ignore this iteration." ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 166 | if validrun < main.warmUp: |
| 167 | validrun += 1 |
| 168 | continue |
| 169 | else: |
| 170 | invalidrun += 1 |
| 171 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 172 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 173 | try: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 174 | latency = int( withdrawResult.split()[ 5 ] ) |
| 175 | main.log.info( withdrawResult ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 176 | except: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 177 | main.log.error( "Failed to get latency, ignore this iteration." ) |
| 178 | main.log.error( "Response from ONOS:" ) |
| 179 | print( withdrawResult ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 180 | if validrun < main.warmUp: |
| 181 | validrun += 1 |
| 182 | continue |
| 183 | else: |
| 184 | invalidrun += 1 |
| 185 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 186 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 187 | if validrun >= main.warmUp: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 188 | main.withdrawLatList.append( latency ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 189 | else: |
| 190 | invalidrun += 1 |
| 191 | continue |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 192 | time.sleep( 2 ) |
| 193 | main.CLIs[ 0 ].purgeWithdrawnIntents() |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 194 | validrun += 1 |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 195 | installave = numpy.average( main.installLatList ) |
| 196 | installstd = numpy.std( main.installLatList ) |
| 197 | withdrawave = numpy.average( main.withdrawLatList ) |
| 198 | withdrawstd = numpy.std( main.withdrawLatList ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 199 | # log report |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 200 | main.log.report( "----------------------------------------------------" ) |
| 201 | main.log.report( "Scale: " + str( main.numCtrls ) ) |
| 202 | main.log.report( "Intent batch: " + str( batchSize ) ) |
| 203 | main.log.report( "Install average: {} std: {}".format( installave, installstd ) ) |
| 204 | main.log.report( "Withdraw average: {} std: {}".format( withdrawave, withdrawstd ) ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 205 | # write result to database file |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 206 | if not ( numpy.isnan( installave ) or numpy.isnan( installstd ) or\ |
| 207 | numpy.isnan( withdrawstd ) or numpy.isnan( withdrawave ) ): |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 208 | databaseString = "'" + main.commit + "'," |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 209 | databaseString += str( main.numCtrls ) + "," |
| 210 | databaseString += str( batchSize ) + "," |
| 211 | databaseString += str( installave ) + "," |
| 212 | databaseString += str( installstd ) + "," |
| 213 | databaseString += str( withdrawave ) + "," |
| 214 | databaseString += str( withdrawstd ) + "\n" |
| 215 | resultsDB = open( main.dbFileName, "a" ) |
| 216 | resultsDB.write( databaseString ) |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 217 | resultsDB.close() |