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) |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 191 | |
| 192 | main.step( "Set up ONOS secure SSH" ) |
| 193 | secureSshResult = main.TRUE |
| 194 | for i in range( int( main.numCtrls ) ): |
| 195 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] ) |
| 196 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 197 | onpass="Test step PASS", |
| 198 | onfail="Test step FAIL" ) |
| 199 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 200 | time.sleep(2) |
| 201 | main.step("Start ONOS CLI on all nodes") |
| 202 | cliResult = main.TRUE |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 203 | main.step(" Start ONOS cli using thread ") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 204 | startCliResult = main.TRUE |
| 205 | pool = [] |
| 206 | main.threadID = 0 |
| 207 | for i in range(int(main.numCtrls)): |
| 208 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 209 | threadID=main.threadID, |
| 210 | name="startOnosCli", |
| 211 | args=[main.ONOSip[i]], |
| 212 | kwargs={"onosStartTimeout": main.timeout}) |
| 213 | pool.append(t) |
| 214 | t.start() |
| 215 | main.threadID = main.threadID + 1 |
| 216 | for t in pool: |
| 217 | t.join() |
| 218 | startCliResult = startCliResult and t.result |
| 219 | time.sleep(main.startUpSleep) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 220 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 221 | # configure apps |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 222 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 223 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute") |
| 224 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 225 | main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false") |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 226 | if main.flowObj: |
| 227 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 228 | "useFlowObjectives", value="true") |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 229 | time.sleep(main.startUpSleep) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 230 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 231 | # Balance Master |
| 232 | main.CLIs[0].balanceMasters() |
| 233 | if len(main.ONOSip) > 1: |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 234 | main.CLIs[0].deviceRole(main.end1[ 'name' ], main.ONOSip[0]) |
| 235 | main.CLIs[0].deviceRole(main.end2[ 'name' ], main.ONOSip[0]) |
YPZhang | 2b9b26d | 2016-06-20 16:18:29 -0700 | [diff] [blame] | 236 | time.sleep( main.setMasterSleep ) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 237 | |
| 238 | def CASE2( self, main ): |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 239 | import time |
| 240 | import numpy |
| 241 | import datetime |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 242 | import json |
| 243 | # from scipy import stats |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 244 | |
| 245 | ts = time.time() |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 246 | print(main.intentsList) |
| 247 | for batchSize in main.intentsList: |
| 248 | main.log.report("Intent Batch size: " + str(batchSize) + "\n ") |
| 249 | main.LatencyList = [] |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 250 | validRun = 0 |
| 251 | invalidRun = 0 |
| 252 | while validRun <= main.warmUp + main.sampleSize and invalidRun <= 20: |
| 253 | if validRun >= main.warmUp: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 254 | main.log.info("================================================") |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 255 | main.log.info("Starting test iteration: {} ".format(validRun - main.warmUp)) |
| 256 | main.log.info("Total iteration: {}".format(validRun + invalidRun)) |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 257 | main.log.info("================================================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 258 | else: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 259 | main.log.info("====================Warm Up=====================") |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 260 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 261 | # push intents |
| 262 | main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize, |
| 263 | offset=1, options="-i", timeout=main.timeout) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 264 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 265 | # check links and flows |
| 266 | k = 0 |
| 267 | verify = main.FALSE |
| 268 | linkCheck = 0 |
| 269 | flowsCheck = 0 |
| 270 | while k <= main.verifyAttempts: |
| 271 | time.sleep(main.verifySleep) |
| 272 | summary = json.loads(main.CLIs[0].summary(timeout=main.timeout)) |
| 273 | linkCheck = summary.get("links") |
| 274 | flowsCheck = summary.get("flows") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 275 | if linkCheck == main.deviceCount * 2 and flowsCheck == batchSize * (main.deviceCount - 1 ): |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 276 | main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
| 277 | verify = main.TRUE |
| 278 | break |
| 279 | k += 1 |
| 280 | if not verify: |
| 281 | main.log.warn("Links or flows number are not match!") |
| 282 | main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 283 | # bring back topology |
| 284 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 285 | time.sleep(1) |
| 286 | main.CLIs[0].purgeWithdrawnIntents() |
| 287 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0) |
| 288 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 289 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 290 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 291 | if validRun >= main.warmUp: |
| 292 | invalidRun += 1 |
| 293 | continue |
| 294 | else: |
| 295 | validRun += 1 |
| 296 | continue |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 297 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 298 | # Bring link down |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 299 | main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down", |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 300 | timeout=main.timeout, showResponse=False) |
| 301 | verify = main.FALSE |
| 302 | k = 0 |
| 303 | topoManagerLog = "" |
| 304 | while k <= main.verifyAttempts: |
| 305 | time.sleep(main.verifySleep) |
| 306 | summary = json.loads(main.CLIs[0].summary(timeout=main.timeout)) |
| 307 | linkCheck = summary.get("links") |
| 308 | flowsCheck = summary.get("flows") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 309 | if linkCheck == (main.deviceCount - 1) * 2: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 310 | main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck)) |
| 311 | verify = main.TRUE |
| 312 | break |
| 313 | k += 1 |
| 314 | if not verify: |
| 315 | main.log.warn("Links number are not match in TopologyManager log!") |
| 316 | main.log.warn(topoManagerLog) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 317 | # bring back topology |
| 318 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 319 | time.sleep(1) |
| 320 | main.CLIs[0].purgeWithdrawnIntents() |
| 321 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0) |
| 322 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 323 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 324 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 325 | if validRun >= main.warmUp: |
| 326 | invalidRun += 1 |
| 327 | continue |
| 328 | else: |
| 329 | validRun += 1 |
| 330 | continue |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -0700 | [diff] [blame] | 331 | |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 332 | try: |
| 333 | # expect twice to clean the pexpect buffer |
| 334 | main.ONOSbench.handle.sendline("") |
| 335 | main.ONOSbench.handle.expect("\$") |
| 336 | main.ONOSbench.handle.expect("\$") |
| 337 | # send line by using bench, can't use driver because pexpect buffer problem |
| 338 | cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1" |
| 339 | main.ONOSbench.handle.sendline(cmd) |
| 340 | time.sleep(1) |
| 341 | main.ONOSbench.handle.expect(":~") |
| 342 | topoManagerLog = main.ONOSbench.handle.before |
| 343 | topoManagerLogTemp = topoManagerLog.splitlines() |
| 344 | # To make sure we get correct topology log |
| 345 | for lines in topoManagerLogTemp: |
| 346 | if "creationTime" in lines: |
| 347 | topoManagerLog = lines |
| 348 | main.log.info("Topology Manager log:") |
| 349 | print(topoManagerLog) |
| 350 | cutTimestamp = float(topoManagerLog.split("creationTime=")[1].split(",")[0]) |
| 351 | except: |
| 352 | main.log.error("Topology Log is not correct!") |
| 353 | print(topoManagerLog) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 354 | # bring back topology |
| 355 | verify = main.FALSE |
| 356 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 357 | time.sleep(1) |
| 358 | main.CLIs[0].purgeWithdrawnIntents() |
| 359 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0) |
| 360 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 361 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 362 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
| 363 | if validRun >= main.warmUp: |
| 364 | invalidRun += 1 |
| 365 | else: |
| 366 | validRun += 1 |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 367 | # If we got wrong Topology log, we should skip this iteration, and continue for next one |
| 368 | continue |
| 369 | |
| 370 | installedTemp = [] |
| 371 | time.sleep(1) |
| 372 | for cli in main.CLIs: |
| 373 | tempJson = json.loads(cli.intentsEventsMetrics()) |
| 374 | Installedtime = tempJson.get('intentInstalledTimestamp').get('value') |
| 375 | installedTemp.append(float(Installedtime)) |
| 376 | for i in range(0, len(installedTemp)): |
| 377 | main.log.info("ONOS Node {} Installed Time stemp: {}".format((i + 1), installedTemp[i])) |
| 378 | maxInstallTime = float(max(installedTemp)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 379 | if validRun >= main.warmUp and verify: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 380 | main.log.info("Installed time stemp: {0:f}".format(maxInstallTime)) |
| 381 | main.log.info("CutTimestamp: {0:f}".format(cutTimestamp)) |
| 382 | # Both timeStemps are milliseconds |
| 383 | main.log.info("Latency: {0:f}".format(float(maxInstallTime - cutTimestamp))) |
| 384 | main.LatencyList.append(float(maxInstallTime - cutTimestamp)) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 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 |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 389 | main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up", |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 390 | timeout=main.timeout) |
| 391 | k = 0 |
| 392 | verify = main.FALSE |
| 393 | linkCheck = 0 |
| 394 | flowsCheck = 0 |
| 395 | while k <= main.verifyAttempts: |
| 396 | time.sleep(main.verifySleep) |
| 397 | main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout) |
| 398 | time.sleep(1) |
| 399 | main.CLIs[0].purgeWithdrawnIntents() |
| 400 | summary = json.loads(main.CLIs[0].summary()) |
| 401 | linkCheck = summary.get("links") |
| 402 | flowsCheck = summary.get("flows") |
| 403 | intentCheck = summary.get("intents") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 404 | if linkCheck == main.deviceCount * 2 and flowsCheck == 0 and intentCheck == 0: |
YPZhang | febf730 | 2016-05-24 16:45:56 -0700 | [diff] [blame] | 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") |
Chiyu Cheng | 1976db5 | 2016-10-21 15:57:30 -0700 | [diff] [blame] | 419 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount) |
YPZhang | 8742d2e | 2016-06-16 15:31:58 -0700 | [diff] [blame] | 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 | |
| 423 | aveLatency = 0 |
| 424 | stdLatency = 0 |
| 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)) |
cameron@onlab.us | 78b8965 | 2015-07-08 15:21:03 -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] |