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