blob: e29b76b12e04003cc4f46c8525d9940fcd21b342 [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
82 if not (cli1 and cli2 and cli3):
83 main.log.info("Attempting to start cli again")
84 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
85 cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
86 cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
andrewonlab867212a2014-10-22 20:13:38 -040087
88 main.step("Enable metrics feature")
89 main.ONOS1cli.feature_install("onos-app-metrics-topology")
90 main.ONOS2cli.feature_install("onos-app-metrics-topology")
91 main.ONOS3cli.feature_install("onos-app-metrics-topology")
92
andrewonlab2a6c9342014-10-16 13:40:15 -040093 utilities.assert_equals(expect=main.TRUE,
94 actual= cell_file_result and cell_apply_result and\
95 verify_cell_result and checkout_result and\
96 pull_result and mvn_result and\
andrewonlabe9fb6722014-10-24 12:20:35 -040097 install1_result and install2_result and\
98 install3_result,
andrewonlab8d29f122014-10-22 17:15:04 -040099 onpass="ONOS started successfully",
100 onfail="Failed to start ONOS")
andrewonlab2a6c9342014-10-16 13:40:15 -0400101
andrewonlabba44bcf2014-10-16 16:54:41 -0400102 def CASE2(self, main):
103 '''
104 Assign s1 to ONOS1 and measure latency
105 '''
106 import time
andrewonlabe6745342014-10-17 14:29:13 -0400107 import subprocess
108 import json
109 import requests
110 import os
andrewonlabba44bcf2014-10-16 16:54:41 -0400111
112 ONOS1_ip = main.params['CTRL']['ip1']
113 ONOS2_ip = main.params['CTRL']['ip2']
114 ONOS3_ip = main.params['CTRL']['ip3']
andrewonlabe6745342014-10-17 14:29:13 -0400115 ONOS_user = main.params['CTRL']['user']
116
andrewonlabba44bcf2014-10-16 16:54:41 -0400117 default_sw_port = main.params['CTRL']['port1']
118
119 #Number of iterations of case
120 num_iter = main.params['TEST']['numIter']
121
andrewonlab226024e2014-10-24 16:01:32 -0400122 #Timestamp 'keys' for json metrics output.
123 #These are subject to change, hence moved into params
124 deviceTimestamp = main.params['JSON']['deviceTimestamp']
125 graphTimestamp = main.params['JSON']['graphTimestamp']
126
127 #List of switch add latency collected from
128 #all iterations
129 latency_end_to_end_list = []
130 latency_ofp_to_graph_list = []
131 latency_ofp_to_device_list = []
132 latency_t0_to_device_list = []
133
andrewonlabba44bcf2014-10-16 16:54:41 -0400134 #Directory/file to store tshark results
135 tshark_of_output = "/tmp/tshark_of_topo.txt"
136 tshark_tcp_output = "/tmp/tshark_tcp_topo.txt"
137
138 #String to grep in tshark output
139 tshark_tcp_string = "TCP 74 "+default_sw_port
140 tshark_of_string = "OFP 86 Vendor"
andrewonlabe6745342014-10-17 14:29:13 -0400141
142 #Initialize assertion to TRUE
143 assertion = main.TRUE
144
andrewonlabba44bcf2014-10-16 16:54:41 -0400145 main.log.report("Latency of adding one switch")
146
147 for i in range(0, int(num_iter)):
148 main.log.info("Starting tshark capture")
149
150 #* TCP [ACK, SYN] is used as t0_a, the
151 # very first "exchange" between ONOS and
152 # the switch for end-to-end measurement
153 #* OFP [Stats Reply] is used for t0_b
154 # the very last OFP message between ONOS
155 # and the switch for ONOS measurement
156 main.ONOS1.tshark_grep(tshark_tcp_string,
157 tshark_tcp_output)
158 main.ONOS1.tshark_grep(tshark_of_string,
159 tshark_of_output)
160
161 #Wait and ensure tshark is started and
162 #capturing
163 time.sleep(10)
164
165 main.log.info("Assigning s1 to controller")
166
167 main.Mininet1.assign_sw_controller(sw="1",
168 ip1=ONOS1_ip, port1=default_sw_port)
169
170 #Wait and ensure switch is assigned
171 #before stopping tshark
andrewonlab867212a2014-10-22 20:13:38 -0400172 time.sleep(30)
andrewonlab226024e2014-10-24 16:01:32 -0400173
174 main.log.info("Stopping all Tshark processes")
andrewonlabba44bcf2014-10-16 16:54:41 -0400175 main.ONOS1.stop_tshark()
176
andrewonlabe6745342014-10-17 14:29:13 -0400177 #tshark output is saved in ONOS. Use subprocess
178 #to copy over files to TestON for parsing
179 main.log.info("Copying over tshark files")
180
181 #TCP CAPTURE ****
andrewonlab8d29f122014-10-22 17:15:04 -0400182 #Copy the tshark output from ONOS machine to
183 #TestON machine in tshark_tcp_output directory>file
184 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
185 tshark_tcp_output+" /tmp/")
186 tcp_file = open(tshark_tcp_output, 'r')
187 temp_text = tcp_file.readline()
andrewonlabe6745342014-10-17 14:29:13 -0400188 temp_text = temp_text.split(" ")
andrewonlabba44bcf2014-10-16 16:54:41 -0400189
andrewonlabe6745342014-10-17 14:29:13 -0400190 main.log.info("Object read in from TCP capture: "+
191 str(temp_text))
andrewonlab867212a2014-10-22 20:13:38 -0400192 if len(temp_text) > 1:
andrewonlabe6745342014-10-17 14:29:13 -0400193 t0_tcp = int(float(temp_text[1])*1000)
194 else:
195 main.log.error("Tshark output file for TCP"+
196 " returned unexpected results")
197 t0_tcp = 0
198 assertion = main.FALSE
andrewonlab8d29f122014-10-22 17:15:04 -0400199
200 tcp_file.close()
andrewonlabe6745342014-10-17 14:29:13 -0400201 #****************
andrewonlabba44bcf2014-10-16 16:54:41 -0400202
andrewonlabe6745342014-10-17 14:29:13 -0400203 #OF CAPTURE ****
andrewonlab8d29f122014-10-22 17:15:04 -0400204 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
205 tshark_of_output+" /tmp/")
206 of_file = open(tshark_of_output, 'r')
207
208 line_ofp = ""
andrewonlab226024e2014-10-24 16:01:32 -0400209 #Read until last line of file
andrewonlabe6745342014-10-17 14:29:13 -0400210 while True:
andrewonlab8d29f122014-10-22 17:15:04 -0400211 temp_text = of_file.readline()
212 if temp_text !='':
andrewonlabe6745342014-10-17 14:29:13 -0400213 line_ofp = temp_text
214 else:
215 break
216 obj = line_ofp.split(" ")
217
218 main.log.info("Object read in from OFP capture: "+
219 str(line_ofp))
220
andrewonlab867212a2014-10-22 20:13:38 -0400221 if len(line_ofp) > 1:
andrewonlabe6745342014-10-17 14:29:13 -0400222 t0_ofp = int(float(obj[1])*1000)
223 else:
224 main.log.error("Tshark output file for OFP"+
225 " returned unexpected results")
226 t0_ofp = 0
227 assertion = main.FALSE
andrewonlab8d29f122014-10-22 17:15:04 -0400228
229 of_file.close()
andrewonlabe6745342014-10-17 14:29:13 -0400230 #****************
231
232 #TODO:
233 #Get json object from all 3 ONOS instances
andrewonlab867212a2014-10-22 20:13:38 -0400234 json_str_1 = main.ONOS1cli.topology_events_metrics()
235 json_str_2 = main.ONOS2cli.topology_events_metrics()
236 json_str_3 = main.ONOS3cli.topology_events_metrics()
andrewonlab867212a2014-10-22 20:13:38 -0400237
238 json_obj_1 = json.loads(json_str_1)
239 json_obj_2 = json.loads(json_str_2)
240 json_obj_3 = json.loads(json_str_3)
241
andrewonlab226024e2014-10-24 16:01:32 -0400242 #Obtain graph timestamp. This timestsamp captures
243 #the epoch time at which the topology graph was updated.
244 graph_timestamp_1 = \
245 json_obj_1[graphTimestamp]['value']
246 graph_timestamp_2 = \
247 json_obj_2[graphTimestamp]['value']
248 graph_timestamp_3 = \
249 json_obj_3[graphTimestamp]['value']
andrewonlab867212a2014-10-22 20:13:38 -0400250
andrewonlab226024e2014-10-24 16:01:32 -0400251 #Obtain device timestamp. This timestamp captures
252 #the epoch time at which the device event happened
253 device_timestamp_1 = \
254 json_obj_1[deviceTimestamp]['value']
255 device_timestamp_2 = \
256 json_obj_2[deviceTimestamp]['value']
257 device_timestamp_3 = \
258 json_obj_3[deviceTimestamp]['value']
andrewonlabe9fb6722014-10-24 12:20:35 -0400259
andrewonlab226024e2014-10-24 16:01:32 -0400260 #t0 to device processing latency
261 delta_device_1 = int(device_timestamp_1) - int(t0_tcp)
262 delta_device_2 = int(device_timestamp_2) - int(t0_tcp)
263 delta_device_3 = int(device_timestamp_3) - int(t0_tcp)
264
265 #Get average of delta from all instances
266 avg_delta_device = \
267 (int(delta_device_1)+\
268 int(delta_device_2)+\
269 int(delta_device_3)) / 3
andrewonlabba44bcf2014-10-16 16:54:41 -0400270
andrewonlab226024e2014-10-24 16:01:32 -0400271 #Ensure avg delta meets the threshold before appending
272 if avg_delta_device > 0.0 and avg_delta_device < 10000:
273 latency_t0_to_device_list.append(avg_delta_device)
274
275 #t0 to graph processing latency (end-to-end)
276 delta_graph_1 = int(graph_timestamp_1) - int(t0_tcp)
277 delta_graph_2 = int(graph_timestamp_2) - int(t0_tcp)
278 delta_graph_3 = int(graph_timestamp_3) - int(t0_tcp)
279
280 #Get average of delta from all instances
281 avg_delta_graph = \
282 (int(delta_graph_1)+\
283 int(delta_graph_2)+\
284 int(delta_graph_3)) / 3
285
286 latency_end_to_end_list.append(avg_delta_graph)
287
288 #Ensure avg delta meets the threshold before appending
289 if avg_delta_graph > 0.0 and avg_delta_graph < 10000:
290 latency_t0_to_device_list.append(avg_delta_graph)
291
292 #ofp to graph processing latency (ONOS processing)
293 delta_ofp_graph_1 = int(graph_timestamp_1) - int(t0_ofp)
294 delta_ofp_graph_2 = int(graph_timestamp_2) - int(t0_ofp)
295 delta_ofp_graph_3 = int(graph_timestamp_3) - int(t0_ofp)
296
297 avg_delta_ofp_graph = \
298 (int(delta_ofp_graph_1)+\
299 int(delta_ofp_graph_2)+\
300 int(delta_ofp_graph_3)) / 3
301
302 if avg_delta_ofp_graph > 0.0 and avg_delta_ofp_graph < 10000:
303 latency_ofp_to_graph_list.append(avg_delta_ofp_graph)
304
305 #ofp to device processing latency (ONOS processing)
306 delta_ofp_device_1 = int(device_timestamp_1) - int(t0_ofp)
307 delta_ofp_device_2 = int(device_timestamp_2) - int(t0_ofp)
308 delta_ofp_device_3 = int(device_timestamp_3) - int(t0_ofp)
309
310 avg_delta_ofp_device = \
311 (int(delta_ofp_device_1)+\
312 int(delta_ofp_device_2)+\
313 int(delta_ofp_device_3)) / 3
314
315 if avg_delta_ofp_device > 0.0 and avg_delta_ofp_device < 10000:
316 latency_ofp_to_device_list.append(avg_delta_ofp_device)
andrewonlabba44bcf2014-10-16 16:54:41 -0400317
andrewonlabe6745342014-10-17 14:29:13 -0400318 #TODO:
319 #Fetch logs upon threshold excess
andrewonlabba44bcf2014-10-16 16:54:41 -0400320
andrewonlab226024e2014-10-24 16:01:32 -0400321 main.log.info("ONOS1 delta end-to-end: "+
322 str(delta_graph_1))
323 main.log.info("ONOS2 delta end-to-end: "+
324 str(delta_graph_2))
325 main.log.info("ONSO3 delta end-to-end: "+
326 str(delta_graph_3))
andrewonlabba44bcf2014-10-16 16:54:41 -0400327
andrewonlab226024e2014-10-24 16:01:32 -0400328 main.log.info("ONOS1 delta OFP - graph: "+
329 str(delta_ofp_graph_1))
330 main.log.info("ONOS2 delta OFP - graph: "+
331 str(delta_ofp_graph_2))
332 main.log.info("ONOS3 delta OFP - graph: "+
333 str(delta_ofp_graph_3))
andrewonlabe6745342014-10-17 14:29:13 -0400334
andrewonlab226024e2014-10-24 16:01:32 -0400335 main.log.info("ONOS1 delta device - t0: "+
336 str(delta_device_1))
337 main.log.info("ONOS2 delta device - t0: "+
338 str(delta_device_2))
339 main.log.info("ONOS3 delta device - t0: "+
340 str(delta_device_3))
341
342 main.log.info("ONOS1 delta OFP - device: "+
343 str(delta_ofp_device_1))
344 main.log.info("ONOS2 delta OFP - device: "+
345 str(delta_ofp_device_2))
346 main.log.info("ONOS3 delta OFP - device: "+
347 str(delta_ofp_device_3))
348
andrewonlab8d29f122014-10-22 17:15:04 -0400349 main.step("Remove switch from controller")
350 main.Mininet1.delete_sw_controller("s1")
andrewonlabba44bcf2014-10-16 16:54:41 -0400351
andrewonlab8d29f122014-10-22 17:15:04 -0400352 time.sleep(5)
andrewonlabba44bcf2014-10-16 16:54:41 -0400353
andrewonlabc15c9582014-10-24 16:35:52 -0400354 #If there are at least 1 element in each list,
355 #pass the test case
356 if len(latency_end_to_end_list) > 0 and\
357 len(latency_ofp_to_graph_list) > 0 and\
358 len(latency_ofp_to_device_list) > 0 and\
359 len(latency_t0_to_device_list) > 0:
360 assertion = main.TRUE
361
362 #Calculate min, max, avg of latency lists
363 latency_end_to_end_max = \
364 max(float(latency_end_to_end_list))
365 latency_end_to_end_min = \
366 min(float(latency_end_to_end_list))
367 latency_end_to_end_avg = \
368 (sum(float(latency_end_to_end_list)) / \
369 len(latency_end_to_end_list))
370
371 latency_ofp_to_graph_max = \
372 max(float(latency_ofp_to_graph_list))
373 latency_ofp_to_graph_min = \
374 min(float(latency_ofp_to_graph_list))
375 latency_ofp_to_graph_avg = \
376 (sum(float(latency_ofp_to_graph_list)) / \
377 len(latency_ofp_to_graph_list))
378
379 latency_ofp_to_device_max = \
380 max(float(latency_ofp_to_device_list))
381 latency_ofp_to_device_min = \
382 min(float(latency_ofp_to_device_list))
383 latency_ofp_to_device_avg = \
384 (sum(float(latency_ofp_to_device_list)) / \
385 len(latency_ofp_to_device_list))
386
387 latency_t0_to_device_max = \
388 max(float(latency_t0_to_device_list))
389 latency_t0_to_device_min = \
390 min(float(latency_t0_to_device_list))
391 latency_t0_to_device_avg = \
392 (sum(float(latency_t0_to_device_list)) / \
393 len(latency_ofp_to_device_list))
394
395 main.log.report("Switch add - End-to-end latency: \n"+\
396 "Min: "+str(latency_end_to_end_min)+"\n"+\
397 "Max: "+str(latency_end_to_end_max)+"\n"+\
398 "Avg: "+str(latency_end_to_end_avg))
399 main.log.report("Switch add - OFP-to-Graph latency: \n"+\
400 "Min: "+str(latency_ofp_to_graph_min)+"\n"+\
401 "Max: "+str(latency_ofp_to_graph_max)+"\n"+\
402 "Avg: "+str(latency_ofp_to_graph_avg))
403 main.log.report("Switch add - OFP-to-Device latency: \n"+\
404 "Min: "+str(latency_ofp_to_device_min)+"\n"+\
405 "Max: "+str(latency_ofp_to_device_max)+"\n"+\
406 "Avg: "+str(latency_ofp_to_device_avg))
407 main.log.report("Switch add - t0-to-Device latency: \n"+\
408 "Min: "+str(latency_t0_to_device_min)+"\n"+\
409 "Max: "+str(latency_t0_to_device_max)+"\n"+\
410 "Avg: "+str(latency_t0_to_device_avg))
andrewonlab226024e2014-10-24 16:01:32 -0400411
andrewonlab8d29f122014-10-22 17:15:04 -0400412 utilities.assert_equals(expect=main.TRUE, actual=assertion,
413 onpass="Switch latency test successful",
414 onfail="Switch latency test failed")
andrewonlabba44bcf2014-10-16 16:54:41 -0400415
andrewonlab8d29f122014-10-22 17:15:04 -0400416 def CASE3(self, main):
417 '''
418 Bring port up / down and measure latency.
419 Port enable / disable is simulated by ifconfig up / down
420 '''
421 import time
422 import subprocess
423 import os
424 import requests
425 import json
andrewonlab2a6c9342014-10-16 13:40:15 -0400426
andrewonlab8d29f122014-10-22 17:15:04 -0400427 ONOS1_ip = main.params['CTRL']['ip1']
428 default_sw_port = main.params['CTRL']['port1']
429 ONOS_user = main.params['CTRL']['user']
430 num_iter = main.params['TEST']['numIter']
431
432 tshark_port_status = "OFP 130 Port Status"
433
434 tshark_port_up = "/tmp/tshark_port_up.txt"
435 tshark_port_down = "/tmp/tshark_port_down.txt"
436
437 main.log.report("Port enable / disable latency")
438
439 main.step("Assign switch to controller")
440 main.Mininet1.assign_sw_controller(sw="1",ip1=ONOS1_ip,
441 port1=default_sw_port)
442
443 main.step("Verify switch is assigned correctly")
444 result_s1 = main.Mininet1.get_sw_controller(sw="s1")
445 if result_s1 == main.FALSE:
446 main.log.info("Switch s1 was not assigned correctly")
447 assertion = main.FALSE
448 else:
449 main.log.info("Switch s1 was assigned correctly")
450
451 for i in range(0, int(num_iter)):
452 main.step("Starting wireshark capture for port status down")
453 main.ONOS1.tshark_grep(tshark_port_status,
454 tshark_port_down)
455
456 time.sleep(10)
457
458 main.step("Disable port (interface s1-eth2)")
459 main.Mininet2.handle.sendline("sudo ifconfig s1-eth2 down")
460 main.Mininet2.handle.expect("\$")
461 time.sleep(20)
462
463 main.ONOS1.tshark_stop()
464 time.sleep(5)
465
466 #Copy tshark output file from ONOS to TestON instance
467 #/tmp directory
468 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
469 tshark_port_down+" /tmp/")
470
471 f_port_down = open(tshark_port_down, 'r')
472 f_line = f_port_down.readline()
473 obj_down = f_line.split(" ")
474 if len(f_line) > 0:
475 timestamp_begin_pt_down = int(float(obj_down[1])*1000)
476 else:
477 main.log.info("Tshark output file returned unexpected"+
478 " results")
479 timestamp_begin_pt_down = 0
480
481 main.step("Obtain t1 by REST call")
482 #TODO: Implement json object parsing here
483
484 timestamp_end_pt_down_1 = 0
485 timestamp_end_pt_down_2 = 0
486 timestamp_end_pt_down_3 = 0
487
488 delta_pt_down_1 = int(timestamp_end_pt_down_1) - \
489 int(timestamp_begin_pt_down)
490 delta_pt_down_2 = int(timestamp_end_pt_down_2) - \
491 int(timestamp_begin_pt_down)
492 delta_pt_down_3 = int(timestamp_end_pt_down_3) - \
493 int(timestamp_begin_pt_down)
494
495 #TODO: Remove these logs. For test purposes only
496 main.log.info("Delta1: "+str(delta_pt_down_1))
497 main.log.info("Delta2: "+str(delta_pt_down_2))
498 main.log.info("Delta3: "+str(delta_pt_down_3))
499
500 #Port up events
501 main.step("Enable port and obtain timestamp")
502 main.step("Starting wireshark capture for port status up")
503 main.ONOS1.tshark_grep("OFP 130 Port Status", tshark_port_up)
504 time.sleep(10)
505
506 main.Mininet2.handle.sendline("sudo ifconfig s1-eth2 up")
507 main.Mininet2.handle.expect("\$")
508 time.sleep(20)
509
510 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
511 tshark_port_up+" /tmp/")
512
513 f_port_up = open(tshark_port_up, 'r')
514 f_line = f_port_down.readline()
515 obj_up = f_line.split(" ")
516 if len(f_line) > 0:
517 timestamp_begin_pt_up = int(float(obj_up[1])*1000)
518 else:
519 main.log.info("Tshark output file returned unexpected"+
520 " results.")
521 timestamp_begin_pt_up = 0
522
523 main.step("Obtain t1 by REST call")
524 #TODO: Implement json object parsing here
525
526 timestamp_end_pt_up_1 = 0
527 timestamp_end_pt_up_2 = 0
528 timestamp_end_pt_up_3 = 0
529
530 delta_pt_up_1 = int(timestamp_end_pt_up_1) - \
531 int(timestamp_begin_pt_up)
532 delta_pt_up_2 = int(timestamp_end_pt_up_2) - \
533 int(timestamp_begin_pt_up)
534 delta_pt_up_3 = int(timestamp_end_pt_up_3) - \
535 int(timestamp_begin_pt_up)
536
537 #TODO: Remove these logs. For test purposes only
538 main.log.info("Delta1: "+str(delta_pt_up_1))
539 main.log.info("Delta2: "+str(delta_pt_up_2))
540 main.log.info("Delta3: "+str(delta_pt_up_3))
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555