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): |
| 146 | main.ONOSbench.onosDie(main.ONOSip[i]) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 147 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 148 | main.log.info("NODE COUNT = %s" % main.numCtrls) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 149 | main.ONOSbench.createCellFile(main.ONOSbench.ip_address, |
| 150 | main.cellName, |
| 151 | main.MN1Ip, |
| 152 | main.apps, |
| 153 | main.ONOSip) |
| 154 | main.step("Apply cell to environment") |
| 155 | cellResult = main.ONOSbench.setCell(main.cellName) |
| 156 | verifyResult = main.ONOSbench.verifyCell() |
| 157 | stepResult = cellResult and verifyResult |
| 158 | utilities.assert_equals(expect=main.TRUE, |
| 159 | actual=stepResult, |
| 160 | onpass="Successfully applied cell to " + \ |
| 161 | "environment", |
| 162 | onfail="Failed to apply cell to environment ") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 163 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 164 | main.step("Creating ONOS package") |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 165 | packageResult = main.ONOSbench.buckBuild() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 166 | stepResult = packageResult |
| 167 | utilities.assert_equals(expect=main.TRUE, |
| 168 | actual=stepResult, |
| 169 | onpass="Successfully created ONOS package", |
| 170 | onfail="Failed to create ONOS package") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 171 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 172 | main.step("Uninstall ONOS package on all Nodes") |
| 173 | uninstallResult = main.TRUE |
| 174 | for i in range(int(main.numCtrls)): |
| 175 | main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i]) |
| 176 | u_result = main.ONOSbench.onosUninstall(main.ONOSip[i]) |
| 177 | utilities.assert_equals(expect=main.TRUE, actual=u_result, |
| 178 | onpass="Test step PASS", |
| 179 | onfail="Test step FAIL") |
| 180 | uninstallResult = (uninstallResult and u_result) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 181 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 182 | main.step("Install ONOS package on all Nodes") |
| 183 | installResult = main.TRUE |
| 184 | for i in range(int(main.numCtrls)): |
| 185 | main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i]) |
| 186 | i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i]) |
| 187 | utilities.assert_equals(expect=main.TRUE, actual=i_result, |
| 188 | onpass="Test step PASS", |
| 189 | onfail="Test step FAIL") |
| 190 | installResult = installResult and i_result |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 191 | |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame^] | 192 | main.step( "Set up ONOS secure SSH" ) |
| 193 | secureSshResult = main.TRUE |
| 194 | for i in range( int( main.numCtrls ) ): |
| 195 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] ) |
| 196 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 197 | onpass="Test step PASS", |
| 198 | onfail="Test step FAIL" ) |
| 199 | |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 200 | main.step( "Starting ONOS service" ) |
| 201 | stopResult = main.TRUE |
| 202 | startResult = main.TRUE |
| 203 | onosIsUp = main.TRUE |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 204 | |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 205 | for i in range( main.numCtrls ): |
| 206 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 207 | if onosIsUp == main.TRUE: |
| 208 | main.log.report( "ONOS instance is up and ready" ) |
| 209 | else: |
| 210 | main.log.report( "ONOS instance may not be up, stop and " + |
| 211 | "start ONOS again " ) |
| 212 | |
| 213 | for i in range( main.numCtrls ): |
| 214 | stopResult = stopResult and \ |
| 215 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 216 | for i in range( main.numCtrls ): |
| 217 | startResult = startResult and \ |
| 218 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 219 | stepResult = onosIsUp and stopResult and startResult |
| 220 | utilities.assert_equals( expect=main.TRUE, actual=stepResult, |
| 221 | onpass="Test step PASS", |
| 222 | onfail="Test step FAIL" ) |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame^] | 223 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 224 | time.sleep(2) |
| 225 | main.step("Start ONOS CLI on all nodes") |
| 226 | cliResult = main.TRUE |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 227 | main.step(" Start ONOS cli using thread ") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 228 | startCliResult = main.TRUE |
| 229 | pool = [] |
| 230 | main.threadID = 0 |
| 231 | for i in range(int(main.numCtrls)): |
| 232 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 233 | threadID=main.threadID, |
| 234 | name="startOnosCli", |
| 235 | args=[main.ONOSip[i]], |
| 236 | kwargs={"onosStartTimeout": main.timeout}) |
| 237 | pool.append(t) |
| 238 | t.start() |
| 239 | main.threadID = main.threadID + 1 |
| 240 | for t in pool: |
| 241 | t.join() |
| 242 | startCliResult = startCliResult and t.result |
| 243 | time.sleep(main.startUpSleep) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 244 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 245 | # configure apps |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 246 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 247 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute") |
| 248 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 249 | main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 250 | if main.flowObj: |
| 251 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 252 | "useFlowObjectives", value="true") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 253 | time.sleep( main.startUpSleep ) |
| 254 | for i in range( int( main.numCtrls ) ): |
| 255 | main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology" ) |
| 256 | main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.intent" ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 257 | # Balance Master |
| 258 | main.CLIs[0].balanceMasters() |
| 259 | if len(main.ONOSip) > 1: |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 260 | main.CLIs[0].deviceRole(main.end1[ 'name' ], main.ONOSip[0]) |
| 261 | main.CLIs[0].deviceRole(main.end2[ 'name' ], main.ONOSip[0]) |
YPZhang | 2b9b26d | 2016-06-20 16:18:29 -0700 | [diff] [blame] | 262 | time.sleep( main.setMasterSleep ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 263 | |
| 264 | def CASE2( self, main ): |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 265 | import time |
| 266 | import numpy |
| 267 | import datetime |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 268 | import json |
| 269 | # from scipy import stats |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 270 | |
| 271 | ts = time.time() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 272 | print(main.intentsList) |
| 273 | for batchSize in main.intentsList: |
| 274 | main.log.report("Intent Batch size: " + str(batchSize) + "\n ") |
| 275 | main.LatencyList = [] |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 276 | main.LatencyListTopoToFirstInstalled = [] |
| 277 | main.LatencyListFirstInstalledToLastInstalled = [] |
| 278 | main.validRun = 0 |
| 279 | main.invalidRun = 0 |
| 280 | # initial a variables to record the term of startLine in karaf logs of each node |
| 281 | main.totalLines = [] |
| 282 | for i in range( main.numCtrls ): |
| 283 | main.totalLines.append( '' ) |
| 284 | while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= 20: |
| 285 | if main.validRun >= main.warmUp: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 286 | main.log.info("================================================") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 287 | main.log.info("Starting test iteration: {} ".format( main.validRun - main.warmUp)) |
| 288 | main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun)) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 289 | main.log.info("================================================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 290 | else: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 291 | main.log.info("====================Warm Up=====================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 292 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 293 | # push intents |
| 294 | main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize, |
| 295 | offset=1, options="-i", timeout=main.timeout) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 296 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 297 | # check links and flows |
| 298 | k = 0 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 299 | main.verify = main.FALSE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 300 | linkCheck = 0 |
| 301 | flowsCheck = 0 |
| 302 | while k <= main.verifyAttempts: |
| 303 | time.sleep(main.verifySleep) |
| 304 | summary = json.loads(main.CLIs[0].summary(timeout=main.timeout)) |
| 305 | linkCheck = summary.get("links") |
| 306 | flowsCheck = summary.get("flows") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 307 | if linkCheck == main.deviceCount * 2 and flowsCheck == batchSize * (main.deviceCount - 1 ): |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 308 | main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 309 | main.verify = main.TRUE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 310 | break |
| 311 | k += 1 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 312 | if not main.verify: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 313 | main.log.warn("Links or flows number are not match!") |
| 314 | main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 315 | # bring back topology |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 316 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
| 317 | if main.validRun >= main.warmUp: |
| 318 | main.invalidRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 319 | continue |
| 320 | else: |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 321 | main.validRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 322 | continue |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 323 | # Bring link down |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 324 | main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down", |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 325 | timeout=main.timeout, showResponse=False) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 326 | main.verify = main.FALSE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 327 | k = 0 |
| 328 | topoManagerLog = "" |
| 329 | while k <= main.verifyAttempts: |
| 330 | time.sleep(main.verifySleep) |
| 331 | summary = json.loads(main.CLIs[0].summary(timeout=main.timeout)) |
| 332 | linkCheck = summary.get("links") |
| 333 | flowsCheck = summary.get("flows") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 334 | if linkCheck == (main.deviceCount - 1) * 2: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 335 | main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 336 | main.verify = main.TRUE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 337 | break |
| 338 | k += 1 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 339 | if not main.verify: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 340 | main.log.warn("Links number are not match in TopologyManager log!") |
| 341 | main.log.warn(topoManagerLog) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 342 | # bring back topology |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 343 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
| 344 | if main.validRun >= main.warmUp: |
| 345 | main.invalidRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 346 | continue |
| 347 | else: |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 348 | main.validRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 349 | continue |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 350 | # record the link romving time as the startLine |
| 351 | for i in range( main.numCtrls ): |
| 352 | logNum = main.intentRerouteLatFuncs.checkLog( main, i ) |
| 353 | main.totalLines[i] = str(main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum )) |
| 354 | main.log.info("Node " + str( i+1 ) + ": the start timestamp is " + main.totalLines[i] + " this iteration" ) |
| 355 | #Calculate values |
| 356 | lastTopologyToFirstInstalled, firstInstalledToLastInstalled, totalTime = main.intentRerouteLatFuncs.getValues( main ) |
| 357 | if totalTime == -1: |
| 358 | if main.validRun >= main.warmUp: |
| 359 | main.invalidRun += 1 |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 360 | else: |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 361 | main.validRun += 1 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 362 | continue |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 363 | else: |
| 364 | main.log.info("Get valid latency") |
| 365 | main.validRun += 1 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 366 | |
| 367 | # Verify Summary after we bring up link, and withdrawn intents |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 368 | main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up", |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 369 | timeout=main.timeout) |
| 370 | k = 0 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 371 | main.verify = main.FALSE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 372 | linkCheck = 0 |
| 373 | flowsCheck = 0 |
| 374 | while k <= main.verifyAttempts: |
| 375 | time.sleep(main.verifySleep) |
| 376 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 377 | time.sleep(1) |
| 378 | main.CLIs[0].purgeWithdrawnIntents() |
| 379 | summary = json.loads(main.CLIs[0].summary()) |
| 380 | linkCheck = summary.get("links") |
| 381 | flowsCheck = summary.get("flows") |
| 382 | intentCheck = summary.get("intents") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 383 | if linkCheck == main.deviceCount * 2 and flowsCheck == 0 and intentCheck == 0: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 384 | main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck)) |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 385 | main.verify = main.TRUE |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 386 | break |
| 387 | k += 1 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 388 | if not main.verify: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 389 | main.log.error("links, flows, or intents are not correct!") |
| 390 | main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 391 | # bring back topology |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 392 | main.intentRerouteLatFuncs.bringBackTopology( main ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 393 | continue |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 394 | main.log.info("total negative results num: " + str( main.record ) ) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 395 | |
| 396 | aveLatency = 0 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 397 | aveLatencyTopoToFirstInstalled = 0 |
| 398 | aveLatencyFirstInstalledToLastInstalled = 0 |
| 399 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 400 | stdLatency = 0 |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 401 | stdLatencyTopoToFirstInstalled = 0 |
| 402 | stdLatencyFirstInstalledToLastInstalled = 0 |
| 403 | |
| 404 | aveLatency = numpy.average( main.LatencyList ) |
| 405 | aveLatencyTopoToFirstInstalled = numpy.average( main.LatencyListTopoToFirstInstalled ) |
| 406 | aveLatencyFirstInstalledToLastInstalled = numpy.average( main.LatencyListFirstInstalledToLastInstalled ) |
| 407 | |
| 408 | stdLatency = numpy.std( main.LatencyList ) |
| 409 | stdLatencyTopoToFirstInstalled = numpy.std( main.LatencyListTopoToFirstInstalled ) |
| 410 | stdLatencyFirstInstalledToLastInstalled = numpy.std( main.LatencyListFirstInstalledToLastInstalled ) |
| 411 | |
| 412 | main.log.report( "Scale: " + str( main.numCtrls ) + " \tIntent batch: " + str( batchSize ) ) |
| 413 | main.log.report( "Total Latency average:................" + str( aveLatency ) ) |
| 414 | main.log.report( "Latency standard deviation:..........." + str( stdLatency ) ) |
| 415 | main.log.report( "Last Topology to first installed Latency average:................." + str( aveLatencyTopoToFirstInstalled ) ) |
| 416 | main.log.report( "Last Topology to first installed Latency standard deviation:......" + str( stdLatencyTopoToFirstInstalled ) ) |
| 417 | main.log.report( "First installed to last installed Latency average:................" + str( aveLatencyFirstInstalledToLastInstalled ) ) |
| 418 | main.log.report( "First installed to last installed Latency standard deviation:....." + str( stdLatencyFirstInstalledToLastInstalled ) ) |
| 419 | main.log.report( "________________________________________________________" ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 420 | |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 421 | if not (numpy.isnan(aveLatency) or numpy.isnan(stdLatency)): |
| 422 | # check if got NaN for result |
| 423 | resultsDB = open(main.dbFileName, "a") |
| 424 | resultsDB.write("'" + main.commit + "',") |
| 425 | resultsDB.write(str(main.numCtrls) + ",") |
| 426 | resultsDB.write(str(batchSize) + ",") |
| 427 | resultsDB.write(str(aveLatency) + ",") |
Chiyu Cheng | ec63bde | 2016-11-17 18:11:36 -0800 | [diff] [blame] | 428 | resultsDB.write(str(stdLatency) + ",") |
| 429 | resultsDB.write(str(aveLatencyTopoToFirstInstalled) + ",") |
| 430 | resultsDB.write(str(stdLatencyTopoToFirstInstalled) + ",") |
| 431 | resultsDB.write(str(aveLatencyFirstInstalledToLastInstalled) + ",") |
| 432 | resultsDB.write(str(stdLatencyFirstInstalledToLastInstalled) + "\n") |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 433 | resultsDB.close() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 434 | del main.scale[0] |