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 | |
| 57 | main.step("Building ONOS branch: " + gitBranch) |
| 58 | stepResult = main.ONOSbench.cleanInstall(skipTest=True) |
| 59 | utilities.assert_equals(expect=main.TRUE, |
| 60 | actual=stepResult, |
| 61 | onpass="Successfully build onos.", |
| 62 | onfail="Failed to build onos. Exiting test...") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 63 | if not stepResult: |
| 64 | main.exit() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 65 | |
| 66 | else: |
| 67 | main.log.warn("Skipped pulling onos and Skipped building ONOS") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 68 | main.onosIp = main.ONOSbench.getOnosIps() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 69 | main.apps = main.params['ENV']['cellApps'] |
| 70 | main.BENCHUser = main.params['BENCH']['user'] |
| 71 | main.BENCHIp = main.params['BENCH']['ip1'] |
| 72 | main.MN1Ip = main.params['MN']['ip1'] |
| 73 | main.maxNodes = int(main.params['max']) |
| 74 | main.skipMvn = main.params['TEST']['skipCleanInstall'] |
| 75 | main.cellName = main.params['ENV']['cellName'] |
| 76 | main.scale = (main.params['SCALE']).split(",") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 77 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 78 | main.startUpSleep = int(main.params['SLEEP']['startup']) |
| 79 | main.installSleep = int(main.params['SLEEP']['install']) |
| 80 | main.verifySleep = int(main.params['SLEEP']['verify']) |
YPZhang | 2b9b26d | 2016-06-20 16:18:29 -0700 | [diff] [blame] | 81 | main.setMasterSleep = int(main.params['SLEEP']['setmaster']) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 82 | main.verifyAttempts = int(main.params['ATTEMPTS']['verify']) |
| 83 | main.sampleSize = int(main.params['TEST']['sampleSize']) |
| 84 | main.warmUp = int(main.params['TEST']['warmUp']) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 85 | main.ingress = main.params['TEST']['ingress'] |
| 86 | main.egress = main.params['TEST']['egress'] |
| 87 | main.debug = main.params['TEST']['debug'] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 88 | main.flowObj = main.params['TEST']['flowObj'] |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 89 | main.deviceCount = int(main.params['TEST']['deviceCount']) |
| 90 | main.end1 = main.params['TEST']['end1'] |
| 91 | main.end2 = main.params['TEST']['end2'] |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 92 | main.searchTerm = main.params['SEARCHTERM'] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 93 | if main.flowObj == "True": |
| 94 | main.flowObj = True |
| 95 | main.dbFileName = main.params['DATABASE']['dbFlowObj'] |
YPZhang | 3b5a78f | 2016-07-14 10:43:33 -0700 | [diff] [blame] | 96 | main.intentsList = (main.params['TEST']['FObjintents']).split(",") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 97 | else: |
| 98 | main.flowObj = False |
| 99 | main.dbFileName = main.params['DATABASE']['dbName'] |
YPZhang | 3b5a78f | 2016-07-14 10:43:33 -0700 | [diff] [blame] | 100 | main.intentsList = (main.params['TEST']['intents']).split(",") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 101 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 102 | for i in range(0, len(main.intentsList)): |
| 103 | main.intentsList[i] = int(main.intentsList[i]) |
| 104 | # Create DataBase file |
| 105 | main.log.info("Create Database file " + main.dbFileName) |
| 106 | resultsDB = open(main.dbFileName, "w+") |
| 107 | resultsDB.close() |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 108 | file1 = main.params[ "DEPENDENCY" ][ "FILE1" ] |
| 109 | main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ] |
| 110 | main.intentRerouteLatFuncs = imp.load_source(file1, main.dependencyPath + file1 + ".py") |
| 111 | |
| 112 | main.record = 0 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 113 | |
| 114 | def CASE1( self, main ): |
| 115 | ''' |
| 116 | clean up test environment and set up |
| 117 | ''' |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 118 | import time |
| 119 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 120 | main.log.info("Get ONOS cluster IP") |
| 121 | print(main.scale) |
| 122 | main.numCtrls = int(main.scale[0]) |
| 123 | main.ONOSip = [] |
| 124 | main.maxNumBatch = 0 |
| 125 | main.AllONOSip = main.ONOSbench.getOnosIps() |
| 126 | for i in range(main.numCtrls): |
| 127 | main.ONOSip.append(main.AllONOSip[i]) |
| 128 | main.log.info(main.ONOSip) |
| 129 | main.CLIs = [] |
| 130 | main.log.info("Creating list of ONOS cli handles") |
| 131 | for i in range(main.numCtrls): |
| 132 | main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1))) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 133 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 134 | if not main.CLIs: |
| 135 | main.log.error("Failed to create the list of ONOS cli handles") |
| 136 | main.cleanup() |
| 137 | main.exit() |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 138 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 139 | main.commit = main.ONOSbench.getVersion(report=True) |
| 140 | main.commit = main.commit.split(" ")[1] |
| 141 | main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls) |
| 142 | main.log.info("Safety check, killing all ONOS processes" + |
| 143 | " before initiating environment setup") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 144 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 145 | for i in range(main.numCtrls): |
You Wang | b98a9fa | 2017-02-15 17:27:42 -0800 | [diff] [blame] | 146 | main.ONOSbench.onosStop(main.ONOSip[i]) |
| 147 | main.ONOSbench.onosKill(main.ONOSip[i]) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 148 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 149 | main.log.info("NODE COUNT = %s" % main.numCtrls) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 150 | main.ONOSbench.createCellFile(main.ONOSbench.ip_address, |
| 151 | main.cellName, |
| 152 | main.MN1Ip, |
| 153 | main.apps, |
| 154 | main.ONOSip) |
| 155 | main.step("Apply cell to environment") |
| 156 | cellResult = main.ONOSbench.setCell(main.cellName) |
| 157 | verifyResult = main.ONOSbench.verifyCell() |
| 158 | stepResult = cellResult and verifyResult |
| 159 | utilities.assert_equals(expect=main.TRUE, |
| 160 | actual=stepResult, |
| 161 | onpass="Successfully applied cell to " + \ |
| 162 | "environment", |
| 163 | onfail="Failed to apply cell to environment ") |
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("Creating ONOS package") |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 166 | packageResult = main.ONOSbench.buckBuild() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 167 | stepResult = packageResult |
| 168 | utilities.assert_equals(expect=main.TRUE, |
| 169 | actual=stepResult, |
| 170 | onpass="Successfully created ONOS package", |
| 171 | onfail="Failed to create ONOS package") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 172 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 173 | main.step("Uninstall ONOS package on all Nodes") |
| 174 | uninstallResult = main.TRUE |
| 175 | for i in range(int(main.numCtrls)): |
| 176 | main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i]) |
| 177 | u_result = main.ONOSbench.onosUninstall(main.ONOSip[i]) |
| 178 | utilities.assert_equals(expect=main.TRUE, actual=u_result, |
| 179 | onpass="Test step PASS", |
| 180 | onfail="Test step FAIL") |
| 181 | uninstallResult = (uninstallResult and u_result) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 182 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 183 | main.step("Install ONOS package on all Nodes") |
| 184 | installResult = main.TRUE |
| 185 | for i in range(int(main.numCtrls)): |
| 186 | main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i]) |
| 187 | i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i]) |
| 188 | utilities.assert_equals(expect=main.TRUE, actual=i_result, |
| 189 | onpass="Test step PASS", |
| 190 | onfail="Test step FAIL") |
| 191 | installResult = installResult and i_result |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 192 | |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 193 | main.step( "Set up ONOS secure SSH" ) |
| 194 | secureSshResult = main.TRUE |
| 195 | for i in range( int( main.numCtrls ) ): |
| 196 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] ) |
| 197 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 198 | onpass="Test step PASS", |
| 199 | onfail="Test step FAIL" ) |
| 200 | |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 201 | main.step( "Starting ONOS service" ) |
| 202 | stopResult = main.TRUE |
| 203 | startResult = main.TRUE |
| 204 | onosIsUp = main.TRUE |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 205 | |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 206 | for i in range( main.numCtrls ): |
| 207 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 208 | if onosIsUp == main.TRUE: |
| 209 | main.log.report( "ONOS instance is up and ready" ) |
| 210 | else: |
| 211 | main.log.report( "ONOS instance may not be up, stop and " + |
| 212 | "start ONOS again " ) |
| 213 | |
| 214 | for i in range( main.numCtrls ): |
| 215 | stopResult = stopResult and \ |
| 216 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 217 | for i in range( main.numCtrls ): |
| 218 | startResult = startResult and \ |
| 219 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 220 | stepResult = onosIsUp and stopResult and startResult |
| 221 | utilities.assert_equals( expect=main.TRUE, actual=stepResult, |
| 222 | onpass="Test step PASS", |
| 223 | onfail="Test step FAIL" ) |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 224 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 225 | time.sleep(2) |
| 226 | main.step("Start ONOS CLI on all nodes") |
| 227 | cliResult = main.TRUE |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 228 | main.step(" Start ONOS cli using thread ") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 229 | startCliResult = main.TRUE |
| 230 | pool = [] |
| 231 | main.threadID = 0 |
| 232 | for i in range(int(main.numCtrls)): |
| 233 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 234 | threadID=main.threadID, |
| 235 | name="startOnosCli", |
| 236 | args=[main.ONOSip[i]], |
| 237 | kwargs={"onosStartTimeout": main.timeout}) |
| 238 | pool.append(t) |
| 239 | t.start() |
| 240 | main.threadID = main.threadID + 1 |
| 241 | for t in pool: |
| 242 | t.join() |
| 243 | startCliResult = startCliResult and t.result |
| 244 | time.sleep(main.startUpSleep) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 245 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 246 | # configure apps |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 247 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 248 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute") |
| 249 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 250 | main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 251 | if main.flowObj: |
| 252 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 253 | "useFlowObjectives", value="true") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 254 | time.sleep( main.startUpSleep ) |
| 255 | for i in range( int( main.numCtrls ) ): |
| 256 | main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology" ) |
| 257 | main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.intent" ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 258 | # Balance Master |
| 259 | main.CLIs[0].balanceMasters() |
| 260 | if len(main.ONOSip) > 1: |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 261 | main.CLIs[0].deviceRole(main.end1[ 'name' ], main.ONOSip[0]) |
| 262 | main.CLIs[0].deviceRole(main.end2[ 'name' ], main.ONOSip[0]) |
YPZhang | 2b9b26d | 2016-06-20 16:18:29 -0700 | [diff] [blame] | 263 | time.sleep( main.setMasterSleep ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 264 | |
| 265 | def CASE2( self, main ): |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 266 | import time |
| 267 | import numpy |
| 268 | import datetime |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 269 | import json |
| 270 | # from scipy import stats |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 271 | |
| 272 | ts = time.time() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 273 | print(main.intentsList) |
| 274 | for batchSize in main.intentsList: |
| 275 | main.log.report("Intent Batch size: " + str(batchSize) + "\n ") |
| 276 | main.LatencyList = [] |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 277 | main.LatencyListTopoToFirstInstalled = [] |
| 278 | main.LatencyListFirstInstalledToLastInstalled = [] |
| 279 | main.validRun = 0 |
| 280 | main.invalidRun = 0 |
| 281 | # initial a variables to record the term of startLine in karaf logs of each node |
| 282 | main.totalLines = [] |
| 283 | for i in range( main.numCtrls ): |
| 284 | main.totalLines.append( '' ) |
| 285 | while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= 20: |
| 286 | if main.validRun >= main.warmUp: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 287 | main.log.info("================================================") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 288 | main.log.info("Starting test iteration: {} ".format( main.validRun - main.warmUp)) |
| 289 | main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun)) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 290 | main.log.info("================================================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 291 | else: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 292 | main.log.info("====================Warm Up=====================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 293 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 294 | # push intents |
| 295 | main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize, |
| 296 | offset=1, options="-i", timeout=main.timeout) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 297 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 298 | # check links and flows |
| 299 | k = 0 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 300 | main.verify = main.FALSE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 301 | linkCheck = 0 |
| 302 | flowsCheck = 0 |
| 303 | while k <= main.verifyAttempts: |
| 304 | time.sleep(main.verifySleep) |
| 305 | summary = json.loads(main.CLIs[0].summary(timeout=main.timeout)) |
| 306 | linkCheck = summary.get("links") |
| 307 | flowsCheck = summary.get("flows") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 308 | if linkCheck == main.deviceCount * 2 and flowsCheck == batchSize * (main.deviceCount - 1 ): |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 309 | main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 310 | main.verify = main.TRUE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 311 | break |
| 312 | k += 1 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 313 | if not main.verify: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 314 | main.log.warn("Links or flows number are not match!") |
| 315 | main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 316 | # bring back topology |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 317 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
| 318 | if main.validRun >= main.warmUp: |
| 319 | main.invalidRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 320 | continue |
| 321 | else: |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 322 | main.validRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 323 | continue |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 324 | # Bring link down |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 325 | main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down", |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 326 | timeout=main.timeout, showResponse=False) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 327 | main.verify = main.FALSE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 328 | k = 0 |
| 329 | topoManagerLog = "" |
| 330 | while k <= main.verifyAttempts: |
| 331 | time.sleep(main.verifySleep) |
| 332 | summary = json.loads(main.CLIs[0].summary(timeout=main.timeout)) |
| 333 | linkCheck = summary.get("links") |
| 334 | flowsCheck = summary.get("flows") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 335 | if linkCheck == (main.deviceCount - 1) * 2: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 336 | main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 337 | main.verify = main.TRUE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 338 | break |
| 339 | k += 1 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 340 | if not main.verify: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 341 | main.log.warn("Links number are not match in TopologyManager log!") |
| 342 | main.log.warn(topoManagerLog) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 343 | # bring back topology |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 344 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
| 345 | if main.validRun >= main.warmUp: |
| 346 | main.invalidRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 347 | continue |
| 348 | else: |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 349 | main.validRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 350 | continue |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 351 | # record the link romving time as the startLine |
| 352 | for i in range( main.numCtrls ): |
| 353 | logNum = main.intentRerouteLatFuncs.checkLog( main, i ) |
| 354 | main.totalLines[i] = str(main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum )) |
| 355 | main.log.info("Node " + str( i+1 ) + ": the start timestamp is " + main.totalLines[i] + " this iteration" ) |
| 356 | #Calculate values |
| 357 | lastTopologyToFirstInstalled, firstInstalledToLastInstalled, totalTime = main.intentRerouteLatFuncs.getValues( main ) |
| 358 | if totalTime == -1: |
| 359 | if main.validRun >= main.warmUp: |
| 360 | main.invalidRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 361 | else: |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 362 | main.validRun += 1 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 363 | continue |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 364 | else: |
| 365 | main.log.info("Get valid latency") |
| 366 | main.validRun += 1 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 367 | |
| 368 | # Verify Summary after we bring up link, and withdrawn intents |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 369 | main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up", |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 370 | timeout=main.timeout) |
| 371 | k = 0 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 372 | main.verify = main.FALSE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 373 | linkCheck = 0 |
| 374 | flowsCheck = 0 |
| 375 | while k <= main.verifyAttempts: |
| 376 | time.sleep(main.verifySleep) |
| 377 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 378 | time.sleep(1) |
| 379 | main.CLIs[0].purgeWithdrawnIntents() |
| 380 | summary = json.loads(main.CLIs[0].summary()) |
| 381 | linkCheck = summary.get("links") |
| 382 | flowsCheck = summary.get("flows") |
| 383 | intentCheck = summary.get("intents") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 384 | if linkCheck == main.deviceCount * 2 and flowsCheck == 0 and intentCheck == 0: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 385 | main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck)) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 386 | main.verify = main.TRUE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 387 | break |
| 388 | k += 1 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 389 | if not main.verify: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 390 | main.log.error("links, flows, or intents are not correct!") |
| 391 | main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 392 | # bring back topology |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 393 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 394 | continue |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 395 | main.log.info("total negative results num: " + str( main.record ) ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 396 | |
| 397 | aveLatency = 0 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 398 | aveLatencyTopoToFirstInstalled = 0 |
| 399 | aveLatencyFirstInstalledToLastInstalled = 0 |
| 400 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 401 | stdLatency = 0 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 402 | stdLatencyTopoToFirstInstalled = 0 |
| 403 | stdLatencyFirstInstalledToLastInstalled = 0 |
| 404 | |
| 405 | aveLatency = numpy.average( main.LatencyList ) |
| 406 | aveLatencyTopoToFirstInstalled = numpy.average( main.LatencyListTopoToFirstInstalled ) |
| 407 | aveLatencyFirstInstalledToLastInstalled = numpy.average( main.LatencyListFirstInstalledToLastInstalled ) |
| 408 | |
| 409 | stdLatency = numpy.std( main.LatencyList ) |
| 410 | stdLatencyTopoToFirstInstalled = numpy.std( main.LatencyListTopoToFirstInstalled ) |
| 411 | stdLatencyFirstInstalledToLastInstalled = numpy.std( main.LatencyListFirstInstalledToLastInstalled ) |
| 412 | |
| 413 | main.log.report( "Scale: " + str( main.numCtrls ) + " \tIntent batch: " + str( batchSize ) ) |
| 414 | main.log.report( "Total Latency average:................" + str( aveLatency ) ) |
| 415 | main.log.report( "Latency standard deviation:..........." + str( stdLatency ) ) |
| 416 | main.log.report( "Last Topology to first installed Latency average:................." + str( aveLatencyTopoToFirstInstalled ) ) |
| 417 | main.log.report( "Last Topology to first installed Latency standard deviation:......" + str( stdLatencyTopoToFirstInstalled ) ) |
| 418 | main.log.report( "First installed to last installed Latency average:................" + str( aveLatencyFirstInstalledToLastInstalled ) ) |
| 419 | main.log.report( "First installed to last installed Latency standard deviation:....." + str( stdLatencyFirstInstalledToLastInstalled ) ) |
| 420 | main.log.report( "________________________________________________________" ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 421 | |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 422 | if not (numpy.isnan(aveLatency) or numpy.isnan(stdLatency)): |
| 423 | # check if got NaN for result |
| 424 | resultsDB = open(main.dbFileName, "a") |
| 425 | resultsDB.write("'" + main.commit + "',") |
| 426 | resultsDB.write(str(main.numCtrls) + ",") |
| 427 | resultsDB.write(str(batchSize) + ",") |
| 428 | resultsDB.write(str(aveLatency) + ",") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 429 | resultsDB.write(str(stdLatency) + ",") |
| 430 | resultsDB.write(str(aveLatencyTopoToFirstInstalled) + ",") |
| 431 | resultsDB.write(str(stdLatencyTopoToFirstInstalled) + ",") |
| 432 | resultsDB.write(str(aveLatencyFirstInstalledToLastInstalled) + ",") |
| 433 | resultsDB.write(str(stdLatencyFirstInstalledToLastInstalled) + "\n") |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 434 | resultsDB.close() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 435 | del main.scale[0] |