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 | |
| 17 | class SCPFintentRerouteLat: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 18 | def __init__(self): |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 19 | self.default = '' |
| 20 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 21 | def CASE0( self, main ): |
| 22 | ''' |
| 23 | - GIT |
| 24 | - BUILDING ONOS |
| 25 | Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| 26 | This step is usually skipped. Because in a Jenkins driven automated |
| 27 | test env. We want Jenkins jobs to pull&build for flexibility to handle |
| 28 | different versions of ONOS. |
| 29 | - Construct tests variables |
| 30 | ''' |
| 31 | gitPull = main.params['GIT']['gitPull'] |
| 32 | gitBranch = main.params['GIT']['gitBranch'] |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 33 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 34 | main.case("Pull onos branch and build onos on Teststation.") |
| 35 | |
| 36 | if gitPull == 'True': |
| 37 | main.step("Git Checkout ONOS branch: " + gitBranch) |
| 38 | stepResult = main.ONOSbench.gitCheckout(branch=gitBranch) |
| 39 | utilities.assert_equals(expect=main.TRUE, |
| 40 | actual=stepResult, |
| 41 | onpass="Successfully checkout onos branch.", |
| 42 | onfail="Failed to checkout onos branch. Exiting test...") |
| 43 | if not stepResult: main.exit() |
| 44 | |
| 45 | main.step("Git Pull on ONOS branch:" + gitBranch) |
| 46 | stepResult = main.ONOSbench.gitPull() |
| 47 | utilities.assert_equals(expect=main.TRUE, |
| 48 | actual=stepResult, |
| 49 | onpass="Successfully pull onos. ", |
| 50 | onfail="Failed to pull onos. Exiting test ...") |
| 51 | if not stepResult: main.exit() |
| 52 | |
| 53 | main.step("Building ONOS branch: " + gitBranch) |
| 54 | stepResult = main.ONOSbench.cleanInstall(skipTest=True) |
| 55 | utilities.assert_equals(expect=main.TRUE, |
| 56 | actual=stepResult, |
| 57 | onpass="Successfully build onos.", |
| 58 | onfail="Failed to build onos. Exiting test...") |
| 59 | if not stepResult: main.exit() |
| 60 | |
| 61 | else: |
| 62 | main.log.warn("Skipped pulling onos and Skipped building ONOS") |
| 63 | |
| 64 | main.apps = main.params['ENV']['cellApps'] |
| 65 | main.BENCHUser = main.params['BENCH']['user'] |
| 66 | main.BENCHIp = main.params['BENCH']['ip1'] |
| 67 | main.MN1Ip = main.params['MN']['ip1'] |
| 68 | main.maxNodes = int(main.params['max']) |
| 69 | main.skipMvn = main.params['TEST']['skipCleanInstall'] |
| 70 | main.cellName = main.params['ENV']['cellName'] |
| 71 | main.scale = (main.params['SCALE']).split(",") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 72 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 73 | main.startUpSleep = int(main.params['SLEEP']['startup']) |
| 74 | main.installSleep = int(main.params['SLEEP']['install']) |
| 75 | main.verifySleep = int(main.params['SLEEP']['verify']) |
YPZhang | 2b9b26d | 2016-06-20 16:18:29 -0700 | [diff] [blame] | 76 | main.setMasterSleep = int(main.params['SLEEP']['setmaster']) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 77 | main.verifyAttempts = int(main.params['ATTEMPTS']['verify']) |
| 78 | main.sampleSize = int(main.params['TEST']['sampleSize']) |
| 79 | main.warmUp = int(main.params['TEST']['warmUp']) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 80 | main.ingress = main.params['TEST']['ingress'] |
| 81 | main.egress = main.params['TEST']['egress'] |
| 82 | main.debug = main.params['TEST']['debug'] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 83 | main.flowObj = main.params['TEST']['flowObj'] |
| 84 | |
| 85 | if main.flowObj == "True": |
| 86 | main.flowObj = True |
| 87 | main.dbFileName = main.params['DATABASE']['dbFlowObj'] |
YPZhang | 3b5a78f | 2016-07-14 10:43:33 -0700 | [diff] [blame] | 88 | main.intentsList = (main.params['TEST']['FObjintents']).split(",") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 89 | else: |
| 90 | main.flowObj = False |
| 91 | main.dbFileName = main.params['DATABASE']['dbName'] |
YPZhang | 3b5a78f | 2016-07-14 10:43:33 -0700 | [diff] [blame] | 92 | main.intentsList = (main.params['TEST']['intents']).split(",") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 93 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 94 | for i in range(0, len(main.intentsList)): |
| 95 | main.intentsList[i] = int(main.intentsList[i]) |
| 96 | # Create DataBase file |
| 97 | main.log.info("Create Database file " + main.dbFileName) |
| 98 | resultsDB = open(main.dbFileName, "w+") |
| 99 | resultsDB.close() |
| 100 | |
| 101 | def CASE1( self, main ): |
| 102 | ''' |
| 103 | clean up test environment and set up |
| 104 | ''' |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 105 | import time |
| 106 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 107 | main.log.info("Get ONOS cluster IP") |
| 108 | print(main.scale) |
| 109 | main.numCtrls = int(main.scale[0]) |
| 110 | main.ONOSip = [] |
| 111 | main.maxNumBatch = 0 |
| 112 | main.AllONOSip = main.ONOSbench.getOnosIps() |
| 113 | for i in range(main.numCtrls): |
| 114 | main.ONOSip.append(main.AllONOSip[i]) |
| 115 | main.log.info(main.ONOSip) |
| 116 | main.CLIs = [] |
| 117 | main.log.info("Creating list of ONOS cli handles") |
| 118 | for i in range(main.numCtrls): |
| 119 | main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1))) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 120 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 121 | if not main.CLIs: |
| 122 | main.log.error("Failed to create the list of ONOS cli handles") |
| 123 | main.cleanup() |
| 124 | main.exit() |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 125 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 126 | main.commit = main.ONOSbench.getVersion(report=True) |
| 127 | main.commit = main.commit.split(" ")[1] |
| 128 | main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls) |
| 129 | main.log.info("Safety check, killing all ONOS processes" + |
| 130 | " before initiating environment setup") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 131 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 132 | for i in range(main.numCtrls): |
| 133 | main.ONOSbench.onosDie(main.ONOSip[i]) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 134 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 135 | main.log.info("NODE COUNT = %s" % main.numCtrls) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 136 | main.ONOSbench.createCellFile(main.ONOSbench.ip_address, |
| 137 | main.cellName, |
| 138 | main.MN1Ip, |
| 139 | main.apps, |
| 140 | main.ONOSip) |
| 141 | main.step("Apply cell to environment") |
| 142 | cellResult = main.ONOSbench.setCell(main.cellName) |
| 143 | verifyResult = main.ONOSbench.verifyCell() |
| 144 | stepResult = cellResult and verifyResult |
| 145 | utilities.assert_equals(expect=main.TRUE, |
| 146 | actual=stepResult, |
| 147 | onpass="Successfully applied cell to " + \ |
| 148 | "environment", |
| 149 | onfail="Failed to apply cell to environment ") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 150 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 151 | main.step("Creating ONOS package") |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame^] | 152 | packageResult = main.ONOSbench.buckBuild() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 153 | stepResult = packageResult |
| 154 | utilities.assert_equals(expect=main.TRUE, |
| 155 | actual=stepResult, |
| 156 | onpass="Successfully created ONOS package", |
| 157 | onfail="Failed to create ONOS package") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 158 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 159 | main.step("Uninstall ONOS package on all Nodes") |
| 160 | uninstallResult = main.TRUE |
| 161 | for i in range(int(main.numCtrls)): |
| 162 | main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i]) |
| 163 | u_result = main.ONOSbench.onosUninstall(main.ONOSip[i]) |
| 164 | utilities.assert_equals(expect=main.TRUE, actual=u_result, |
| 165 | onpass="Test step PASS", |
| 166 | onfail="Test step FAIL") |
| 167 | uninstallResult = (uninstallResult and u_result) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 168 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 169 | main.step("Install ONOS package on all Nodes") |
| 170 | installResult = main.TRUE |
| 171 | for i in range(int(main.numCtrls)): |
| 172 | main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i]) |
| 173 | i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i]) |
| 174 | utilities.assert_equals(expect=main.TRUE, actual=i_result, |
| 175 | onpass="Test step PASS", |
| 176 | onfail="Test step FAIL") |
| 177 | installResult = installResult and i_result |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 178 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 179 | main.step("Verify ONOS nodes UP status") |
| 180 | statusResult = main.TRUE |
| 181 | for i in range(int(main.numCtrls)): |
| 182 | main.log.info("ONOS Node " + main.ONOSip[i] + " status:") |
| 183 | onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i]) |
| 184 | utilities.assert_equals(expect=main.TRUE, actual=onos_status, |
| 185 | onpass="Test step PASS", |
| 186 | onfail="Test step FAIL") |
| 187 | statusResult = (statusResult and onos_status) |
| 188 | time.sleep(2) |
| 189 | main.step("Start ONOS CLI on all nodes") |
| 190 | cliResult = main.TRUE |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 191 | main.step(" Start ONOS cli using thread ") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 192 | startCliResult = main.TRUE |
| 193 | pool = [] |
| 194 | main.threadID = 0 |
| 195 | for i in range(int(main.numCtrls)): |
| 196 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 197 | threadID=main.threadID, |
| 198 | name="startOnosCli", |
| 199 | args=[main.ONOSip[i]], |
| 200 | kwargs={"onosStartTimeout": main.timeout}) |
| 201 | pool.append(t) |
| 202 | t.start() |
| 203 | main.threadID = main.threadID + 1 |
| 204 | for t in pool: |
| 205 | t.join() |
| 206 | startCliResult = startCliResult and t.result |
| 207 | time.sleep(main.startUpSleep) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 208 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 209 | # configure apps |
| 210 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8) |
| 211 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute") |
| 212 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 213 | main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 214 | if main.flowObj: |
| 215 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 216 | "useFlowObjectives", value="true") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 217 | time.sleep(main.startUpSleep) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 218 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 219 | # Balance Master |
| 220 | main.CLIs[0].balanceMasters() |
| 221 | if len(main.ONOSip) > 1: |
| 222 | main.CLIs[0].deviceRole("null:0000000000000003", main.ONOSip[0]) |
| 223 | main.CLIs[0].deviceRole("null:0000000000000004", main.ONOSip[0]) |
YPZhang | 2b9b26d | 2016-06-20 16:18:29 -0700 | [diff] [blame] | 224 | time.sleep( main.setMasterSleep ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 225 | |
| 226 | def CASE2( self, main ): |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 227 | import time |
| 228 | import numpy |
| 229 | import datetime |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 230 | import json |
| 231 | # from scipy import stats |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 232 | |
| 233 | ts = time.time() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 234 | print(main.intentsList) |
| 235 | for batchSize in main.intentsList: |
| 236 | main.log.report("Intent Batch size: " + str(batchSize) + "\n ") |
| 237 | main.LatencyList = [] |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 238 | validRun = 0 |
| 239 | invalidRun = 0 |
| 240 | while validRun <= main.warmUp + main.sampleSize and invalidRun <= 20: |
| 241 | if validRun >= main.warmUp: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 242 | main.log.info("================================================") |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 243 | main.log.info("Starting test iteration: {} ".format(validRun - main.warmUp)) |
| 244 | main.log.info("Total iteration: {}".format(validRun + invalidRun)) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 245 | main.log.info("================================================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 246 | else: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 247 | main.log.info("====================Warm Up=====================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 248 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 249 | # push intents |
| 250 | main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize, |
| 251 | offset=1, options="-i", timeout=main.timeout) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 252 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 253 | # check links and flows |
| 254 | k = 0 |
| 255 | verify = main.FALSE |
| 256 | linkCheck = 0 |
| 257 | flowsCheck = 0 |
| 258 | while k <= main.verifyAttempts: |
| 259 | time.sleep(main.verifySleep) |
| 260 | summary = json.loads(main.CLIs[0].summary(timeout=main.timeout)) |
| 261 | linkCheck = summary.get("links") |
| 262 | flowsCheck = summary.get("flows") |
| 263 | if linkCheck == 16 and flowsCheck == batchSize * 7: |
| 264 | main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
| 265 | verify = main.TRUE |
| 266 | break |
| 267 | k += 1 |
| 268 | if not verify: |
| 269 | main.log.warn("Links or flows number are not match!") |
| 270 | main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 271 | # bring back topology |
| 272 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 273 | time.sleep(1) |
| 274 | main.CLIs[0].purgeWithdrawnIntents() |
| 275 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0) |
| 276 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false") |
| 277 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8) |
| 278 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 279 | if validRun >= main.warmUp: |
| 280 | invalidRun += 1 |
| 281 | continue |
| 282 | else: |
| 283 | validRun += 1 |
| 284 | continue |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 285 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 286 | # Bring link down |
| 287 | main.CLIs[0].link("0000000000000004/1", "0000000000000003/2", "down", |
| 288 | timeout=main.timeout, showResponse=False) |
| 289 | verify = main.FALSE |
| 290 | k = 0 |
| 291 | topoManagerLog = "" |
| 292 | while k <= main.verifyAttempts: |
| 293 | time.sleep(main.verifySleep) |
| 294 | summary = json.loads(main.CLIs[0].summary(timeout=main.timeout)) |
| 295 | linkCheck = summary.get("links") |
| 296 | flowsCheck = summary.get("flows") |
| 297 | if linkCheck == 14: |
| 298 | main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
| 299 | verify = main.TRUE |
| 300 | break |
| 301 | k += 1 |
| 302 | if not verify: |
| 303 | main.log.warn("Links number are not match in TopologyManager log!") |
| 304 | main.log.warn(topoManagerLog) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 305 | # bring back topology |
| 306 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 307 | time.sleep(1) |
| 308 | main.CLIs[0].purgeWithdrawnIntents() |
| 309 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0) |
| 310 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false") |
| 311 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8) |
| 312 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 313 | if validRun >= main.warmUp: |
| 314 | invalidRun += 1 |
| 315 | continue |
| 316 | else: |
| 317 | validRun += 1 |
| 318 | continue |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 319 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 320 | try: |
| 321 | # expect twice to clean the pexpect buffer |
| 322 | main.ONOSbench.handle.sendline("") |
| 323 | main.ONOSbench.handle.expect("\$") |
| 324 | main.ONOSbench.handle.expect("\$") |
| 325 | # send line by using bench, can't use driver because pexpect buffer problem |
| 326 | cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1" |
| 327 | main.ONOSbench.handle.sendline(cmd) |
| 328 | time.sleep(1) |
| 329 | main.ONOSbench.handle.expect(":~") |
| 330 | topoManagerLog = main.ONOSbench.handle.before |
| 331 | topoManagerLogTemp = topoManagerLog.splitlines() |
| 332 | # To make sure we get correct topology log |
| 333 | for lines in topoManagerLogTemp: |
| 334 | if "creationTime" in lines: |
| 335 | topoManagerLog = lines |
| 336 | main.log.info("Topology Manager log:") |
| 337 | print(topoManagerLog) |
| 338 | cutTimestamp = float(topoManagerLog.split("creationTime=")[1].split(",")[0]) |
| 339 | except: |
| 340 | main.log.error("Topology Log is not correct!") |
| 341 | print(topoManagerLog) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 342 | # bring back topology |
| 343 | verify = main.FALSE |
| 344 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 345 | time.sleep(1) |
| 346 | main.CLIs[0].purgeWithdrawnIntents() |
| 347 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0) |
| 348 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false") |
| 349 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8) |
| 350 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 351 | if validRun >= main.warmUp: |
| 352 | invalidRun += 1 |
| 353 | else: |
| 354 | validRun += 1 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 355 | # If we got wrong Topology log, we should skip this iteration, and continue for next one |
| 356 | continue |
| 357 | |
| 358 | installedTemp = [] |
| 359 | time.sleep(1) |
| 360 | for cli in main.CLIs: |
| 361 | tempJson = json.loads(cli.intentsEventsMetrics()) |
| 362 | Installedtime = tempJson.get('intentInstalledTimestamp').get('value') |
| 363 | installedTemp.append(float(Installedtime)) |
| 364 | for i in range(0, len(installedTemp)): |
| 365 | main.log.info("ONOS Node {} Installed Time stemp: {}".format((i + 1), installedTemp[i])) |
| 366 | maxInstallTime = float(max(installedTemp)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 367 | if validRun >= main.warmUp and verify: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 368 | main.log.info("Installed time stemp: {0:f}".format(maxInstallTime)) |
| 369 | main.log.info("CutTimestamp: {0:f}".format(cutTimestamp)) |
| 370 | # Both timeStemps are milliseconds |
| 371 | main.log.info("Latency: {0:f}".format(float(maxInstallTime - cutTimestamp))) |
| 372 | main.LatencyList.append(float(maxInstallTime - cutTimestamp)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 373 | # We get valid latency, validRun + 1 |
| 374 | validRun += 1 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 375 | |
| 376 | # Verify Summary after we bring up link, and withdrawn intents |
| 377 | main.CLIs[0].link("0000000000000004/1", "0000000000000003/2", "up", |
| 378 | timeout=main.timeout) |
| 379 | k = 0 |
| 380 | verify = main.FALSE |
| 381 | linkCheck = 0 |
| 382 | flowsCheck = 0 |
| 383 | while k <= main.verifyAttempts: |
| 384 | time.sleep(main.verifySleep) |
| 385 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 386 | time.sleep(1) |
| 387 | main.CLIs[0].purgeWithdrawnIntents() |
| 388 | summary = json.loads(main.CLIs[0].summary()) |
| 389 | linkCheck = summary.get("links") |
| 390 | flowsCheck = summary.get("flows") |
| 391 | intentCheck = summary.get("intents") |
| 392 | if linkCheck == 16 and flowsCheck == 0 and intentCheck == 0: |
| 393 | main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck)) |
| 394 | verify = main.TRUE |
| 395 | break |
| 396 | k += 1 |
| 397 | if not verify: |
| 398 | main.log.error("links, flows, or intents are not correct!") |
| 399 | main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 400 | # bring back topology |
| 401 | main.log.info("Bring back topology...") |
| 402 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 403 | time.sleep(1) |
| 404 | main.CLIs[0].purgeWithdrawnIntents() |
| 405 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0) |
| 406 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false") |
| 407 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8) |
| 408 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 409 | continue |
| 410 | |
| 411 | aveLatency = 0 |
| 412 | stdLatency = 0 |
| 413 | aveLatency = numpy.average(main.LatencyList) |
| 414 | stdLatency = numpy.std(main.LatencyList) |
| 415 | main.log.report("Scale: " + str(main.numCtrls) + " \tIntent batch: " + str(batchSize)) |
| 416 | main.log.report("Latency average:................" + str(aveLatency)) |
| 417 | main.log.report("Latency standard deviation:....." + str(stdLatency)) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 418 | main.log.report("________________________________________________________") |
| 419 | |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 420 | if not (numpy.isnan(aveLatency) or numpy.isnan(stdLatency)): |
| 421 | # check if got NaN for result |
| 422 | resultsDB = open(main.dbFileName, "a") |
| 423 | resultsDB.write("'" + main.commit + "',") |
| 424 | resultsDB.write(str(main.numCtrls) + ",") |
| 425 | resultsDB.write(str(batchSize) + ",") |
| 426 | resultsDB.write(str(aveLatency) + ",") |
| 427 | resultsDB.write(str(stdLatency) + "\n") |
| 428 | resultsDB.close() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 429 | del main.scale[0] |