YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 1 | # SCPFintentRerouteLat |
| 2 | """ |
| 3 | SCPFintentRerouteLat |
| 4 | - Test Intent Reroute Latency |
| 5 | - Test Algorithm: |
| 6 | 1. Start Null Provider reroute Topology |
| 7 | 2. Using Push-test-intents to push batch size intents from switch 1 to switch 7 |
| 8 | 3. Cut the link between switch 3 and switch 4 (the path will reroute to switch 8) |
| 9 | 4. Get the topology time stamp |
| 10 | 5. Get Intent reroute(Installed) time stamp from each nodes |
| 11 | 6. Use the latest intent time stamp subtract topology time stamp |
| 12 | - This test will run 5 warm up by default, warm up iteration can be setup in Param file |
| 13 | - The intent batch size will default set to 1, 100, and 1000, also can be set in Param file |
| 14 | - The unit of the latency result is milliseconds |
| 15 | """ |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 16 | |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 17 | |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 18 | class SCPFintentRerouteLat: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 19 | def __init__(self): |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 20 | self.default = '' |
| 21 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 22 | def CASE0( self, main ): |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 23 | import imp |
| 24 | import os |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 25 | ''' |
| 26 | - GIT |
| 27 | - BUILDING ONOS |
| 28 | Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| 29 | This step is usually skipped. Because in a Jenkins driven automated |
| 30 | test env. We want Jenkins jobs to pull&build for flexibility to handle |
| 31 | different versions of ONOS. |
| 32 | - Construct tests variables |
| 33 | ''' |
| 34 | gitPull = main.params['GIT']['gitPull'] |
| 35 | gitBranch = main.params['GIT']['gitBranch'] |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 36 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 37 | main.case("Pull onos branch and build onos on Teststation.") |
| 38 | |
| 39 | if gitPull == 'True': |
| 40 | main.step("Git Checkout ONOS branch: " + gitBranch) |
| 41 | stepResult = main.ONOSbench.gitCheckout(branch=gitBranch) |
| 42 | utilities.assert_equals(expect=main.TRUE, |
| 43 | actual=stepResult, |
| 44 | onpass="Successfully checkout onos branch.", |
| 45 | onfail="Failed to checkout onos branch. Exiting test...") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 46 | if not stepResult: |
| 47 | main.exit() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 48 | |
| 49 | main.step("Git Pull on ONOS branch:" + gitBranch) |
| 50 | stepResult = main.ONOSbench.gitPull() |
| 51 | utilities.assert_equals(expect=main.TRUE, |
| 52 | actual=stepResult, |
| 53 | onpass="Successfully pull onos. ", |
| 54 | onfail="Failed to pull onos. Exiting test ...") |
| 55 | if not stepResult: main.exit() |
| 56 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 57 | else: |
| 58 | main.log.warn("Skipped pulling onos and Skipped building ONOS") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 59 | main.onosIp = main.ONOSbench.getOnosIps() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 60 | main.apps = main.params['ENV']['cellApps'] |
| 61 | main.BENCHUser = main.params['BENCH']['user'] |
| 62 | main.BENCHIp = main.params['BENCH']['ip1'] |
| 63 | main.MN1Ip = main.params['MN']['ip1'] |
| 64 | main.maxNodes = int(main.params['max']) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 65 | main.cellName = main.params['ENV']['cellName'] |
| 66 | main.scale = (main.params['SCALE']).split(",") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 67 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 68 | main.startUpSleep = int(main.params['SLEEP']['startup']) |
| 69 | main.installSleep = int(main.params['SLEEP']['install']) |
| 70 | main.verifySleep = int(main.params['SLEEP']['verify']) |
YPZhang | 2b9b26d | 2016-06-20 16:18:29 -0700 | [diff] [blame] | 71 | main.setMasterSleep = int(main.params['SLEEP']['setmaster']) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 72 | main.verifyAttempts = int(main.params['ATTEMPTS']['verify']) |
You Wang | 0b9039d | 2017-01-12 16:51:29 -0800 | [diff] [blame] | 73 | main.maxInvalidRun = int(main.params['ATTEMPTS']['maxInvalidRun']) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 74 | main.sampleSize = int(main.params['TEST']['sampleSize']) |
| 75 | main.warmUp = int(main.params['TEST']['warmUp']) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 76 | main.ingress = main.params['TEST']['ingress'] |
| 77 | main.egress = main.params['TEST']['egress'] |
| 78 | main.debug = main.params['TEST']['debug'] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 79 | main.flowObj = main.params['TEST']['flowObj'] |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 80 | main.deviceCount = int(main.params['TEST']['deviceCount']) |
| 81 | main.end1 = main.params['TEST']['end1'] |
| 82 | main.end2 = main.params['TEST']['end2'] |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 83 | main.searchTerm = main.params['SEARCHTERM'] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 84 | if main.flowObj == "True": |
| 85 | main.flowObj = True |
| 86 | main.dbFileName = main.params['DATABASE']['dbFlowObj'] |
YPZhang | 3b5a78f | 2016-07-14 10:43:33 -0700 | [diff] [blame] | 87 | main.intentsList = (main.params['TEST']['FObjintents']).split(",") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 88 | else: |
| 89 | main.flowObj = False |
| 90 | main.dbFileName = main.params['DATABASE']['dbName'] |
YPZhang | 3b5a78f | 2016-07-14 10:43:33 -0700 | [diff] [blame] | 91 | main.intentsList = (main.params['TEST']['intents']).split(",") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 92 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 93 | for i in range(0, len(main.intentsList)): |
| 94 | main.intentsList[i] = int(main.intentsList[i]) |
| 95 | # Create DataBase file |
| 96 | main.log.info("Create Database file " + main.dbFileName) |
| 97 | resultsDB = open(main.dbFileName, "w+") |
| 98 | resultsDB.close() |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 99 | file1 = main.params[ "DEPENDENCY" ][ "FILE1" ] |
| 100 | main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ] |
| 101 | main.intentRerouteLatFuncs = imp.load_source(file1, main.dependencyPath + file1 + ".py") |
| 102 | |
| 103 | main.record = 0 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 104 | |
| 105 | def CASE1( self, main ): |
| 106 | ''' |
| 107 | clean up test environment and set up |
| 108 | ''' |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 109 | import time |
| 110 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 111 | main.log.info("Get ONOS cluster IP") |
| 112 | print(main.scale) |
| 113 | main.numCtrls = int(main.scale[0]) |
| 114 | main.ONOSip = [] |
| 115 | main.maxNumBatch = 0 |
| 116 | main.AllONOSip = main.ONOSbench.getOnosIps() |
| 117 | for i in range(main.numCtrls): |
| 118 | main.ONOSip.append(main.AllONOSip[i]) |
| 119 | main.log.info(main.ONOSip) |
| 120 | main.CLIs = [] |
| 121 | main.log.info("Creating list of ONOS cli handles") |
| 122 | for i in range(main.numCtrls): |
Devin Lim | 2870684 | 2017-06-08 10:23:48 -0700 | [diff] [blame] | 123 | main.CLIs.append(getattr(main, 'ONOScli%s' % (i + 1))) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 124 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 125 | if not main.CLIs: |
| 126 | main.log.error("Failed to create the list of ONOS cli handles") |
| 127 | main.cleanup() |
| 128 | main.exit() |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 129 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 130 | main.commit = main.ONOSbench.getVersion(report=True) |
| 131 | main.commit = main.commit.split(" ")[1] |
| 132 | main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls) |
| 133 | main.log.info("Safety check, killing all ONOS processes" + |
| 134 | " before initiating environment setup") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 135 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 136 | for i in range(main.numCtrls): |
You Wang | b98a9fa | 2017-02-15 17:27:42 -0800 | [diff] [blame] | 137 | main.ONOSbench.onosStop(main.ONOSip[i]) |
| 138 | main.ONOSbench.onosKill(main.ONOSip[i]) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 139 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 140 | main.log.info("NODE COUNT = %s" % main.numCtrls) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 141 | main.ONOSbench.createCellFile(main.ONOSbench.ip_address, |
| 142 | main.cellName, |
| 143 | main.MN1Ip, |
| 144 | main.apps, |
Devin Lim | 461f087 | 2017-06-05 16:49:33 -0700 | [diff] [blame] | 145 | main.ONOSip, |
| 146 | main.ONOScli1.user_name) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 147 | main.step("Apply cell to environment") |
| 148 | cellResult = main.ONOSbench.setCell(main.cellName) |
| 149 | verifyResult = main.ONOSbench.verifyCell() |
| 150 | stepResult = cellResult and verifyResult |
| 151 | utilities.assert_equals(expect=main.TRUE, |
| 152 | actual=stepResult, |
| 153 | onpass="Successfully applied cell to " + \ |
| 154 | "environment", |
| 155 | onfail="Failed to apply cell to environment ") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 156 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 157 | main.step("Creating ONOS package") |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 158 | packageResult = main.ONOSbench.buckBuild() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 159 | stepResult = packageResult |
| 160 | utilities.assert_equals(expect=main.TRUE, |
| 161 | actual=stepResult, |
| 162 | onpass="Successfully created ONOS package", |
| 163 | onfail="Failed to create ONOS package") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 164 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 165 | main.step("Uninstall ONOS package on all Nodes") |
| 166 | uninstallResult = main.TRUE |
| 167 | for i in range(int(main.numCtrls)): |
| 168 | main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i]) |
| 169 | u_result = main.ONOSbench.onosUninstall(main.ONOSip[i]) |
| 170 | utilities.assert_equals(expect=main.TRUE, actual=u_result, |
| 171 | onpass="Test step PASS", |
| 172 | onfail="Test step FAIL") |
| 173 | uninstallResult = (uninstallResult and u_result) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 174 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 175 | main.step("Install ONOS package on all Nodes") |
| 176 | installResult = main.TRUE |
| 177 | for i in range(int(main.numCtrls)): |
| 178 | main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i]) |
| 179 | i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i]) |
| 180 | utilities.assert_equals(expect=main.TRUE, actual=i_result, |
| 181 | onpass="Test step PASS", |
| 182 | onfail="Test step FAIL") |
| 183 | installResult = installResult and i_result |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 184 | |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 185 | main.step( "Set up ONOS secure SSH" ) |
| 186 | secureSshResult = main.TRUE |
| 187 | for i in range( int( main.numCtrls ) ): |
| 188 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] ) |
| 189 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 190 | onpass="Test step PASS", |
| 191 | onfail="Test step FAIL" ) |
| 192 | |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 193 | main.step( "Starting ONOS service" ) |
| 194 | stopResult = main.TRUE |
| 195 | startResult = main.TRUE |
| 196 | onosIsUp = main.TRUE |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 197 | |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 198 | for i in range( main.numCtrls ): |
| 199 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 200 | if onosIsUp == main.TRUE: |
| 201 | main.log.report( "ONOS instance is up and ready" ) |
| 202 | else: |
| 203 | main.log.report( "ONOS instance may not be up, stop and " + |
| 204 | "start ONOS again " ) |
| 205 | |
| 206 | for i in range( main.numCtrls ): |
| 207 | stopResult = stopResult and \ |
| 208 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 209 | for i in range( main.numCtrls ): |
| 210 | startResult = startResult and \ |
| 211 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 212 | stepResult = onosIsUp and stopResult and startResult |
| 213 | utilities.assert_equals( expect=main.TRUE, actual=stepResult, |
| 214 | onpass="Test step PASS", |
| 215 | onfail="Test step FAIL" ) |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 216 | |
You Wang | 0b9039d | 2017-01-12 16:51:29 -0800 | [diff] [blame] | 217 | time.sleep(main.startUpSleep) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 218 | main.step("Start ONOS CLI on all nodes") |
| 219 | cliResult = main.TRUE |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 220 | main.step(" Start ONOS cli using thread ") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 221 | startCliResult = main.TRUE |
| 222 | pool = [] |
| 223 | main.threadID = 0 |
| 224 | for i in range(int(main.numCtrls)): |
| 225 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 226 | threadID=main.threadID, |
| 227 | name="startOnosCli", |
| 228 | args=[main.ONOSip[i]], |
| 229 | kwargs={"onosStartTimeout": main.timeout}) |
| 230 | pool.append(t) |
| 231 | t.start() |
| 232 | main.threadID = main.threadID + 1 |
| 233 | for t in pool: |
| 234 | t.join() |
| 235 | startCliResult = startCliResult and t.result |
| 236 | time.sleep(main.startUpSleep) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 237 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 238 | # configure apps |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 239 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 240 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute") |
| 241 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 242 | if main.flowObj: |
| 243 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 244 | "useFlowObjectives", value="true") |
You Wang | 106d0fa | 2017-05-15 17:22:15 -0700 | [diff] [blame] | 245 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 246 | "defaultFlowObjectiveCompiler", |
| 247 | value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler') |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 248 | time.sleep( main.startUpSleep ) |
| 249 | for i in range( int( main.numCtrls ) ): |
| 250 | main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology" ) |
| 251 | main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.intent" ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 252 | # Balance Master |
| 253 | main.CLIs[0].balanceMasters() |
You Wang | 0b9039d | 2017-01-12 16:51:29 -0800 | [diff] [blame] | 254 | time.sleep( main.setMasterSleep ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 255 | if len(main.ONOSip) > 1: |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 256 | main.CLIs[0].deviceRole(main.end1[ 'name' ], main.ONOSip[0]) |
| 257 | main.CLIs[0].deviceRole(main.end2[ 'name' ], main.ONOSip[0]) |
YPZhang | 2b9b26d | 2016-06-20 16:18:29 -0700 | [diff] [blame] | 258 | time.sleep( main.setMasterSleep ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 259 | |
| 260 | def CASE2( self, main ): |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 261 | import time |
| 262 | import numpy |
| 263 | import datetime |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 264 | import json |
| 265 | # from scipy import stats |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 266 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 267 | print(main.intentsList) |
| 268 | for batchSize in main.intentsList: |
You Wang | 0b9039d | 2017-01-12 16:51:29 -0800 | [diff] [blame] | 269 | main.batchSize = batchSize |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 270 | main.log.report("Intent Batch size: " + str(batchSize) + "\n ") |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 271 | firstLocalLatencies = [] |
| 272 | lastLocalLatencies = [] |
| 273 | firstGlobalLatencies = [] |
| 274 | lastGlobalLatencies = [] |
| 275 | main.startLine = {} |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 276 | main.validRun = 0 |
| 277 | main.invalidRun = 0 |
You Wang | 0b9039d | 2017-01-12 16:51:29 -0800 | [diff] [blame] | 278 | while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= main.maxInvalidRun: |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 279 | if main.validRun >= main.warmUp: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 280 | main.log.info("================================================") |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 281 | main.log.info("Valid iteration: {} ".format( main.validRun - main.warmUp)) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 282 | main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun)) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 283 | main.log.info("================================================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 284 | else: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 285 | main.log.info("====================Warm Up=====================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 286 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 287 | # push intents |
You Wang | 0b9039d | 2017-01-12 16:51:29 -0800 | [diff] [blame] | 288 | main.CLIs[0].pushTestIntents(main.ingress, main.egress, main.batchSize, |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 289 | offset=1, options="-i", timeout=main.timeout) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 290 | |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 291 | # check links, flows and intents |
| 292 | main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, batchSize * (main.deviceCount - 1 ), main.batchSize ) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 293 | if not main.verify: |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 294 | main.log.warn( "Sanity check failed, skipping this iteration..." ) |
| 295 | continue |
| 296 | |
| 297 | # Insert one line in karaf.log before link down |
| 298 | for i in range( main.numCtrls ): |
| 299 | main.CLIs[ i ].log( "\'Scale: {}, Batch:{}, Iteration: {}\'".format( main.numCtrls, batchSize, main.validRun + main.invalidRun ) ) |
| 300 | |
| 301 | # bring link down |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 302 | main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down", |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 303 | timeout=main.timeout, showResponse=False) |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 304 | |
| 305 | # check links, flows and intents |
| 306 | main.intentRerouteLatFuncs.sanityCheck( main, (main.deviceCount - 1) * 2, batchSize * main.deviceCount, main.batchSize ) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 307 | if not main.verify: |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 308 | main.log.warn( "Sanity check failed, skipping this iteration..." ) |
| 309 | continue |
| 310 | |
| 311 | # Get timestamp of last LINK_REMOVED event as separator between iterations |
| 312 | skip = False |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 313 | for i in range( main.numCtrls ): |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 314 | logNum = main.intentRerouteLatFuncs.getLogNum( main, i ) |
| 315 | timestamp = str( main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ) ) |
| 316 | if timestamp == main.ERROR: |
| 317 | # Try again in case that the log number just increased |
| 318 | logNum = main.intentRerouteLatFuncs.getLogNum( main, i ) |
| 319 | timestamp = str( main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ) ) |
| 320 | if timestamp == main.ERROR: |
| 321 | main.log.warn( "Cannot find the event we want in the log, skipping this iteration..." ) |
| 322 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
| 323 | if main.validRun >= main.warmUp: |
| 324 | main.invalidRun += 1 |
| 325 | else: |
| 326 | main.validRun += 1 |
| 327 | skip = True |
| 328 | break |
| 329 | else: |
| 330 | main.startLine[ i ] = timestamp |
| 331 | main.log.info( "Timestamp of last LINK_REMOVED event on node {} is {}".format( i+1, main.startLine[ i ] ) ) |
| 332 | if skip: continue |
| 333 | |
| 334 | # calculate values |
| 335 | topologyTimestamps = main.intentRerouteLatFuncs.getTopologyTimestamps( main ) |
| 336 | intentTimestamps = main.intentRerouteLatFuncs.getIntentTimestamps( main ) |
| 337 | if intentTimestamps == main.ERROR or topologyTimestamps == main.ERROR: |
| 338 | main.log.info( "Got invalid timestamp, skipping this iteration..." ) |
| 339 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 340 | if main.validRun >= main.warmUp: |
| 341 | main.invalidRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 342 | else: |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 343 | main.validRun += 1 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 344 | continue |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 345 | else: |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 346 | main.log.info( "Got valid timestamps" ) |
| 347 | |
| 348 | firstLocalLatnecy, lastLocalLatnecy, firstGlobalLatency, lastGlobalLatnecy = main.intentRerouteLatFuncs.calculateLatency( main, topologyTimestamps, intentTimestamps ) |
| 349 | if firstLocalLatnecy < 0: |
| 350 | main.log.info( "Got negative latency, skipping this iteration..." ) |
| 351 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
| 352 | if main.validRun >= main.warmUp: |
| 353 | main.invalidRun += 1 |
| 354 | else: |
| 355 | main.validRun += 1 |
| 356 | continue |
| 357 | else: |
| 358 | main.log.info( "Got valid latencies" ) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 359 | main.validRun += 1 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 360 | |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 361 | firstLocalLatencies.append( firstLocalLatnecy ) |
| 362 | lastLocalLatencies.append( lastLocalLatnecy ) |
| 363 | firstGlobalLatencies.append( firstGlobalLatency ) |
| 364 | lastGlobalLatencies.append( lastGlobalLatnecy ) |
| 365 | |
| 366 | # bring up link and withdraw intents |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 367 | main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up", |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 368 | timeout=main.timeout) |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 369 | main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize, |
| 370 | offset=1, options="-w", timeout=main.timeout) |
| 371 | main.CLIs[0].purgeWithdrawnIntents() |
| 372 | |
| 373 | # check links, flows and intents |
| 374 | main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, 0, 0 ) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 375 | if not main.verify: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 376 | continue |
| 377 | |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 378 | aveLocalLatency = numpy.average( lastLocalLatencies ) |
| 379 | aveGlobalLatency = numpy.average( lastGlobalLatencies ) |
| 380 | stdLocalLatency = numpy.std( lastLocalLatencies ) |
| 381 | stdGlobalLatency = numpy.std( lastGlobalLatencies ) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 382 | |
| 383 | main.log.report( "Scale: " + str( main.numCtrls ) + " \tIntent batch: " + str( batchSize ) ) |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 384 | main.log.report( "Local latency average:................" + str( aveLocalLatency ) ) |
| 385 | main.log.report( "Global latency average:................" + str( aveGlobalLatency ) ) |
| 386 | main.log.report( "Local latency std:................" + str( stdLocalLatency ) ) |
| 387 | main.log.report( "Global latency std:................" + str( stdGlobalLatency ) ) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 388 | main.log.report( "________________________________________________________" ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 389 | |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 390 | if not ( numpy.isnan( aveLocalLatency ) or numpy.isnan( aveGlobalLatency ) ): |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 391 | # check if got NaN for result |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 392 | resultsDB = open( main.dbFileName, "a" ) |
| 393 | resultsDB.write( "'" + main.commit + "'," ) |
| 394 | resultsDB.write( str( main.numCtrls ) + "," ) |
| 395 | resultsDB.write( str( batchSize ) + "," ) |
| 396 | resultsDB.write( str( aveLocalLatency ) + "," ) |
| 397 | resultsDB.write( str( stdLocalLatency ) + "\n" ) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 398 | resultsDB.close() |
You Wang | 6d301d4 | 2017-04-21 10:49:33 -0700 | [diff] [blame] | 399 | del main.scale[ 0 ] |