blob: 04c1903e0ed944a2de89a3a1a6ae1319ddb5a800 [file] [log] [blame]
andrewonlabadd2fd62014-11-11 18:37:35 -05001#TopoPerfNext
2#
andrewonlab51b180b2014-11-12 18:19:28 -05003#Topology Convergence scale-out test for ONOS-next
4#NOTE: This test supports up to 7 nodes scale-out scenario
andrewonlabadd2fd62014-11-11 18:37:35 -05005#
6#andrew@onlab.us
7
8import time
9import sys
10import os
11import re
12
13class TopoConvNext:
14 def __init__(self):
15 self.default = ''
16
andrewonlabadd2fd62014-11-11 18:37:35 -050017 def CASE1(self, main):
18 '''
19 ONOS startup sequence
20 '''
21 import time
andrewonlab54cec4b2014-11-12 13:30:23 -050022
23 #******
24 #Global cluster count for scale-out purposes
25 global cluster_count
andrewonlab51b180b2014-11-12 18:19:28 -050026 cluster_count = 1
andrewonlab54cec4b2014-11-12 13:30:23 -050027 #******
andrewonlabadd2fd62014-11-11 18:37:35 -050028 cell_name = main.params['ENV']['cellName']
29
30 git_pull = main.params['GIT']['autoPull']
31 checkout_branch = main.params['GIT']['checkout']
32
33 ONOS1_ip = main.params['CTRL']['ip1']
andrewonlab54cec4b2014-11-12 13:30:23 -050034 ONOS2_ip = main.params['CTRL']['ip2']
35 ONOS3_ip = main.params['CTRL']['ip3']
36 ONOS4_ip = main.params['CTRL']['ip4']
37 ONOS5_ip = main.params['CTRL']['ip5']
38 ONOS6_ip = main.params['CTRL']['ip6']
39 ONOS7_ip = main.params['CTRL']['ip7']
andrewonlabadd2fd62014-11-11 18:37:35 -050040 MN1_ip = main.params['MN']['ip1']
41 BENCH_ip = main.params['BENCH']['ip']
42
43 main.case("Setting up test environment")
44 main.log.report("Setting up test environment")
45
46 main.step("Creating cell file")
47 cell_file_result = main.ONOSbench.create_cell_file(
48 BENCH_ip, cell_name, MN1_ip, "onos-core",
andrewonlab54cec4b2014-11-12 13:30:23 -050049 ONOS1_ip, ONOS2_ip, ONOS3_ip, ONOS4_ip,
50 ONOS5_ip, ONOS6_ip, ONOS7_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -050051
52 main.step("Applying cell file to environment")
53 cell_apply_result = main.ONOSbench.set_cell(cell_name)
54 verify_cell_result = main.ONOSbench.verify_cell()
55
56 main.step("Git checkout and pull "+checkout_branch)
57 if git_pull == 'on':
58 checkout_result = \
59 main.ONOSbench.git_checkout(checkout_branch)
60 pull_result = main.ONOSbench.git_pull()
61 else:
62 checkout_result = main.TRUE
63 pull_result = main.TRUE
64 main.log.info("Skipped git checkout and pull")
65
66 main.step("Using mvn clean & install")
67 #mvn_result = main.ONOSbench.clean_install()
68 mvn_result = main.TRUE
69
70 main.step("Set cell for ONOS cli env")
71 main.ONOS1cli.set_cell(cell_name)
andrewonlab54cec4b2014-11-12 13:30:23 -050072 main.ONOS2cli.set_cell(cell_name)
73 main.ONOS3cli.set_cell(cell_name)
74 main.ONOS4cli.set_cell(cell_name)
75 main.ONOS5cli.set_cell(cell_name)
76 main.ONOS6cli.set_cell(cell_name)
77 main.ONOS7cli.set_cell(cell_name)
78
andrewonlabadd2fd62014-11-11 18:37:35 -050079 main.step("Creating ONOS package")
80 package_result = main.ONOSbench.onos_package()
81
andrewonlab54cec4b2014-11-12 13:30:23 -050082 #Start test with single node only
andrewonlabadd2fd62014-11-11 18:37:35 -050083 main.step("Installing ONOS package")
84 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
85
86 time.sleep(10)
87
88 main.step("Start onos cli")
89 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
90
91 main.step("Enable metrics feature")
92 main.ONOS1cli.feature_install("onos-app-metrics")
93
94 utilities.assert_equals(expect=main.TRUE,
95 actual= cell_file_result and cell_apply_result and\
96 verify_cell_result and checkout_result and\
97 pull_result and mvn_result and\
andrewonlab54cec4b2014-11-12 13:30:23 -050098 install1_result,
andrewonlabadd2fd62014-11-11 18:37:35 -050099 onpass="Test Environment setup successful",
100 onfail="Failed to setup test environment")
101
102 def CASE2(self, main):
103 '''
104 100 Switch discovery latency
105
106 Important:
107 This test case can be potentially dangerous if
108 your machine has previously set iptables rules.
109 One of the steps of the test case will flush
110 all existing iptables rules.
111 Note:
112 You can specify the number of switches in the
113 params file to adjust the switch discovery size
114 (and specify the corresponding topology in Mininet1
115 .topo file)
116 '''
117 import time
118 import subprocess
119 import os
120 import requests
121 import json
andrewonlab51b180b2014-11-12 18:19:28 -0500122 import numpy
andrewonlabadd2fd62014-11-11 18:37:35 -0500123
124 ONOS_ip_list = []
andrewonlab51b180b2014-11-12 18:19:28 -0500125 ONOS_ip_list.append('0')
andrewonlab54cec4b2014-11-12 13:30:23 -0500126 ONOS_ip_list.append(main.params['CTRL']['ip1'])
127 ONOS_ip_list.append(main.params['CTRL']['ip2'])
128 ONOS_ip_list.append(main.params['CTRL']['ip3'])
129 ONOS_ip_list.append(main.params['CTRL']['ip4'])
130 ONOS_ip_list.append(main.params['CTRL']['ip5'])
131 ONOS_ip_list.append(main.params['CTRL']['ip6'])
132 ONOS_ip_list.append(main.params['CTRL']['ip7'])
andrewonlabadd2fd62014-11-11 18:37:35 -0500133 MN1_ip = main.params['MN']['ip1']
134 ONOS_user = main.params['CTRL']['user']
135
136 default_sw_port = main.params['CTRL']['port1']
137
138 #Number of iterations of case
139 num_iter = main.params['TEST']['numIter']
140 num_sw = main.params['TEST']['numSwitch']
141
142 #Timestamp 'keys' for json metrics output.
143 #These are subject to change, hence moved into params
144 deviceTimestamp = main.params['JSON']['deviceTimestamp']
145 graphTimestamp = main.params['JSON']['graphTimestamp']
146
andrewonlabadd2fd62014-11-11 18:37:35 -0500147 #Threshold for this test case
148 sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
149 sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
150 sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
151 sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
152
andrewonlab51b180b2014-11-12 18:19:28 -0500153 assertion = main.TRUE
andrewonlabadd2fd62014-11-11 18:37:35 -0500154 sw_discovery_lat_list = []
155
andrewonlab51b180b2014-11-12 18:19:28 -0500156 main.case(str(num_sw)+" switch per "+str(cluster_count)+
157 " nodes convergence latency")
andrewonlab0d4478f2014-11-11 20:31:20 -0500158
159 main.log.report("Currently active ONOS node(s): ")
160 report_str = "Node "
andrewonlab51b180b2014-11-12 18:19:28 -0500161 for node in range(1, cluster_count+1):
162 report_str += (str(node) + " ")
andrewonlab0d4478f2014-11-11 20:31:20 -0500163 main.log.report(report_str)
andrewonlabadd2fd62014-11-11 18:37:35 -0500164
andrewonlab0d4478f2014-11-11 20:31:20 -0500165 main.step("Assigning "+num_sw+" switches to each ONOS")
166 index = 1
andrewonlab51b180b2014-11-12 18:19:28 -0500167 for node in range(1, cluster_count+1):
andrewonlab0d4478f2014-11-11 20:31:20 -0500168 for i in range(index, int(num_sw)+index):
169 main.Mininet1.assign_sw_controller(
170 sw=str(i),
171 ip1=ONOS_ip_list[node],
172 port1=default_sw_port)
andrewonlab54cec4b2014-11-12 13:30:23 -0500173 index = i+1
174
175 main.log.info("Please check ptpd configuration to ensure "+\
176 "all nodes' system times are in sync")
andrewonlab54cec4b2014-11-12 13:30:23 -0500177
andrewonlab54cec4b2014-11-12 13:30:23 -0500178 time.sleep(10)
179
andrewonlab51b180b2014-11-12 18:19:28 -0500180 for i in range(0, int(num_iter)):
181 main.step("Set iptables rule to block sw connections")
182
183 #INPUT rules
184 main.ONOS1.handle.sendline(
185 "sudo iptables -A INPUT -p tcp -s "+
186 MN1_ip+" --dport "+default_sw_port+" -j DROP")
187 main.ONOS2.handle.sendline(
188 "sudo iptables -A INPUT -p tcp -s "+
189 MN1_ip+" --dport "+default_sw_port+" -j DROP")
190 main.ONOS3.handle.sendline(
191 "sudo iptables -A INPUT -p tcp -s "+
192 MN1_ip+" --dport "+default_sw_port+" -j DROP")
193 main.ONOS4.handle.sendline(
194 "sudo iptables -A INPUT -p tcp -s "+
195 MN1_ip+" --dport "+default_sw_port+" -j DROP")
196 main.ONOS5.handle.sendline(
197 "sudo iptables -A INPUT -p tcp -s "+
198 MN1_ip+" --dport "+default_sw_port+" -j DROP")
199 main.ONOS6.handle.sendline(
200 "sudo iptables -A INPUT -p tcp -s "+
201 MN1_ip+" --dport "+default_sw_port+" -j DROP")
202 main.ONOS7.handle.sendline(
203 "sudo iptables -A INPUT -p tcp -s "+
204 MN1_ip+" --dport "+default_sw_port+" -j DROP")
205
206 #OUTPUT rules
207 main.ONOS1.handle.sendline(
208 "sudo iptables -A OUTPUT -p tcp -s "+
209 MN1_ip+" --dport "+default_sw_port+" -j DROP")
210 main.ONOS2.handle.sendline(
211 "sudo iptables -A OUTPUT -p tcp -s "+
212 MN1_ip+" --dport "+default_sw_port+" -j DROP")
213 main.ONOS3.handle.sendline(
214 "sudo iptables -A OUTPUT -p tcp -s "+
215 MN1_ip+" --dport "+default_sw_port+" -j DROP")
216 main.ONOS4.handle.sendline(
217 "sudo iptables -A OUTPUT -p tcp -s "+
218 MN1_ip+" --dport "+default_sw_port+" -j DROP")
219 main.ONOS5.handle.sendline(
220 "sudo iptables -A OUTPUT -p tcp -s "+
221 MN1_ip+" --dport "+default_sw_port+" -j DROP")
222 main.ONOS6.handle.sendline(
223 "sudo iptables -A OUTPUT -p tcp -s "+
224 MN1_ip+" --dport "+default_sw_port+" -j DROP")
225 main.ONOS7.handle.sendline(
226 "sudo iptables -A OUTPUT -p tcp -s "+
227 MN1_ip+" --dport "+default_sw_port+" -j DROP")
andrewonlab0d4478f2014-11-11 20:31:20 -0500228
andrewonlab51b180b2014-11-12 18:19:28 -0500229 main.log.info("Please wait for switch connection to timeout")
230 time.sleep(60)
andrewonlabadd2fd62014-11-11 18:37:35 -0500231
andrewonlab51b180b2014-11-12 18:19:28 -0500232 main.step("Flushing iptables and obtaining t0")
233 t0_system = time.time()*1000
234 main.ONOS1.handle.sendline("sudo iptables -F")
235 main.ONOS2.handle.sendline("sudo iptables -F")
236 main.ONOS3.handle.sendline("sudo iptables -F")
237 main.ONOS4.handle.sendline("sudo iptables -F")
238 main.ONOS5.handle.sendline("sudo iptables -F")
239 main.ONOS6.handle.sendline("sudo iptables -F")
240 main.ONOS7.handle.sendline("sudo iptables -F")
241
242 counter_loop = 0
243 counter_avail1 = 0
244 counter_avail2 = 0
245 counter_avail3 = 0
246 counter_avail4 = 0
247 counter_avail5 = 0
248 counter_avail6 = 0
249 counter_avail7 = 0
250 onos1_dev = False
251 onos2_dev = False
252 onos3_dev = False
253 onos4_dev = False
254 onos5_dev = False
255 onos6_dev = False
256 onos7_dev = False
257
258 #TODO: Think of a more elegant way to check all
259 # switches across all nodes
260 #Goodluck debugging this loop
261 while counter_loop < 60:
262 for node in range(1, cluster_count+1):
263 if node == 1 and not onos1_dev:
264 device_str_obj1 = main.ONOS1cli.devices()
265 print device_str_obj1
266 device_json1 = json.loads(device_str_obj1)
267 for device1 in device_json1:
268 if device1['available'] == True:
269 counter_avail1 += 1
270 if counter_avail1 == int(num_sw):
271 onos1_dev = True
272 main.log.info("All devices have been"+
273 " discovered on ONOS1")
274 else:
275 counter_avail1 = 0
276 if node == 2 and not onos2_dev:
277 device_str_obj2 = main.ONOS2cli.devices()
278 device_json2 = json.loads(device_str_obj2)
279 for device2 in device_json2:
280 if device2['available'] == True:
281 counter_avail2 += 1
282 if counter_avail2 == int(num_sw):
283 onos2_dev = True
284 main.log.info("All devices have been"+
285 " discovered on ONOS2")
286 else:
287 counter_avail2 = 0
288 if node == 3 and not onos3_dev:
289 device_str_obj3 = main.ONOS3cli.devices()
290 device_json3 = json.loads(device_str_obj3)
291 for device3 in device_json3:
292 if device3['available'] == True:
293 counter_avail3 += 1
294 if counter_avail3 == int(num_sw):
295 onos3_dev = True
296 main.log.info("All devices have been"+
297 " discovered on ONOS3")
298 else:
299 counter_avail3 = 0
300 if node == 4 and not onos4_dev:
301 device_str_obj4 = main.ONOS4cli.devices()
302 device_json4 = json.loads(device_str_obj4)
303 for device4 in device_json4:
304 if device4['available'] == True:
305 counter_avail4 += 1
306 if counter_avail4 == int(num_sw):
307 onos4_dev = True
308 main.log.info("All devices have been"+
309 " discovered on ONOS4")
310 else:
311 counter_avail4 = 0
312 if node == 5 and not onos5_dev:
313 device_str_obj5 = main.ONOS5cli.devices()
314 device_json5 = json.loads(device_str_obj5)
315 for device5 in device_json5:
316 if device5['available'] == True:
317 counter_avail5 += 1
318 if counter_avail5 == int(num_sw):
319 onos5_dev = True
320 main.log.info("All devices have been"+
321 " discovered on ONOS5")
322 else:
323 counter_avail5 = 0
324 if node == 6 and not onos6_dev:
325 device_str_obj6 = main.ONOS6cli.devices()
326 device_json6 = json.loads(device_str_obj6)
327 for device6 in device_json6:
328 if device6['available'] == True:
329 counter_avail6 += 1
330 if counter_avail6 == int(num_sw):
331 onos6_dev = True
332 main.log.info("All devices have been"+
333 " discovered on ONOS6")
334 else:
335 counter_avail6 = 0
336 if node == 7 and not onos7_dev:
337 device_str_obj7 = main.ONOS7cli.devices()
338 device_json7 = json.loads(device_str_obj7)
339 for device7 in device_json7:
340 if device7['available'] == True:
341 counter_avail7 += 1
342 if counter_avail7 == int(num_sw):
343 onos7_dev = True
344 main.log.info("All devices have been"+
345 " discovered on ONOS7")
346 else:
347 counter_avail7 = 0
348 #END node loop
349
350 #TODO: clean up this mess of an if statements if possible
351 #Treat each if as a separate test case with the given
352 # cluster count. Hence when the cluster count changes
353 # the desired calculations will be made
354 if cluster_count == 1:
355 if onos1_dev:
356 main.log.info("All devices have been discovered"+
357 " on all ONOS instances")
358 json_str_metrics_1 =\
359 main.ONOS1cli.topology_events_metrics()
360 json_obj_1 = json.loads(json_str_metrics_1)
361 graph_timestamp_1 =\
362 json_obj_1[graphTimestamp]['value']
363
364 graph_lat_1 = \
365 int(graph_timestamp_1) - int(t0_system)
366
367 if graph_lat_1 > sw_disc_threshold_min\
368 and graph_lat_1 < sw_disc_threshold_max:
369 sw_discovery_lat_list.append(
370 graph_lat_1)
371 else:
372 main.log.info("Switch discovery latency "+
373 "exceeded the threshold.")
374
375 #Break while loop
376 break
377 if cluster_count == 2:
378 if onos1_dev and onos2_dev:
379 main.log.info("All devices have been discovered"+
380 " on all ONOS instances")
381 json_str_metrics_1 =\
382 main.ONOS1cli.topology_events_metrics()
383 json_str_metrics_2 =\
384 main.ONOS2cli.topology_events_metrics()
385 json_obj_1 = json.loads(json_str_metrics_1)
386 json_obj_2 = json.loads(json_str_metrics_2)
387 graph_timestamp_1 =\
388 json_obj_1[graphTimestamp]['value']
389 graph_timestamp_2 =\
390 json_obj_2[graphTimestamp]['value']
391
392 graph_lat_1 = \
393 int(graph_timestamp_1) - int(t0_system)
394 graph_lat_2 = \
395 int(graph_timestamp_2) - int(t0_system)
396
397 avg_graph_lat = \
398 (int(graph_lat_1) +\
399 int(graph_lat_2)) / 2
400
401 if avg_graph_lat > sw_disc_threshold_min\
402 and avg_graph_lat < sw_disc_threshold_max:
403 sw_discovery_lat_list.append(
404 avg_graph_lat)
405 else:
406 main.log.info("Switch discovery latency "+
407 "exceeded the threshold.")
408
409 break
410 if cluster_count == 3:
411 if onos1_dev and onos2_dev and onos3_dev:
412 main.log.info("All devices have been discovered"+
413 " on all ONOS instances")
414 json_str_metrics_1 =\
415 main.ONOS1cli.topology_events_metrics()
416 json_str_metrics_2 =\
417 main.ONOS2cli.topology_events_metrics()
418 json_str_metrics_3 =\
419 main.ONOS3cli.topology_events_metrics()
420 json_obj_1 = json.loads(json_str_metrics_1)
421 json_obj_2 = json.loads(json_str_metrics_2)
422 json_obj_3 = json.loads(json_str_metrics_3)
423 graph_timestamp_1 =\
424 json_obj_1[graphTimestamp]['value']
425 graph_timestamp_2 =\
426 json_obj_2[graphTimestamp]['value']
427 graph_timestamp_3 =\
428 json_obj_3[graphTimestamp]['value']
429
430 graph_lat_1 = \
431 int(graph_timestamp_1) - int(t0_system)
432 graph_lat_2 = \
433 int(graph_timestamp_2) - int(t0_system)
434 graph_lat_3 = \
435 int(graph_timestamp_3) - int(t0_system)
436
437 avg_graph_lat = \
438 (int(graph_lat_1) +\
439 int(graph_lat_2) +\
440 int(graph_lat_3)) / 3
441
442 if avg_graph_lat > sw_disc_threshold_min\
443 and avg_graph_lat < sw_disc_threshold_max:
444 sw_discovery_lat_list.append(
445 avg_graph_lat)
446 else:
447 main.log.info("Switch discovery latency "+
448 "exceeded the threshold.")
449
450 break
451 if cluster_count == 4:
452 if onos1_dev and onos2_dev and onos3_dev and\
453 onos4_dev:
454 main.log.info("All devices have been discovered"+
455 " on all ONOS instances")
456 json_str_metrics_1 =\
457 main.ONOS1cli.topology_events_metrics()
458 json_str_metrics_2 =\
459 main.ONOS2cli.topology_events_metrics()
460 json_str_metrics_3 =\
461 main.ONOS3cli.topology_events_metrics()
462 json_str_metrics_4 =\
463 main.ONOS4cli.topology_events_metrics()
464 json_obj_1 = json.loads(json_str_metrics_1)
465 json_obj_2 = json.loads(json_str_metrics_2)
466 json_obj_3 = json.loads(json_str_metrics_3)
467 json_obj_4 = json.loads(json_str_metrics_4)
468 graph_timestamp_1 =\
469 json_obj_1[graphTimestamp]['value']
470 graph_timestamp_2 =\
471 json_obj_2[graphTimestamp]['value']
472 graph_timestamp_3 =\
473 json_obj_3[graphTimestamp]['value']
474 graph_timestamp_4 =\
475 json_obj_4[graphTimestamp]['value']
476
477 graph_lat_1 = \
478 int(graph_timestamp_1) - int(t0_system)
479 graph_lat_2 = \
480 int(graph_timestamp_2) - int(t0_system)
481 graph_lat_3 = \
482 int(graph_timestamp_3) - int(t0_system)
483 graph_lat_4 = \
484 int(graph_timestamp_4) - int(t0_system)
485
486 avg_graph_lat = \
487 (int(graph_lat_1) +\
488 int(graph_lat_2) +\
489 int(graph_lat_3) +\
490 int(graph_lat_4)) / 4
491
492 if avg_graph_lat > sw_disc_threshold_min\
493 and avg_graph_lat < sw_disc_threshold_max:
494 sw_discovery_lat_list.append(
495 avg_graph_lat)
496 else:
497 main.log.info("Switch discovery latency "+
498 "exceeded the threshold.")
499
500 break
501 if cluster_count == 5:
502 if onos1_dev and onos2_dev and onos3_dev and\
503 onos4_dev and onos5_dev:
504 main.log.info("All devices have been discovered"+
505 " on all ONOS instances")
506 json_str_metrics_1 =\
507 main.ONOS1cli.topology_events_metrics()
508 json_str_metrics_2 =\
509 main.ONOS2cli.topology_events_metrics()
510 json_str_metrics_3 =\
511 main.ONOS3cli.topology_events_metrics()
512 json_str_metrics_4 =\
513 main.ONOS4cli.topology_events_metrics()
514 json_str_metrics_5 =\
515 main.ONOS5cli.topology_events_metrics()
516 json_obj_1 = json.loads(json_str_metrics_1)
517 json_obj_2 = json.loads(json_str_metrics_2)
518 json_obj_3 = json.loads(json_str_metrics_3)
519 json_obj_4 = json.loads(json_str_metrics_4)
520 json_obj_5 = json.loads(json_str_metrics_5)
521 graph_timestamp_1 =\
522 json_obj_1[graphTimestamp]['value']
523 graph_timestamp_2 =\
524 json_obj_2[graphTimestamp]['value']
525 graph_timestamp_3 =\
526 json_obj_3[graphTimestamp]['value']
527 graph_timestamp_4 =\
528 json_obj_4[graphTimestamp]['value']
529 graph_timestamp_5 =\
530 json_obj_5[graphTimestamp]['value']
531
532 graph_lat_1 = \
533 int(graph_timestamp_1) - int(t0_system)
534 graph_lat_2 = \
535 int(graph_timestamp_2) - int(t0_system)
536 graph_lat_3 = \
537 int(graph_timestamp_3) - int(t0_system)
538 graph_lat_4 = \
539 int(graph_timestamp_4) - int(t0_system)
540 graph_lat_5 = \
541 int(graph_timestamp_5) - int(t0_system)
542
543 avg_graph_lat = \
544 (int(graph_lat_1) +\
545 int(graph_lat_2) +\
546 int(graph_lat_3) +\
547 int(graph_lat_4) +\
548 int(graph_lat_5)) / 5
549
550 if avg_graph_lat > sw_disc_threshold_min\
551 and avg_graph_lat < sw_disc_threshold_max:
552 sw_discovery_lat_list.append(
553 avg_graph_lat)
554 else:
555 main.log.info("Switch discovery latency "+
556 "exceeded the threshold.")
557
558 break
559 if cluster_count == 6:
560 if onos1_dev and onos2_dev and onos3_dev and\
561 onos4_dev and onos5_dev and onos6_dev:
562 main.log.info("All devices have been discovered"+
563 " on all ONOS instances")
564 json_str_metrics_1 =\
565 main.ONOS1cli.topology_events_metrics()
566 json_str_metrics_2 =\
567 main.ONOS2cli.topology_events_metrics()
568 json_str_metrics_3 =\
569 main.ONOS3cli.topology_events_metrics()
570 json_str_metrics_4 =\
571 main.ONOS4cli.topology_events_metrics()
572 json_str_metrics_5 =\
573 main.ONOS5cli.topology_events_metrics()
574 json_str_metrics_6 =\
575 main.ONOS6cli.topology_events_metrics()
576 json_obj_1 = json.loads(json_str_metrics_1)
577 json_obj_2 = json.loads(json_str_metrics_2)
578 json_obj_3 = json.loads(json_str_metrics_3)
579 json_obj_4 = json.loads(json_str_metrics_4)
580 json_obj_5 = json.loads(json_str_metrics_5)
581 json_obj_6 = json.loads(json_str_metrics_6)
582 graph_timestamp_1 =\
583 json_obj_1[graphTimestamp]['value']
584 graph_timestamp_2 =\
585 json_obj_2[graphTimestamp]['value']
586 graph_timestamp_3 =\
587 json_obj_3[graphTimestamp]['value']
588 graph_timestamp_4 =\
589 json_obj_4[graphTimestamp]['value']
590 graph_timestamp_5 =\
591 json_obj_5[graphTimestamp]['value']
592 graph_timestamp_6 =\
593 json_obj_6[graphTimestamp]['value']
594
595 graph_lat_1 = \
596 int(graph_timestamp_1) - int(t0_system)
597 graph_lat_2 = \
598 int(graph_timestamp_2) - int(t0_system)
599 graph_lat_3 = \
600 int(graph_timestamp_3) - int(t0_system)
601 graph_lat_4 = \
602 int(graph_timestamp_4) - int(t0_system)
603 graph_lat_5 = \
604 int(graph_timestamp_5) - int(t0_system)
605 graph_lat_6 = \
606 int(graph_timestamp_6) - int(t0_system)
607
608 avg_graph_lat = \
609 (int(graph_lat_1) +\
610 int(graph_lat_2) +\
611 int(graph_lat_3) +\
612 int(graph_lat_4) +\
613 int(graph_lat_5) +\
614 int(graph_lat_6)) / 6
615
616 if avg_graph_lat > sw_disc_threshold_min\
617 and avg_graph_lat < sw_disc_threshold_max:
618 sw_discovery_lat_list.append(
619 avg_graph_lat)
620 else:
621 main.log.info("Switch discovery latency "+
622 "exceeded the threshold.")
623
624 break
625 if cluster_count == 7:
626 if onos1_dev and onos2_dev and onos3_dev and\
627 onos4_dev and onos5_dev and onos6_dev and\
628 onos7_dev:
629 main.log.info("All devices have been discovered"+
630 " on all ONOS instances")
631 json_str_metrics_1 =\
632 main.ONOS1cli.topology_events_metrics()
633 json_str_metrics_2 =\
634 main.ONOS2cli.topology_events_metrics()
635 json_str_metrics_3 =\
636 main.ONOS3cli.topology_events_metrics()
637 json_str_metrics_4 =\
638 main.ONOS4cli.topology_events_metrics()
639 json_str_metrics_5 =\
640 main.ONOS5cli.topology_events_metrics()
641 json_str_metrics_6 =\
642 main.ONOS6cli.topology_events_metrics()
643 json_str_metrics_7 =\
644 main.ONOS7cli.topology_events_metrics()
645 json_obj_1 = json.loads(json_str_metrics_1)
646 json_obj_2 = json.loads(json_str_metrics_2)
647 json_obj_3 = json.loads(json_str_metrics_3)
648 json_obj_4 = json.loads(json_str_metrics_4)
649 json_obj_5 = json.loads(json_str_metrics_5)
650 json_obj_6 = json.loads(json_str_metrics_6)
651 json_obj_7 = json.loads(json_str_metrics_7)
652 graph_timestamp_1 =\
653 json_obj_1[graphTimestamp]['value']
654 graph_timestamp_2 =\
655 json_obj_2[graphTimestamp]['value']
656 graph_timestamp_3 =\
657 json_obj_3[graphTimestamp]['value']
658 graph_timestamp_4 =\
659 json_obj_4[graphTimestamp]['value']
660 graph_timestamp_5 =\
661 json_obj_5[graphTimestamp]['value']
662 graph_timestamp_6 =\
663 json_obj_6[graphTimestamp]['value']
664 graph_timestamp_7 =\
665 json_obj_7[graphTimestamp]['value']
666
667 graph_lat_1 = \
668 int(graph_timestamp_1) - int(t0_system)
669 graph_lat_2 = \
670 int(graph_timestamp_2) - int(t0_system)
671 graph_lat_3 = \
672 int(graph_timestamp_3) - int(t0_system)
673 graph_lat_4 = \
674 int(graph_timestamp_4) - int(t0_system)
675 graph_lat_5 = \
676 int(graph_timestamp_5) - int(t0_system)
677 graph_lat_6 = \
678 int(graph_timestamp_6) - int(t0_system)
679 graph_lat_7 = \
680 int(graph_timestamp_7) - int(t0_system)
681
682 avg_graph_lat = \
683 (int(graph_lat_1) +\
684 int(graph_lat_2) +\
685 int(graph_lat_3) +\
686 int(graph_lat_4) +\
687 int(graph_lat_5) +\
688 int(graph_lat_6) +\
689 int(graph_lat_7)) / 7
690
691 if avg_graph_lat > sw_disc_threshold_min\
692 and avg_graph_lat < sw_disc_threshold_max:
693 sw_discovery_lat_list.append(
694 avg_graph_lat)
695 else:
696 main.log.info("Switch discovery latency "+
697 "exceeded the threshold.")
698
699 break
700
701 counter_loop += 1
702 time.sleep(3)
703 #END WHILE LOOP
704 #END ITERATION LOOP
705 #REPORT HERE
706
707 if len(sw_discovery_lat_list) > 0:
708 sw_lat_avg = sum(sw_discovery_lat_list) / \
709 len(sw_discovery_lat_list)
710 sw_lat_dev = numpy.dev(sw_discovery_lat_list)
711 else:
712 assertion = main.FALSE
713
714 main.log.report("Switch discovery lat for "+\
715 str(cluster_count)+" instances, 100 sw each: ")
716 main.log.report("Avg: "+str(sw_lat_avg)+" ms")
717 main.log.report("Std Deviation: "+str(sw_lat_dev)+" ms")
718
719 utilities.assert_equals(expect=main.TRUE, actual=assertion,
720 onpass="Switch discovery convergence latency" +\
721 " test successful",
722 onfail="Switch discovery convergence latency" +\
723 " test failed")
724
andrewonlabadd2fd62014-11-11 18:37:35 -0500725
726 def CASE3(self, main):
727 '''
andrewonlab54cec4b2014-11-12 13:30:23 -0500728 Increase number of nodes and initiate CLI
andrewonlabadd2fd62014-11-11 18:37:35 -0500729 '''
730 import time
731 import subprocess
732 import os
733 import requests
734 import json
735
736 ONOS_ip_list = []
andrewonlab51b180b2014-11-12 18:19:28 -0500737 ONOS_ip_list.append('0') #Append 0 for index 0
andrewonlab54cec4b2014-11-12 13:30:23 -0500738 ONOS_ip_list.append(main.params['CTRL']['ip1'])
739 ONOS_ip_list.append(main.params['CTRL']['ip2'])
740 ONOS_ip_list.append(main.params['CTRL']['ip3'])
741 ONOS_ip_list.append(main.params['CTRL']['ip4'])
742 ONOS_ip_list.append(main.params['CTRL']['ip5'])
743 ONOS_ip_list.append(main.params['CTRL']['ip6'])
744 ONOS_ip_list.append(main.params['CTRL']['ip7'])
andrewonlabadd2fd62014-11-11 18:37:35 -0500745
746 MN1_ip = main.params['MN']['ip1']
747 BENCH_ip = main.params['BENCH']['ip']
748
749 #NOTE:We start with cluster_count at 1. The first
750 #case already initialized ONOS1. Increase the
751 #cluster count and start from 2.
752 #You can optionally change the increment to
753 #test steps of node sizes, such as 1,3,5,7
754
755 global cluster_count
andrewonlab54cec4b2014-11-12 13:30:23 -0500756 cluster_count += 2
andrewonlabadd2fd62014-11-11 18:37:35 -0500757
758 #Supports up to 7 node configuration
andrewonlab51b180b2014-11-12 18:19:28 -0500759 for node in range(1, cluster_count+1):
760 if node == 2:
andrewonlabadd2fd62014-11-11 18:37:35 -0500761 main.log.info("Starting CLI for instance "+
762 ONOS_ip_list[node])
763 main.ONOS3cli.start_onos_cli(ONOS_ip_list[node])
764 elif node == 3:
765 main.log.info("Starting CLI for instance "+
766 ONOS_ip_list[node])
767 main.ONOS3cli.start_onos_cli(ONOS_ip_list[node])
768 elif node == 4:
769 main.log.info("Starting CLI for instance "+
770 ONOS_ip_list[node])
771 main.ONOS4cli.start_onos_cli(ONOS_ip_list[node])
772 elif node == 5:
773 main.log.info("Starting CLI for instance "+
774 ONOS_ip_list[node])
775 main.ONOS5cli.start_onos_cli(ONOS_ip_list[node])
776 elif node == 6:
777 main.log.info("Starting CLI for instance "+
778 ONOS_ip_list[node])
779 main.ONOS6cli.start_onos_cli(ONOS_ip_list[node])
780 elif node == 7:
781 main.log.info("Starting CLI for instance "+
782 ONOS_ip_list[node])
783 main.ONOS7cli.start_onos_cli(ONOS_ip_list[node])
784 time.sleep(5)
785
786
787
788
789