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