blob: adc3b96e448bc3f2415ad6e44571739c32dfeee1 [file] [log] [blame]
andrewonlab2a6c9342014-10-16 13:40:15 -04001#TopoPerfNext
2#
3#Topology Performance test for ONOS-next
4#
5#andrew@onlab.us
6
7import time
8import sys
9import os
10import re
11
12class TopoPerfNext:
13 def __init__(self):
14 self.default = ''
15
16 def CASE1(self, main):
17 '''
18 ONOS startup sequence
19 '''
andrewonlabe9fb6722014-10-24 12:20:35 -040020 import time
21
andrewonlab2a6c9342014-10-16 13:40:15 -040022 cell_name = main.params['ENV']['cellName']
23
24 git_pull = main.params['GIT']['autoPull']
25 checkout_branch = main.params['GIT']['checkout']
26
27 ONOS1_ip = main.params['CTRL']['ip1']
andrewonlabba44bcf2014-10-16 16:54:41 -040028 ONOS2_ip = main.params['CTRL']['ip2']
29 ONOS3_ip = main.params['CTRL']['ip3']
andrewonlab2a6c9342014-10-16 13:40:15 -040030 MN1_ip = main.params['MN']['ip1']
31 BENCH_ip = main.params['BENCH']['ip']
32
33 main.case("Setting up test environment")
34
35 main.step("Creating cell file")
36 cell_file_result = main.ONOSbench.create_cell_file(
andrewonlabe6745342014-10-17 14:29:13 -040037 BENCH_ip, cell_name, MN1_ip, "onos-core",
andrewonlabba44bcf2014-10-16 16:54:41 -040038 ONOS1_ip, ONOS2_ip, ONOS3_ip)
andrewonlab2a6c9342014-10-16 13:40:15 -040039
40 main.step("Applying cell file to environment")
41 cell_apply_result = main.ONOSbench.set_cell(cell_name)
42 verify_cell_result = main.ONOSbench.verify_cell()
43
44 main.step("Git checkout and pull "+checkout_branch)
45 if git_pull == 'on':
46 checkout_result = \
47 main.ONOSbench.git_checkout(checkout_branch)
48 pull_result = main.ONOSbench.git_pull()
49 else:
50 checkout_result = main.TRUE
51 pull_result = main.TRUE
52 main.log.info("Skipped git checkout and pull")
53
54 main.step("Using mvn clean & install")
andrewonlab8d29f122014-10-22 17:15:04 -040055 #mvn_result = main.ONOSbench.clean_install()
56 mvn_result = main.TRUE
andrewonlab2a6c9342014-10-16 13:40:15 -040057
58 main.step("Creating ONOS package")
59 package_result = main.ONOSbench.onos_package()
60
61 main.step("Installing ONOS package")
andrewonlabe9fb6722014-10-24 12:20:35 -040062 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
63 install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
64 install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
andrewonlab2a6c9342014-10-16 13:40:15 -040065
andrewonlabe9fb6722014-10-24 12:20:35 -040066 #NOTE: This step may be unnecessary
67 #main.step("Starting ONOS service")
68 #start_result = main.ONOSbench.onos_start(ONOS1_ip)
andrewonlab2a6c9342014-10-16 13:40:15 -040069
andrewonlab867212a2014-10-22 20:13:38 -040070 main.step("Set cell for ONOS cli env")
71 main.ONOS1cli.set_cell(cell_name)
72 main.ONOS2cli.set_cell(cell_name)
73 main.ONOS3cli.set_cell(cell_name)
74
andrewonlabe9fb6722014-10-24 12:20:35 -040075 time.sleep(10)
76
andrewonlab867212a2014-10-22 20:13:38 -040077 main.step("Start onos cli")
andrewonlabe9fb6722014-10-24 12:20:35 -040078 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
79 cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
80 cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
81
andrewonlab867212a2014-10-22 20:13:38 -040082 main.step("Enable metrics feature")
83 main.ONOS1cli.feature_install("onos-app-metrics-topology")
84 main.ONOS2cli.feature_install("onos-app-metrics-topology")
85 main.ONOS3cli.feature_install("onos-app-metrics-topology")
86
andrewonlab2a6c9342014-10-16 13:40:15 -040087 utilities.assert_equals(expect=main.TRUE,
88 actual= cell_file_result and cell_apply_result and\
89 verify_cell_result and checkout_result and\
90 pull_result and mvn_result and\
andrewonlabe9fb6722014-10-24 12:20:35 -040091 install1_result and install2_result and\
92 install3_result,
andrewonlab8d29f122014-10-22 17:15:04 -040093 onpass="ONOS started successfully",
94 onfail="Failed to start ONOS")
andrewonlab2a6c9342014-10-16 13:40:15 -040095
andrewonlabba44bcf2014-10-16 16:54:41 -040096 def CASE2(self, main):
97 '''
98 Assign s1 to ONOS1 and measure latency
andrewonlab3a7c3c72014-10-24 17:21:03 -040099
100 There are 4 levels of latency measurements to this test:
101 1) End-to-end measurement: Complete end-to-end measurement
102 from TCP (SYN/ACK) handshake to Graph change
103 2) OFP-to-graph measurement: 'ONOS processing' snippet of
104 measurement from OFP Vendor message to Graph change
105 3) OFP-to-device measurement: 'ONOS processing without
106 graph change' snippet of measurement from OFP vendor
107 message to Device change timestamp
108 4) T0-to-device measurement: Measurement that includes
109 the switch handshake to devices timestamp without
110 the graph view change. (TCP handshake -> Device
111 change)
andrewonlabba44bcf2014-10-16 16:54:41 -0400112 '''
113 import time
andrewonlabe6745342014-10-17 14:29:13 -0400114 import subprocess
115 import json
116 import requests
117 import os
andrewonlabba44bcf2014-10-16 16:54:41 -0400118
119 ONOS1_ip = main.params['CTRL']['ip1']
120 ONOS2_ip = main.params['CTRL']['ip2']
121 ONOS3_ip = main.params['CTRL']['ip3']
andrewonlabe6745342014-10-17 14:29:13 -0400122 ONOS_user = main.params['CTRL']['user']
123
andrewonlabba44bcf2014-10-16 16:54:41 -0400124 default_sw_port = main.params['CTRL']['port1']
125
126 #Number of iterations of case
127 num_iter = main.params['TEST']['numIter']
128
andrewonlab226024e2014-10-24 16:01:32 -0400129 #Timestamp 'keys' for json metrics output.
130 #These are subject to change, hence moved into params
131 deviceTimestamp = main.params['JSON']['deviceTimestamp']
132 graphTimestamp = main.params['JSON']['graphTimestamp']
133
134 #List of switch add latency collected from
135 #all iterations
136 latency_end_to_end_list = []
137 latency_ofp_to_graph_list = []
138 latency_ofp_to_device_list = []
139 latency_t0_to_device_list = []
140
andrewonlabba44bcf2014-10-16 16:54:41 -0400141 #Directory/file to store tshark results
142 tshark_of_output = "/tmp/tshark_of_topo.txt"
143 tshark_tcp_output = "/tmp/tshark_tcp_topo.txt"
144
145 #String to grep in tshark output
146 tshark_tcp_string = "TCP 74 "+default_sw_port
147 tshark_of_string = "OFP 86 Vendor"
andrewonlabe6745342014-10-17 14:29:13 -0400148
149 #Initialize assertion to TRUE
150 assertion = main.TRUE
151
andrewonlabba44bcf2014-10-16 16:54:41 -0400152 main.log.report("Latency of adding one switch")
153
154 for i in range(0, int(num_iter)):
155 main.log.info("Starting tshark capture")
156
157 #* TCP [ACK, SYN] is used as t0_a, the
158 # very first "exchange" between ONOS and
159 # the switch for end-to-end measurement
160 #* OFP [Stats Reply] is used for t0_b
161 # the very last OFP message between ONOS
162 # and the switch for ONOS measurement
163 main.ONOS1.tshark_grep(tshark_tcp_string,
164 tshark_tcp_output)
165 main.ONOS1.tshark_grep(tshark_of_string,
166 tshark_of_output)
167
168 #Wait and ensure tshark is started and
169 #capturing
170 time.sleep(10)
171
172 main.log.info("Assigning s1 to controller")
173
174 main.Mininet1.assign_sw_controller(sw="1",
175 ip1=ONOS1_ip, port1=default_sw_port)
176
177 #Wait and ensure switch is assigned
178 #before stopping tshark
andrewonlab867212a2014-10-22 20:13:38 -0400179 time.sleep(30)
andrewonlab226024e2014-10-24 16:01:32 -0400180
181 main.log.info("Stopping all Tshark processes")
andrewonlabba44bcf2014-10-16 16:54:41 -0400182 main.ONOS1.stop_tshark()
183
andrewonlabe6745342014-10-17 14:29:13 -0400184 #tshark output is saved in ONOS. Use subprocess
185 #to copy over files to TestON for parsing
186 main.log.info("Copying over tshark files")
187
188 #TCP CAPTURE ****
andrewonlab8d29f122014-10-22 17:15:04 -0400189 #Copy the tshark output from ONOS machine to
190 #TestON machine in tshark_tcp_output directory>file
191 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
192 tshark_tcp_output+" /tmp/")
193 tcp_file = open(tshark_tcp_output, 'r')
194 temp_text = tcp_file.readline()
andrewonlabe6745342014-10-17 14:29:13 -0400195 temp_text = temp_text.split(" ")
andrewonlabba44bcf2014-10-16 16:54:41 -0400196
andrewonlabe6745342014-10-17 14:29:13 -0400197 main.log.info("Object read in from TCP capture: "+
198 str(temp_text))
andrewonlab867212a2014-10-22 20:13:38 -0400199 if len(temp_text) > 1:
andrewonlab3a7c3c72014-10-24 17:21:03 -0400200 t0_tcp = float(temp_text[1])*1000.0
andrewonlabe6745342014-10-17 14:29:13 -0400201 else:
202 main.log.error("Tshark output file for TCP"+
203 " returned unexpected results")
204 t0_tcp = 0
205 assertion = main.FALSE
andrewonlab8d29f122014-10-22 17:15:04 -0400206
207 tcp_file.close()
andrewonlabe6745342014-10-17 14:29:13 -0400208 #****************
andrewonlabba44bcf2014-10-16 16:54:41 -0400209
andrewonlabe6745342014-10-17 14:29:13 -0400210 #OF CAPTURE ****
andrewonlab8d29f122014-10-22 17:15:04 -0400211 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
212 tshark_of_output+" /tmp/")
213 of_file = open(tshark_of_output, 'r')
214
215 line_ofp = ""
andrewonlab226024e2014-10-24 16:01:32 -0400216 #Read until last line of file
andrewonlabe6745342014-10-17 14:29:13 -0400217 while True:
andrewonlab8d29f122014-10-22 17:15:04 -0400218 temp_text = of_file.readline()
219 if temp_text !='':
andrewonlabe6745342014-10-17 14:29:13 -0400220 line_ofp = temp_text
221 else:
222 break
223 obj = line_ofp.split(" ")
224
225 main.log.info("Object read in from OFP capture: "+
226 str(line_ofp))
227
andrewonlab867212a2014-10-22 20:13:38 -0400228 if len(line_ofp) > 1:
andrewonlab3a7c3c72014-10-24 17:21:03 -0400229 t0_ofp = float(obj[1])*1000.0
andrewonlabe6745342014-10-17 14:29:13 -0400230 else:
231 main.log.error("Tshark output file for OFP"+
232 " returned unexpected results")
233 t0_ofp = 0
234 assertion = main.FALSE
andrewonlab8d29f122014-10-22 17:15:04 -0400235
236 of_file.close()
andrewonlabe6745342014-10-17 14:29:13 -0400237 #****************
238
andrewonlab867212a2014-10-22 20:13:38 -0400239 json_str_1 = main.ONOS1cli.topology_events_metrics()
240 json_str_2 = main.ONOS2cli.topology_events_metrics()
241 json_str_3 = main.ONOS3cli.topology_events_metrics()
andrewonlab867212a2014-10-22 20:13:38 -0400242
243 json_obj_1 = json.loads(json_str_1)
244 json_obj_2 = json.loads(json_str_2)
245 json_obj_3 = json.loads(json_str_3)
246
andrewonlab226024e2014-10-24 16:01:32 -0400247 #Obtain graph timestamp. This timestsamp captures
248 #the epoch time at which the topology graph was updated.
249 graph_timestamp_1 = \
250 json_obj_1[graphTimestamp]['value']
251 graph_timestamp_2 = \
252 json_obj_2[graphTimestamp]['value']
253 graph_timestamp_3 = \
254 json_obj_3[graphTimestamp]['value']
andrewonlab867212a2014-10-22 20:13:38 -0400255
andrewonlab226024e2014-10-24 16:01:32 -0400256 #Obtain device timestamp. This timestamp captures
257 #the epoch time at which the device event happened
258 device_timestamp_1 = \
259 json_obj_1[deviceTimestamp]['value']
260 device_timestamp_2 = \
261 json_obj_2[deviceTimestamp]['value']
262 device_timestamp_3 = \
263 json_obj_3[deviceTimestamp]['value']
andrewonlabe9fb6722014-10-24 12:20:35 -0400264
andrewonlab226024e2014-10-24 16:01:32 -0400265 #t0 to device processing latency
266 delta_device_1 = int(device_timestamp_1) - int(t0_tcp)
267 delta_device_2 = int(device_timestamp_2) - int(t0_tcp)
268 delta_device_3 = int(device_timestamp_3) - int(t0_tcp)
269
270 #Get average of delta from all instances
271 avg_delta_device = \
272 (int(delta_device_1)+\
273 int(delta_device_2)+\
274 int(delta_device_3)) / 3
andrewonlabba44bcf2014-10-16 16:54:41 -0400275
andrewonlab226024e2014-10-24 16:01:32 -0400276 #Ensure avg delta meets the threshold before appending
277 if avg_delta_device > 0.0 and avg_delta_device < 10000:
278 latency_t0_to_device_list.append(avg_delta_device)
andrewonlabee4efeb2014-10-24 16:44:51 -0400279 else:
andrewonlab09d973e2014-10-24 18:56:58 -0400280 main.log.info("Results for t0-to-device ignored"+\
281 "due to excess in threshold")
andrewonlabee4efeb2014-10-24 16:44:51 -0400282
andrewonlab226024e2014-10-24 16:01:32 -0400283 #t0 to graph processing latency (end-to-end)
284 delta_graph_1 = int(graph_timestamp_1) - int(t0_tcp)
285 delta_graph_2 = int(graph_timestamp_2) - int(t0_tcp)
286 delta_graph_3 = int(graph_timestamp_3) - int(t0_tcp)
287
288 #Get average of delta from all instances
289 avg_delta_graph = \
290 (int(delta_graph_1)+\
291 int(delta_graph_2)+\
292 int(delta_graph_3)) / 3
293
andrewonlab226024e2014-10-24 16:01:32 -0400294 #Ensure avg delta meets the threshold before appending
295 if avg_delta_graph > 0.0 and avg_delta_graph < 10000:
andrewonlab09d973e2014-10-24 18:56:58 -0400296 latency_end_to_end_list.append(avg_delta_graph)
andrewonlabee4efeb2014-10-24 16:44:51 -0400297 else:
andrewonlab09d973e2014-10-24 18:56:58 -0400298 main.log.info("Results for end-to-end ignored"+\
299 "due to excess in threshold")
andrewonlab226024e2014-10-24 16:01:32 -0400300
301 #ofp to graph processing latency (ONOS processing)
302 delta_ofp_graph_1 = int(graph_timestamp_1) - int(t0_ofp)
303 delta_ofp_graph_2 = int(graph_timestamp_2) - int(t0_ofp)
304 delta_ofp_graph_3 = int(graph_timestamp_3) - int(t0_ofp)
305
306 avg_delta_ofp_graph = \
307 (int(delta_ofp_graph_1)+\
308 int(delta_ofp_graph_2)+\
309 int(delta_ofp_graph_3)) / 3
310
311 if avg_delta_ofp_graph > 0.0 and avg_delta_ofp_graph < 10000:
312 latency_ofp_to_graph_list.append(avg_delta_ofp_graph)
andrewonlabee4efeb2014-10-24 16:44:51 -0400313 else:
andrewonlab09d973e2014-10-24 18:56:58 -0400314 main.log.info("Results for ofp-to-graph "+\
315 "ignored due to excess in threshold")
andrewonlabee4efeb2014-10-24 16:44:51 -0400316
andrewonlab226024e2014-10-24 16:01:32 -0400317 #ofp to device processing latency (ONOS processing)
andrewonlabee4efeb2014-10-24 16:44:51 -0400318 delta_ofp_device_1 = float(device_timestamp_1) - float(t0_ofp)
319 delta_ofp_device_2 = float(device_timestamp_2) - float(t0_ofp)
320 delta_ofp_device_3 = float(device_timestamp_3) - float(t0_ofp)
andrewonlab226024e2014-10-24 16:01:32 -0400321
322 avg_delta_ofp_device = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400323 (float(delta_ofp_device_1)+\
324 float(delta_ofp_device_2)+\
325 float(delta_ofp_device_3)) / 3.0
andrewonlab226024e2014-10-24 16:01:32 -0400326
andrewonlabf47993a2014-10-24 17:56:01 -0400327 #NOTE: ofp - delta measurements are occasionally negative
328 # due to system time misalignment.
329 #TODO: Implement ptp across all clusters
330 #Just add the calculation to list for now
331 latency_ofp_to_device_list.append(avg_delta_ofp_device)
andrewonlabba44bcf2014-10-16 16:54:41 -0400332
andrewonlabe6745342014-10-17 14:29:13 -0400333 #TODO:
334 #Fetch logs upon threshold excess
andrewonlabba44bcf2014-10-16 16:54:41 -0400335
andrewonlabf47993a2014-10-24 17:56:01 -0400336
andrewonlab226024e2014-10-24 16:01:32 -0400337 main.log.info("ONOS1 delta end-to-end: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400338 str(delta_graph_1) + " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400339 main.log.info("ONOS2 delta end-to-end: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400340 str(delta_graph_2) + " ms")
341 main.log.info("ONOS3 delta end-to-end: "+
342 str(delta_graph_3) + " ms")
andrewonlabba44bcf2014-10-16 16:54:41 -0400343
andrewonlab226024e2014-10-24 16:01:32 -0400344 main.log.info("ONOS1 delta OFP - graph: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400345 str(delta_ofp_graph_1) + " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400346 main.log.info("ONOS2 delta OFP - graph: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400347 str(delta_ofp_graph_2) + " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400348 main.log.info("ONOS3 delta OFP - graph: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400349 str(delta_ofp_graph_3) + " ms")
andrewonlabe6745342014-10-17 14:29:13 -0400350
andrewonlab226024e2014-10-24 16:01:32 -0400351 main.log.info("ONOS1 delta device - t0: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400352 str(delta_device_1) + " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400353 main.log.info("ONOS2 delta device - t0: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400354 str(delta_device_2) + " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400355 main.log.info("ONOS3 delta device - t0: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400356 str(delta_device_3) + " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400357
358 main.log.info("ONOS1 delta OFP - device: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400359 str(delta_ofp_device_1) + " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400360 main.log.info("ONOS2 delta OFP - device: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400361 str(delta_ofp_device_2) + " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400362 main.log.info("ONOS3 delta OFP - device: "+
andrewonlab09d973e2014-10-24 18:56:58 -0400363 str(delta_ofp_device_3) + " ms")
andrewonlab226024e2014-10-24 16:01:32 -0400364
andrewonlab8d29f122014-10-22 17:15:04 -0400365 main.step("Remove switch from controller")
366 main.Mininet1.delete_sw_controller("s1")
andrewonlabba44bcf2014-10-16 16:54:41 -0400367
andrewonlab8d29f122014-10-22 17:15:04 -0400368 time.sleep(5)
andrewonlabba44bcf2014-10-16 16:54:41 -0400369
andrewonlab09d973e2014-10-24 18:56:58 -0400370 #END of for loop iteration
andrewonlabf47993a2014-10-24 17:56:01 -0400371
andrewonlabee4efeb2014-10-24 16:44:51 -0400372 #If there is at least 1 element in each list,
andrewonlabc15c9582014-10-24 16:35:52 -0400373 #pass the test case
374 if len(latency_end_to_end_list) > 0 and\
375 len(latency_ofp_to_graph_list) > 0 and\
376 len(latency_ofp_to_device_list) > 0 and\
377 len(latency_t0_to_device_list) > 0:
378 assertion = main.TRUE
andrewonlabf47993a2014-10-24 17:56:01 -0400379 elif len(latency_end_to_end_list) == 0:
380 #The appending of 0 here is to prevent
381 #the min,max,sum functions from failing
382 #below
383 latency_end_to_end_list.append(0)
384 assertion = main.FALSE
385 elif len(latency_ofp_to_graph_list) == 0:
386 latency_ofp_to_graph_list.append(0)
387 assertion = main.FALSE
388 elif len(latency_ofp_to_device_list) == 0:
389 latency_ofp_to_device_list.append(0)
390 assertion = main.FALSE
391 elif len(latency_t0_to_device_list) == 0:
392 latency_t0_to_device_list.append(0)
393 assertion = main.FALSE
andrewonlabc15c9582014-10-24 16:35:52 -0400394
395 #Calculate min, max, avg of latency lists
396 latency_end_to_end_max = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400397 int(max(latency_end_to_end_list))
andrewonlabc15c9582014-10-24 16:35:52 -0400398 latency_end_to_end_min = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400399 int(min(latency_end_to_end_list))
andrewonlabc15c9582014-10-24 16:35:52 -0400400 latency_end_to_end_avg = \
andrewonlabc90667c2014-10-24 16:48:28 -0400401 (int(sum(latency_end_to_end_list)) / \
andrewonlabc15c9582014-10-24 16:35:52 -0400402 len(latency_end_to_end_list))
403
404 latency_ofp_to_graph_max = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400405 int(max(latency_ofp_to_graph_list))
andrewonlabc15c9582014-10-24 16:35:52 -0400406 latency_ofp_to_graph_min = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400407 int(min(latency_ofp_to_graph_list))
andrewonlabc15c9582014-10-24 16:35:52 -0400408 latency_ofp_to_graph_avg = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400409 (int(sum(latency_ofp_to_graph_list)) / \
andrewonlabc15c9582014-10-24 16:35:52 -0400410 len(latency_ofp_to_graph_list))
411
412 latency_ofp_to_device_max = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400413 int(max(latency_ofp_to_device_list))
andrewonlabc15c9582014-10-24 16:35:52 -0400414 latency_ofp_to_device_min = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400415 int(min(latency_ofp_to_device_list))
andrewonlabc15c9582014-10-24 16:35:52 -0400416 latency_ofp_to_device_avg = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400417 (int(sum(latency_ofp_to_device_list)) / \
andrewonlabc15c9582014-10-24 16:35:52 -0400418 len(latency_ofp_to_device_list))
419
420 latency_t0_to_device_max = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400421 float(max(latency_t0_to_device_list))
andrewonlabc15c9582014-10-24 16:35:52 -0400422 latency_t0_to_device_min = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400423 float(min(latency_t0_to_device_list))
andrewonlabc15c9582014-10-24 16:35:52 -0400424 latency_t0_to_device_avg = \
andrewonlabee4efeb2014-10-24 16:44:51 -0400425 (float(sum(latency_t0_to_device_list)) / \
andrewonlabc15c9582014-10-24 16:35:52 -0400426 len(latency_ofp_to_device_list))
427
428 main.log.report("Switch add - End-to-end latency: \n"+\
429 "Min: "+str(latency_end_to_end_min)+"\n"+\
430 "Max: "+str(latency_end_to_end_max)+"\n"+\
431 "Avg: "+str(latency_end_to_end_avg))
432 main.log.report("Switch add - OFP-to-Graph latency: \n"+\
433 "Min: "+str(latency_ofp_to_graph_min)+"\n"+\
434 "Max: "+str(latency_ofp_to_graph_max)+"\n"+\
435 "Avg: "+str(latency_ofp_to_graph_avg))
436 main.log.report("Switch add - OFP-to-Device latency: \n"+\
437 "Min: "+str(latency_ofp_to_device_min)+"\n"+\
438 "Max: "+str(latency_ofp_to_device_max)+"\n"+\
439 "Avg: "+str(latency_ofp_to_device_avg))
440 main.log.report("Switch add - t0-to-Device latency: \n"+\
441 "Min: "+str(latency_t0_to_device_min)+"\n"+\
442 "Max: "+str(latency_t0_to_device_max)+"\n"+\
443 "Avg: "+str(latency_t0_to_device_avg))
andrewonlab226024e2014-10-24 16:01:32 -0400444
andrewonlab8d29f122014-10-22 17:15:04 -0400445 utilities.assert_equals(expect=main.TRUE, actual=assertion,
446 onpass="Switch latency test successful",
447 onfail="Switch latency test failed")
andrewonlabba44bcf2014-10-16 16:54:41 -0400448
andrewonlab8d29f122014-10-22 17:15:04 -0400449 def CASE3(self, main):
450 '''
451 Bring port up / down and measure latency.
452 Port enable / disable is simulated by ifconfig up / down
andrewonlab393531a2014-10-27 18:36:26 -0400453
454 In ONOS-next, we must ensure that the port we are
455 manipulating is connected to another switch with a valid
456 connection. Otherwise, graph view will not be updated.
andrewonlab8d29f122014-10-22 17:15:04 -0400457 '''
458 import time
459 import subprocess
460 import os
461 import requests
462 import json
andrewonlab2a6c9342014-10-16 13:40:15 -0400463
andrewonlab8d29f122014-10-22 17:15:04 -0400464 ONOS1_ip = main.params['CTRL']['ip1']
andrewonlab393531a2014-10-27 18:36:26 -0400465 ONOS2_ip = main.params['CTRL']['ip2']
466 ONOS3_ip = main.params['CTRL']['ip3']
andrewonlab8d29f122014-10-22 17:15:04 -0400467 ONOS_user = main.params['CTRL']['user']
andrewonlab8d29f122014-10-22 17:15:04 -0400468
andrewonlab393531a2014-10-27 18:36:26 -0400469 default_sw_port = main.params['CTRL']['port1']
470
471 #Number of iterations of case
472 num_iter = main.params['TEST']['numIter']
473
474 #Timestamp 'keys' for json metrics output.
475 #These are subject to change, hence moved into params
476 deviceTimestamp = main.params['JSON']['deviceTimestamp']
477 graphTimestamp = main.params['JSON']['graphTimestamp']
478
479 #NOTE: Some hardcoded variables you may need to configure
480 # besides the params
481
andrewonlab8d29f122014-10-22 17:15:04 -0400482 tshark_port_status = "OFP 130 Port Status"
483
484 tshark_port_up = "/tmp/tshark_port_up.txt"
485 tshark_port_down = "/tmp/tshark_port_down.txt"
andrewonlab393531a2014-10-27 18:36:26 -0400486 interface_config = "s1-eth1"
andrewonlab8d29f122014-10-22 17:15:04 -0400487
488 main.log.report("Port enable / disable latency")
489
andrewonlab393531a2014-10-27 18:36:26 -0400490 main.step("Assign switches s1 and s2 to controller 1")
andrewonlab8d29f122014-10-22 17:15:04 -0400491 main.Mininet1.assign_sw_controller(sw="1",ip1=ONOS1_ip,
492 port1=default_sw_port)
andrewonlab393531a2014-10-27 18:36:26 -0400493 main.Mininet1.assign_sw_controller(sw="2",ip1=ONOS1_ip,
494 port1=default_sw_port)
andrewonlab8d29f122014-10-22 17:15:04 -0400495
496 main.step("Verify switch is assigned correctly")
497 result_s1 = main.Mininet1.get_sw_controller(sw="s1")
andrewonlab393531a2014-10-27 18:36:26 -0400498 result_s2 = main.Mininet1.get_sw_controller(sw="s2")
499 if result_s1 == main.FALSE or result_s2 == main.FALSE:
andrewonlab8d29f122014-10-22 17:15:04 -0400500 main.log.info("Switch s1 was not assigned correctly")
501 assertion = main.FALSE
502 else:
503 main.log.info("Switch s1 was assigned correctly")
504
andrewonlab393531a2014-10-27 18:36:26 -0400505 port_up_device_to_ofp_list = []
506 port_up_graph_to_ofp_list = []
507 port_down_device_to_ofp_list = []
508 port_down_graph_to_ofp_list = []
509
andrewonlab8d29f122014-10-22 17:15:04 -0400510 for i in range(0, int(num_iter)):
511 main.step("Starting wireshark capture for port status down")
512 main.ONOS1.tshark_grep(tshark_port_status,
513 tshark_port_down)
514
515 time.sleep(10)
516
andrewonlab393531a2014-10-27 18:36:26 -0400517 #Disable interface that is connected to switch 2
518 main.step("Disable port: "+interface_config)
519 main.Mininet2.handle.sendline("sudo ifconfig "+
520 interface_config+" down")
andrewonlab8d29f122014-10-22 17:15:04 -0400521 main.Mininet2.handle.expect("\$")
522 time.sleep(20)
523
524 main.ONOS1.tshark_stop()
525 time.sleep(5)
526
527 #Copy tshark output file from ONOS to TestON instance
528 #/tmp directory
529 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
530 tshark_port_down+" /tmp/")
531
532 f_port_down = open(tshark_port_down, 'r')
andrewonlab393531a2014-10-27 18:36:26 -0400533 #Get first line of port down event from tshark
andrewonlab8d29f122014-10-22 17:15:04 -0400534 f_line = f_port_down.readline()
535 obj_down = f_line.split(" ")
536 if len(f_line) > 0:
andrewonlab393531a2014-10-27 18:36:26 -0400537 timestamp_begin_pt_down = int(float(obj_down[1]))*1000
538 main.log.info("Port down begin timestamp: "+
539 str(timestamp_begin_pt_down))
andrewonlab8d29f122014-10-22 17:15:04 -0400540 else:
541 main.log.info("Tshark output file returned unexpected"+
andrewonlab393531a2014-10-27 18:36:26 -0400542 " results: "+str(obj_down))
andrewonlab8d29f122014-10-22 17:15:04 -0400543 timestamp_begin_pt_down = 0
andrewonlab393531a2014-10-27 18:36:26 -0400544
545 f_port_down.close()
andrewonlab8d29f122014-10-22 17:15:04 -0400546
andrewonlab4e124482014-11-04 13:37:25 -0500547 main.log.info("TEST tshark obj: "+str(obj_down))
548
andrewonlab8d29f122014-10-22 17:15:04 -0400549 main.step("Obtain t1 by REST call")
andrewonlab393531a2014-10-27 18:36:26 -0400550 json_str_1 = main.ONOS1cli.topology_events_metrics()
551 json_str_2 = main.ONOS2cli.topology_events_metrics()
552 json_str_3 = main.ONOS3cli.topology_events_metrics()
andrewonlab8d29f122014-10-22 17:15:04 -0400553
andrewonlab4e124482014-11-04 13:37:25 -0500554 main.log.info("TEST json_str 1: "+str(json_str_1))
555
andrewonlab393531a2014-10-27 18:36:26 -0400556 json_obj_1 = json.loads(json_str_1)
557 json_obj_2 = json.loads(json_str_2)
558 json_obj_3 = json.loads(json_str_3)
andrewonlab8d29f122014-10-22 17:15:04 -0400559
andrewonlab393531a2014-10-27 18:36:26 -0400560 time.sleep(5)
561
562 #Obtain graph timestamp. This timestsamp captures
563 #the epoch time at which the topology graph was updated.
564 graph_timestamp_1 = \
565 json_obj_1[graphTimestamp]['value']
566 graph_timestamp_2 = \
567 json_obj_2[graphTimestamp]['value']
568 graph_timestamp_3 = \
569 json_obj_3[graphTimestamp]['value']
570
andrewonlab393531a2014-10-27 18:36:26 -0400571 #Obtain device timestamp. This timestamp captures
572 #the epoch time at which the device event happened
573 device_timestamp_1 = \
574 json_obj_1[deviceTimestamp]['value']
575 device_timestamp_2 = \
576 json_obj_2[deviceTimestamp]['value']
577 device_timestamp_3 = \
578 json_obj_3[deviceTimestamp]['value']
andrewonlab393531a2014-10-27 18:36:26 -0400579
580 #Get delta between graph event and OFP
581 pt_down_graph_to_ofp_1 = int(graph_timestamp_1) -\
582 int(timestamp_begin_pt_down)
583 pt_down_graph_to_ofp_2 = int(graph_timestamp_2) -\
584 int(timestamp_begin_pt_down)
585 pt_down_graph_to_ofp_3 = int(graph_timestamp_3) -\
586 int(timestamp_begin_pt_down)
587
588 #Get delta between device event and OFP
589 pt_down_device_to_ofp_1 = int(device_timestamp_1) -\
590 int(timestamp_begin_pt_down)
591 pt_down_device_to_ofp_2 = int(device_timestamp_2) -\
592 int(timestamp_begin_pt_down)
593 pt_down_device_to_ofp_3 = int(device_timestamp_3) -\
594 int(timestamp_begin_pt_down)
595
596 #Caluclate average across clusters
597 pt_down_graph_to_ofp_avg =\
598 (int(pt_down_graph_to_ofp_1) +
599 int(pt_down_graph_to_ofp_2) +
600 int(pt_down_graph_to_ofp_3)) / 3
601 pt_down_device_to_ofp_avg = \
602 (int(pt_down_device_to_ofp_1) +
603 int(pt_down_device_to_ofp_2) +
604 int(pt_down_device_to_ofp_3)) / 3
605
andrewonlab4e124482014-11-04 13:37:25 -0500606 if pt_down_graph_to_ofp_avg > 0.0 and \
andrewonlab393531a2014-10-27 18:36:26 -0400607 pt_down_graph_to_ofp_avg < 1000:
608 port_down_graph_to_ofp_list.append(
andrewonlababb11c32014-11-04 15:03:24 -0500609 pt_down_graph_to_ofp_avg)
610 main.log.info("Port down: graph to ofp avg: "+
611 str(pt_down_graph_to_ofp_avg) + " ms")
andrewonlab393531a2014-10-27 18:36:26 -0400612 else:
613 main.log.info("Average port down graph-to-ofp result" +
614 " exceeded the threshold: "+
615 str(pt_down_graph_to_ofp_avg))
616
andrewonlab3622beb2014-10-28 16:07:56 -0400617 if pt_down_device_to_ofp_avg > 0 and \
618 pt_down_device_to_ofp_avg < 1000:
619 port_down_device_to_ofp_list.append(
andrewonlababb11c32014-11-04 15:03:24 -0500620 pt_down_device_to_ofp_avg)
621 main.log.info("Port down: device to ofp avg: "+
622 str(pt_down_device_to_ofp_avg) + " ms")
andrewonlab3622beb2014-10-28 16:07:56 -0400623 else:
624 main.log.info("Average port down device-to-ofp result" +
625 " exceeded the threshold: "+
626 str(pt_down_device_to_ofp_avg))
627
andrewonlab8d29f122014-10-22 17:15:04 -0400628 #Port up events
629 main.step("Enable port and obtain timestamp")
630 main.step("Starting wireshark capture for port status up")
631 main.ONOS1.tshark_grep("OFP 130 Port Status", tshark_port_up)
632 time.sleep(10)
633
andrewonlab393531a2014-10-27 18:36:26 -0400634 main.Mininet2.handle.sendline("sudo ifconfig "+
635 interface_config+" up")
andrewonlab8d29f122014-10-22 17:15:04 -0400636 main.Mininet2.handle.expect("\$")
637 time.sleep(20)
638
639 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
640 tshark_port_up+" /tmp/")
641
642 f_port_up = open(tshark_port_up, 'r')
andrewonlab393531a2014-10-27 18:36:26 -0400643 f_line = f_port_up.readline()
andrewonlab8d29f122014-10-22 17:15:04 -0400644 obj_up = f_line.split(" ")
645 if len(f_line) > 0:
andrewonlab393531a2014-10-27 18:36:26 -0400646 timestamp_begin_pt_up = int(float(obj_up[1]))*1000
647 main.log.info("Port up begin timestamp: "+
648 str(timestamp_begin_pt_up))
andrewonlab8d29f122014-10-22 17:15:04 -0400649 else:
650 main.log.info("Tshark output file returned unexpected"+
651 " results.")
652 timestamp_begin_pt_up = 0
653
andrewonlab393531a2014-10-27 18:36:26 -0400654 f_port_up.close()
655
andrewonlab8d29f122014-10-22 17:15:04 -0400656 main.step("Obtain t1 by REST call")
andrewonlab393531a2014-10-27 18:36:26 -0400657 json_str_1 = main.ONOS1cli.topology_events_metrics()
658 json_str_2 = main.ONOS2cli.topology_events_metrics()
659 json_str_3 = main.ONOS3cli.topology_events_metrics()
andrewonlab8d29f122014-10-22 17:15:04 -0400660
andrewonlab393531a2014-10-27 18:36:26 -0400661 json_obj_1 = json.loads(json_str_1)
662 json_obj_2 = json.loads(json_str_2)
663 json_obj_3 = json.loads(json_str_3)
andrewonlab8d29f122014-10-22 17:15:04 -0400664
andrewonlab393531a2014-10-27 18:36:26 -0400665 #Obtain graph timestamp. This timestsamp captures
666 #the epoch time at which the topology graph was updated.
667 graph_timestamp_1 = \
668 json_obj_1[graphTimestamp]['value']
669 graph_timestamp_2 = \
670 json_obj_2[graphTimestamp]['value']
671 graph_timestamp_3 = \
672 json_obj_3[graphTimestamp]['value']
673
674 #Obtain device timestamp. This timestamp captures
675 #the epoch time at which the device event happened
676 device_timestamp_1 = \
677 json_obj_1[deviceTimestamp]['value']
678 device_timestamp_2 = \
679 json_obj_2[deviceTimestamp]['value']
680 device_timestamp_3 = \
681 json_obj_3[deviceTimestamp]['value']
682
683 #Get delta between graph event and OFP
684 pt_up_graph_to_ofp_1 = int(graph_timestamp_1) -\
andrewonlab8d29f122014-10-22 17:15:04 -0400685 int(timestamp_begin_pt_up)
andrewonlab393531a2014-10-27 18:36:26 -0400686 pt_up_graph_to_ofp_2 = int(graph_timestamp_2) -\
andrewonlab8d29f122014-10-22 17:15:04 -0400687 int(timestamp_begin_pt_up)
andrewonlab393531a2014-10-27 18:36:26 -0400688 pt_up_graph_to_ofp_3 = int(graph_timestamp_3) -\
689 int(timestamp_begin_pt_up)
690
691 #Get delta between device event and OFP
692 pt_up_device_to_ofp_1 = int(device_timestamp_1) -\
693 int(timestamp_begin_pt_up)
694 pt_up_device_to_ofp_2 = int(device_timestamp_2) -\
695 int(timestamp_begin_pt_up)
696 pt_up_device_to_ofp_3 = int(device_timestamp_3) -\
andrewonlab8d29f122014-10-22 17:15:04 -0400697 int(timestamp_begin_pt_up)
andrewonlab3622beb2014-10-28 16:07:56 -0400698
699 pt_up_graph_to_ofp_avg = \
700 (float(pt_up_graph_to_ofp_1) +
701 float(pt_up_graph_to_ofp_2) +
702 float(pt_up_graph_to_ofp_3)) / 3
703
704 pt_up_device_to_ofp_avg = \
705 (float(pt_up_device_to_ofp_1) +
706 float(pt_up_device_to_ofp_2) +
707 float(pt_up_device_to_ofp_3)) / 3
708
709 if pt_up_graph_to_ofp_avg > 0 and \
710 pt_up_graph_to_ofp_avg < 1000:
711 port_up_graph_to_ofp_list.append(
712 pt_up_graph_to_ofp_avg)
andrewonlababb11c32014-11-04 15:03:24 -0500713 main.log.info("Port down: graph to ofp avg: "+
714 str(pt_up_graph_to_ofp_avg) + " ms")
andrewonlab3622beb2014-10-28 16:07:56 -0400715 else:
716 main.log.info("Average port up graph-to-ofp result"+
717 " exceeded the threshold: "+
718 str(pt_up_graph_to_ofp_avg))
719
720 if pt_up_device_to_ofp_avg > 0 and \
721 pt_up_device_to_ofp_avg < 1000:
722 port_up_device_to_ofp_list.append(
723 pt_up_device_to_ofp_avg)
andrewonlababb11c32014-11-04 15:03:24 -0500724 main.log.info("Port up: device to ofp avg: "+
725 str(pt_up_device_to_ofp_avg) + " ms")
andrewonlab3622beb2014-10-28 16:07:56 -0400726 else:
andrewonlababb11c32014-11-04 15:03:24 -0500727 main.log.info("Average port up device-to-ofp result"+
andrewonlab3622beb2014-10-28 16:07:56 -0400728 " exceeded the threshold: "+
729 str(pt_up_device_to_ofp_avg))
andrewonlab8d29f122014-10-22 17:15:04 -0400730
andrewonlab3622beb2014-10-28 16:07:56 -0400731 #END ITERATION FOR LOOP
andrewonlababb11c32014-11-04 15:03:24 -0500732
733 #Calculate and report latency measurements
andrewonlab3622beb2014-10-28 16:07:56 -0400734 port_down_graph_to_ofp_min = min(port_down_graph_to_ofp_list)
735 port_down_graph_to_ofp_max = max(port_down_graph_to_ofp_list)
736 port_down_graph_to_ofp_avg = \
737 (sum(port_down_graph_to_ofp_list) /
738 len(port_down_graph_to_ofp_list))
739
andrewonlababb11c32014-11-04 15:03:24 -0500740 main.log.report("Port down graph-to-ofp Min: "+
741 str(port_down_graph_to_ofp_min))
742 main.log.report("Port down graph-to-ofp Max: "+
743 str(port_down_graph_to_ofp_max))
744 main.log.report("Port down graph-to-ofp Avg: "+
745 str(port_down_graph_to_ofp_avg))
746
747 port_down_device_to_ofp_min = min(port_down_device_to_ofp_list)
748 port_down_device_to_ofp_max = max(port_down_device_to_ofp_list)
749 port_down_device_to_ofp_avg = \
750 (sum(port_down_device_to_ofp_list) /\
751 len(port_down_device_to_ofp_list))
752
753 main.log.report("Port down device-to-ofp Min: "+
754 str(port_down_device_to_ofp_min))
755 main.log.report("Port down device-to-ofp Max: "+
756 str(port_down_device_to_ofp_max))
757 main.log.report("Port down device-to-ofp Avg: "+
758 str(port_down_device_to_ofp_avg))
759
760 port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list)
761 port_up_graph_to_ofp_max = max(port_up_graph_to_ofp_list)
762 port_up_graph_to_ofp_avg = \
763 (sum(port_up_graph_to_ofp_list) /\
764 len(port_up_graph_to_ofp_list))
765
766
andrewonlab3622beb2014-10-28 16:07:56 -0400767 def CASE4(self, main):
768 '''
769 Link down event using loss rate 100%
andrewonlab53b641c2014-10-31 19:44:44 -0400770
771 Important:
772 Use a simple 2 switch topology with 1 link between
773 the two switches. Ensure that mac addresses of the
774 switches are 1 / 2 respectively
andrewonlab3622beb2014-10-28 16:07:56 -0400775 '''
776 import time
777 import subprocess
778 import os
779 import requests
780 import json
781
782 ONOS1_ip = main.params['CTRL']['ip1']
783 ONOS2_ip = main.params['CTRL']['ip2']
784 ONOS3_ip = main.params['CTRL']['ip3']
785 ONOS_user = main.params['CTRL']['user']
786
787 default_sw_port = main.params['CTRL']['port1']
788
789 #Number of iterations of case
790 num_iter = main.params['TEST']['numIter']
791
792 #Timestamp 'keys' for json metrics output.
793 #These are subject to change, hence moved into params
794 deviceTimestamp = main.params['JSON']['deviceTimestamp']
795 linkTimestamp = main.params['JSON']['linkTimestamp']
andrewonlab53b641c2014-10-31 19:44:44 -0400796 graphTimestamp = main.params['JSON']['graphTimestamp']
797
andrewonlab3622beb2014-10-28 16:07:56 -0400798 assertion = main.TRUE
799 #Link event timestamp to system time list
800 link_down_link_to_system_list = []
801 link_up_link_to_system_list = []
802 #Graph event timestamp to system time list
803 link_down_graph_to_system_list = []
804 link_up_graph_to_system_list = []
805
806 main.log.report("Add / remove link latency between "+
807 "two switches")
808
809 main.step("Assign all switches")
810 main.Mininet1.assign_sw_controller(sw="1",
811 ip1=ONOS1_ip, port1=default_sw_port)
812 main.Mininet1.assign_sw_controller(sw="2",
813 ip1=ONOS1_ip, port1=default_sw_port)
814
815 main.step("Verifying switch assignment")
816 result_s1 = main.Mininet1.get_sw_controller(sw="s1")
817 result_s2 = main.Mininet1.get_sw_controller(sw="s2")
andrewonlab3622beb2014-10-28 16:07:56 -0400818
819 #Allow time for events to finish before taking measurements
820 time.sleep(10)
821
andrewonlababb11c32014-11-04 15:03:24 -0500822 link_down1 = False
823 link_down2 = False
824 link_down3 = False
andrewonlab3622beb2014-10-28 16:07:56 -0400825 #Start iteration of link event test
826 for i in range(0, int(num_iter)):
827 main.step("Getting initial system time as t0")
andrewonlab8d29f122014-10-22 17:15:04 -0400828
andrewonlab3622beb2014-10-28 16:07:56 -0400829 timestamp_link_down_t0 = time.time() * 1000
830 #Link down is simulated by 100% loss rate using traffic
831 #control command
832 main.Mininet1.handle.sendline(
833 "sh tc qdisc add dev s1-eth1 root netem loss 100%")
834
andrewonlab53b641c2014-10-31 19:44:44 -0400835 #TODO: Iterate through 'links' command to verify that
andrewonlababb11c32014-11-04 15:03:24 -0500836 # link s1 -> s2 went down (loop timeout 30 seconds)
837 # on all 3 ONOS instances
andrewonlab53b641c2014-10-31 19:44:44 -0400838 main.log.info("Checking ONOS for link update")
839 loop_count = 0
andrewonlababb11c32014-11-04 15:03:24 -0500840 while( not (link_down1 and link_down2 and link_down3)\
841 and loop_count < 30 ):
842 json_str1 = main.ONOS1cli.links()
843 json_str2 = main.ONOS2cli.links()
844 json_str3 = main.ONOS3cli.links()
845
846 if not (json_str1 and json_str2 and json_str3):
847 main.log.error("CLI command returned error ")
andrewonlab53b641c2014-10-31 19:44:44 -0400848 break
849 else:
andrewonlababb11c32014-11-04 15:03:24 -0500850 json_obj1 = json.loads(json_str1)
851 json_obj2 = json.loads(json_str2)
852 json_obj3 = json.loads(json_str3)
853 for obj1 in json_obj1:
854 if '01' not in obj1['src']['device']:
855 link_down1 = True
andrewonlab53b641c2014-10-31 19:44:44 -0400856 main.log.report("Link down from "+
andrewonlababb11c32014-11-04 15:03:24 -0500857 "s1 -> s2 on ONOS1 detected")
858 for obj2 in json_obj2:
859 if '01' not in obj2['src']['device']:
860 link_down2 = True
861 main.log.report("Link down from "+
862 "s1 -> s2 on ONOS2 detected")
863 for obj3 in json_obj3:
864 if '01' not in obj3['src']['device']:
865 link_down3 = True
866 main.log.report("Link down from "+
867 "s1 -> s2 on ONOS3 detected")
868
andrewonlab53b641c2014-10-31 19:44:44 -0400869 loop_count += 1
andrewonlababb11c32014-11-04 15:03:24 -0500870 #If CLI doesn't like the continuous requests
871 #and exits in this loop, increase the sleep here.
872 #Consequently, while loop timeout will increase
andrewonlab53b641c2014-10-31 19:44:44 -0400873 time.sleep(1)
874
875 #Give time for metrics measurement to catch up
andrewonlababb11c32014-11-04 15:03:24 -0500876 #NOTE: May need to be configured more accurately
andrewonlab53b641c2014-10-31 19:44:44 -0400877 time.sleep(10)
andrewonlababb11c32014-11-04 15:03:24 -0500878 #If we exited the while loop and link down 1,2,3 are still
andrewonlab53b641c2014-10-31 19:44:44 -0400879 #false, then ONOS has failed to discover link down event
andrewonlababb11c32014-11-04 15:03:24 -0500880 if not (link_down1 and link_down2 and link_down3):
andrewonlab53b641c2014-10-31 19:44:44 -0400881 main.log.info("Link down discovery failed")
882
883 link_down_lat_graph1 = 0
884 link_down_lat_graph2 = 0
885 link_down_lat_graph3 = 0
886 link_down_lat_device1 = 0
887 link_down_lat_device2 = 0
888 link_down_lat_device3 = 0
889
890 assertion = main.FALSE
891 else:
892 json_topo_metrics_1 =\
893 main.ONOS1cli.topology_events_metrics()
894 json_topo_metrics_2 =\
895 main.ONOS2cli.topology_events_metrics()
896 json_topo_metrics_3 =\
897 main.ONOS3cli.topology_events_metrics()
898 json_topo_metrics_1 = json.loads(json_topo_metrics_1)
899 json_topo_metrics_2 = json.loads(json_topo_metrics_2)
900 json_topo_metrics_3 = json.loads(json_topo_metrics_3)
901
902 main.log.info("Obtaining graph and device timestamp")
903 graph_timestamp_1 = \
904 json_topo_metrics_1[graphTimestamp]['value']
905 graph_timestamp_2 = \
906 json_topo_metrics_2[graphTimestamp]['value']
907 graph_timestamp_3 = \
908 json_topo_metrics_3[graphTimestamp]['value']
909
910 link_timestamp_1 = \
911 json_topo_metrics_1[linkTimestamp]['value']
912 link_timestamp_2 = \
913 json_topo_metrics_2[linkTimestamp]['value']
914 link_timestamp_3 = \
915 json_topo_metrics_3[linkTimestamp]['value']
916
917 if graph_timestamp_1 and graph_timestamp_2 and\
918 graph_timestamp_3 and link_timestamp_1 and\
919 link_timestamp_2 and link_timestamp_3:
920 link_down_lat_graph1 = int(graph_timestamp_1) -\
921 timestamp_link_down_t0
922 link_down_lat_graph2 = int(graph_timestamp_2) -\
923 timestamp_link_down_t0
924 link_down_lat_graph3 = int(graph_timestamp_3) -\
925 timestamp_link_down_t0
926
927 link_down_lat_link1 = int(link_timestamp_1) -\
928 timestamp_link_down_t0
929 link_down_lat_link2 = int(link_timestamp_2) -\
930 timestamp_link_down_t0
931 link_down_lat_link3 = int(link_timestamp_3) -\
932 timestamp_link_down_t0
933 else:
934 main.log.error("There was an error calculating"+
935 " the delta for link down event")
936 link_down_lat_graph1 = 0
937 link_down_lat_graph2 = 0
938 link_down_lat_graph3 = 0
939
940 link_down_lat_device1 = 0
941 link_down_lat_device2 = 0
942 link_down_lat_device3 = 0
943
andrewonlab4e124482014-11-04 13:37:25 -0500944 main.log.report("Link down latency ONOS1 iteration "+
945 str(i)+" (end-to-end): "+
andrewonlababb11c32014-11-04 15:03:24 -0500946 str(link_down_lat_graph1)+" ms")
andrewonlab4e124482014-11-04 13:37:25 -0500947 main.log.report("Link down latency ONOS2 iteration "+
948 str(i)+" (end-to-end): "+
andrewonlababb11c32014-11-04 15:03:24 -0500949 str(link_down_lat_graph2)+" ms")
andrewonlab4e124482014-11-04 13:37:25 -0500950 main.log.report("Link down latency ONOS3 iteration "+
951 str(i)+" (end-to-end): "+
andrewonlababb11c32014-11-04 15:03:24 -0500952 str(link_down_lat_graph3)+" ms")
andrewonlab4e124482014-11-04 13:37:25 -0500953
954 main.log.report("Link down latency ONOS1 iteration "+
955 str(i)+" (link-event-to-system-timestamp): "+
andrewonlababb11c32014-11-04 15:03:24 -0500956 str(link_down_lat_link1)+" ms")
andrewonlab4e124482014-11-04 13:37:25 -0500957 main.log.report("Link down latency ONOS2 iteration "+
958 str(i)+" (link-event-to-system-timestamp): "+
andrewonlababb11c32014-11-04 15:03:24 -0500959 str(link_down_lat_link2)+" ms")
andrewonlab4e124482014-11-04 13:37:25 -0500960 main.log.report("Link down latency ONOS3 iteration "+
961 str(i)+" (link-event-to-system-timestamp): "+
962 str(link_down_lat_link3))
963
964 #Calculate avg of node calculations
965 link_down_lat_graph_avg =\
andrewonlababb11c32014-11-04 15:03:24 -0500966 (link_down_lat_graph1 +
967 link_down_lat_graph2 +
968 link_down_lat_graph3) / 3.0
andrewonlab4e124482014-11-04 13:37:25 -0500969 link_down_lat_link_avg =\
andrewonlababb11c32014-11-04 15:03:24 -0500970 (link_down_lat_link1 +
971 link_down_lat_link2 +
972 link_down_lat_link3) / 3.0
andrewonlab53b641c2014-10-31 19:44:44 -0400973
andrewonlab4e124482014-11-04 13:37:25 -0500974 #Set threshold and append latency to list
975 if link_down_lat_graph_avg > 0.0 and\
976 link_down_lat_graph_avg < 30000:
977 link_down_graph_to_system_list.append(
978 link_down_lat_graph_avg)
979 if link_down_lat_link_avg > 0.0 and\
980 link_down_lat_link_avg < 30000:
981 link_down_link_to_system_list.append(
982 link_down_lat_link_avg)
andrewonlab53b641c2014-10-31 19:44:44 -0400983
984 #NOTE: To remove loss rate and measure latency:
985 # 'sh tc qdisc del dev s1-eth1 root'
andrewonlababb11c32014-11-04 15:03:24 -0500986 timestamp_link_up_t0 = time.time() * 1000
andrewonlab53b641c2014-10-31 19:44:44 -0400987 main.Mininet1.handle.sendline("sh tc qdisc del dev "+
988 "s1-eth1 root")
989 main.Mininet1.handle.expect("mininet>")
andrewonlababb11c32014-11-04 15:03:24 -0500990
991 main.log.info("Checking ONOS for link update")
992
993 link_down1 = True
994 link_down2 = True
995 link_down3 = True
996 loop_count = 0
997 while( (link_down1 and link_down2 and link_down3)\
998 and loop_count < 30 ):
999 json_str1 = main.ONOS1cli.links()
1000 json_str2 = main.ONOS2cli.links()
1001 json_str3 = main.ONOS3cli.links()
1002 if not (json_str1 and json_str2 and json_str3):
1003 main.log.error("CLI command returned error ")
1004 break
1005 else:
1006 json_obj1 = json.loads(json_str1)
1007 json_obj2 = json.loads(json_str2)
1008 json_obj3 = json.loads(json_str3)
1009
1010 for obj1 in json_obj1:
1011 if '01' in obj1['src']['device']:
1012 link_down1 = False
1013 main.log.report("Link up from "+
1014 "s1 -> s2 on ONOS1 detected")
1015 for obj2 in json_obj2:
1016 if '01' in obj2['src']['device']:
1017 link_down2 = False
1018 main.log.report("Link up from "+
1019 "s1 -> s2 on ONOS2 detected")
1020 for obj3 in json_obj3:
1021 if '01' in obj3['src']['device']:
1022 link_down3 = False
1023 main.log.report("Link up from "+
1024 "s1 -> s2 on ONOS3 detected")
1025
1026 loop_count += 1
1027 time.sleep(1)
1028
1029 if (link_down1 and link_down2 and link_down3):
1030 main.log.info("Link up discovery failed")
1031
1032 link_up_lat_graph1 = 0
1033 link_up_lat_graph2 = 0
1034 link_up_lat_graph3 = 0
1035 link_up_lat_device1 = 0
1036 link_up_lat_device2 = 0
1037 link_up_lat_device3 = 0
1038
1039 assertion = main.FALSE
1040 else:
1041 json_topo_metrics_1 =\
1042 main.ONOS1cli.topology_events_metrics()
1043 json_topo_metrics_2 =\
1044 main.ONOS2cli.topology_events_metrics()
1045 json_topo_metrics_3 =\
1046 main.ONOS3cli.topology_events_metrics()
1047 json_topo_metrics_1 = json.loads(json_topo_metrics_1)
1048 json_topo_metrics_2 = json.loads(json_topo_metrics_2)
1049 json_topo_metrics_3 = json.loads(json_topo_metrics_3)
1050
1051 main.log.info("Obtaining graph and device timestamp")
1052 graph_timestamp_1 = \
1053 json_topo_metrics_1[graphTimestamp]['value']
1054 graph_timestamp_2 = \
1055 json_topo_metrics_2[graphTimestamp]['value']
1056 graph_timestamp_3 = \
1057 json_topo_metrics_3[graphTimestamp]['value']
1058
1059 link_timestamp_1 = \
1060 json_topo_metrics_1[linkTimestamp]['value']
1061 link_timestamp_2 = \
1062 json_topo_metrics_2[linkTimestamp]['value']
1063 link_timestamp_3 = \
1064 json_topo_metrics_3[linkTimestamp]['value']
1065
1066 if graph_timestamp_1 and graph_timestamp_2 and\
1067 graph_timestamp_3 and link_timestamp_1 and\
1068 link_timestamp_2 and link_timestamp_3:
1069 link_up_lat_graph1 = int(graph_timestamp_1) -\
1070 timestamp_link_up_t0
1071 link_up_lat_graph2 = int(graph_timestamp_2) -\
1072 timestamp_link_up_t0
1073 link_up_lat_graph3 = int(graph_timestamp_3) -\
1074 timestamp_link_up_t0
1075
1076 link_up_lat_link1 = int(link_timestamp_1) -\
1077 timestamp_link_up_t0
1078 link_up_lat_link2 = int(link_timestamp_2) -\
1079 timestamp_link_up_t0
1080 link_up_lat_link3 = int(link_timestamp_3) -\
1081 timestamp_link_up_t0
1082 else:
1083 main.log.error("There was an error calculating"+
1084 " the delta for link down event")
1085 link_up_lat_graph1 = 0
1086 link_up_lat_graph2 = 0
1087 link_up_lat_graph3 = 0
1088
1089 link_up_lat_device1 = 0
1090 link_up_lat_device2 = 0
1091 link_up_lat_device3 = 0
1092
1093 main.log.info("Link up latency ONOS1 iteration "+
1094 str(i)+" (end-to-end): "+
1095 str(link_up_lat_graph1)+" ms")
1096 main.log.info("Link up latency ONOS2 iteration "+
1097 str(i)+" (end-to-end): "+
1098 str(link_up_lat_graph2)+" ms")
1099 main.log.info("Link up latency ONOS3 iteration "+
1100 str(i)+" (end-to-end): "+
1101 str(link_up_lat_graph3)+" ms")
1102
1103 main.log.info("Link up latency ONOS1 iteration "+
1104 str(i)+" (link-event-to-system-timestamp): "+
1105 str(link_up_lat_link1)+" ms")
1106 main.log.info("Link up latency ONOS2 iteration "+
1107 str(i)+" (link-event-to-system-timestamp): "+
1108 str(link_up_lat_link2)+" ms")
1109 main.log.info("Link up latency ONOS3 iteration "+
1110 str(i)+" (link-event-to-system-timestamp): "+
1111 str(link_up_lat_link3))
1112
1113 #Calculate avg of node calculations
1114 link_up_lat_graph_avg =\
1115 (link_up_lat_graph1 +
1116 link_up_lat_graph2 +
1117 link_up_lat_graph3) / 3.0
1118 link_up_lat_link_avg =\
1119 (link_up_lat_link1 +
1120 link_up_lat_link2 +
1121 link_up_lat_link3) / 3.0
1122
1123 #Set threshold and append latency to list
1124 if link_up_lat_graph_avg > 0.0 and\
1125 link_up_lat_graph_avg < 30000:
1126 link_up_graph_to_system_list.append(
1127 link_up_lat_graph_avg)
1128 if link_up_lat_link_avg > 0.0 and\
1129 link_up_lat_link_avg < 30000:
1130 link_up_link_to_system_list.append(
1131 link_up_lat_link_avg)
andrewonlab53b641c2014-10-31 19:44:44 -04001132
andrewonlab4e124482014-11-04 13:37:25 -05001133 #Calculate min, max, avg of list and report
1134 link_down_min = min(link_down_graph_to_system_list)
1135 link_down_max = max(link_down_graph_to_system_list)
1136 link_down_avg = sum(link_down_graph_to_system_list) / \
1137 len(link_down_graph_to_system_list)
andrewonlababb11c32014-11-04 15:03:24 -05001138 link_up_min = min(link_up_graph_to_system_list)
1139 link_up_max = max(link_up_graph_to_system_list)
1140 link_up_avg = sum(link_up_graph_to_system_list) / \
1141 len(link_up_graph_to_system_list)
1142
1143 main.log.report("Link down latency - Min: "+
1144 str(link_down_min)+"ms Max: "+
1145 str(link_down_max)+"ms Avg: "+
1146 str(link_down_avg)+"ms")
1147 main.log.report("Link up latency - Min: "+
1148 str(link_up_min)+"ms Max: "+
1149 str(link_up_max)+"ms Avg: "+
1150 str(link_up_avg)+"ms")
andrewonlab4e124482014-11-04 13:37:25 -05001151
andrewonlabb54b85b2014-10-28 18:43:57 -04001152 def CASE5(self, main):
1153 '''
1154 100 Switch discovery latency
1155
1156 Important:
1157 If a simple topology was used in previous cases,
1158 you will need to change the topology file in the
1159 params for this case to proceed
andrewonlab16ce4852014-10-30 13:41:09 -04001160
1161 This test case can be potentially dangerous if
1162 your machine has previously set iptables rules.
1163 One of the steps of the test case will flush
1164 all existing iptables rules.
andrewonlabb54b85b2014-10-28 18:43:57 -04001165 '''
1166 import time
1167 import subprocess
1168 import os
1169 import requests
1170 import json
1171
1172 ONOS1_ip = main.params['CTRL']['ip1']
1173 ONOS2_ip = main.params['CTRL']['ip2']
1174 ONOS3_ip = main.params['CTRL']['ip3']
1175 MN1_ip = main.params['MN']['ip1']
1176 ONOS_user = main.params['CTRL']['user']
1177
1178 default_sw_port = main.params['CTRL']['port1']
1179
1180 #Number of iterations of case
1181 num_iter = main.params['TEST']['numIter']
andrewonlab16ce4852014-10-30 13:41:09 -04001182 num_sw = main.params['TEST']['numSwitch']
1183
andrewonlabb54b85b2014-10-28 18:43:57 -04001184 #Timestamp 'keys' for json metrics output.
1185 #These are subject to change, hence moved into params
1186 deviceTimestamp = main.params['JSON']['deviceTimestamp']
andrewonlab16ce4852014-10-30 13:41:09 -04001187 graphTimestamp = main.params['JSON']['graphTimestamp']
1188
andrewonlab53b641c2014-10-31 19:44:44 -04001189 tshark_ofp_output = "/tmp/tshark_ofp_"+num_sw+"sw.txt"
1190 tshark_tcp_output = "/tmp/tshark_tcp_"+num_sw+"sw.txt"
1191
1192 tshark_ofp_result_list = []
1193 tshark_tcp_result_list = []
andrewonlabb54b85b2014-10-28 18:43:57 -04001194
andrewonlab16ce4852014-10-30 13:41:09 -04001195 main.case(num_sw+" Switch discovery latency")
andrewonlabb54b85b2014-10-28 18:43:57 -04001196 main.step("Assigning all switches to ONOS1")
andrewonlab16ce4852014-10-30 13:41:09 -04001197 for i in range(1, int(num_sw)+1):
andrewonlabb54b85b2014-10-28 18:43:57 -04001198 main.Mininet1.assign_sw_controller(
1199 sw=str(i),
1200 ip1=ONOS1_ip,
1201 port1=default_sw_port)
andrewonlab16ce4852014-10-30 13:41:09 -04001202
andrewonlabb54b85b2014-10-28 18:43:57 -04001203 #Ensure that nodes are configured with ptpd
andrewonlab16ce4852014-10-30 13:41:09 -04001204 #Just a warning message
1205 main.log.info("Please check ptpd configuration to ensure"+\
1206 " All nodes' system times are in sync")
1207 time.sleep(5)
andrewonlabb54b85b2014-10-28 18:43:57 -04001208
1209 for i in range(0, int(num_iter)):
andrewonlab8d29f122014-10-22 17:15:04 -04001210
andrewonlabb54b85b2014-10-28 18:43:57 -04001211 main.step("Set iptables rule to block incoming sw connections")
1212 #Set iptables rule to block incoming switch connections
andrewonlab53b641c2014-10-31 19:44:44 -04001213 #The rule description is as follows:
1214 # Append to INPUT rule,
1215 # behavior DROP that matches following:
1216 # * packet type: tcp
1217 # * source IP: MN1_ip
1218 # * destination PORT: 6633
andrewonlabb54b85b2014-10-28 18:43:57 -04001219 main.ONOS1.handle.sendline(
andrewonlab16ce4852014-10-30 13:41:09 -04001220 "sudo iptables -A INPUT -p tcp -s "+MN1_ip+
andrewonlabb54b85b2014-10-28 18:43:57 -04001221 " --dport "+default_sw_port+" -j DROP")
1222 main.ONOS1.handle.expect("\$")
andrewonlab53b641c2014-10-31 19:44:44 -04001223 # Append to OUTPUT rule,
1224 # behavior DROP that matches following:
1225 # * packet type: tcp
1226 # * source IP: MN1_ip
1227 # * destination PORT: 6633
1228 main.ONOS1.handle.sendline(
1229 "sudo iptables -A OUTPUT -p tcp -s "+MN1_ip+
1230 " --dport "+default_sw_port+" -j DROP")
1231 main.ONOS1.handle.expect("\$")
andrewonlabb54b85b2014-10-28 18:43:57 -04001232 #Give time to allow rule to take effect
andrewonlab16ce4852014-10-30 13:41:09 -04001233 main.log.info("Please wait for switch connection to "+
1234 "time out")
1235 time.sleep(60)
1236
1237 #Gather vendor OFP with tshark
1238 main.ONOS1.tshark_grep("OFP 86 Vendor",
1239 tshark_ofp_output)
andrewonlab53b641c2014-10-31 19:44:44 -04001240 main.ONOS1.tshark_grep("TCP 74 ",
1241 tshark_tcp_output)
andrewonlabb54b85b2014-10-28 18:43:57 -04001242
andrewonlab16ce4852014-10-30 13:41:09 -04001243 #NOTE: Remove all iptables rule quickly (flush)
andrewonlabb54b85b2014-10-28 18:43:57 -04001244 # Before removal, obtain TestON timestamp at which
andrewonlab16ce4852014-10-30 13:41:09 -04001245 # removal took place
1246 # (ensuring nodes are configured via ptp)
andrewonlabb54b85b2014-10-28 18:43:57 -04001247 # sudo iptables -F
andrewonlab16ce4852014-10-30 13:41:09 -04001248
1249 t0_system = time.time() * 1000
1250 main.ONOS1.handle.sendline(
1251 "sudo iptables -F")
andrewonlabb54b85b2014-10-28 18:43:57 -04001252
andrewonlab16ce4852014-10-30 13:41:09 -04001253 #Counter to track loop count
1254 counter_loop = 0
1255 counter_avail1 = 0
1256 counter_avail2 = 0
1257 counter_avail3 = 0
1258 onos1_dev = False
1259 onos2_dev = False
1260 onos3_dev = False
1261 while counter_loop < 60:
1262 #Continue to check devices for all device
1263 #availability. When all devices in all 3
1264 #ONOS instances indicate that devices are available
1265 #obtain graph event timestamp for t1.
1266 device_str_obj1 = main.ONOS1cli.devices()
1267 device_str_obj2 = main.ONOS2cli.devices()
1268 device_str_obj3 = main.ONOS3cli.devices()
1269
1270 device_json1 = json.loads(device_str_obj1)
1271 device_json2 = json.loads(device_str_obj2)
1272 device_json3 = json.loads(device_str_obj3)
1273
1274 for device1 in device_json1:
1275 if device1['available'] == True:
1276 counter_avail1 += 1
1277 if counter_avail1 == int(num_sw):
1278 onos1_dev = True
1279 main.log.info("All devices have been "+
1280 "discovered on ONOS1")
1281 else:
1282 counter_avail1 = 0
1283 for device2 in device_json2:
1284 if device2['available'] == True:
1285 counter_avail2 += 1
1286 if counter_avail2 == int(num_sw):
1287 onos2_dev = True
1288 main.log.info("All devices have been "+
1289 "discovered on ONOS2")
1290 else:
1291 counter_avail2 = 0
1292 for device3 in device_json3:
1293 if device3['available'] == True:
1294 counter_avail3 += 1
1295 if counter_avail3 == int(num_sw):
1296 onos3_dev = True
1297 main.log.info("All devices have been "+
1298 "discovered on ONOS3")
1299 else:
1300 counter_avail3 = 0
1301
1302 if onos1_dev and onos2_dev and onos3_dev:
1303 main.log.info("All devices have been discovered "+
1304 "on all ONOS instances")
1305 json_str_topology_metrics_1 =\
1306 main.ONOS1cli.topology_events_metrics()
1307 json_str_topology_metrics_2 =\
1308 main.ONOS2cli.topology_events_metrics()
1309 json_str_topology_metrics_3 =\
1310 main.ONOS3cli.topology_events_metrics()
andrewonlab53b641c2014-10-31 19:44:44 -04001311
1312 #Exit while loop if all devices discovered
andrewonlab16ce4852014-10-30 13:41:09 -04001313 break
1314
1315 counter_loop += 1
1316 #Give some time in between CLI calls
1317 #(will not affect measurement)
1318 time.sleep(3)
1319
1320 main.ONOS1.tshark_stop()
1321
1322 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
1323 tshark_ofp_output+" /tmp/")
andrewonlab53b641c2014-10-31 19:44:44 -04001324 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
1325 tshark_tcp_output+" /tmp/")
andrewonlab16ce4852014-10-30 13:41:09 -04001326 ofp_file = open(tshark_ofp_output, 'r')
1327
1328 #The following is for information purpose only.
1329 #TODO: Automate OFP output analysis
1330 main.log.info("Tshark OFP Vendor output: ")
1331 for line in ofp_file:
andrewonlab53b641c2014-10-31 19:44:44 -04001332 tshark_ofp_result_list.append(line)
andrewonlab16ce4852014-10-30 13:41:09 -04001333 main.log.info(line)
1334
andrewonlab53b641c2014-10-31 19:44:44 -04001335 ofp_file.close()
1336
1337 tcp_file = open(tshark_tcp_output, 'r')
1338 main.log.info("Tshark TCP 74 output: ")
1339 for line in tcp_file:
1340 tshark_tcp_result_list.append(line)
1341 main.log.info(line)
1342
1343 tcp_file.close()
1344
andrewonlab16ce4852014-10-30 13:41:09 -04001345 json_obj_1 = json.loads(json_str_topology_metrics_1)
1346 json_obj_2 = json.loads(json_str_topology_metrics_2)
1347 json_obj_3 = json.loads(json_str_topology_metrics_3)
1348
1349 graph_timestamp_1 = \
1350 json_obj_1[graphTimestamp]['value']
1351 graph_timestamp_2 = \
1352 json_obj_2[graphTimestamp]['value']
1353 graph_timestamp_3 = \
1354 json_obj_3[graphTimestamp]['value']
1355
1356 main.log.info(
1357 int(graph_timestamp_1) - int(t0_system))
1358 main.log.info(
1359 int(graph_timestamp_2) - int(t0_system))
1360 main.log.info(
1361 int(graph_timestamp_3) - int(t0_system))
1362
1363
1364
1365
1366
1367
andrewonlabb54b85b2014-10-28 18:43:57 -04001368