blob: f824a5cf6b3ea58b73edee5208b53912b888ab34 [file] [log] [blame]
cameron@onlab.usc80a8c82015-04-15 14:57:37 -07001# ScaleOutTemplate
cameron@onlab.us1201bc42015-04-01 16:30:05 -07002#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
8import os.path
9
10
11class IntentRerouteLat:
12
13 def __init__( self ):
14 self.default = ''
15
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070016 def CASE1( self, main ):
17
18 import time
19 global init
20 try:
21 if type(init) is not bool:
22 init = False
23 except NameError:
24 init = False
25
cameron@onlab.us1201bc42015-04-01 16:30:05 -070026 #Load values from params file
27 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070030 Apps = main.params[ 'ENV' ][ 'cellApps' ]
cameron@onlab.us1201bc42015-04-01 16:30:05 -070031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
33 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
34 maxNodes = int(main.params[ 'availableNodes' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070035 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070036 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us1201bc42015-04-01 16:30:05 -070037
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070038 # -- INIT SECTION, ONLY RUNS ONCE -- #
39 if init == False:
40 init = True
41 global clusterCount #number of nodes running
42 global ONOSIp #list of ONOS IP addresses
43 global scale
44 global commit
cameron@onlab.us1201bc42015-04-01 16:30:05 -070045
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070046 clusterCount = 0
47 ONOSIp = [ 0 ]
48 scale = (main.params[ 'SCALE' ]).split(",")
49 clusterCount = int(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070050
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070051 #Populate ONOSIp with ips from params
52 for i in range(1, maxNodes + 1):
53 ipString = 'ip' + str(i)
54 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
55
56 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
57 if skipMvn != "yes":
58 mvnResult = main.ONOSbench.cleanInstall()
cameron@onlab.us1201bc42015-04-01 16:30:05 -070059
cameron@onlab.us1201bc42015-04-01 16:30:05 -070060 #git
61 main.step( "Git checkout and pull " + checkoutBranch )
62 if gitPull == 'on':
63 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
64 pullResult = main.ONOSbench.gitPull()
65
66 else:
67 checkoutResult = main.TRUE
68 pullResult = main.TRUE
69 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070070
71 commit = main.ONOSbench.getVersion()
72 commit = (commit.split(" "))[1]
cameron@onlab.us1201bc42015-04-01 16:30:05 -070073
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070074 resultsDB = open("IntentRerouteLatDB", "w+")
75 resultsDB.close()
cameron@onlab.us1201bc42015-04-01 16:30:05 -070076
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070077 # -- END OF INIT SECTION --#
78
79 clusterCount = int(scale[0])
80 scale.remove(scale[0])
81
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070082 #kill off all onos processes
83 main.log.step("Safety check, killing all ONOS processes")
84 main.log.step("before initiating enviornment setup")
85 for node in range(1, maxNodes + 1):
86 main.ONOSbench.onosDie(ONOSIp[node])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070087
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070088 #Uninstall everywhere
89 main.log.step( "Cleaning Enviornment..." )
90 for i in range(1, maxNodes + 1):
91 main.log.info(" Uninstalling ONOS " + str(i) )
92 main.ONOSbench.onosUninstall( ONOSIp[i] )
93
94 #construct the cell file
cameron@onlab.us1201bc42015-04-01 16:30:05 -070095 main.log.info("Creating cell file")
cameron@onlab.us1201bc42015-04-01 16:30:05 -070096 cellIp = []
97 for node in range (1, clusterCount + 1):
98 cellIp.append(ONOSIp[node])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070099
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700100 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700101
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700102 main.step( "Set Cell" )
103 main.ONOSbench.setCell(cellName)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700104
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700105 main.step( "Creating ONOS package" )
106 packageResult = main.ONOSbench.onosPackage()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700107
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700108 main.step( "verify cells" )
109 verifyCellResult = main.ONOSbench.verifyCell()
110
111 main.log.report( "Initializing " + str( clusterCount ) + " node cluster." )
112 for node in range(1, clusterCount + 1):
113 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
114 main.ONOSbench.onosInstall( ONOSIp[node])
115
116 for node in range(1, clusterCount + 1):
117 for i in range( 2 ):
118 isup = main.ONOSbench.isup( ONOSIp[node] )
119 if isup:
120 main.log.info("ONOS " + str(node) + " is up\n")
121 break
122 if not isup:
123 main.log.report( "ONOS " + str(node) + " didn't start!" )
124 main.log.info("Startup sequence complete")
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700125
126 deviceMastership = (main.params[ 'TEST' ][ "s" + str(clusterCount) ]).split(",")
127 print("Device mastership list: " + str(deviceMastership))
128
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700129 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount 8 " """)
130 main.ONOSbench.handle.expect(":~")
131 print repr(main.ONOSbench.handle.before)
132 time.sleep(3)
133 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape reroute" """)
134 main.ONOSbench.handle.expect(":~")
135 print repr(main.ONOSbench.handle.before)
136 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700137
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700138 time.sleep(10)
139
140 once = True
141 for attempt in range(0,10):
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700142 main.ONOSbench.handle.sendline("onos $OC1 summary")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700143 main.ONOSbench.handle.expect(":~")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700144 x = main.ONOSbench.handle.before
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700145 main.log.info("Initial setup. ONOS summary response: \n" + x + "\n")
146
147 if "devices=8" in x and "links=16," in x:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700148 break
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700149 else:
150 if once == False:
151 main.log.error("Null provider start failed, retrying..")
152 once = False
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700153 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders enabled false" """)
154 main.ONOSbench.handle.expect(":~")
155 time.sleep(3)
156 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders enabled true" """)
157 main.ONOSbench.handle.expect(":~")
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700158 time.sleep(8)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700159
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700160 index = 1
161 for node in deviceMastership:
162 for attempt in range(0,10):
163 cmd = ( "onos $OC" + node + """ "device-role null:000000000000000""" + str(index) + " " + ONOSIp[int(node)] + """ master" """)
164 main.log.info("assigning mastership of device " + str(index) + " to node " + node + ": \n " + cmd + "\n")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700165 main.ONOSbench.handle.sendline(cmd)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700166 main.ONOSbench.handle.expect(":~")
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700167 time.sleep(4)
168
169 cmd = ( "onos $OC" + node + " roles|grep 00000" + str(index))
170 main.log.info(cmd)
171 main.ONOSbench.handle.sendline(cmd)
172 main.ONOSbench.handle.expect(":~")
173 check = main.ONOSbench.handle.before
174 main.log.info("CHECK:\n" + check)
175 if ("master=" + ONOSIp[int(node)]) in check:
176 break
177 index += 1
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700178
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700179
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700180 def CASE2( self, main ):
181
182 import time
183 import numpy
184 import datetime
185 #from scipy import stats
186
187 ts = time.time()
188 date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
189
190 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
191 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
192 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
193 debug = main.params[ 'TEST' ][ 'debug' ]
194 for i in range(0,len(intentsList)):
195 intentsList[i] = int(intentsList[i])
196
197 timestampMetrics = []
198 if main.params['METRICS']['Submitted'] == "1":
199 timestampMetrics.append("Submitted")
200 if main.params['METRICS']['Installed'] == "1":
201 timestampMetrics.append("Installed")
202 if main.params['METRICS']['Failed'] == "1":
203 timestampMetrics.append("Failed")
204 if main.params['METRICS']['Withdraw'] == "1":
205 timestampMetrics.append("Withdraw")
206 if main.params['METRICS']['Withdrawn'] == "1":
207 timestampMetrics.append("Withdrawn")
208 if debug: main.log.info(timestampMetrics)
209
210 if debug == "True":
211 debug = True
212 else:
213 debug = False
214
215 ingress = "null:0000000000000001"
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700216 egress = "null:0000000000000007"
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700217
218 for intents in intentsList:
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700219 main.log.report("Intent Batch size: " + str(intents) + "\n ")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700220 myResult = [["latency", "lastNode"] for x in range(sampleSize)]
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700221
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700222 for run in range(0, (warmUp + sampleSize)):
223 if run > warmUp:
224 main.log.info("Starting test iteration " + str(run-warmUp))
225
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700226 cmd = """onos $OC1 "push-test-intents -i """
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700227 cmd += ingress + "/0 "
228 cmd += egress + "/0 "
229 cmd += str(intents) +""" 1" """
230 if debug: main.log.info(cmd)
231
232 withdrawCmd = cmd.replace("intents -i", "intents -w ")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700233
234 #push-test-intents
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700235 main.ONOSbench.handle.sendline(cmd)
236 main.ONOSbench.handle.expect(":~")
237 myRawResult = main.ONOSbench.handle.before
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700238
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700239 for i in range(0, 40):
240 main.ONOSbench.handle.sendline("onos $OC1 summary")
241 main.ONOSbench.handle.expect(":~")
242 linkCheck = main.ONOSbench.handle.before
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700243 if ("links=16,") in linkCheck and ("flows=" + str(intents*7) + ","):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700244 break
245 if i == 39:
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700246 main.log.error("Flow/link count incorrect, data invalid."+ linkCheck)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700247
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700248
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700249 #collect timestamp from link cut
250 cmd = """onos $OC1 null-link "null:0000000000000004/1 null:0000000000000003/2 down" """
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700251 if debug: main.log.info("COMMAND: " + str(cmd))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700252 main.ONOSbench.handle.sendline(cmd)
253
254 cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1"
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700255 for i in range(0,10):
256 main.ONOSbench.handle.sendline(cmd)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700257 time.sleep(2)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700258 main.ONOSbench.handle.expect(":~")
259 raw = main.ONOSbench.handle.before
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700260 #if "NullLinkProvider" in raw and "links=14" in raw:
261 if "links=14" in raw:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700262 break
263 if i >= 9:
264 main.log.error("Expected output not being recieved... continuing")
265 main.log.info(raw)
266 break
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700267 time.sleep(2)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700268
269 temp = raw.splitlines()
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700270 for line in temp:
271 if str(date) in line:
272 temp = line
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700273 break
274
275 cutTimestamp = (temp.split(" "))[0] + " " + (temp.split(" "))[1]
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700276 if debug: main.log.info("Cut timestamp: " + cutTimestamp)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700277
278 #validate link count and flow count
279 for i in range(0, 40):
280 main.ONOSbench.handle.sendline("onos $OC1 summary")
281 main.ONOSbench.handle.expect(":~")
282 linkCheck = main.ONOSbench.handle.before
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700283 #if "links=" + str(7*intents)+ "," in linkCheck and ("flows=" + str(7*intents) + ",") in linkCheck:
284 if "links=14," in linkCheck and ("flows=" + str(8*intents) + ",") in linkCheck:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700285 break
286 if i == 39:
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700287 main.log.error("Link or flow count incorrect, data invalid." + linkCheck)
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700288
289 time.sleep(5) #trying to avoid negative values
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700290
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700291 #intents events metrics installed timestamp
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700292 IEMtimestamps = [0]*(clusterCount + 1)
293 installedTemp = [0]*(clusterCount + 1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700294 for node in range(1, clusterCount +1):
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700295 cmd = "onos $OC" + str(node) + """ "intents-events-metrics"|grep Timestamp """
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700296 raw = ""
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700297 while "epoch)" not in raw:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700298 main.ONOSbench.handle.sendline(cmd)
299 main.ONOSbench.handle.expect(":~")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700300 raw = main.ONOSbench.handle.before
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700301
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700302 print(raw)
303
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700304 intentsTimestamps = {}
305 rawTimestamps = raw.splitlines()
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700306 for line in rawTimestamps:
307 if "Timestamp" in line and "grep" not in line:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700308 metricKey = (line.split(" "))[1]
309 metricTimestamp = (line.split(" ")[len(line.split(" ")) -1]).replace("epoch)=","")
310 metricTimestamp = float(metricTimestamp)
311 metricTimestamp = numpy.divide(metricTimestamp, 1000)
312 if debug: main.log.info(repr(metricTimestamp))
313 intentsTimestamps[metricKey] = metricTimestamp
314 if metricKey == "Installed":
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700315 installedTemp[node] = metricTimestamp
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700316
317 main.log.info("Node: " + str(node) + " Timestamps: " + str(intentsTimestamps))
318 IEMtimestamps[node] = intentsTimestamps
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700319
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700320 myMax = max(installedTemp)
321 indexOfMax = installedTemp.index(myMax)
322
323 #number crunch
324 for metric in timestampMetrics: #this is where we sould add support for computing other timestamp metrics
325 if metric == "Installed":
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700326 if run >= warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700327 main.log.report("link cut timestamp: " + cutTimestamp)
328 #readableInstalledTimestamp = str(intentsTimestamps["Installed"])
329 readableInstalledTimestamp = str(myMax)
330
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700331 #main.log.report("Intent Installed timestamp: " + str(intentsTimestamps["Installed"]))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700332 main.log.report("Intent Installed timestamp: " + str(myMax))
333
334 cutEpoch = time.mktime(time.strptime(cutTimestamp, "%Y-%m-%d %H:%M:%S,%f"))
335 if debug: main.log.info("cutEpoch=" + str(cutEpoch))
336 #rerouteLatency = float(intentsTimestamps["Installed"] - cutEpoch)
337 rerouteLatency = float(myMax - cutEpoch)
338
339 rerouteLatency = numpy.divide(rerouteLatency, 1000)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700340 main.log.report("Reroute latency:" + str(rerouteLatency) + " (seconds)\n ")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700341 myResult[run-warmUp][0] = rerouteLatency
342 myResult[run-warmUp][1] = indexOfMax
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700343 if debug: main.log.info("Latency: " + str(myResult[run-warmUp][0]))
344 if debug: main.log.info("last node: " + str(myResult[run-warmUp][1]))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700345
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700346 cmd = """ onos $OC1 null-link "null:0000000000000004/1 null:0000000000000003/2 up" """
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700347
348 #wait for intent withdraw
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700349 if debug: main.log.info(cmd)
350 main.ONOSbench.handle.sendline(cmd)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700351 main.ONOSbench.handle.expect(":~")
352 main.ONOSbench.handle.sendline("onos $OC1 intents|grep WITHDRAWN|wc -l")
353 main.ONOSbench.handle.expect(":~")
354 intentWithdrawCheck = main.ONOSbench.handle.before
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700355 if (str(intents)) in intentWithdrawCheck:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700356 main.log.info("intents withdrawn")
357 if debug: main.log.info(intentWithdrawCheck)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700358
359 # wait for links to be reestablished
360 for i in range(0, 10):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700361 main.ONOSbench.handle.sendline("onos $OC1 summary")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700362 main.ONOSbench.handle.expect(":~")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700363 linkCheck = main.ONOSbench.handle.before
364 if "links=16," in linkCheck:
365 break
366 time.sleep(1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700367 if i == 9:
368 main.log.info("Links Failed to reconnect, next iteration of data invalid." + linkCheck)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700369
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700370 if run < warmUp:
371 main.log.info("Warm up run " + str(run+1) + " completed")
372
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700373 if debug: main.log.info(myResult)
374 latTemp = []
375 nodeTemp = []
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700376 for i in myResult:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700377 latTemp.append(i[0])
378 nodeTemp.append(i[1])
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700379
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700380 mode = {}
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700381 for i in nodeTemp:
382 if i in mode:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700383 mode[i] += 1
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700384 else:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700385 mode[i] = 1
386
387 for i in mode.keys():
388 if mode[i] == max(mode.values()):
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700389 nodeMode = i
390
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700391 average = numpy.average(latTemp)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700392 stdDev = numpy.std(latTemp)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700393
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700394 average = numpy.multiply(average, 1000)
395 stdDev = numpy.multiply(stdDev, 1000)
396
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700397 main.log.report("Scale: " + str(clusterCount) + " \tIntent batch: " + str(intents))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700398 main.log.report("Latency average:................" + str(average))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700399 main.log.report("Latency standard deviation:....." + str(stdDev))
400 main.log.report("Mode of last node to respond:..." + str(nodeMode))
401 main.log.report("________________________________________________________")
402
cameron@onlab.us42f5a5b2015-05-06 13:55:34 -0700403 resultsDB = open("IntentRerouteLatDB", "a")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700404 resultsDB.write("'" + commit + "',")
405 resultsDB.write(str(clusterCount) + ",")
406 resultsDB.write(str(intents) + ",")
407 resultsDB.write(str(average) + ",")
408 resultsDB.write(str(stdDev) + "\n")
409 resultsDB.close()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700410