blob: 4d72293d81c2b603dcb1b4bef39f9db055b74005 [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):
You Wangb98a9fa2017-02-15 17:27:42 -0800146 main.ONOSbench.onosStop(main.ONOSip[i])
147 main.ONOSbench.onosKill(main.ONOSip[i])
cameron@onlab.us78b89652015-07-08 15:21:03 -0700148
YPZhangfebf7302016-05-24 16:45:56 -0700149 main.log.info("NODE COUNT = %s" % main.numCtrls)
YPZhangfebf7302016-05-24 16:45:56 -0700150 main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
151 main.cellName,
152 main.MN1Ip,
153 main.apps,
154 main.ONOSip)
155 main.step("Apply cell to environment")
156 cellResult = main.ONOSbench.setCell(main.cellName)
157 verifyResult = main.ONOSbench.verifyCell()
158 stepResult = cellResult and verifyResult
159 utilities.assert_equals(expect=main.TRUE,
160 actual=stepResult,
161 onpass="Successfully applied cell to " + \
162 "environment",
163 onfail="Failed to apply cell to environment ")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700164
YPZhangfebf7302016-05-24 16:45:56 -0700165 main.step("Creating ONOS package")
Jon Hallbd60ea02016-08-23 10:03:59 -0700166 packageResult = main.ONOSbench.buckBuild()
YPZhangfebf7302016-05-24 16:45:56 -0700167 stepResult = packageResult
168 utilities.assert_equals(expect=main.TRUE,
169 actual=stepResult,
170 onpass="Successfully created ONOS package",
171 onfail="Failed to create ONOS package")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700172
YPZhangfebf7302016-05-24 16:45:56 -0700173 main.step("Uninstall ONOS package on all Nodes")
174 uninstallResult = main.TRUE
175 for i in range(int(main.numCtrls)):
176 main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
177 u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
178 utilities.assert_equals(expect=main.TRUE, actual=u_result,
179 onpass="Test step PASS",
180 onfail="Test step FAIL")
181 uninstallResult = (uninstallResult and u_result)
Jon Hall4ba53f02015-07-29 13:07:41 -0700182
YPZhangfebf7302016-05-24 16:45:56 -0700183 main.step("Install ONOS package on all Nodes")
184 installResult = main.TRUE
185 for i in range(int(main.numCtrls)):
186 main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
187 i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
188 utilities.assert_equals(expect=main.TRUE, actual=i_result,
189 onpass="Test step PASS",
190 onfail="Test step FAIL")
191 installResult = installResult and i_result
cameron@onlab.us78b89652015-07-08 15:21:03 -0700192
You Wangf5de25b2017-01-06 15:13:01 -0800193 main.step( "Set up ONOS secure SSH" )
194 secureSshResult = main.TRUE
195 for i in range( int( main.numCtrls ) ):
196 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
197 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
198 onpass="Test step PASS",
199 onfail="Test step FAIL" )
200
Chiyu Chengec63bde2016-11-17 18:11:36 -0800201 main.step( "Starting ONOS service" )
202 stopResult = main.TRUE
203 startResult = main.TRUE
204 onosIsUp = main.TRUE
Chiyu Chengef109502016-11-21 15:51:38 -0800205
Chiyu Chengec63bde2016-11-17 18:11:36 -0800206 for i in range( main.numCtrls ):
207 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
208 if onosIsUp == main.TRUE:
209 main.log.report( "ONOS instance is up and ready" )
210 else:
211 main.log.report( "ONOS instance may not be up, stop and " +
212 "start ONOS again " )
213
214 for i in range( main.numCtrls ):
215 stopResult = stopResult and \
216 main.ONOSbench.onosStop( main.ONOSip[ i ] )
217 for i in range( main.numCtrls ):
218 startResult = startResult and \
219 main.ONOSbench.onosStart( main.ONOSip[ i ] )
220 stepResult = onosIsUp and stopResult and startResult
221 utilities.assert_equals( expect=main.TRUE, actual=stepResult,
222 onpass="Test step PASS",
223 onfail="Test step FAIL" )
You Wangf5de25b2017-01-06 15:13:01 -0800224
YPZhangfebf7302016-05-24 16:45:56 -0700225 time.sleep(2)
226 main.step("Start ONOS CLI on all nodes")
227 cliResult = main.TRUE
Jon Hall6509dbf2016-06-21 17:01:17 -0700228 main.step(" Start ONOS cli using thread ")
YPZhangfebf7302016-05-24 16:45:56 -0700229 startCliResult = main.TRUE
230 pool = []
231 main.threadID = 0
232 for i in range(int(main.numCtrls)):
233 t = main.Thread(target=main.CLIs[i].startOnosCli,
234 threadID=main.threadID,
235 name="startOnosCli",
236 args=[main.ONOSip[i]],
237 kwargs={"onosStartTimeout": main.timeout})
238 pool.append(t)
239 t.start()
240 main.threadID = main.threadID + 1
241 for t in pool:
242 t.join()
243 startCliResult = startCliResult and t.result
244 time.sleep(main.startUpSleep)
Jon Hall4ba53f02015-07-29 13:07:41 -0700245
YPZhangfebf7302016-05-24 16:45:56 -0700246 # configure apps
Chiyu Cheng1976db52016-10-21 15:57:30 -0700247 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
YPZhangfebf7302016-05-24 16:45:56 -0700248 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute")
249 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
250 main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false")
YPZhange6ef82a2016-07-05 16:48:15 -0700251 if main.flowObj:
252 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
253 "useFlowObjectives", value="true")
Chiyu Chengec63bde2016-11-17 18:11:36 -0800254 time.sleep( main.startUpSleep )
255 for i in range( int( main.numCtrls ) ):
256 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology" )
257 main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.intent" )
YPZhangfebf7302016-05-24 16:45:56 -0700258 # Balance Master
259 main.CLIs[0].balanceMasters()
260 if len(main.ONOSip) > 1:
Chiyu Cheng1976db52016-10-21 15:57:30 -0700261 main.CLIs[0].deviceRole(main.end1[ 'name' ], main.ONOSip[0])
262 main.CLIs[0].deviceRole(main.end2[ 'name' ], main.ONOSip[0])
YPZhang2b9b26d2016-06-20 16:18:29 -0700263 time.sleep( main.setMasterSleep )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700264
265 def CASE2( self, main ):
cameron@onlab.us78b89652015-07-08 15:21:03 -0700266 import time
267 import numpy
268 import datetime
YPZhangfebf7302016-05-24 16:45:56 -0700269 import json
270 # from scipy import stats
cameron@onlab.us78b89652015-07-08 15:21:03 -0700271
272 ts = time.time()
YPZhangfebf7302016-05-24 16:45:56 -0700273 print(main.intentsList)
274 for batchSize in main.intentsList:
275 main.log.report("Intent Batch size: " + str(batchSize) + "\n ")
276 main.LatencyList = []
Chiyu Chengec63bde2016-11-17 18:11:36 -0800277 main.LatencyListTopoToFirstInstalled = []
278 main.LatencyListFirstInstalledToLastInstalled = []
279 main.validRun = 0
280 main.invalidRun = 0
281 # initial a variables to record the term of startLine in karaf logs of each node
282 main.totalLines = []
283 for i in range( main.numCtrls ):
284 main.totalLines.append( '' )
285 while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= 20:
286 if main.validRun >= main.warmUp:
YPZhangfebf7302016-05-24 16:45:56 -0700287 main.log.info("================================================")
Chiyu Chengec63bde2016-11-17 18:11:36 -0800288 main.log.info("Starting test iteration: {} ".format( main.validRun - main.warmUp))
289 main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun))
YPZhangfebf7302016-05-24 16:45:56 -0700290 main.log.info("================================================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700291 else:
YPZhangfebf7302016-05-24 16:45:56 -0700292 main.log.info("====================Warm Up=====================")
cameron@onlab.us78b89652015-07-08 15:21:03 -0700293
YPZhangfebf7302016-05-24 16:45:56 -0700294 # push intents
295 main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
296 offset=1, options="-i", timeout=main.timeout)
cameron@onlab.us78b89652015-07-08 15:21:03 -0700297
YPZhangfebf7302016-05-24 16:45:56 -0700298 # check links and flows
299 k = 0
Chiyu Chengec63bde2016-11-17 18:11:36 -0800300 main.verify = main.FALSE
YPZhangfebf7302016-05-24 16:45:56 -0700301 linkCheck = 0
302 flowsCheck = 0
303 while k <= main.verifyAttempts:
304 time.sleep(main.verifySleep)
305 summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
306 linkCheck = summary.get("links")
307 flowsCheck = summary.get("flows")
Chiyu Cheng1976db52016-10-21 15:57:30 -0700308 if linkCheck == main.deviceCount * 2 and flowsCheck == batchSize * (main.deviceCount - 1 ):
YPZhangfebf7302016-05-24 16:45:56 -0700309 main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
Chiyu Chengec63bde2016-11-17 18:11:36 -0800310 main.verify = main.TRUE
YPZhangfebf7302016-05-24 16:45:56 -0700311 break
312 k += 1
Chiyu Chengec63bde2016-11-17 18:11:36 -0800313 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700314 main.log.warn("Links or flows number are not match!")
315 main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck))
YPZhang8742d2e2016-06-16 15:31:58 -0700316 # bring back topology
Chiyu Chengec63bde2016-11-17 18:11:36 -0800317 main.intentRerouteLatFuncs.bringBackTopology( main )
318 if main.validRun >= main.warmUp:
319 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700320 continue
321 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800322 main.validRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700323 continue
YPZhangfebf7302016-05-24 16:45:56 -0700324 # Bring link down
Chiyu Cheng1976db52016-10-21 15:57:30 -0700325 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "down",
YPZhangfebf7302016-05-24 16:45:56 -0700326 timeout=main.timeout, showResponse=False)
Chiyu Chengec63bde2016-11-17 18:11:36 -0800327 main.verify = main.FALSE
YPZhangfebf7302016-05-24 16:45:56 -0700328 k = 0
329 topoManagerLog = ""
330 while k <= main.verifyAttempts:
331 time.sleep(main.verifySleep)
332 summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
333 linkCheck = summary.get("links")
334 flowsCheck = summary.get("flows")
Chiyu Cheng1976db52016-10-21 15:57:30 -0700335 if linkCheck == (main.deviceCount - 1) * 2:
YPZhangfebf7302016-05-24 16:45:56 -0700336 main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
Chiyu Chengec63bde2016-11-17 18:11:36 -0800337 main.verify = main.TRUE
YPZhangfebf7302016-05-24 16:45:56 -0700338 break
339 k += 1
Chiyu Chengec63bde2016-11-17 18:11:36 -0800340 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700341 main.log.warn("Links number are not match in TopologyManager log!")
342 main.log.warn(topoManagerLog)
YPZhang8742d2e2016-06-16 15:31:58 -0700343 # bring back topology
Chiyu Chengec63bde2016-11-17 18:11:36 -0800344 main.intentRerouteLatFuncs.bringBackTopology( main )
345 if main.validRun >= main.warmUp:
346 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700347 continue
348 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800349 main.validRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700350 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800351 # record the link romving time as the startLine
352 for i in range( main.numCtrls ):
353 logNum = main.intentRerouteLatFuncs.checkLog( main, i )
354 main.totalLines[i] = str(main.CLIs[ i ].getTimeStampFromLog( "last", "LINK_REMOVED", "time = ", " ", logNum=logNum ))
355 main.log.info("Node " + str( i+1 ) + ": the start timestamp is " + main.totalLines[i] + " this iteration" )
356 #Calculate values
357 lastTopologyToFirstInstalled, firstInstalledToLastInstalled, totalTime = main.intentRerouteLatFuncs.getValues( main )
358 if totalTime == -1:
359 if main.validRun >= main.warmUp:
360 main.invalidRun += 1
YPZhang8742d2e2016-06-16 15:31:58 -0700361 else:
Chiyu Chengec63bde2016-11-17 18:11:36 -0800362 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700363 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800364 else:
365 main.log.info("Get valid latency")
366 main.validRun += 1
YPZhangfebf7302016-05-24 16:45:56 -0700367
368 # Verify Summary after we bring up link, and withdrawn intents
Chiyu Cheng1976db52016-10-21 15:57:30 -0700369 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up",
YPZhangfebf7302016-05-24 16:45:56 -0700370 timeout=main.timeout)
371 k = 0
Chiyu Chengec63bde2016-11-17 18:11:36 -0800372 main.verify = main.FALSE
YPZhangfebf7302016-05-24 16:45:56 -0700373 linkCheck = 0
374 flowsCheck = 0
375 while k <= main.verifyAttempts:
376 time.sleep(main.verifySleep)
377 main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
378 time.sleep(1)
379 main.CLIs[0].purgeWithdrawnIntents()
380 summary = json.loads(main.CLIs[0].summary())
381 linkCheck = summary.get("links")
382 flowsCheck = summary.get("flows")
383 intentCheck = summary.get("intents")
Chiyu Cheng1976db52016-10-21 15:57:30 -0700384 if linkCheck == main.deviceCount * 2 and flowsCheck == 0 and intentCheck == 0:
YPZhangfebf7302016-05-24 16:45:56 -0700385 main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
Chiyu Chengec63bde2016-11-17 18:11:36 -0800386 main.verify = main.TRUE
YPZhangfebf7302016-05-24 16:45:56 -0700387 break
388 k += 1
Chiyu Chengec63bde2016-11-17 18:11:36 -0800389 if not main.verify:
YPZhangfebf7302016-05-24 16:45:56 -0700390 main.log.error("links, flows, or intents are not correct!")
391 main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
YPZhang8742d2e2016-06-16 15:31:58 -0700392 # bring back topology
Chiyu Chengec63bde2016-11-17 18:11:36 -0800393 main.intentRerouteLatFuncs.bringBackTopology( main )
YPZhangfebf7302016-05-24 16:45:56 -0700394 continue
Chiyu Chengec63bde2016-11-17 18:11:36 -0800395 main.log.info("total negative results num: " + str( main.record ) )
YPZhangfebf7302016-05-24 16:45:56 -0700396
397 aveLatency = 0
Chiyu Chengec63bde2016-11-17 18:11:36 -0800398 aveLatencyTopoToFirstInstalled = 0
399 aveLatencyFirstInstalledToLastInstalled = 0
400
YPZhangfebf7302016-05-24 16:45:56 -0700401 stdLatency = 0
Chiyu Chengec63bde2016-11-17 18:11:36 -0800402 stdLatencyTopoToFirstInstalled = 0
403 stdLatencyFirstInstalledToLastInstalled = 0
404
405 aveLatency = numpy.average( main.LatencyList )
406 aveLatencyTopoToFirstInstalled = numpy.average( main.LatencyListTopoToFirstInstalled )
407 aveLatencyFirstInstalledToLastInstalled = numpy.average( main.LatencyListFirstInstalledToLastInstalled )
408
409 stdLatency = numpy.std( main.LatencyList )
410 stdLatencyTopoToFirstInstalled = numpy.std( main.LatencyListTopoToFirstInstalled )
411 stdLatencyFirstInstalledToLastInstalled = numpy.std( main.LatencyListFirstInstalledToLastInstalled )
412
413 main.log.report( "Scale: " + str( main.numCtrls ) + " \tIntent batch: " + str( batchSize ) )
414 main.log.report( "Total Latency average:................" + str( aveLatency ) )
415 main.log.report( "Latency standard deviation:..........." + str( stdLatency ) )
416 main.log.report( "Last Topology to first installed Latency average:................." + str( aveLatencyTopoToFirstInstalled ) )
417 main.log.report( "Last Topology to first installed Latency standard deviation:......" + str( stdLatencyTopoToFirstInstalled ) )
418 main.log.report( "First installed to last installed Latency average:................" + str( aveLatencyFirstInstalledToLastInstalled ) )
419 main.log.report( "First installed to last installed Latency standard deviation:....." + str( stdLatencyFirstInstalledToLastInstalled ) )
420 main.log.report( "________________________________________________________" )
cameron@onlab.us78b89652015-07-08 15:21:03 -0700421
YPZhang8742d2e2016-06-16 15:31:58 -0700422 if not (numpy.isnan(aveLatency) or numpy.isnan(stdLatency)):
423 # check if got NaN for result
424 resultsDB = open(main.dbFileName, "a")
425 resultsDB.write("'" + main.commit + "',")
426 resultsDB.write(str(main.numCtrls) + ",")
427 resultsDB.write(str(batchSize) + ",")
428 resultsDB.write(str(aveLatency) + ",")
Chiyu Chengec63bde2016-11-17 18:11:36 -0800429 resultsDB.write(str(stdLatency) + ",")
430 resultsDB.write(str(aveLatencyTopoToFirstInstalled) + ",")
431 resultsDB.write(str(stdLatencyTopoToFirstInstalled) + ",")
432 resultsDB.write(str(aveLatencyFirstInstalledToLastInstalled) + ",")
433 resultsDB.write(str(stdLatencyFirstInstalledToLastInstalled) + "\n")
YPZhang8742d2e2016-06-16 15:31:58 -0700434 resultsDB.close()
YPZhangfebf7302016-05-24 16:45:56 -0700435 del main.scale[0]