YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 1 | """ |
| 2 | SCPFintentInstallWithdrawLat: |
| 3 | - Test the latency of intent installed and withdrawn |
| 4 | - Use Push-test-intents command to push intents |
| 5 | - Use Null provider with 7 devices and linear topology |
| 6 | - Always push intents between 1/6 and 7/5 |
| 7 | - The batch size is defined in parm file. (default 1,100,1000) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 8 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 9 | yunpeng@onlab.us |
| 10 | """ |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 11 | class SCPFintentInstallWithdrawLat: |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 12 | def __init__( self ): |
| 13 | self.default = '' |
| 14 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 15 | def CASE0( self, main ): |
| 16 | ''' |
| 17 | - GIT |
| 18 | - BUILDING ONOS |
| 19 | Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| 20 | This step is usually skipped. Because in a Jenkins driven automated |
| 21 | test env. We want Jenkins jobs to pull&build for flexibility to handle |
| 22 | different versions of ONOS. |
| 23 | - Construct tests variables |
| 24 | ''' |
| 25 | gitPull = main.params['GIT']['gitPull'] |
| 26 | gitBranch = main.params['GIT']['gitBranch'] |
| 27 | |
| 28 | main.case("Pull onos branch and build onos on Teststation.") |
| 29 | |
| 30 | if gitPull == 'True': |
| 31 | main.step("Git Checkout ONOS branch: " + gitBranch) |
| 32 | stepResult = main.ONOSbench.gitCheckout(branch=gitBranch) |
| 33 | utilities.assert_equals(expect=main.TRUE, |
| 34 | actual=stepResult, |
| 35 | onpass="Successfully checkout onos branch.", |
| 36 | onfail="Failed to checkout onos branch. Exiting test...") |
| 37 | if not stepResult: main.exit() |
| 38 | |
| 39 | main.step("Git Pull on ONOS branch:" + gitBranch) |
| 40 | stepResult = main.ONOSbench.gitPull() |
| 41 | utilities.assert_equals(expect=main.TRUE, |
| 42 | actual=stepResult, |
| 43 | onpass="Successfully pull onos. ", |
| 44 | onfail="Failed to pull onos. Exiting test ...") |
| 45 | if not stepResult: main.exit() |
| 46 | |
| 47 | main.step("Building ONOS branch: " + gitBranch) |
| 48 | stepResult = main.ONOSbench.cleanInstall(skipTest=True) |
| 49 | utilities.assert_equals(expect=main.TRUE, |
| 50 | actual=stepResult, |
| 51 | onpass="Successfully build onos.", |
| 52 | onfail="Failed to build onos. Exiting test...") |
| 53 | if not stepResult: main.exit() |
| 54 | |
| 55 | else: |
| 56 | main.log.warn("Skipped pulling onos and Skipped building ONOS") |
| 57 | |
| 58 | main.apps = main.params['ENV']['cellApps'] |
| 59 | main.BENCHUser = main.params['BENCH']['user'] |
| 60 | main.BENCHIp = main.params['BENCH']['ip1'] |
| 61 | main.MN1Ip = main.params['MN']['ip1'] |
| 62 | main.maxNodes = int(main.params['max']) |
| 63 | main.cellName = main.params['ENV']['cellName'] |
| 64 | main.scale = (main.params['SCALE']).split(",") |
| 65 | main.dbFileName = main.params['DATABASE']['file'] |
| 66 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 67 | main.startUpSleep = int(main.params['SLEEP']['startup']) |
| 68 | main.installSleep = int(main.params['SLEEP']['install']) |
| 69 | main.verifySleep = int(main.params['SLEEP']['verify']) |
| 70 | main.verifyAttempts = int(main.params['ATTEMPTS']['verify']) |
| 71 | main.sampleSize = int(main.params['TEST']['sampleSize']) |
| 72 | main.warmUp = int(main.params['TEST']['warmUp']) |
| 73 | main.intentsList = (main.params['TEST']['intents']).split(",") |
| 74 | main.ingress = main.params['TEST']['ingress'] |
| 75 | main.egress = main.params['TEST']['egress'] |
| 76 | main.debug = main.params['TEST']['debug'] |
| 77 | for i in range(0, len(main.intentsList)): |
| 78 | main.intentsList[i] = int(main.intentsList[i]) |
| 79 | # Create DataBase file |
| 80 | main.log.info("Create Database file " + main.dbFileName) |
| 81 | resultsDB = open(main.dbFileName, "w+") |
| 82 | resultsDB.close() |
| 83 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 84 | def CASE1( self, main ): |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 85 | # Clean up test environment and set up |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 86 | import time |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 87 | main.log.info("Get ONOS cluster IP") |
| 88 | print(main.scale) |
| 89 | main.numCtrls = int(main.scale[0]) |
| 90 | main.ONOSip = [] |
| 91 | main.maxNumBatch = 0 |
| 92 | main.AllONOSip = main.ONOSbench.getOnosIps() |
| 93 | for i in range(main.numCtrls): |
| 94 | main.ONOSip.append(main.AllONOSip[i]) |
| 95 | main.log.info(main.ONOSip) |
| 96 | main.CLIs = [] |
| 97 | main.log.info("Creating list of ONOS cli handles") |
| 98 | for i in range(main.numCtrls): |
| 99 | main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1))) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 100 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 101 | if not main.CLIs: |
| 102 | main.log.error("Failed to create the list of ONOS cli handles") |
| 103 | main.cleanup() |
| 104 | main.exit() |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 105 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 106 | main.commit = main.ONOSbench.getVersion(report=True) |
| 107 | main.commit = main.commit.split(" ")[1] |
| 108 | main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls) |
| 109 | main.log.info("Safety check, killing all ONOS processes" + |
| 110 | " before initiating environment setup") |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 111 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 112 | for i in range(main.numCtrls): |
| 113 | main.ONOSbench.onosDie(main.ONOSip[i]) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 114 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 115 | main.log.info("NODE COUNT = %s" % main.numCtrls) |
| 116 | main.ONOSbench.createCellFile(main.ONOSbench.ip_address, |
| 117 | main.cellName, |
| 118 | main.MN1Ip, |
| 119 | main.apps, |
| 120 | main.ONOSip) |
| 121 | main.step("Apply cell to environment") |
| 122 | cellResult = main.ONOSbench.setCell(main.cellName) |
| 123 | verifyResult = main.ONOSbench.verifyCell() |
| 124 | stepResult = cellResult and verifyResult |
| 125 | utilities.assert_equals(expect=main.TRUE, |
| 126 | actual=stepResult, |
| 127 | onpass="Successfully applied cell to " + \ |
| 128 | "environment", |
| 129 | onfail="Failed to apply cell to environment ") |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 130 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 131 | main.step("Creating ONOS package") |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 132 | packageResult = main.ONOSbench.onosPackage() |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 133 | stepResult = packageResult |
| 134 | utilities.assert_equals(expect=main.TRUE, |
| 135 | actual=stepResult, |
| 136 | onpass="Successfully created ONOS package", |
| 137 | onfail="Failed to create ONOS package") |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 138 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 139 | main.step("Uninstall ONOS package on all Nodes") |
| 140 | uninstallResult = main.TRUE |
| 141 | for i in range(int(main.numCtrls)): |
| 142 | main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i]) |
| 143 | u_result = main.ONOSbench.onosUninstall(main.ONOSip[i]) |
| 144 | utilities.assert_equals(expect=main.TRUE, actual=u_result, |
| 145 | onpass="Test step PASS", |
| 146 | onfail="Test step FAIL") |
| 147 | uninstallResult = (uninstallResult and u_result) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 148 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 149 | main.step("Install ONOS package on all Nodes") |
| 150 | installResult = main.TRUE |
| 151 | for i in range(int(main.numCtrls)): |
| 152 | main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i]) |
| 153 | i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i]) |
| 154 | utilities.assert_equals(expect=main.TRUE, actual=i_result, |
| 155 | onpass="Test step PASS", |
| 156 | onfail="Test step FAIL") |
| 157 | installResult = installResult and i_result |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 158 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 159 | main.step("Verify ONOS nodes UP status") |
| 160 | statusResult = main.TRUE |
| 161 | for i in range(int(main.numCtrls)): |
| 162 | main.log.info("ONOS Node " + main.ONOSip[i] + " status:") |
| 163 | onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i]) |
| 164 | utilities.assert_equals(expect=main.TRUE, actual=onos_status, |
| 165 | onpass="Test step PASS", |
| 166 | onfail="Test step FAIL") |
| 167 | statusResult = (statusResult and onos_status) |
| 168 | time.sleep(2) |
| 169 | main.step("Start ONOS CLI on all nodes") |
| 170 | cliResult = main.TRUE |
| 171 | main.log.step(" Start ONOS cli using thread ") |
| 172 | startCliResult = main.TRUE |
| 173 | pool = [] |
| 174 | main.threadID = 0 |
| 175 | for i in range(int(main.numCtrls)): |
| 176 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 177 | threadID=main.threadID, |
| 178 | name="startOnosCli", |
| 179 | args=[main.ONOSip[i]], |
| 180 | kwargs={"onosStartTimeout": main.timeout}) |
| 181 | pool.append(t) |
| 182 | t.start() |
| 183 | main.threadID = main.threadID + 1 |
| 184 | for t in pool: |
| 185 | t.join() |
| 186 | startCliResult = startCliResult and t.result |
| 187 | time.sleep(main.startUpSleep) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 188 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 189 | # configure apps |
| 190 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=7) |
| 191 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="linear") |
| 192 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
YPZhang | 325822f | 2016-06-17 16:01:45 -0700 | [diff] [blame] | 193 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.IntentManager", "skipReleaseResourcesOnWithdrawal", value="true") |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 194 | time.sleep(main.startUpSleep) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 195 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 196 | # balanceMasters |
| 197 | main.CLIs[0].balanceMasters() |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 198 | |
| 199 | def CASE2( self, main ): |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 200 | import time |
| 201 | import numpy |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 202 | import json |
| 203 | print(main.intentsList) |
| 204 | for batchSize in main.intentsList: |
| 205 | main.log.report("Intent Batch size: {}".format(batchSize)) |
| 206 | main.installLatList = [] |
| 207 | main.withdrawLatList = [] |
| 208 | validrun = 0 |
| 209 | invalidrun = 0 |
| 210 | # we use two variables to control the iteration |
| 211 | while validrun <= main.warmUp + main.sampleSize and invalidrun < 20: |
| 212 | if validrun >= main.warmUp: |
| 213 | main.log.info("================================================") |
| 214 | main.log.info("Starting test iteration " + str(validrun - main.warmUp)) |
| 215 | main.log.info("Total test iteration: " + str(invalidrun + validrun)) |
| 216 | main.log.info("================================================") |
| 217 | else: |
| 218 | main.log.info("====================Warm Up=====================") |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 219 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 220 | # push intents |
| 221 | installResult = main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize, |
| 222 | offset=1, options="-i", timeout=main.timeout, |
| 223 | getResponse=True) |
| 224 | if type(installResult) is str: |
| 225 | if "Failure" in installResult: |
| 226 | main.log.error("Install Intents failure, ignore this iteration.") |
| 227 | if validrun < main.warmUp: |
| 228 | validrun += 1 |
| 229 | continue |
| 230 | else: |
| 231 | invalidrun += 1 |
| 232 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 233 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 234 | try: |
| 235 | latency = int(installResult.split()[5]) |
| 236 | main.log.info(installResult) |
| 237 | except: |
| 238 | main.log.error("Failed to get latency, ignore this iteration.") |
| 239 | main.log.error("Response from ONOS:") |
| 240 | print(installResult) |
| 241 | if validrun < main.warmUp: |
| 242 | validrun += 1 |
| 243 | continue |
| 244 | else: |
| 245 | invalidrun += 1 |
| 246 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 247 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 248 | if validrun >= main.warmUp: |
| 249 | main.installLatList.append(latency) |
| 250 | else: |
| 251 | invalidrun += 1 |
| 252 | continue |
| 253 | time.sleep(2) |
| 254 | # Withdraw Intents |
| 255 | withdrawResult = main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize, |
| 256 | offset=1, options="-w", timeout=main.timeout, |
| 257 | getResponse=True) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 258 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 259 | if type(withdrawResult) is str: |
| 260 | if "Failure" in withdrawResult: |
| 261 | main.log.error("withdraw Intents failure, ignore this iteration.") |
| 262 | if validrun < main.warmUp: |
| 263 | validrun += 1 |
| 264 | continue |
| 265 | else: |
| 266 | invalidrun += 1 |
| 267 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 268 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 269 | try: |
| 270 | latency = int(withdrawResult.split()[5]) |
| 271 | main.log.info(withdrawResult) |
| 272 | except: |
| 273 | main.log.error("Failed to get latency, ignore this iteration.") |
| 274 | main.log.error("Response from ONOS:") |
| 275 | print(withdrawResult) |
| 276 | if validrun < main.warmUp: |
| 277 | validrun += 1 |
| 278 | continue |
| 279 | else: |
| 280 | invalidrun += 1 |
| 281 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 282 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 283 | if validrun >= main.warmUp: |
| 284 | main.withdrawLatList.append(latency) |
| 285 | else: |
| 286 | invalidrun += 1 |
| 287 | continue |
| 288 | time.sleep(2) |
| 289 | main.CLIs[0].purgeWithdrawnIntents() |
| 290 | validrun += 1 |
| 291 | installave = numpy.average(main.installLatList) |
| 292 | installstd = numpy.std(main.installLatList) |
| 293 | withdrawave = numpy.average(main.withdrawLatList) |
| 294 | withdrawstd = numpy.std(main.withdrawLatList) |
| 295 | # log report |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 296 | main.log.report("----------------------------------------------------") |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 297 | main.log.report("Scale: " + str(main.numCtrls)) |
| 298 | main.log.report("Intent batch: " + str(batchSize)) |
| 299 | main.log.report("Install average: {} std: {}".format(installave, installstd)) |
| 300 | main.log.report("Withdraw average: {} std: {}".format(withdrawave, withdrawstd)) |
| 301 | # write result to database file |
| 302 | if not (numpy.isnan(installave) or numpy.isnan(installstd) or\ |
| 303 | numpy.isnan(withdrawstd) or numpy.isnan(withdrawave)): |
| 304 | databaseString = "'" + main.commit + "'," |
| 305 | databaseString += str(main.numCtrls) + "," |
| 306 | databaseString += str(batchSize) + "," |
| 307 | databaseString += str(installave) + "," |
| 308 | databaseString += str(installstd) + "," |
| 309 | databaseString += str(withdrawave) + "," |
| 310 | databaseString += str(withdrawstd) + "\n" |
| 311 | resultsDB = open(main.dbFileName, "a") |
| 312 | resultsDB.write(databaseString) |
| 313 | resultsDB.close() |
| 314 | del main.scale[0] |