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