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 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 | """ |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 21 | # SCPFintentRerouteLat |
| 22 | """ |
| 23 | SCPFintentRerouteLat |
| 24 | - Test Intent Reroute Latency |
| 25 | - Test Algorithm: |
| 26 | 1. Start Null Provider reroute Topology |
| 27 | 2. Using Push-test-intents to push batch size intents from switch 1 to switch 7 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 28 | 3. Cut the link between switch 3 and switch 4 ( the path will reroute to switch 8 ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 29 | 4. Get the topology time stamp |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 30 | 5. Get Intent reroute( Installed ) time stamp from each nodes |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 31 | 6. Use the latest intent time stamp subtract topology time stamp |
| 32 | - This test will run 5 warm up by default, warm up iteration can be setup in Param file |
| 33 | - The intent batch size will default set to 1, 100, and 1000, also can be set in Param file |
| 34 | - The unit of the latency result is milliseconds |
| 35 | """ |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 36 | class SCPFintentRerouteLat: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 37 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 38 | def __init__( self ): |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 39 | self.default = '' |
| 40 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 41 | def CASE0( self, main ): |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 42 | import imp |
| 43 | import os |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 44 | """ |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 45 | - GIT |
| 46 | - BUILDING ONOS |
| 47 | Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| 48 | This step is usually skipped. Because in a Jenkins driven automated |
| 49 | test env. We want Jenkins jobs to pull&build for flexibility to handle |
| 50 | different versions of ONOS. |
| 51 | - Construct tests variables |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 52 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 53 | try: |
| 54 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 55 | main.testSetUp = ONOSSetup() |
| 56 | except ImportError: |
| 57 | main.log.error( "ONOSSetup not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 58 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 59 | main.testSetUp.envSetupDescription() |
| 60 | stepResult = main.FALSE |
| 61 | try: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 62 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 63 | main.BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 64 | main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 65 | main.MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 66 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 67 | main.scale = ( main.params[ 'SCALE' ] ).split( "," ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 68 | main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] ) |
| 69 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 70 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 71 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
| 72 | main.setMasterSleep = int( main.params[ 'SLEEP' ][ 'setmaster' ] ) |
| 73 | main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] ) |
| 74 | main.maxInvalidRun = int( main.params[ 'ATTEMPTS' ][ 'maxInvalidRun' ] ) |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 75 | main.cfgRetry = int( main.params[ 'ATTEMPTS' ][ 'cfg' ] ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 76 | main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 77 | main.intentManagerCfg = main.params[ 'CFG' ][ 'intentManager' ] |
| 78 | main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ] |
| 79 | main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ] |
| 80 | main.linkCollectionIntentCfg = main.params[ 'CFG' ][ 'linkCollectionIntent' ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 81 | main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] ) |
| 82 | main.ingress = main.params[ 'TEST' ][ 'ingress' ] |
| 83 | main.egress = main.params[ 'TEST' ][ 'egress' ] |
| 84 | main.debug = main.params[ 'TEST' ][ 'debug' ] |
| 85 | main.flowObj = main.params[ 'TEST' ][ 'flowObj' ] |
| 86 | main.deviceCount = int( main.params[ 'TEST' ][ 'deviceCount' ] ) |
| 87 | main.end1 = main.params[ 'TEST' ][ 'end1' ] |
| 88 | main.end2 = main.params[ 'TEST' ][ 'end2' ] |
| 89 | main.searchTerm = main.params[ 'SEARCHTERM' ] |
| 90 | if main.flowObj == "True": |
| 91 | main.flowObj = True |
| 92 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ] |
| 93 | main.intentsList = ( main.params[ 'TEST' ][ 'FObjintents' ] ).split( "," ) |
| 94 | else: |
| 95 | main.flowObj = False |
| 96 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ] |
| 97 | main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 98 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 99 | stepResult = main.testSetUp.envSetup() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 100 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 101 | for i in range( 0, len( main.intentsList ) ): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 102 | main.intentsList[ i ] = int( main.intentsList[ i ] ) |
| 103 | # Create DataBase file |
| 104 | main.log.info( "Create Database file " + main.dbFileName ) |
| 105 | resultsDB = open( main.dbFileName, "w+" ) |
| 106 | resultsDB.close() |
| 107 | file1 = main.params[ "DEPENDENCY" ][ "FILE1" ] |
| 108 | main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ] |
| 109 | main.intentRerouteLatFuncs = imp.load_source( file1, main.dependencyPath + file1 + ".py" ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 110 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 111 | main.record = 0 |
| 112 | except Exception as e: |
| 113 | main.testSetUp.envSetupException( e ) |
| 114 | main.testSetUp.evnSetupConclusion( stepResult ) |
You Wang | 47b9183 | 2017-08-02 11:36:13 -0700 | [diff] [blame] | 115 | main.commit = main.commit.split( " " )[ 1 ] |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 116 | |
| 117 | def CASE1( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 118 | """ |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 119 | clean up test environment and set up |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 120 | """ |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 121 | import time |
| 122 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 123 | main.maxNumBatch = 0 |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 124 | main.testSetUp.ONOSSetUp( main.Cluster, True, |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 125 | cellName=main.cellName, killRemoveMax=False ) |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 126 | configRetry = 0 |
| 127 | main.cfgCheck = False |
| 128 | while configRetry < main.cfgRetry: |
| 129 | # configure apps |
| 130 | stepResult = main.TRUE |
| 131 | stepResult = stepResult and \ |
| 132 | main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, |
| 133 | "deviceCount", |
| 134 | value=main.deviceCount ) |
| 135 | |
| 136 | stepResult = stepResult and \ |
| 137 | main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, |
| 138 | "topoShape", |
| 139 | value="reroute" ) |
| 140 | stepResult = stepResult and \ |
| 141 | main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, |
| 142 | "enabled", |
| 143 | value="true" ) |
| 144 | |
| 145 | stepResult = stepResult and \ |
| 146 | main.Cluster.active( 0 ).CLI.setCfg( main.intentManagerCfg, |
| 147 | "skipReleaseResourcesOnWithdrawal", |
| 148 | value="true" ) |
| 149 | if main.flowObj: |
| 150 | stepResult = stepResult and \ |
| 151 | main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg, |
| 152 | "useFlowObjectives", |
| 153 | value="true" ) |
| 154 | stepResult = stepResult and \ |
| 155 | main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg, |
| 156 | "defaultFlowObjectiveCompiler", |
| 157 | value=main.linkCollectionIntentCfg ) |
| 158 | if stepResult: |
| 159 | main.cfgCheck = True |
| 160 | break |
| 161 | configRetry += 1 |
| 162 | time.sleep( main.verifySleep ) |
| 163 | |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 164 | time.sleep( main.startUpSleep ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 165 | for ctrl in main.Cluster.active(): |
| 166 | ctrl.CLI.logSet( "DEBUG", "org.onosproject.metrics.topology" ) |
| 167 | ctrl.CLI.logSet( "DEBUG", "org.onosproject.metrics.intent" ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 168 | # Balance Master |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 169 | main.Cluster.active( 0 ).CLI.balanceMasters() |
You Wang | 0b9039d | 2017-01-12 16:51:29 -0800 | [diff] [blame] | 170 | time.sleep( main.setMasterSleep ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 171 | if main.Cluster.numCtrls: |
| 172 | main.Cluster.active( 0 ).CLI.deviceRole( main.end1[ 'name' ], main.Cluster.active( 0 ).ipAddress ) |
| 173 | main.Cluster.active( 0 ).CLI.deviceRole( main.end2[ 'name' ], main.Cluster.active( 0 ).ipAddress ) |
YPZhang | 2b9b26d | 2016-06-20 16:18:29 -0700 | [diff] [blame] | 174 | time.sleep( main.setMasterSleep ) |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 175 | if not main.cfgCheck: |
| 176 | main.log.error( "Setting configuration to the ONOS failed. Skip the rest of the steps" ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 177 | |
| 178 | def CASE2( self, main ): |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 179 | import time |
| 180 | import numpy |
| 181 | import datetime |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 182 | import json |
| 183 | # from scipy import stats |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 184 | testResult = main.TRUE |
| 185 | main.case( "Intent Reroute starts" ) |
| 186 | main.step( "Checking intent reroute" ) |
| 187 | if main.cfgCheck: |
| 188 | print( main.intentsList ) |
| 189 | for batchSize in main.intentsList: |
| 190 | main.batchSize = batchSize |
| 191 | main.log.report( "Intent Batch size: " + str( batchSize ) + "\n " ) |
| 192 | firstLocalLatencies = [] |
| 193 | lastLocalLatencies = [] |
| 194 | firstGlobalLatencies = [] |
| 195 | lastGlobalLatencies = [] |
| 196 | main.startLine = {} |
| 197 | main.validRun = 0 |
| 198 | main.invalidRun = 0 |
| 199 | while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= main.maxInvalidRun: |
| 200 | if main.validRun >= main.warmUp: |
| 201 | main.log.info( "================================================" ) |
| 202 | main.log.info( "Valid iteration: {} ".format( main.validRun - main.warmUp ) ) |
| 203 | main.log.info( "Total iteration: {}".format( main.validRun + main.invalidRun ) ) |
| 204 | main.log.info( "================================================" ) |
| 205 | else: |
| 206 | main.log.info( "====================Warm Up=====================" ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 207 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 208 | # push intents |
| 209 | main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress, |
| 210 | main.egress, |
| 211 | main.batchSize, |
| 212 | offset=1, |
| 213 | options="-i", |
| 214 | timeout=main.timeout ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 215 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 216 | # check links, flows and intents |
| 217 | main.intentRerouteLatFuncs.sanityCheck( main, |
| 218 | main.deviceCount * 2, |
| 219 | batchSize * ( main.deviceCount - 1 ), |
| 220 | main.batchSize ) |
| 221 | if not main.verify: |
| 222 | main.log.warn( "Sanity check failed, skipping this iteration..." ) |
| 223 | continue |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 224 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 225 | # Insert one line in karaf.log before link down |
| 226 | main.Cluster.command( "log", |
| 227 | args=[ "\'Scale: {}, Batch:{}, Iteration: {}\'".format( |
| 228 | main.Cluster.numCtrls, batchSize, main.validRun + main.invalidRun ) ], |
| 229 | returnBool=True, specificDriver=2 ) |
| 230 | # bring link down |
| 231 | main.Cluster.active( 0 ).CLI.link( main.end1[ 'port' ], main.end2[ 'port' ], "down", |
| 232 | timeout=main.timeout, showResponse=False ) |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 233 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 234 | # check links, flows and intents |
| 235 | main.intentRerouteLatFuncs.sanityCheck( main, |
| 236 | ( main.deviceCount - 1 ) * 2, |
| 237 | batchSize * main.deviceCount, |
| 238 | main.batchSize ) |
| 239 | if not main.verify: |
| 240 | main.log.warn( "Sanity check failed, skipping this iteration..." ) |
| 241 | continue |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 242 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 243 | # Get timestamp of last LINK_REMOVED event as separator between iterations |
| 244 | skip = False |
| 245 | for i in range( main.Cluster.numCtrls ): |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 246 | logNum = main.intentRerouteLatFuncs.getLogNum( main, i ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 247 | timestamp = str( main.Cluster.active( i ).CLI.getTimeStampFromLog( "last", |
| 248 | "LINK_REMOVED", |
| 249 | "time = ", " ", |
| 250 | logNum=logNum ) ) |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 251 | if timestamp == main.ERROR: |
| 252 | # Try again in case that the log number just increased |
| 253 | logNum = main.intentRerouteLatFuncs.getLogNum( main, i ) |
| 254 | timestamp = str( main.Cluster.active( i ).CLI.getTimeStampFromLog( "last", |
| 255 | "LINK_REMOVED", |
| 256 | "time = ", " ", |
| 257 | logNum=logNum ) ) |
| 258 | if timestamp == main.ERROR: |
| 259 | main.log.warn( "Cannot find the event we want in the log, skipping this iteration..." ) |
| 260 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
| 261 | if main.validRun >= main.warmUp: |
| 262 | main.invalidRun += 1 |
| 263 | else: |
| 264 | main.validRun += 1 |
| 265 | skip = True |
| 266 | break |
| 267 | else: |
| 268 | main.startLine[ i ] = timestamp |
| 269 | main.log.info( "Timestamp of last LINK_REMOVED event on node {} is {}".format( i + 1, |
| 270 | main.startLine[ i ] ) ) |
| 271 | if skip: |
| 272 | continue |
| 273 | |
| 274 | # calculate values |
| 275 | topologyTimestamps = main.intentRerouteLatFuncs.getTopologyTimestamps( main ) |
| 276 | intentTimestamps = main.intentRerouteLatFuncs.getIntentTimestamps( main ) |
| 277 | if intentTimestamps == main.ERROR or topologyTimestamps == main.ERROR: |
| 278 | main.log.info( "Got invalid timestamp, skipping this iteration..." ) |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 279 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
| 280 | if main.validRun >= main.warmUp: |
| 281 | main.invalidRun += 1 |
| 282 | else: |
| 283 | main.validRun += 1 |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 284 | continue |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 285 | else: |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 286 | main.log.info( "Got valid timestamps" ) |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 287 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 288 | firstLocalLatnecy, lastLocalLatnecy, firstGlobalLatency, lastGlobalLatnecy \ |
| 289 | = main.intentRerouteLatFuncs.calculateLatency( main, topologyTimestamps, intentTimestamps ) |
| 290 | if firstLocalLatnecy < 0: |
| 291 | main.log.info( "Got negative latency, skipping this iteration..." ) |
| 292 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
| 293 | if main.validRun >= main.warmUp: |
| 294 | main.invalidRun += 1 |
| 295 | else: |
| 296 | main.validRun += 1 |
| 297 | continue |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 298 | else: |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 299 | main.log.info( "Got valid latencies" ) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 300 | main.validRun += 1 |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 301 | |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 302 | if main.validRun >= main.warmUp: |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 303 | firstLocalLatencies.append( firstLocalLatnecy ) |
| 304 | lastLocalLatencies.append( lastLocalLatnecy ) |
| 305 | firstGlobalLatencies.append( firstGlobalLatency ) |
| 306 | lastGlobalLatencies.append( lastGlobalLatnecy ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 307 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 308 | # bring up link and withdraw intents |
| 309 | main.Cluster.active( 0 ).CLI.link( main.end1[ 'port' ], |
| 310 | main.end2[ 'port' ], |
| 311 | "up", |
| 312 | timeout=main.timeout ) |
| 313 | main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress, |
| 314 | main.egress, |
| 315 | batchSize, |
| 316 | offset=1, |
| 317 | options="-w", |
| 318 | timeout=main.timeout ) |
| 319 | main.Cluster.active( 0 ).CLI.purgeWithdrawnIntents() |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 320 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 321 | # check links, flows and intents |
| 322 | main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, 0, 0 ) |
| 323 | if not main.verify: |
| 324 | main.log.warn( "Sanity check failed, skipping this iteration..." ) |
| 325 | continue |
| 326 | result = ( main.TRUE if main.invalidRun <= main.maxInvalidRun else main.FALSE ) |
| 327 | aveLocalLatency = numpy.average( lastLocalLatencies ) if lastLocalLatencies and result else 0 |
| 328 | aveGlobalLatency = numpy.average( lastGlobalLatencies ) if lastGlobalLatencies and result else 0 |
| 329 | stdLocalLatency = numpy.std( lastLocalLatencies ) if lastLocalLatencies and result else 0 |
| 330 | stdGlobalLatency = numpy.std( lastGlobalLatencies ) if lastGlobalLatencies and result else 0 |
| 331 | testResult = testResult and result |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 332 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 333 | main.log.report( "Scale: " + str( main.Cluster.numCtrls ) + " \tIntent batch: " + str( batchSize ) ) |
| 334 | main.log.report( "Local latency average:................" + str( aveLocalLatency ) ) |
| 335 | main.log.report( "Global latency average:................" + str( aveGlobalLatency ) ) |
| 336 | main.log.report( "Local latency std:................" + str( stdLocalLatency ) ) |
| 337 | main.log.report( "Global latency std:................" + str( stdGlobalLatency ) ) |
| 338 | main.log.report( "________________________________________________________" ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 339 | |
Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 340 | if not ( numpy.isnan( aveLocalLatency ) or numpy.isnan( aveGlobalLatency ) ): |
| 341 | # check if got NaN for result |
| 342 | resultsDB = open( main.dbFileName, "a" ) |
| 343 | resultsDB.write( "'" + main.commit + "'," ) |
| 344 | resultsDB.write( str( main.Cluster.numCtrls ) + "," ) |
| 345 | resultsDB.write( str( batchSize ) + "," ) |
| 346 | resultsDB.write( str( aveLocalLatency ) + "," ) |
| 347 | resultsDB.write( str( stdLocalLatency ) + "\n" ) |
| 348 | resultsDB.close() |
| 349 | else: |
| 350 | testResult = main.FALSE |
| 351 | utilities.assert_equals( expect=main.TRUE, |
| 352 | actual=testResult, |
| 353 | onpass="Installing and withdrawing intents reroute properly", |
| 354 | onfail="There was something wrong installing and withdrawing intents reroute" ) |