blob: 70b8a1e545102894937f01c188b05b4c66743da7 [file] [log] [blame]
YPZhangfebf7302016-05-24 16:45:56 -07001# SCPFintentRerouteLatWithFlowObj
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
YPZhang8742d2e2016-06-16 15:31:58 -070013 - The intent batch size will default set to 1 and 100, also can be set in Param file
YPZhangfebf7302016-05-24 16:45:56 -070014 - The unit of the latency result is milliseconds
15 - Ues flowObject set to True
16"""
YPZhang737d0012016-03-24 13:56:24 -070017
18class SCPFintentRerouteLatWithFlowObj:
YPZhangfebf7302016-05-24 16:45:56 -070019 def __init__(self):
YPZhang8742d2e2016-06-16 15:31:58 -070020 self.default = ''
YPZhang737d0012016-03-24 13:56:24 -070021
YPZhangfebf7302016-05-24 16:45:56 -070022 def CASE0( self, main ):
23 '''
24 - GIT
25 - BUILDING ONOS
26 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
27 This step is usually skipped. Because in a Jenkins driven automated
28 test env. We want Jenkins jobs to pull&build for flexibility to handle
29 different versions of ONOS.
30 - Construct tests variables
31 '''
32 gitPull = main.params['GIT']['gitPull']
33 gitBranch = main.params['GIT']['gitBranch']
34
35 main.case("Pull onos branch and build onos on Teststation.")
36
37 if gitPull == 'True':
38 main.step("Git Checkout ONOS branch: " + gitBranch)
39 stepResult = main.ONOSbench.gitCheckout(branch=gitBranch)
40 utilities.assert_equals(expect=main.TRUE,
41 actual=stepResult,
42 onpass="Successfully checkout onos branch.",
43 onfail="Failed to checkout onos branch. Exiting test...")
44 if not stepResult: main.exit()
45
46 main.step("Git Pull on ONOS branch:" + gitBranch)
47 stepResult = main.ONOSbench.gitPull()
48 utilities.assert_equals(expect=main.TRUE,
49 actual=stepResult,
50 onpass="Successfully pull onos. ",
51 onfail="Failed to pull onos. Exiting test ...")
52 if not stepResult: main.exit()
53
54 main.step("Building ONOS branch: " + gitBranch)
55 stepResult = main.ONOSbench.cleanInstall(skipTest=True)
56 utilities.assert_equals(expect=main.TRUE,
57 actual=stepResult,
58 onpass="Successfully build onos.",
59 onfail="Failed to build onos. Exiting test...")
60 if not stepResult: main.exit()
61
62 else:
63 main.log.warn("Skipped pulling onos and Skipped building ONOS")
64
65 main.apps = main.params['ENV']['cellApps']
66 main.BENCHUser = main.params['BENCH']['user']
67 main.BENCHIp = main.params['BENCH']['ip1']
68 main.MN1Ip = main.params['MN']['ip1']
69 main.maxNodes = int(main.params['max'])
70 main.skipMvn = main.params['TEST']['skipCleanInstall']
71 main.cellName = main.params['ENV']['cellName']
72 main.scale = (main.params['SCALE']).split(",")
73 main.dbFileName = main.params['DATABASE']['file']
74 main.timeout = int(main.params['SLEEP']['timeout'])
75 main.startUpSleep = int(main.params['SLEEP']['startup'])
76 main.installSleep = int(main.params['SLEEP']['install'])
YPZhang2b9b26d2016-06-20 16:18:29 -070077 main.setMasterSleep = int(main.params['SLEEP']['setmaster'])
YPZhangfebf7302016-05-24 16:45:56 -070078 main.verifySleep = int(main.params['SLEEP']['verify'])
79 main.verifyAttempts = int(main.params['ATTEMPTS']['verify'])
80 main.sampleSize = int(main.params['TEST']['sampleSize'])
81 main.warmUp = int(main.params['TEST']['warmUp'])
82 main.intentsList = (main.params['TEST']['intents']).split(",")
83 main.ingress = main.params['TEST']['ingress']
84 main.egress = main.params['TEST']['egress']
85 main.debug = main.params['TEST']['debug']
YPZhang8742d2e2016-06-16 15:31:58 -070086 for i in range(0, len(main.intentsList)):
YPZhangfebf7302016-05-24 16:45:56 -070087 main.intentsList[i] = int(main.intentsList[i])
YPZhang8742d2e2016-06-16 15:31:58 -070088 # Create DataBase file
89 main.log.info("Create Database file " + main.dbFileName)
90 resultsDB = open(main.dbFileName, "w+")
YPZhangfebf7302016-05-24 16:45:56 -070091 resultsDB.close()
92
YPZhang737d0012016-03-24 13:56:24 -070093 def CASE1( self, main ):
YPZhangfebf7302016-05-24 16:45:56 -070094 '''
95 clean up test environment and set up
96 '''
YPZhang737d0012016-03-24 13:56:24 -070097 import time
98
YPZhang8742d2e2016-06-16 15:31:58 -070099 main.log.info("Get ONOS cluster IP")
YPZhangfebf7302016-05-24 16:45:56 -0700100 print(main.scale)
101 main.numCtrls = int(main.scale[0])
102 main.ONOSip = []
103 main.maxNumBatch = 0
104 main.AllONOSip = main.ONOSbench.getOnosIps()
105 for i in range(main.numCtrls):
106 main.ONOSip.append(main.AllONOSip[i])
107 main.log.info(main.ONOSip)
YPZhang8742d2e2016-06-16 15:31:58 -0700108 main.CLIs = []
YPZhangfebf7302016-05-24 16:45:56 -0700109 main.log.info("Creating list of ONOS cli handles")
110 for i in range(main.numCtrls):
111 main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1)))
YPZhang737d0012016-03-24 13:56:24 -0700112
YPZhangfebf7302016-05-24 16:45:56 -0700113 if not main.CLIs:
114 main.log.error("Failed to create the list of ONOS cli handles")
115 main.cleanup()
116 main.exit()
YPZhang737d0012016-03-24 13:56:24 -0700117
YPZhangfebf7302016-05-24 16:45:56 -0700118 main.commit = main.ONOSbench.getVersion(report=True)
119 main.commit = main.commit.split(" ")[1]
120 main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls)
121 main.log.info("Safety check, killing all ONOS processes" +
122 " before initiating environment setup")
YPZhang737d0012016-03-24 13:56:24 -0700123
YPZhangfebf7302016-05-24 16:45:56 -0700124 for i in range(main.numCtrls):
125 main.ONOSbench.onosDie(main.ONOSip[i])
YPZhang737d0012016-03-24 13:56:24 -0700126
YPZhangfebf7302016-05-24 16:45:56 -0700127 main.log.info("NODE COUNT = %s" % main.numCtrls)
YPZhangfebf7302016-05-24 16:45:56 -0700128 main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
129 main.cellName,
130 main.MN1Ip,
131 main.apps,
YPZhang8742d2e2016-06-16 15:31:58 -0700132 main.ONOSip)
YPZhangfebf7302016-05-24 16:45:56 -0700133 main.step("Apply cell to environment")
134 cellResult = main.ONOSbench.setCell(main.cellName)
135 verifyResult = main.ONOSbench.verifyCell()
136 stepResult = cellResult and verifyResult
137 utilities.assert_equals(expect=main.TRUE,
138 actual=stepResult,
139 onpass="Successfully applied cell to " + \
140 "environment",
141 onfail="Failed to apply cell to environment ")
YPZhang737d0012016-03-24 13:56:24 -0700142
YPZhangfebf7302016-05-24 16:45:56 -0700143 main.step("Creating ONOS package")
YPZhang737d0012016-03-24 13:56:24 -0700144 packageResult = main.ONOSbench.onosPackage()
YPZhangfebf7302016-05-24 16:45:56 -0700145 stepResult = packageResult
146 utilities.assert_equals(expect=main.TRUE,
147 actual=stepResult,
148 onpass="Successfully created ONOS package",
149 onfail="Failed to create ONOS package")
YPZhang737d0012016-03-24 13:56:24 -0700150
YPZhangfebf7302016-05-24 16:45:56 -0700151 main.step("Uninstall ONOS package on all Nodes")
152 uninstallResult = main.TRUE
153 for i in range(int(main.numCtrls)):
154 main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
155 u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
156 utilities.assert_equals(expect=main.TRUE, actual=u_result,
157 onpass="Test step PASS",
158 onfail="Test step FAIL")
159 uninstallResult = (uninstallResult and u_result)
YPZhang737d0012016-03-24 13:56:24 -0700160
YPZhangfebf7302016-05-24 16:45:56 -0700161 main.step("Install ONOS package on all Nodes")
162 installResult = main.TRUE
163 for i in range(int(main.numCtrls)):
164 main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
165 i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
166 utilities.assert_equals(expect=main.TRUE, actual=i_result,
167 onpass="Test step PASS",
168 onfail="Test step FAIL")
169 installResult = installResult and i_result
YPZhang737d0012016-03-24 13:56:24 -0700170
YPZhangfebf7302016-05-24 16:45:56 -0700171 main.step("Verify ONOS nodes UP status")
172 statusResult = main.TRUE
173 for i in range(int(main.numCtrls)):
174 main.log.info("ONOS Node " + main.ONOSip[i] + " status:")
175 onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i])
176 utilities.assert_equals(expect=main.TRUE, actual=onos_status,
177 onpass="Test step PASS",
178 onfail="Test step FAIL")
179 statusResult = (statusResult and onos_status)
180 time.sleep(2)
181 main.step("Start ONOS CLI on all nodes")
182 cliResult = main.TRUE
183 main.log.step(" Start ONOS cli using thread ")
184 startCliResult = main.TRUE
185 pool = []
YPZhang8742d2e2016-06-16 15:31:58 -0700186 main.threadID = 0
YPZhangfebf7302016-05-24 16:45:56 -0700187 for i in range(int(main.numCtrls)):
188 t = main.Thread(target=main.CLIs[i].startOnosCli,
189 threadID=main.threadID,
190 name="startOnosCli",
191 args=[main.ONOSip[i]],
192 kwargs={"onosStartTimeout": main.timeout})
193 pool.append(t)
194 t.start()
195 main.threadID = main.threadID + 1
196 for t in pool:
197 t.join()
198 startCliResult = startCliResult and t.result
199 time.sleep(main.startUpSleep)
YPZhang737d0012016-03-24 13:56:24 -0700200
YPZhangfebf7302016-05-24 16:45:56 -0700201 # configure apps
202 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
203 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute")
204 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
205 main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false")
206 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
207 "useFlowObjectives", value="true")
YPZhang8742d2e2016-06-16 15:31:58 -0700208
YPZhangfebf7302016-05-24 16:45:56 -0700209 time.sleep(main.startUpSleep)
YPZhang737d0012016-03-24 13:56:24 -0700210
YPZhangfebf7302016-05-24 16:45:56 -0700211 # Balance Master
212 main.CLIs[0].balanceMasters()
213 if len(main.ONOSip) > 1:
214 main.CLIs[0].deviceRole("null:0000000000000003", main.ONOSip[0])
215 main.CLIs[0].deviceRole("null:0000000000000004", main.ONOSip[0])
YPZhang2b9b26d2016-06-20 16:18:29 -0700216 time.sleep( main.setMasterSleep )
YPZhang737d0012016-03-24 13:56:24 -0700217
YPZhang8742d2e2016-06-16 15:31:58 -0700218 def CASE2( self, main ):
YPZhang737d0012016-03-24 13:56:24 -0700219 import time
220 import numpy
221 import datetime
YPZhangfebf7302016-05-24 16:45:56 -0700222 import json
223 # from scipy import stats
YPZhang737d0012016-03-24 13:56:24 -0700224
225 ts = time.time()
YPZhang8742d2e2016-06-16 15:31:58 -0700226 print(main.intentsList)
YPZhangfebf7302016-05-24 16:45:56 -0700227 for batchSize in main.intentsList:
228 main.log.report("Intent Batch size: " + str(batchSize) + "\n ")
229 main.LatencyList = []
YPZhang8742d2e2016-06-16 15:31:58 -0700230 validRun = 0
231 invalidRun = 0
232 while validRun <= main.warmUp + main.sampleSize and invalidRun <= 20:
233 if validRun >= main.warmUp:
234 main.log.info("================================================")
235 main.log.info("Starting test iteration: {} ".format(validRun - main.warmUp))
236 main.log.info("Total iteration: {}".format(validRun + invalidRun))
237 main.log.info("================================================")
YPZhang737d0012016-03-24 13:56:24 -0700238 else:
YPZhang8742d2e2016-06-16 15:31:58 -0700239 main.log.info("====================Warm Up=====================")
YPZhang737d0012016-03-24 13:56:24 -0700240
YPZhangfebf7302016-05-24 16:45:56 -0700241 # push intents
242 main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
YPZhang8742d2e2016-06-16 15:31:58 -0700243 offset=1, options="-i", timeout=main.timeout)
YPZhang737d0012016-03-24 13:56:24 -0700244
YPZhangfebf7302016-05-24 16:45:56 -0700245 # check links and flows
246 k = 0
247 verify = main.FALSE
248 linkCheck = 0
249 flowsCheck = 0
250 while k <= main.verifyAttempts:
YPZhang8742d2e2016-06-16 15:31:58 -0700251 time.sleep(main.verifySleep)
252 summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
YPZhangfebf7302016-05-24 16:45:56 -0700253 linkCheck = summary.get("links")
254 flowsCheck = summary.get("flows")
YPZhang8742d2e2016-06-16 15:31:58 -0700255 if linkCheck == 16 and flowsCheck == batchSize * 7:
256 main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
YPZhangfebf7302016-05-24 16:45:56 -0700257 verify = main.TRUE
258 break
259 k += 1
260 if not verify:
YPZhang8742d2e2016-06-16 15:31:58 -0700261 main.log.warn("Links or flows number are not match!")
262 main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck))
263 # bring back topology
264 main.log.info("Bring back topology...")
265 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
266 time.sleep(1)
267 main.CLIs[0].purgeWithdrawnIntents()
268 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
269 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
270 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
271 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
272 if validRun >= main.warmUp:
273 invalidRun += 1
274 continue
275 else:
276 validRun += 1
277 continue
YPZhang737d0012016-03-24 13:56:24 -0700278
YPZhangfebf7302016-05-24 16:45:56 -0700279 # Bring link down
280 main.CLIs[0].link("0000000000000004/1", "0000000000000003/2", "down",
YPZhang8742d2e2016-06-16 15:31:58 -0700281 timeout=main.timeout, showResponse=False)
YPZhangfebf7302016-05-24 16:45:56 -0700282 verify = main.FALSE
283 k = 0
284 topoManagerLog = ""
285 while k <= main.verifyAttempts:
286 time.sleep(main.verifySleep)
YPZhang8742d2e2016-06-16 15:31:58 -0700287 summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
YPZhangfebf7302016-05-24 16:45:56 -0700288 linkCheck = summary.get("links")
289 flowsCheck = summary.get("flows")
290 if linkCheck == 14:
YPZhang8742d2e2016-06-16 15:31:58 -0700291 main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
YPZhangfebf7302016-05-24 16:45:56 -0700292 verify = main.TRUE
293 break
294 k += 1
295 if not verify:
YPZhang8742d2e2016-06-16 15:31:58 -0700296 main.log.warn("Links number are not match in TopologyManager log!")
297 main.log.warn(topoManagerLog)
298 # bring back topology
299 main.log.info("Bring back topology...")
300 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
301 time.sleep(1)
302 main.CLIs[0].purgeWithdrawnIntents()
303 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
304 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
305 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
306 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
307 if validRun >= main.warmUp:
308 invalidRun += 1
309 continue
310 else:
311 validRun += 1
312 continue
YPZhang737d0012016-03-24 13:56:24 -0700313
YPZhangfebf7302016-05-24 16:45:56 -0700314 try:
315 # expect twice to clean the pexpect buffer
316 main.ONOSbench.handle.sendline("")
317 main.ONOSbench.handle.expect("\$")
318 main.ONOSbench.handle.expect("\$")
319 # send line by using bench, can't use driver because pexpect buffer problem
320 cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1"
321 main.ONOSbench.handle.sendline(cmd)
322 time.sleep(1)
323 main.ONOSbench.handle.expect(":~")
324 topoManagerLog = main.ONOSbench.handle.before
325 topoManagerLogTemp = topoManagerLog.splitlines()
326 # To make sure we get correct topology log
327 for lines in topoManagerLogTemp:
328 if "creationTime" in lines:
329 topoManagerLog = lines
330 main.log.info("Topology Manager log:")
331 print(topoManagerLog)
332 cutTimestamp = float(topoManagerLog.split("creationTime=")[1].split(",")[0])
333 except:
334 main.log.error("Topology Log is not correct!")
335 print(topoManagerLog)
YPZhang8742d2e2016-06-16 15:31:58 -0700336 # bring back topology
337 main.log.info("Bring back topology...")
338 verify = main.FALSE
339 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
340 time.sleep(1)
341 main.CLIs[0].purgeWithdrawnIntents()
342 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
343 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
344 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
345 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
346 if validRun >= main.warmUp:
347 invalidRun += 1
348 else:
349 validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700350 # If we got wrong Topology log, we should skip this iteration, and continue for next one
351 continue
352
353 installedTemp = []
YPZhang8742d2e2016-06-16 15:31:58 -0700354 time.sleep(10)
YPZhangfebf7302016-05-24 16:45:56 -0700355 for cli in main.CLIs:
YPZhang8742d2e2016-06-16 15:31:58 -0700356 tempJson = json.loads(cli.intentsEventsMetrics())
YPZhangfebf7302016-05-24 16:45:56 -0700357 Installedtime = tempJson.get('intentInstalledTimestamp').get('value')
358 installedTemp.append(float(Installedtime))
359 for i in range(0, len(installedTemp)):
YPZhang8742d2e2016-06-16 15:31:58 -0700360 main.log.info("ONOS Node {} Installed Time stemp: {}".format((i + 1), installedTemp[i]))
361 maxInstallTime = float(max(installedTemp))
362 if validRun >= main.warmUp and verify:
363 main.log.info("Installed time stemp: {0:f}".format(maxInstallTime))
364 main.log.info("CutTimestamp: {0:f}".format(cutTimestamp))
YPZhangfebf7302016-05-24 16:45:56 -0700365 # Both timeStemps are milliseconds
YPZhang8742d2e2016-06-16 15:31:58 -0700366 main.log.info("Latency: {0:f}".format(float(maxInstallTime - cutTimestamp)))
367 if float(maxInstallTime - cutTimestamp) < 0:
368 main.log.info("Latency less than 0!")
369 # bring back topology
370 main.log.info("Bring back topology...")
371 verify = main.FALSE
372 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
373 time.sleep(1)
374 main.CLIs[0].purgeWithdrawnIntents()
375 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=0)
376 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="false")
377 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
378 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
379 if validRun >= main.warmUp:
380 invalidRun += 1
381 else:
382 validRun += 1
383 continue
384 main.LatencyList.append(float(maxInstallTime - cutTimestamp))
385 # We get valid latency, validRun + 1
386 validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700387
388 # Verify Summary after we bring up link, and withdrawn intents
YPZhang8742d2e2016-06-16 15:31:58 -0700389 main.CLIs[0].link("0000000000000004/1", "0000000000000003/2", "up",
390 timeout=main.timeout)
YPZhangfebf7302016-05-24 16:45:56 -0700391 k = 0
392 verify = main.FALSE
393 linkCheck = 0
394 flowsCheck = 0
395 while k <= main.verifyAttempts:
396 time.sleep(main.verifySleep)
YPZhang8742d2e2016-06-16 15:31:58 -0700397 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
YPZhangfebf7302016-05-24 16:45:56 -0700398 time.sleep(1)
399 main.CLIs[0].purgeWithdrawnIntents()
YPZhang8742d2e2016-06-16 15:31:58 -0700400 summary = json.loads(main.CLIs[0].summary())
YPZhangfebf7302016-05-24 16:45:56 -0700401 linkCheck = summary.get("links")
402 flowsCheck = summary.get("flows")
403 intentCheck = summary.get("intents")
404 if linkCheck == 16 and flowsCheck == 0 and intentCheck == 0:
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))
YPZhang8742d2e2016-06-16 15:31:58 -0700412 # 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")
419 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
420 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
YPZhangfebf7302016-05-24 16:45:56 -0700421 continue
422
YPZhang8742d2e2016-06-16 15:31:58 -0700423 aveLatency = 0
424 stdLatency = 0
YPZhangfebf7302016-05-24 16:45:56 -0700425 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))
YPZhang737d0012016-03-24 13:56:24 -0700430 main.log.report("________________________________________________________")
431
YPZhang8742d2e2016-06-16 15:31:58 -0700432 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()
YPZhangfebf7302016-05-24 16:45:56 -0700441 del main.scale[0]