blob: 2e32f603bda4f47c512e6d57634aac27a655fa3c [file] [log] [blame]
YPZhangfebf7302016-05-24 16:45:56 -07001# SCPFintentRerouteLat
2"""
3SCPFintentRerouteLat
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.us78b89652015-07-08 15:21:03 -070016
17class SCPFintentRerouteLat:
YPZhangfebf7302016-05-24 16:45:56 -070018 def __init__(self):
cameron@onlab.us78b89652015-07-08 15:21:03 -070019 self.default = ''
20
YPZhangfebf7302016-05-24 16:45:56 -070021 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.us78b89652015-07-08 15:21:03 -070033
YPZhangfebf7302016-05-24 16:45:56 -070034 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(",")
YPZhangfebf7302016-05-24 16:45:56 -070072 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'])
YPZhang2b9b26d2016-06-20 16:18:29 -070076 main.setMasterSleep = int(main.params['SLEEP']['setmaster'])
YPZhangfebf7302016-05-24 16:45:56 -070077 main.verifyAttempts = int(main.params['ATTEMPTS']['verify'])
78 main.sampleSize = int(main.params['TEST']['sampleSize'])
79 main.warmUp = int(main.params['TEST']['warmUp'])
YPZhangfebf7302016-05-24 16:45:56 -070080 main.ingress = main.params['TEST']['ingress']
81 main.egress = main.params['TEST']['egress']
82 main.debug = main.params['TEST']['debug']
YPZhange6ef82a2016-07-05 16:48:15 -070083 main.flowObj = main.params['TEST']['flowObj']
84
85 if main.flowObj == "True":
86 main.flowObj = True
87 main.dbFileName = main.params['DATABASE']['dbFlowObj']
YPZhang3b5a78f2016-07-14 10:43:33 -070088 main.intentsList = (main.params['TEST']['FObjintents']).split(",")
YPZhange6ef82a2016-07-05 16:48:15 -070089 else:
90 main.flowObj = False
91 main.dbFileName = main.params['DATABASE']['dbName']
YPZhang3b5a78f2016-07-14 10:43:33 -070092 main.intentsList = (main.params['TEST']['intents']).split(",")
YPZhange6ef82a2016-07-05 16:48:15 -070093
YPZhangfebf7302016-05-24 16:45:56 -070094 for i in range(0, len(main.intentsList)):
95 main.intentsList[i] = int(main.intentsList[i])
96 # Create DataBase file
97 main.log.info("Create Database file " + main.dbFileName)
98 resultsDB = open(main.dbFileName, "w+")
99 resultsDB.close()
100
101 def CASE1( self, main ):
102 '''
103 clean up test environment and set up
104 '''
cameron@onlab.us78b89652015-07-08 15:21:03 -0700105 import time
106
YPZhangfebf7302016-05-24 16:45:56 -0700107 main.log.info("Get ONOS cluster IP")
108 print(main.scale)
109 main.numCtrls = int(main.scale[0])
110 main.ONOSip = []
111 main.maxNumBatch = 0
112 main.AllONOSip = main.ONOSbench.getOnosIps()
113 for i in range(main.numCtrls):
114 main.ONOSip.append(main.AllONOSip[i])
115 main.log.info(main.ONOSip)
116 main.CLIs = []
117 main.log.info("Creating list of ONOS cli handles")
118 for i in range(main.numCtrls):
119 main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1)))
cameron@onlab.us78b89652015-07-08 15:21:03 -0700120
YPZhangfebf7302016-05-24 16:45:56 -0700121 if not main.CLIs:
122 main.log.error("Failed to create the list of ONOS cli handles")
123 main.cleanup()
124 main.exit()
cameron@onlab.us78b89652015-07-08 15:21:03 -0700125
YPZhangfebf7302016-05-24 16:45:56 -0700126 main.commit = main.ONOSbench.getVersion(report=True)
127 main.commit = main.commit.split(" ")[1]
128 main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls)
129 main.log.info("Safety check, killing all ONOS processes" +
130 " before initiating environment setup")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700131
YPZhangfebf7302016-05-24 16:45:56 -0700132 for i in range(main.numCtrls):
133 main.ONOSbench.onosDie(main.ONOSip[i])
cameron@onlab.us78b89652015-07-08 15:21:03 -0700134
YPZhangfebf7302016-05-24 16:45:56 -0700135 main.log.info("NODE COUNT = %s" % main.numCtrls)
YPZhangfebf7302016-05-24 16:45:56 -0700136 main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
137 main.cellName,
138 main.MN1Ip,
139 main.apps,
140 main.ONOSip)
141 main.step("Apply cell to environment")
142 cellResult = main.ONOSbench.setCell(main.cellName)
143 verifyResult = main.ONOSbench.verifyCell()
144 stepResult = cellResult and verifyResult
145 utilities.assert_equals(expect=main.TRUE,
146 actual=stepResult,
147 onpass="Successfully applied cell to " + \
148 "environment",
149 onfail="Failed to apply cell to environment ")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700150
YPZhangfebf7302016-05-24 16:45:56 -0700151 main.step("Creating ONOS package")
Jon Hallbd60ea02016-08-23 10:03:59 -0700152 packageResult = main.ONOSbench.buckBuild()
YPZhangfebf7302016-05-24 16:45:56 -0700153 stepResult = packageResult
154 utilities.assert_equals(expect=main.TRUE,
155 actual=stepResult,
156 onpass="Successfully created ONOS package",
157 onfail="Failed to create ONOS package")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700158
YPZhangfebf7302016-05-24 16:45:56 -0700159 main.step("Uninstall ONOS package on all Nodes")
160 uninstallResult = main.TRUE
161 for i in range(int(main.numCtrls)):
162 main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
163 u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
164 utilities.assert_equals(expect=main.TRUE, actual=u_result,
165 onpass="Test step PASS",
166 onfail="Test step FAIL")
167 uninstallResult = (uninstallResult and u_result)
Jon Hall4ba53f02015-07-29 13:07:41 -0700168
YPZhangfebf7302016-05-24 16:45:56 -0700169 main.step("Install ONOS package on all Nodes")
170 installResult = main.TRUE
171 for i in range(int(main.numCtrls)):
172 main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
173 i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
174 utilities.assert_equals(expect=main.TRUE, actual=i_result,
175 onpass="Test step PASS",
176 onfail="Test step FAIL")
177 installResult = installResult and i_result
cameron@onlab.us78b89652015-07-08 15:21:03 -0700178
YPZhangfebf7302016-05-24 16:45:56 -0700179 main.step("Verify ONOS nodes UP status")
180 statusResult = main.TRUE
181 for i in range(int(main.numCtrls)):
182 main.log.info("ONOS Node " + main.ONOSip[i] + " status:")
183 onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i])
184 utilities.assert_equals(expect=main.TRUE, actual=onos_status,
185 onpass="Test step PASS",
186 onfail="Test step FAIL")
187 statusResult = (statusResult and onos_status)
188 time.sleep(2)
189 main.step("Start ONOS CLI on all nodes")
190 cliResult = main.TRUE
Jon Hall6509dbf2016-06-21 17:01:17 -0700191 main.step(" Start ONOS cli using thread ")
YPZhangfebf7302016-05-24 16:45:56 -0700192 startCliResult = main.TRUE
193 pool = []
194 main.threadID = 0
195 for i in range(int(main.numCtrls)):
196 t = main.Thread(target=main.CLIs[i].startOnosCli,
197 threadID=main.threadID,
198 name="startOnosCli",
199 args=[main.ONOSip[i]],
200 kwargs={"onosStartTimeout": main.timeout})
201 pool.append(t)
202 t.start()
203 main.threadID = main.threadID + 1
204 for t in pool:
205 t.join()
206 startCliResult = startCliResult and t.result
207 time.sleep(main.startUpSleep)
Jon Hall4ba53f02015-07-29 13:07:41 -0700208
YPZhangfebf7302016-05-24 16:45:56 -0700209 # configure apps
210 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
211 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute")
212 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
213 main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false")
YPZhange6ef82a2016-07-05 16:48:15 -0700214 if main.flowObj:
215 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
216 "useFlowObjectives", value="true")
YPZhangfebf7302016-05-24 16:45:56 -0700217 time.sleep(main.startUpSleep)
cameron@onlab.us78b89652015-07-08 15:21:03 -0700218
YPZhangfebf7302016-05-24 16:45:56 -0700219 # Balance Master
220 main.CLIs[0].balanceMasters()
221 if len(main.ONOSip) > 1:
222 main.CLIs[0].deviceRole("null:0000000000000003", main.ONOSip[0])
223 main.CLIs[0].deviceRole("null:0000000000000004", main.ONOSip[0])
YPZhang2b9b26d2016-06-20 16:18:29 -0700224 time.sleep( main.setMasterSleep )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700225
226 def CASE2( self, main ):
cameron@onlab.us78b89652015-07-08 15:21:03 -0700227 import time
228 import numpy
229 import datetime
YPZhangfebf7302016-05-24 16:45:56 -0700230 import json
231 # from scipy import stats
cameron@onlab.us78b89652015-07-08 15:21:03 -0700232
233 ts = time.time()
YPZhangfebf7302016-05-24 16:45:56 -0700234 print(main.intentsList)
235 for batchSize in main.intentsList:
236 main.log.report("Intent Batch size: " + str(batchSize) + "\n ")
237 main.LatencyList = []
YPZhang8742d2e2016-06-16 15:31:58 -0700238 validRun = 0
239 invalidRun = 0
240 while validRun <= main.warmUp + main.sampleSize and invalidRun <= 20:
241 if validRun >= main.warmUp:
YPZhangfebf7302016-05-24 16:45:56 -0700242 main.log.info("================================================")
YPZhang8742d2e2016-06-16 15:31:58 -0700243 main.log.info("Starting test iteration: {} ".format(validRun - main.warmUp))
244 main.log.info("Total iteration: {}".format(validRun + invalidRun))
YPZhangfebf7302016-05-24 16:45:56 -0700245 main.log.info("================================================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700246 else:
YPZhangfebf7302016-05-24 16:45:56 -0700247 main.log.info("====================Warm Up=====================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700248
YPZhangfebf7302016-05-24 16:45:56 -0700249 # push intents
250 main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
251 offset=1, options="-i", timeout=main.timeout)
cameron@onlab.us78b89652015-07-08 15:21:03 -0700252
YPZhangfebf7302016-05-24 16:45:56 -0700253 # check links and flows
254 k = 0
255 verify = main.FALSE
256 linkCheck = 0
257 flowsCheck = 0
258 while k <= main.verifyAttempts:
259 time.sleep(main.verifySleep)
260 summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
261 linkCheck = summary.get("links")
262 flowsCheck = summary.get("flows")
263 if linkCheck == 16 and flowsCheck == batchSize * 7:
264 main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
265 verify = main.TRUE
266 break
267 k += 1
268 if not verify:
269 main.log.warn("Links or flows number are not match!")
270 main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck))
YPZhang8742d2e2016-06-16 15:31:58 -0700271 # bring back topology
272 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
273 time.sleep(1)
274 main.CLIs[0].purgeWithdrawnIntents()
275 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
276 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
277 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
278 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
279 if validRun >= main.warmUp:
280 invalidRun += 1
281 continue
282 else:
283 validRun += 1
284 continue
cameron@onlab.us78b89652015-07-08 15:21:03 -0700285
YPZhangfebf7302016-05-24 16:45:56 -0700286 # Bring link down
287 main.CLIs[0].link("0000000000000004/1", "0000000000000003/2", "down",
288 timeout=main.timeout, showResponse=False)
289 verify = main.FALSE
290 k = 0
291 topoManagerLog = ""
292 while k <= main.verifyAttempts:
293 time.sleep(main.verifySleep)
294 summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
295 linkCheck = summary.get("links")
296 flowsCheck = summary.get("flows")
297 if linkCheck == 14:
298 main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
299 verify = main.TRUE
300 break
301 k += 1
302 if not verify:
303 main.log.warn("Links number are not match in TopologyManager log!")
304 main.log.warn(topoManagerLog)
YPZhang8742d2e2016-06-16 15:31:58 -0700305 # bring back topology
306 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
307 time.sleep(1)
308 main.CLIs[0].purgeWithdrawnIntents()
309 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
310 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
311 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
312 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
313 if validRun >= main.warmUp:
314 invalidRun += 1
315 continue
316 else:
317 validRun += 1
318 continue
cameron@onlab.us78b89652015-07-08 15:21:03 -0700319
YPZhangfebf7302016-05-24 16:45:56 -0700320 try:
321 # expect twice to clean the pexpect buffer
322 main.ONOSbench.handle.sendline("")
323 main.ONOSbench.handle.expect("\$")
324 main.ONOSbench.handle.expect("\$")
325 # send line by using bench, can't use driver because pexpect buffer problem
326 cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1"
327 main.ONOSbench.handle.sendline(cmd)
328 time.sleep(1)
329 main.ONOSbench.handle.expect(":~")
330 topoManagerLog = main.ONOSbench.handle.before
331 topoManagerLogTemp = topoManagerLog.splitlines()
332 # To make sure we get correct topology log
333 for lines in topoManagerLogTemp:
334 if "creationTime" in lines:
335 topoManagerLog = lines
336 main.log.info("Topology Manager log:")
337 print(topoManagerLog)
338 cutTimestamp = float(topoManagerLog.split("creationTime=")[1].split(",")[0])
339 except:
340 main.log.error("Topology Log is not correct!")
341 print(topoManagerLog)
YPZhang8742d2e2016-06-16 15:31:58 -0700342 # bring back topology
343 verify = main.FALSE
344 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
345 time.sleep(1)
346 main.CLIs[0].purgeWithdrawnIntents()
347 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
348 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
349 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
350 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
351 if validRun >= main.warmUp:
352 invalidRun += 1
353 else:
354 validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700355 # If we got wrong Topology log, we should skip this iteration, and continue for next one
356 continue
357
358 installedTemp = []
359 time.sleep(1)
360 for cli in main.CLIs:
361 tempJson = json.loads(cli.intentsEventsMetrics())
362 Installedtime = tempJson.get('intentInstalledTimestamp').get('value')
363 installedTemp.append(float(Installedtime))
364 for i in range(0, len(installedTemp)):
365 main.log.info("ONOS Node {} Installed Time stemp: {}".format((i + 1), installedTemp[i]))
366 maxInstallTime = float(max(installedTemp))
YPZhang8742d2e2016-06-16 15:31:58 -0700367 if validRun >= main.warmUp and verify:
YPZhangfebf7302016-05-24 16:45:56 -0700368 main.log.info("Installed time stemp: {0:f}".format(maxInstallTime))
369 main.log.info("CutTimestamp: {0:f}".format(cutTimestamp))
370 # Both timeStemps are milliseconds
371 main.log.info("Latency: {0:f}".format(float(maxInstallTime - cutTimestamp)))
372 main.LatencyList.append(float(maxInstallTime - cutTimestamp))
YPZhang8742d2e2016-06-16 15:31:58 -0700373 # We get valid latency, validRun + 1
374 validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700375
376 # Verify Summary after we bring up link, and withdrawn intents
377 main.CLIs[0].link("0000000000000004/1", "0000000000000003/2", "up",
378 timeout=main.timeout)
379 k = 0
380 verify = main.FALSE
381 linkCheck = 0
382 flowsCheck = 0
383 while k <= main.verifyAttempts:
384 time.sleep(main.verifySleep)
385 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
386 time.sleep(1)
387 main.CLIs[0].purgeWithdrawnIntents()
388 summary = json.loads(main.CLIs[0].summary())
389 linkCheck = summary.get("links")
390 flowsCheck = summary.get("flows")
391 intentCheck = summary.get("intents")
392 if linkCheck == 16 and flowsCheck == 0 and intentCheck == 0:
393 main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
394 verify = main.TRUE
395 break
396 k += 1
397 if not verify:
398 main.log.error("links, flows, or intents are not correct!")
399 main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
YPZhang8742d2e2016-06-16 15:31:58 -0700400 # bring back topology
401 main.log.info("Bring back topology...")
402 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
403 time.sleep(1)
404 main.CLIs[0].purgeWithdrawnIntents()
405 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
406 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
407 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
408 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
YPZhangfebf7302016-05-24 16:45:56 -0700409 continue
410
411 aveLatency = 0
412 stdLatency = 0
413 aveLatency = numpy.average(main.LatencyList)
414 stdLatency = numpy.std(main.LatencyList)
415 main.log.report("Scale: " + str(main.numCtrls) + " \tIntent batch: " + str(batchSize))
416 main.log.report("Latency average:................" + str(aveLatency))
417 main.log.report("Latency standard deviation:....." + str(stdLatency))
cameron@onlab.us78b89652015-07-08 15:21:03 -0700418 main.log.report("________________________________________________________")
419
YPZhang8742d2e2016-06-16 15:31:58 -0700420 if not (numpy.isnan(aveLatency) or numpy.isnan(stdLatency)):
421 # check if got NaN for result
422 resultsDB = open(main.dbFileName, "a")
423 resultsDB.write("'" + main.commit + "',")
424 resultsDB.write(str(main.numCtrls) + ",")
425 resultsDB.write(str(batchSize) + ",")
426 resultsDB.write(str(aveLatency) + ",")
427 resultsDB.write(str(stdLatency) + "\n")
428 resultsDB.close()
YPZhangfebf7302016-05-24 16:45:56 -0700429 del main.scale[0]