blob: e861f0c21206f66269ea7186cc52358fd0fbf941 [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']
Chiyu Cheng1976db52016-10-21 15:57:30 -070084 main.deviceCount = int(main.params['TEST']['deviceCount'])
85 main.end1 = main.params['TEST']['end1']
86 main.end2 = main.params['TEST']['end2']
YPZhange6ef82a2016-07-05 16:48:15 -070087
88 if main.flowObj == "True":
89 main.flowObj = True
90 main.dbFileName = main.params['DATABASE']['dbFlowObj']
YPZhang3b5a78f2016-07-14 10:43:33 -070091 main.intentsList = (main.params['TEST']['FObjintents']).split(",")
YPZhange6ef82a2016-07-05 16:48:15 -070092 else:
93 main.flowObj = False
94 main.dbFileName = main.params['DATABASE']['dbName']
YPZhang3b5a78f2016-07-14 10:43:33 -070095 main.intentsList = (main.params['TEST']['intents']).split(",")
YPZhange6ef82a2016-07-05 16:48:15 -070096
YPZhangfebf7302016-05-24 16:45:56 -070097 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.us78b89652015-07-08 15:21:03 -0700108 import time
109
YPZhangfebf7302016-05-24 16:45:56 -0700110 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.us78b89652015-07-08 15:21:03 -0700123
YPZhangfebf7302016-05-24 16:45:56 -0700124 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.us78b89652015-07-08 15:21:03 -0700128
YPZhangfebf7302016-05-24 16:45:56 -0700129 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.us78b89652015-07-08 15:21:03 -0700134
YPZhangfebf7302016-05-24 16:45:56 -0700135 for i in range(main.numCtrls):
136 main.ONOSbench.onosDie(main.ONOSip[i])
cameron@onlab.us78b89652015-07-08 15:21:03 -0700137
YPZhangfebf7302016-05-24 16:45:56 -0700138 main.log.info("NODE COUNT = %s" % main.numCtrls)
YPZhangfebf7302016-05-24 16:45:56 -0700139 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.us78b89652015-07-08 15:21:03 -0700153
YPZhangfebf7302016-05-24 16:45:56 -0700154 main.step("Creating ONOS package")
Jon Hallbd60ea02016-08-23 10:03:59 -0700155 packageResult = main.ONOSbench.buckBuild()
YPZhangfebf7302016-05-24 16:45:56 -0700156 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.us78b89652015-07-08 15:21:03 -0700161
YPZhangfebf7302016-05-24 16:45:56 -0700162 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 Hall4ba53f02015-07-29 13:07:41 -0700171
YPZhangfebf7302016-05-24 16:45:56 -0700172 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.us78b89652015-07-08 15:21:03 -0700181
YPZhangfebf7302016-05-24 16:45:56 -0700182 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 Chengef109502016-11-21 15:51:38 -0800191
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
YPZhangfebf7302016-05-24 16:45:56 -0700200 time.sleep(2)
201 main.step("Start ONOS CLI on all nodes")
202 cliResult = main.TRUE
Jon Hall6509dbf2016-06-21 17:01:17 -0700203 main.step(" Start ONOS cli using thread ")
YPZhangfebf7302016-05-24 16:45:56 -0700204 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 Hall4ba53f02015-07-29 13:07:41 -0700220
YPZhangfebf7302016-05-24 16:45:56 -0700221 # configure apps
Chiyu Cheng1976db52016-10-21 15:57:30 -0700222 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
YPZhangfebf7302016-05-24 16:45:56 -0700223 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")
YPZhange6ef82a2016-07-05 16:48:15 -0700226 if main.flowObj:
227 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
228 "useFlowObjectives", value="true")
YPZhangfebf7302016-05-24 16:45:56 -0700229 time.sleep(main.startUpSleep)
cameron@onlab.us78b89652015-07-08 15:21:03 -0700230
YPZhangfebf7302016-05-24 16:45:56 -0700231 # Balance Master
232 main.CLIs[0].balanceMasters()
233 if len(main.ONOSip) > 1:
Chiyu Cheng1976db52016-10-21 15:57:30 -0700234 main.CLIs[0].deviceRole(main.end1[ 'name' ], main.ONOSip[0])
235 main.CLIs[0].deviceRole(main.end2[ 'name' ], main.ONOSip[0])
YPZhang2b9b26d2016-06-20 16:18:29 -0700236 time.sleep( main.setMasterSleep )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700237
238 def CASE2( self, main ):
cameron@onlab.us78b89652015-07-08 15:21:03 -0700239 import time
240 import numpy
241 import datetime
YPZhangfebf7302016-05-24 16:45:56 -0700242 import json
243 # from scipy import stats
cameron@onlab.us78b89652015-07-08 15:21:03 -0700244
245 ts = time.time()
YPZhangfebf7302016-05-24 16:45:56 -0700246 print(main.intentsList)
247 for batchSize in main.intentsList:
248 main.log.report("Intent Batch size: " + str(batchSize) + "\n ")
249 main.LatencyList = []
YPZhang8742d2e2016-06-16 15:31:58 -0700250 validRun = 0
251 invalidRun = 0
252 while validRun <= main.warmUp + main.sampleSize and invalidRun <= 20:
253 if validRun >= main.warmUp:
YPZhangfebf7302016-05-24 16:45:56 -0700254 main.log.info("================================================")
YPZhang8742d2e2016-06-16 15:31:58 -0700255 main.log.info("Starting test iteration: {} ".format(validRun - main.warmUp))
256 main.log.info("Total iteration: {}".format(validRun + invalidRun))
YPZhangfebf7302016-05-24 16:45:56 -0700257 main.log.info("================================================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700258 else:
YPZhangfebf7302016-05-24 16:45:56 -0700259 main.log.info("====================Warm Up=====================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700260
YPZhangfebf7302016-05-24 16:45:56 -0700261 # push intents
262 main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
263 offset=1, options="-i", timeout=main.timeout)
cameron@onlab.us78b89652015-07-08 15:21:03 -0700264
YPZhangfebf7302016-05-24 16:45:56 -0700265 # 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 Cheng1976db52016-10-21 15:57:30 -0700275 if linkCheck == main.deviceCount * 2 and flowsCheck == batchSize * (main.deviceCount - 1 ):
YPZhangfebf7302016-05-24 16:45:56 -0700276 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))
YPZhang8742d2e2016-06-16 15:31:58 -0700283 # 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 Cheng1976db52016-10-21 15:57:30 -0700289 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
YPZhang8742d2e2016-06-16 15:31:58 -0700290 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.us78b89652015-07-08 15:21:03 -0700297
YPZhangfebf7302016-05-24 16:45:56 -0700298 # Bring link down
Chiyu Cheng1976db52016-10-21 15:57:30 -0700299 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down",
YPZhangfebf7302016-05-24 16:45:56 -0700300 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 Cheng1976db52016-10-21 15:57:30 -0700309 if linkCheck == (main.deviceCount - 1) * 2:
YPZhangfebf7302016-05-24 16:45:56 -0700310 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)
YPZhang8742d2e2016-06-16 15:31:58 -0700317 # 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 Cheng1976db52016-10-21 15:57:30 -0700323 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
YPZhang8742d2e2016-06-16 15:31:58 -0700324 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.us78b89652015-07-08 15:21:03 -0700331
YPZhangfebf7302016-05-24 16:45:56 -0700332 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)
YPZhang8742d2e2016-06-16 15:31:58 -0700354 # 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 Cheng1976db52016-10-21 15:57:30 -0700361 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
YPZhang8742d2e2016-06-16 15:31:58 -0700362 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
YPZhangfebf7302016-05-24 16:45:56 -0700367 # 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))
YPZhang8742d2e2016-06-16 15:31:58 -0700379 if validRun >= main.warmUp and verify:
YPZhangfebf7302016-05-24 16:45:56 -0700380 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))
YPZhang8742d2e2016-06-16 15:31:58 -0700385 # 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
Chiyu Cheng1976db52016-10-21 15:57:30 -0700389 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up",
YPZhangfebf7302016-05-24 16:45:56 -0700390 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 Cheng1976db52016-10-21 15:57:30 -0700404 if linkCheck == main.deviceCount * 2 and flowsCheck == 0 and intentCheck == 0:
YPZhangfebf7302016-05-24 16:45:56 -0700405 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")
Chiyu Cheng1976db52016-10-21 15:57:30 -0700419 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
YPZhang8742d2e2016-06-16 15:31:58 -0700420 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
YPZhangfebf7302016-05-24 16:45:56 -0700421 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.us78b89652015-07-08 15:21:03 -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]