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(",") |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 65 | main.timeout = int(main.params['SLEEP']['timeout']) |
| 66 | main.startUpSleep = int(main.params['SLEEP']['startup']) |
| 67 | main.installSleep = int(main.params['SLEEP']['install']) |
| 68 | main.verifySleep = int(main.params['SLEEP']['verify']) |
| 69 | main.verifyAttempts = int(main.params['ATTEMPTS']['verify']) |
| 70 | main.sampleSize = int(main.params['TEST']['sampleSize']) |
| 71 | main.warmUp = int(main.params['TEST']['warmUp']) |
| 72 | main.intentsList = (main.params['TEST']['intents']).split(",") |
| 73 | main.ingress = main.params['TEST']['ingress'] |
| 74 | main.egress = main.params['TEST']['egress'] |
| 75 | main.debug = main.params['TEST']['debug'] |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 76 | main.flowObj = main.params['TEST']['flowObj'] |
| 77 | |
| 78 | if main.flowObj == "True": |
| 79 | main.flowObj = True |
| 80 | main.dbFileName = main.params['DATABASE']['dbFlowObj'] |
| 81 | else: |
| 82 | main.flowObj = False |
| 83 | main.dbFileName = main.params['DATABASE']['dbName'] |
| 84 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 85 | for i in range(0, len(main.intentsList)): |
| 86 | main.intentsList[i] = int(main.intentsList[i]) |
| 87 | # Create DataBase file |
| 88 | main.log.info("Create Database file " + main.dbFileName) |
| 89 | resultsDB = open(main.dbFileName, "w+") |
| 90 | resultsDB.close() |
| 91 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 92 | def CASE1( self, main ): |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 93 | # Clean up test environment and set up |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 94 | import time |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 95 | main.log.info("Get ONOS cluster IP") |
| 96 | print(main.scale) |
| 97 | main.numCtrls = int(main.scale[0]) |
| 98 | main.ONOSip = [] |
| 99 | main.maxNumBatch = 0 |
| 100 | main.AllONOSip = main.ONOSbench.getOnosIps() |
| 101 | for i in range(main.numCtrls): |
| 102 | main.ONOSip.append(main.AllONOSip[i]) |
| 103 | main.log.info(main.ONOSip) |
| 104 | main.CLIs = [] |
| 105 | main.log.info("Creating list of ONOS cli handles") |
| 106 | for i in range(main.numCtrls): |
| 107 | main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1))) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 108 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 109 | if not main.CLIs: |
| 110 | main.log.error("Failed to create the list of ONOS cli handles") |
| 111 | main.cleanup() |
| 112 | main.exit() |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 113 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 114 | main.commit = main.ONOSbench.getVersion(report=True) |
| 115 | main.commit = main.commit.split(" ")[1] |
| 116 | main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls) |
| 117 | main.log.info("Safety check, killing all ONOS processes" + |
| 118 | " before initiating environment setup") |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 119 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 120 | for i in range(main.numCtrls): |
You Wang | b98a9fa | 2017-02-15 17:27:42 -0800 | [diff] [blame] | 121 | main.ONOSbench.onosStop(main.ONOSip[i]) |
| 122 | main.ONOSbench.onosKill(main.ONOSip[i]) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 123 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 124 | main.log.info("NODE COUNT = %s" % main.numCtrls) |
| 125 | main.ONOSbench.createCellFile(main.ONOSbench.ip_address, |
| 126 | main.cellName, |
| 127 | main.MN1Ip, |
| 128 | main.apps, |
| 129 | main.ONOSip) |
| 130 | main.step("Apply cell to environment") |
| 131 | cellResult = main.ONOSbench.setCell(main.cellName) |
| 132 | verifyResult = main.ONOSbench.verifyCell() |
| 133 | stepResult = cellResult and verifyResult |
| 134 | utilities.assert_equals(expect=main.TRUE, |
| 135 | actual=stepResult, |
| 136 | onpass="Successfully applied cell to " + \ |
| 137 | "environment", |
| 138 | onfail="Failed to apply cell to environment ") |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 139 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 140 | main.step("Creating ONOS package") |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 141 | packageResult = main.ONOSbench.buckBuild() |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 142 | stepResult = packageResult |
| 143 | utilities.assert_equals(expect=main.TRUE, |
| 144 | actual=stepResult, |
| 145 | onpass="Successfully created ONOS package", |
| 146 | onfail="Failed to create ONOS package") |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 147 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 148 | main.step("Uninstall ONOS package on all Nodes") |
| 149 | uninstallResult = main.TRUE |
| 150 | for i in range(int(main.numCtrls)): |
| 151 | main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i]) |
| 152 | u_result = main.ONOSbench.onosUninstall(main.ONOSip[i]) |
| 153 | utilities.assert_equals(expect=main.TRUE, actual=u_result, |
| 154 | onpass="Test step PASS", |
| 155 | onfail="Test step FAIL") |
| 156 | uninstallResult = (uninstallResult and u_result) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 157 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 158 | main.step("Install ONOS package on all Nodes") |
| 159 | installResult = main.TRUE |
| 160 | for i in range(int(main.numCtrls)): |
| 161 | main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i]) |
| 162 | i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i]) |
| 163 | utilities.assert_equals(expect=main.TRUE, actual=i_result, |
| 164 | onpass="Test step PASS", |
| 165 | onfail="Test step FAIL") |
| 166 | installResult = installResult and i_result |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 167 | |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 168 | main.step( "Set up ONOS secure SSH" ) |
| 169 | secureSshResult = main.TRUE |
| 170 | for i in range( int( main.numCtrls ) ): |
| 171 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] ) |
| 172 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 173 | onpass="Test step PASS", |
| 174 | onfail="Test step FAIL" ) |
| 175 | |
You Wang | 0357c43 | 2017-01-09 16:13:33 -0800 | [diff] [blame] | 176 | time.sleep( main.startUpSleep ) |
| 177 | main.step( "Starting ONOS service" ) |
| 178 | stopResult = main.TRUE |
| 179 | startResult = main.TRUE |
| 180 | onosIsUp = main.TRUE |
| 181 | for i in range( main.numCtrls ): |
| 182 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 183 | if onosIsUp == main.TRUE: |
| 184 | main.log.report( "ONOS instance is up and ready" ) |
| 185 | else: |
| 186 | main.log.report( "ONOS instance may not be up, stop and " + |
| 187 | "start ONOS again " ) |
| 188 | for i in range( main.numCtrls ): |
| 189 | stopResult = stopResult and \ |
| 190 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 191 | for i in range( main.numCtrls ): |
| 192 | startResult = startResult and \ |
| 193 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 194 | stepResult = onosIsUp and stopResult and startResult |
| 195 | utilities.assert_equals( expect=main.TRUE, |
| 196 | actual=stepResult, |
| 197 | onpass="ONOS service is ready", |
| 198 | onfail="ONOS service did not start properly" ) |
| 199 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -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 | b34b7e1 | 2016-06-14 14:28:19 -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) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 220 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 221 | # configure apps |
| 222 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=7) |
| 223 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="linear") |
| 224 | main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true") |
YPZhang | 325822f | 2016-06-17 16:01:45 -0700 | [diff] [blame] | 225 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.IntentManager", "skipReleaseResourcesOnWithdrawal", value="true") |
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") |
You Wang | 106d0fa | 2017-05-15 17:22:15 -0700 | [diff] [blame^] | 229 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 230 | "defaultFlowObjectiveCompiler", |
| 231 | value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler') |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 232 | time.sleep(main.startUpSleep) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 233 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 234 | # balanceMasters |
| 235 | main.CLIs[0].balanceMasters() |
You Wang | 3b148ea | 2016-06-20 20:33:42 -0700 | [diff] [blame] | 236 | time.sleep(main.startUpSleep) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 237 | |
| 238 | def CASE2( self, main ): |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 239 | import time |
| 240 | import numpy |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 241 | import json |
| 242 | print(main.intentsList) |
| 243 | for batchSize in main.intentsList: |
| 244 | main.log.report("Intent Batch size: {}".format(batchSize)) |
| 245 | main.installLatList = [] |
| 246 | main.withdrawLatList = [] |
| 247 | validrun = 0 |
| 248 | invalidrun = 0 |
| 249 | # we use two variables to control the iteration |
| 250 | while validrun <= main.warmUp + main.sampleSize and invalidrun < 20: |
| 251 | if validrun >= main.warmUp: |
| 252 | main.log.info("================================================") |
| 253 | main.log.info("Starting test iteration " + str(validrun - main.warmUp)) |
| 254 | main.log.info("Total test iteration: " + str(invalidrun + validrun)) |
| 255 | main.log.info("================================================") |
| 256 | else: |
| 257 | main.log.info("====================Warm Up=====================") |
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 | # push intents |
| 260 | installResult = main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize, |
| 261 | offset=1, options="-i", timeout=main.timeout, |
| 262 | getResponse=True) |
| 263 | if type(installResult) is str: |
| 264 | if "Failure" in installResult: |
| 265 | main.log.error("Install Intents failure, ignore this iteration.") |
| 266 | if validrun < main.warmUp: |
| 267 | validrun += 1 |
| 268 | continue |
| 269 | else: |
| 270 | invalidrun += 1 |
| 271 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 272 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 273 | try: |
| 274 | latency = int(installResult.split()[5]) |
| 275 | main.log.info(installResult) |
| 276 | except: |
| 277 | main.log.error("Failed to get latency, ignore this iteration.") |
| 278 | main.log.error("Response from ONOS:") |
| 279 | print(installResult) |
| 280 | if validrun < main.warmUp: |
| 281 | validrun += 1 |
| 282 | continue |
| 283 | else: |
| 284 | invalidrun += 1 |
| 285 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 286 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 287 | if validrun >= main.warmUp: |
| 288 | main.installLatList.append(latency) |
| 289 | else: |
| 290 | invalidrun += 1 |
| 291 | continue |
| 292 | time.sleep(2) |
| 293 | # Withdraw Intents |
| 294 | withdrawResult = main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize, |
| 295 | offset=1, options="-w", timeout=main.timeout, |
| 296 | getResponse=True) |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 297 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 298 | if type(withdrawResult) is str: |
| 299 | if "Failure" in withdrawResult: |
| 300 | main.log.error("withdraw Intents failure, ignore this iteration.") |
| 301 | if validrun < main.warmUp: |
| 302 | validrun += 1 |
| 303 | continue |
| 304 | else: |
| 305 | invalidrun += 1 |
| 306 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 307 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 308 | try: |
| 309 | latency = int(withdrawResult.split()[5]) |
| 310 | main.log.info(withdrawResult) |
| 311 | except: |
| 312 | main.log.error("Failed to get latency, ignore this iteration.") |
| 313 | main.log.error("Response from ONOS:") |
| 314 | print(withdrawResult) |
| 315 | if validrun < main.warmUp: |
| 316 | validrun += 1 |
| 317 | continue |
| 318 | else: |
| 319 | invalidrun += 1 |
| 320 | continue |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 321 | |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 322 | if validrun >= main.warmUp: |
| 323 | main.withdrawLatList.append(latency) |
| 324 | else: |
| 325 | invalidrun += 1 |
| 326 | continue |
| 327 | time.sleep(2) |
| 328 | main.CLIs[0].purgeWithdrawnIntents() |
| 329 | validrun += 1 |
| 330 | installave = numpy.average(main.installLatList) |
| 331 | installstd = numpy.std(main.installLatList) |
| 332 | withdrawave = numpy.average(main.withdrawLatList) |
| 333 | withdrawstd = numpy.std(main.withdrawLatList) |
| 334 | # log report |
cameron@onlab.us | 41c16f5 | 2015-07-08 15:40:28 -0700 | [diff] [blame] | 335 | main.log.report("----------------------------------------------------") |
YPZhang | b34b7e1 | 2016-06-14 14:28:19 -0700 | [diff] [blame] | 336 | main.log.report("Scale: " + str(main.numCtrls)) |
| 337 | main.log.report("Intent batch: " + str(batchSize)) |
| 338 | main.log.report("Install average: {} std: {}".format(installave, installstd)) |
| 339 | main.log.report("Withdraw average: {} std: {}".format(withdrawave, withdrawstd)) |
| 340 | # write result to database file |
| 341 | if not (numpy.isnan(installave) or numpy.isnan(installstd) or\ |
| 342 | numpy.isnan(withdrawstd) or numpy.isnan(withdrawave)): |
| 343 | databaseString = "'" + main.commit + "'," |
| 344 | databaseString += str(main.numCtrls) + "," |
| 345 | databaseString += str(batchSize) + "," |
| 346 | databaseString += str(installave) + "," |
| 347 | databaseString += str(installstd) + "," |
| 348 | databaseString += str(withdrawave) + "," |
| 349 | databaseString += str(withdrawstd) + "\n" |
| 350 | resultsDB = open(main.dbFileName, "a") |
| 351 | resultsDB.write(databaseString) |
| 352 | resultsDB.close() |
| 353 | del main.scale[0] |