blob: 513895043d3d798a7ce637d9334eaf7999d5ab1e [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
Chiyu Chengec63bde2016-11-17 18:11:36 -080017
cameron@onlab.us78b89652015-07-08 15:21:03 -070018class SCPFintentRerouteLat:
YPZhangfebf7302016-05-24 16:45:56 -070019 def __init__(self):
cameron@onlab.us78b89652015-07-08 15:21:03 -070020 self.default = ''
21
YPZhangfebf7302016-05-24 16:45:56 -070022 def CASE0( self, main ):
Chiyu Chengec63bde2016-11-17 18:11:36 -080023 import imp
24 import os
YPZhangfebf7302016-05-24 16:45:56 -070025 '''
26 - GIT
27 - BUILDING ONOS
28 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
29 This step is usually skipped. Because in a Jenkins driven automated
30 test env. We want Jenkins jobs to pull&build for flexibility to handle
31 different versions of ONOS.
32 - Construct tests variables
33 '''
34 gitPull = main.params['GIT']['gitPull']
35 gitBranch = main.params['GIT']['gitBranch']
cameron@onlab.us78b89652015-07-08 15:21:03 -070036
YPZhangfebf7302016-05-24 16:45:56 -070037 main.case("Pull onos branch and build onos on Teststation.")
38
39 if gitPull == 'True':
40 main.step("Git Checkout ONOS branch: " + gitBranch)
41 stepResult = main.ONOSbench.gitCheckout(branch=gitBranch)
42 utilities.assert_equals(expect=main.TRUE,
43 actual=stepResult,
44 onpass="Successfully checkout onos branch.",
45 onfail="Failed to checkout onos branch. Exiting test...")
Chiyu Chengec63bde2016-11-17 18:11:36 -080046 if not stepResult:
47 main.exit()
YPZhangfebf7302016-05-24 16:45:56 -070048
49 main.step("Git Pull on ONOS branch:" + gitBranch)
50 stepResult = main.ONOSbench.gitPull()
51 utilities.assert_equals(expect=main.TRUE,
52 actual=stepResult,
53 onpass="Successfully pull onos. ",
54 onfail="Failed to pull onos. Exiting test ...")
55 if not stepResult: main.exit()
56
57 main.step("Building ONOS branch: " + gitBranch)
58 stepResult = main.ONOSbench.cleanInstall(skipTest=True)
59 utilities.assert_equals(expect=main.TRUE,
60 actual=stepResult,
61 onpass="Successfully build onos.",
62 onfail="Failed to build onos. Exiting test...")
Chiyu Chengec63bde2016-11-17 18:11:36 -080063 if not stepResult:
64 main.exit()
YPZhangfebf7302016-05-24 16:45:56 -070065
66 else:
67 main.log.warn("Skipped pulling onos and Skipped building ONOS")
Chiyu Chengec63bde2016-11-17 18:11:36 -080068 main.onosIp = main.ONOSbench.getOnosIps()
YPZhangfebf7302016-05-24 16:45:56 -070069 main.apps = main.params['ENV']['cellApps']
70 main.BENCHUser = main.params['BENCH']['user']
71 main.BENCHIp = main.params['BENCH']['ip1']
72 main.MN1Ip = main.params['MN']['ip1']
73 main.maxNodes = int(main.params['max'])
74 main.skipMvn = main.params['TEST']['skipCleanInstall']
75 main.cellName = main.params['ENV']['cellName']
76 main.scale = (main.params['SCALE']).split(",")
YPZhangfebf7302016-05-24 16:45:56 -070077 main.timeout = int(main.params['SLEEP']['timeout'])
78 main.startUpSleep = int(main.params['SLEEP']['startup'])
79 main.installSleep = int(main.params['SLEEP']['install'])
80 main.verifySleep = int(main.params['SLEEP']['verify'])
YPZhang2b9b26d2016-06-20 16:18:29 -070081 main.setMasterSleep = int(main.params['SLEEP']['setmaster'])
YPZhangfebf7302016-05-24 16:45:56 -070082 main.verifyAttempts = int(main.params['ATTEMPTS']['verify'])
83 main.sampleSize = int(main.params['TEST']['sampleSize'])
84 main.warmUp = int(main.params['TEST']['warmUp'])
YPZhangfebf7302016-05-24 16:45:56 -070085 main.ingress = main.params['TEST']['ingress']
86 main.egress = main.params['TEST']['egress']
87 main.debug = main.params['TEST']['debug']
YPZhange6ef82a2016-07-05 16:48:15 -070088 main.flowObj = main.params['TEST']['flowObj']
Chiyu Cheng1976db52016-10-21 15:57:30 -070089 main.deviceCount = int(main.params['TEST']['deviceCount'])
90 main.end1 = main.params['TEST']['end1']
91 main.end2 = main.params['TEST']['end2']
Chiyu Chengec63bde2016-11-17 18:11:36 -080092 main.searchTerm = main.params['SEARCHTERM']
YPZhange6ef82a2016-07-05 16:48:15 -070093 if main.flowObj == "True":
94 main.flowObj = True
95 main.dbFileName = main.params['DATABASE']['dbFlowObj']
YPZhang3b5a78f2016-07-14 10:43:33 -070096 main.intentsList = (main.params['TEST']['FObjintents']).split(",")
YPZhange6ef82a2016-07-05 16:48:15 -070097 else:
98 main.flowObj = False
99 main.dbFileName = main.params['DATABASE']['dbName']
YPZhang3b5a78f2016-07-14 10:43:33 -0700100 main.intentsList = (main.params['TEST']['intents']).split(",")
YPZhange6ef82a2016-07-05 16:48:15 -0700101
YPZhangfebf7302016-05-24 16:45:56 -0700102 for i in range(0, len(main.intentsList)):
103 main.intentsList[i] = int(main.intentsList[i])
104 # Create DataBase file
105 main.log.info("Create Database file " + main.dbFileName)
106 resultsDB = open(main.dbFileName, "w+")
107 resultsDB.close()
Chiyu Chengec63bde2016-11-17 18:11:36 -0800108 file1 = main.params[ "DEPENDENCY" ][ "FILE1" ]
109 main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ]
110 main.intentRerouteLatFuncs = imp.load_source(file1, main.dependencyPath + file1 + ".py")
111
112 main.record = 0
YPZhangfebf7302016-05-24 16:45:56 -0700113
114 def CASE1( self, main ):
115 '''
116 clean up test environment and set up
117 '''
cameron@onlab.us78b89652015-07-08 15:21:03 -0700118 import time
119
YPZhangfebf7302016-05-24 16:45:56 -0700120 main.log.info("Get ONOS cluster IP")
121 print(main.scale)
122 main.numCtrls = int(main.scale[0])
123 main.ONOSip = []
124 main.maxNumBatch = 0
125 main.AllONOSip = main.ONOSbench.getOnosIps()
126 for i in range(main.numCtrls):
127 main.ONOSip.append(main.AllONOSip[i])
128 main.log.info(main.ONOSip)
129 main.CLIs = []
130 main.log.info("Creating list of ONOS cli handles")
131 for i in range(main.numCtrls):
132 main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1)))
cameron@onlab.us78b89652015-07-08 15:21:03 -0700133
YPZhangfebf7302016-05-24 16:45:56 -0700134 if not main.CLIs:
135 main.log.error("Failed to create the list of ONOS cli handles")
136 main.cleanup()
137 main.exit()
cameron@onlab.us78b89652015-07-08 15:21:03 -0700138
YPZhangfebf7302016-05-24 16:45:56 -0700139 main.commit = main.ONOSbench.getVersion(report=True)
140 main.commit = main.commit.split(" ")[1]
141 main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls)
142 main.log.info("Safety check, killing all ONOS processes" +
143 " before initiating environment setup")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700144
YPZhangfebf7302016-05-24 16:45:56 -0700145 for i in range(main.numCtrls):
146 main.ONOSbench.onosDie(main.ONOSip[i])
cameron@onlab.us78b89652015-07-08 15:21:03 -0700147
YPZhangfebf7302016-05-24 16:45:56 -0700148 main.log.info("NODE COUNT = %s" % main.numCtrls)
YPZhangfebf7302016-05-24 16:45:56 -0700149 main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
150 main.cellName,
151 main.MN1Ip,
152 main.apps,
153 main.ONOSip)
154 main.step("Apply cell to environment")
155 cellResult = main.ONOSbench.setCell(main.cellName)
156 verifyResult = main.ONOSbench.verifyCell()
157 stepResult = cellResult and verifyResult
158 utilities.assert_equals(expect=main.TRUE,
159 actual=stepResult,
160 onpass="Successfully applied cell to " + \
161 "environment",
162 onfail="Failed to apply cell to environment ")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700163
YPZhangfebf7302016-05-24 16:45:56 -0700164 main.step("Creating ONOS package")
Jon Hallbd60ea02016-08-23 10:03:59 -0700165 packageResult = main.ONOSbench.buckBuild()
YPZhangfebf7302016-05-24 16:45:56 -0700166 stepResult = packageResult
167 utilities.assert_equals(expect=main.TRUE,
168 actual=stepResult,
169 onpass="Successfully created ONOS package",
170 onfail="Failed to create ONOS package")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700171
YPZhangfebf7302016-05-24 16:45:56 -0700172 main.step("Uninstall ONOS package on all Nodes")
173 uninstallResult = main.TRUE
174 for i in range(int(main.numCtrls)):
175 main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
176 u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
177 utilities.assert_equals(expect=main.TRUE, actual=u_result,
178 onpass="Test step PASS",
179 onfail="Test step FAIL")
180 uninstallResult = (uninstallResult and u_result)
Jon Hall4ba53f02015-07-29 13:07:41 -0700181
YPZhangfebf7302016-05-24 16:45:56 -0700182 main.step("Install ONOS package on all Nodes")
183 installResult = main.TRUE
184 for i in range(int(main.numCtrls)):
185 main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
186 i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
187 utilities.assert_equals(expect=main.TRUE, actual=i_result,
188 onpass="Test step PASS",
189 onfail="Test step FAIL")
190 installResult = installResult and i_result
cameron@onlab.us78b89652015-07-08 15:21:03 -0700191
You Wangf5de25b2017-01-06 15:13:01 -0800192 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
Chiyu Chengec63bde2016-11-17 18:11:36 -0800200 main.step( "Starting ONOS service" )
201 stopResult = main.TRUE
202 startResult = main.TRUE
203 onosIsUp = main.TRUE
Chiyu Chengef109502016-11-21 15:51:38 -0800204
Chiyu Chengec63bde2016-11-17 18:11:36 -0800205 for i in range( main.numCtrls ):
206 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
207 if onosIsUp == main.TRUE:
208 main.log.report( "ONOS instance is up and ready" )
209 else:
210 main.log.report( "ONOS instance may not be up, stop and " +
211 "start ONOS again " )
212
213 for i in range( main.numCtrls ):
214 stopResult = stopResult and \
215 main.ONOSbench.onosStop( main.ONOSip[ i ] )
216 for i in range( main.numCtrls ):
217 startResult = startResult and \
218 main.ONOSbench.onosStart( main.ONOSip[ i ] )
219 stepResult = onosIsUp and stopResult and startResult
220 utilities.assert_equals( expect=main.TRUE, actual=stepResult,
221 onpass="Test step PASS",
222 onfail="Test step FAIL" )
You Wangf5de25b2017-01-06 15:13:01 -0800223
YPZhangfebf7302016-05-24 16:45:56 -0700224 time.sleep(2)
225 main.step("Start ONOS CLI on all nodes")
226 cliResult = main.TRUE
Jon Hall6509dbf2016-06-21 17:01:17 -0700227 main.step(" Start ONOS cli using thread ")
YPZhangfebf7302016-05-24 16:45:56 -0700228 startCliResult = main.TRUE
229 pool = []
230 main.threadID = 0
231 for i in range(int(main.numCtrls)):
232 t = main.Thread(target=main.CLIs[i].startOnosCli,
233 threadID=main.threadID,
234 name="startOnosCli",
235 args=[main.ONOSip[i]],
236 kwargs={"onosStartTimeout": main.timeout})
237 pool.append(t)
238 t.start()
239 main.threadID = main.threadID + 1
240 for t in pool:
241 t.join()
242 startCliResult = startCliResult and t.result
243 time.sleep(main.startUpSleep)
Jon Hall4ba53f02015-07-29 13:07:41 -0700244
YPZhangfebf7302016-05-24 16:45:56 -0700245 # configure apps
Chiyu Cheng1976db52016-10-21 15:57:30 -0700246 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
YPZhangfebf7302016-05-24 16:45:56 -0700247 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute")
248 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
249 main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false")
YPZhange6ef82a2016-07-05 16:48:15 -0700250 if main.flowObj:
251 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
252 "useFlowObjectives", value="true")
Chiyu Chengec63bde2016-11-17 18:11:36 -0800253 time.sleep( main.startUpSleep )
254 for i in range( int( main.numCtrls ) ):
255 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology" )
256 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.intent" )
YPZhangfebf7302016-05-24 16:45:56 -0700257 # Balance Master
258 main.CLIs[0].balanceMasters()
259 if len(main.ONOSip) > 1:
Chiyu Cheng1976db52016-10-21 15:57:30 -0700260 main.CLIs[0].deviceRole(main.end1[ 'name' ], main.ONOSip[0])
261 main.CLIs[0].deviceRole(main.end2[ 'name' ], main.ONOSip[0])
YPZhang2b9b26d2016-06-20 16:18:29 -0700262 time.sleep( main.setMasterSleep )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700263
264 def CASE2( self, main ):
cameron@onlab.us78b89652015-07-08 15:21:03 -0700265 import time
266 import numpy
267 import datetime
YPZhangfebf7302016-05-24 16:45:56 -0700268 import json
269 # from scipy import stats
cameron@onlab.us78b89652015-07-08 15:21:03 -0700270
271 ts = time.time()
YPZhangfebf7302016-05-24 16:45:56 -0700272 print(main.intentsList)
273 for batchSize in main.intentsList:
274 main.log.report("Intent Batch size: " + str(batchSize) + "\n ")
275 main.LatencyList = []
Chiyu Chengec63bde2016-11-17 18:11:36 -0800276 main.LatencyListTopoToFirstInstalled = []
277 main.LatencyListFirstInstalledToLastInstalled = []
278 main.validRun = 0
279 main.invalidRun = 0
280 # initial a variables to record the term of startLine in karaf logs of each node
281 main.totalLines = []
282 for i in range( main.numCtrls ):
283 main.totalLines.append( '' )
284 while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= 20:
285 if main.validRun >= main.warmUp:
YPZhangfebf7302016-05-24 16:45:56 -0700286 main.log.info("================================================")
Chiyu Chengec63bde2016-11-17 18:11:36 -0800287 main.log.info("Starting test iteration: {} ".format( main.validRun - main.warmUp))
288 main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun))
YPZhangfebf7302016-05-24 16:45:56 -0700289 main.log.info("================================================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700290 else:
YPZhangfebf7302016-05-24 16:45:56 -0700291 main.log.info("====================Warm Up=====================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700292
YPZhangfebf7302016-05-24 16:45:56 -0700293 # push intents
294 main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
295 offset=1, options="-i", timeout=main.timeout)
cameron@onlab.us78b89652015-07-08 15:21:03 -0700296
YPZhangfebf7302016-05-24 16:45:56 -0700297 # check links and flows
298 k = 0
Chiyu Chengec63bde2016-11-17 18:11:36 -0800299 main.verify = main.FALSE
YPZhangfebf7302016-05-24 16:45:56 -0700300 linkCheck = 0
301 flowsCheck = 0
302 while k <= main.verifyAttempts:
303 time.sleep(main.verifySleep)
304 summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
305 linkCheck = summary.get("links")
306 flowsCheck = summary.get("flows")
Chiyu Cheng1976db52016-10-21 15:57:30 -0700307 if linkCheck == main.deviceCount * 2 and flowsCheck == batchSize * (main.deviceCount - 1 ):
YPZhangfebf7302016-05-24 16:45:56 -0700308 main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
Chiyu Chengec63bde2016-11-17 18:11:36 -0800309 main.verify = main.TRUE
YPZhangfebf7302016-05-24 16:45:56 -0700310 break
311 k += 1
Chiyu Chengec63bde2016-11-17 18:11:36 -0800312 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700313 main.log.warn("Links or flows number are not match!")
314 main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck))
YPZhang8742d2e2016-06-16 15:31:58 -0700315 # bring back topology
Chiyu Chengec63bde2016-11-17 18:11:36 -0800316 main.intentRerouteLatFuncs.bringBackTopology( main )
317 if main.validRun >= main.warmUp:
318 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700319 continue
320 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800321 main.validRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700322 continue
YPZhangfebf7302016-05-24 16:45:56 -0700323 # Bring link down
Chiyu Cheng1976db52016-10-21 15:57:30 -0700324 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down",
YPZhangfebf7302016-05-24 16:45:56 -0700325 timeout=main.timeout, showResponse=False)
Chiyu Chengec63bde2016-11-17 18:11:36 -0800326 main.verify = main.FALSE
YPZhangfebf7302016-05-24 16:45:56 -0700327 k = 0
328 topoManagerLog = ""
329 while k <= main.verifyAttempts:
330 time.sleep(main.verifySleep)
331 summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
332 linkCheck = summary.get("links")
333 flowsCheck = summary.get("flows")
Chiyu Cheng1976db52016-10-21 15:57:30 -0700334 if linkCheck == (main.deviceCount - 1) * 2:
YPZhangfebf7302016-05-24 16:45:56 -0700335 main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
Chiyu Chengec63bde2016-11-17 18:11:36 -0800336 main.verify = main.TRUE
YPZhangfebf7302016-05-24 16:45:56 -0700337 break
338 k += 1
Chiyu Chengec63bde2016-11-17 18:11:36 -0800339 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700340 main.log.warn("Links number are not match in TopologyManager log!")
341 main.log.warn(topoManagerLog)
YPZhang8742d2e2016-06-16 15:31:58 -0700342 # bring back topology
Chiyu Chengec63bde2016-11-17 18:11:36 -0800343 main.intentRerouteLatFuncs.bringBackTopology( main )
344 if main.validRun >= main.warmUp:
345 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700346 continue
347 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800348 main.validRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700349 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800350 # record the link romving time as the startLine
351 for i in range( main.numCtrls ):
352 logNum = main.intentRerouteLatFuncs.checkLog( main, i )
353 main.totalLines[i] = str(main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ))
354 main.log.info("Node " + str( i+1 ) + ": the start timestamp is " + main.totalLines[i] + " this iteration" )
355 #Calculate values
356 lastTopologyToFirstInstalled, firstInstalledToLastInstalled, totalTime = main.intentRerouteLatFuncs.getValues( main )
357 if totalTime == -1:
358 if main.validRun >= main.warmUp:
359 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700360 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800361 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700362 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800363 else:
364 main.log.info("Get valid latency")
365 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700366
367 # Verify Summary after we bring up link, and withdrawn intents
Chiyu Cheng1976db52016-10-21 15:57:30 -0700368 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up",
YPZhangfebf7302016-05-24 16:45:56 -0700369 timeout=main.timeout)
370 k = 0
Chiyu Chengec63bde2016-11-17 18:11:36 -0800371 main.verify = main.FALSE
YPZhangfebf7302016-05-24 16:45:56 -0700372 linkCheck = 0
373 flowsCheck = 0
374 while k <= main.verifyAttempts:
375 time.sleep(main.verifySleep)
376 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
377 time.sleep(1)
378 main.CLIs[0].purgeWithdrawnIntents()
379 summary = json.loads(main.CLIs[0].summary())
380 linkCheck = summary.get("links")
381 flowsCheck = summary.get("flows")
382 intentCheck = summary.get("intents")
Chiyu Cheng1976db52016-10-21 15:57:30 -0700383 if linkCheck == main.deviceCount * 2 and flowsCheck == 0 and intentCheck == 0:
YPZhangfebf7302016-05-24 16:45:56 -0700384 main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
Chiyu Chengec63bde2016-11-17 18:11:36 -0800385 main.verify = main.TRUE
YPZhangfebf7302016-05-24 16:45:56 -0700386 break
387 k += 1
Chiyu Chengec63bde2016-11-17 18:11:36 -0800388 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700389 main.log.error("links, flows, or intents are not correct!")
390 main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
YPZhang8742d2e2016-06-16 15:31:58 -0700391 # bring back topology
Chiyu Chengec63bde2016-11-17 18:11:36 -0800392 main.intentRerouteLatFuncs.bringBackTopology( main )
YPZhangfebf7302016-05-24 16:45:56 -0700393 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800394 main.log.info("total negative results num: " + str( main.record ) )
YPZhangfebf7302016-05-24 16:45:56 -0700395
396 aveLatency = 0
Chiyu Chengec63bde2016-11-17 18:11:36 -0800397 aveLatencyTopoToFirstInstalled = 0
398 aveLatencyFirstInstalledToLastInstalled = 0
399
YPZhangfebf7302016-05-24 16:45:56 -0700400 stdLatency = 0
Chiyu Chengec63bde2016-11-17 18:11:36 -0800401 stdLatencyTopoToFirstInstalled = 0
402 stdLatencyFirstInstalledToLastInstalled = 0
403
404 aveLatency = numpy.average( main.LatencyList )
405 aveLatencyTopoToFirstInstalled = numpy.average( main.LatencyListTopoToFirstInstalled )
406 aveLatencyFirstInstalledToLastInstalled = numpy.average( main.LatencyListFirstInstalledToLastInstalled )
407
408 stdLatency = numpy.std( main.LatencyList )
409 stdLatencyTopoToFirstInstalled = numpy.std( main.LatencyListTopoToFirstInstalled )
410 stdLatencyFirstInstalledToLastInstalled = numpy.std( main.LatencyListFirstInstalledToLastInstalled )
411
412 main.log.report( "Scale: " + str( main.numCtrls ) + " \tIntent batch: " + str( batchSize ) )
413 main.log.report( "Total Latency average:................" + str( aveLatency ) )
414 main.log.report( "Latency standard deviation:..........." + str( stdLatency ) )
415 main.log.report( "Last Topology to first installed Latency average:................." + str( aveLatencyTopoToFirstInstalled ) )
416 main.log.report( "Last Topology to first installed Latency standard deviation:......" + str( stdLatencyTopoToFirstInstalled ) )
417 main.log.report( "First installed to last installed Latency average:................" + str( aveLatencyFirstInstalledToLastInstalled ) )
418 main.log.report( "First installed to last installed Latency standard deviation:....." + str( stdLatencyFirstInstalledToLastInstalled ) )
419 main.log.report( "________________________________________________________" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700420
YPZhang8742d2e2016-06-16 15:31:58 -0700421 if not (numpy.isnan(aveLatency) or numpy.isnan(stdLatency)):
422 # check if got NaN for result
423 resultsDB = open(main.dbFileName, "a")
424 resultsDB.write("'" + main.commit + "',")
425 resultsDB.write(str(main.numCtrls) + ",")
426 resultsDB.write(str(batchSize) + ",")
427 resultsDB.write(str(aveLatency) + ",")
Chiyu Chengec63bde2016-11-17 18:11:36 -0800428 resultsDB.write(str(stdLatency) + ",")
429 resultsDB.write(str(aveLatencyTopoToFirstInstalled) + ",")
430 resultsDB.write(str(stdLatencyTopoToFirstInstalled) + ",")
431 resultsDB.write(str(aveLatencyFirstInstalledToLastInstalled) + ",")
432 resultsDB.write(str(stdLatencyFirstInstalledToLastInstalled) + "\n")
YPZhang8742d2e2016-06-16 15:31:58 -0700433 resultsDB.close()
YPZhangfebf7302016-05-24 16:45:56 -0700434 del main.scale[0]