blob: 4b8042c06de5f98971bc53ef287f2cb3611f82fb [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#
andrewonlaba036b402014-11-17 13:47:46 -05006#NOTE: Ensure that you have 'tablet.json' file
7# in the onos/tools/package/config directory
8#NOTE: You must start this test initially with 3 nodes
9#
andrewonlabadd2fd62014-11-11 18:37:35 -050010#andrew@onlab.us
11
12import time
13import sys
14import os
15import re
16
17class TopoConvNext:
18 def __init__(self):
19 self.default = ''
20
andrewonlabadd2fd62014-11-11 18:37:35 -050021 def CASE1(self, main):
22 '''
23 ONOS startup sequence
24 '''
25 import time
andrewonlab54cec4b2014-11-12 13:30:23 -050026
27 #******
28 #Global cluster count for scale-out purposes
29 global cluster_count
andrewonlab7b4e8ba2014-11-20 17:45:04 -050030 global topo_iteration
31 topo_iteration = 1
andrewonlaba036b402014-11-17 13:47:46 -050032 cluster_count = 3
andrewonlab54cec4b2014-11-12 13:30:23 -050033 #******
andrewonlabadd2fd62014-11-11 18:37:35 -050034 cell_name = main.params['ENV']['cellName']
35
36 git_pull = main.params['GIT']['autoPull']
37 checkout_branch = main.params['GIT']['checkout']
38
39 ONOS1_ip = main.params['CTRL']['ip1']
andrewonlab54cec4b2014-11-12 13:30:23 -050040 ONOS2_ip = main.params['CTRL']['ip2']
41 ONOS3_ip = main.params['CTRL']['ip3']
42 ONOS4_ip = main.params['CTRL']['ip4']
43 ONOS5_ip = main.params['CTRL']['ip5']
44 ONOS6_ip = main.params['CTRL']['ip6']
45 ONOS7_ip = main.params['CTRL']['ip7']
andrewonlabadd2fd62014-11-11 18:37:35 -050046 MN1_ip = main.params['MN']['ip1']
47 BENCH_ip = main.params['BENCH']['ip']
48
49 main.case("Setting up test environment")
andrewonlab0e1825c2014-11-20 20:07:00 -050050 main.step("copying topology event accumulator config file"+
51 " to ONOS package/etc/ directory")
52 topo_config_name = main.params['TEST']['topo_config_name']
53 topo_config =\
54 main.params['TEST']['topo_accumulator_config']
55 main.ONOSbench.handle.sendline("cp ~/"+topo_config+
56 " ~/ONOS/tools/package/etc/"+
57 topo_config_name)
58 main.ONOSbench.handle.expect("\$")
59
andrewonlaba036b402014-11-17 13:47:46 -050060 main.log.info("Uninstalling previous instances")
andrewonlab7b4e8ba2014-11-20 17:45:04 -050061 #main.ONOSbench.onos_uninstall(node_ip = ONOS1_ip)
62 #main.ONOSbench.onos_uninstall(node_ip = ONOS2_ip)
63 #main.ONOSbench.onos_uninstall(node_ip = ONOS3_ip)
andrewonlaba036b402014-11-17 13:47:46 -050064 main.ONOSbench.onos_uninstall(node_ip = ONOS4_ip)
65 main.ONOSbench.onos_uninstall(node_ip = ONOS5_ip)
66 main.ONOSbench.onos_uninstall(node_ip = ONOS6_ip)
67 main.ONOSbench.onos_uninstall(node_ip = ONOS7_ip)
68
andrewonlabadd2fd62014-11-11 18:37:35 -050069 main.log.report("Setting up test environment")
70
71 main.step("Creating cell file")
72 cell_file_result = main.ONOSbench.create_cell_file(
andrewonlab81763ee2014-11-13 17:31:34 -050073 BENCH_ip, cell_name, MN1_ip,
andrewonlaba036b402014-11-17 13:47:46 -050074 "onos-core,onos-app-metrics",
75 ONOS1_ip, ONOS2_ip, ONOS3_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -050076
77 main.step("Applying cell file to environment")
78 cell_apply_result = main.ONOSbench.set_cell(cell_name)
79 verify_cell_result = main.ONOSbench.verify_cell()
80
andrewonlab7b4e8ba2014-11-20 17:45:04 -050081 main.step("Removing raft logs")
andrewonlab62749022014-11-19 19:19:58 -050082 main.ONOSbench.onos_remove_raft_logs()
83
andrewonlabadd2fd62014-11-11 18:37:35 -050084 main.step("Git checkout and pull "+checkout_branch)
85 if git_pull == 'on':
86 checkout_result = \
87 main.ONOSbench.git_checkout(checkout_branch)
88 pull_result = main.ONOSbench.git_pull()
89 else:
90 checkout_result = main.TRUE
91 pull_result = main.TRUE
92 main.log.info("Skipped git checkout and pull")
93
andrewonlab62749022014-11-19 19:19:58 -050094 main.log.report("Commit information - ")
95 main.ONOSbench.get_version()
96
andrewonlabadd2fd62014-11-11 18:37:35 -050097 main.step("Using mvn clean & install")
98 #mvn_result = main.ONOSbench.clean_install()
99 mvn_result = main.TRUE
100
101 main.step("Set cell for ONOS cli env")
102 main.ONOS1cli.set_cell(cell_name)
andrewonlab54cec4b2014-11-12 13:30:23 -0500103 main.ONOS2cli.set_cell(cell_name)
104 main.ONOS3cli.set_cell(cell_name)
andrewonlab54cec4b2014-11-12 13:30:23 -0500105
andrewonlabadd2fd62014-11-11 18:37:35 -0500106 main.step("Creating ONOS package")
107 package_result = main.ONOSbench.onos_package()
108
andrewonlab54cec4b2014-11-12 13:30:23 -0500109 #Start test with single node only
andrewonlabadd2fd62014-11-11 18:37:35 -0500110 main.step("Installing ONOS package")
111 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
andrewonlaba036b402014-11-17 13:47:46 -0500112 install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
113 install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -0500114
115 time.sleep(10)
116
117 main.step("Start onos cli")
118 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
andrewonlaba036b402014-11-17 13:47:46 -0500119 cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
120 cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -0500121
122 main.step("Enable metrics feature")
andrewonlab81763ee2014-11-13 17:31:34 -0500123 #main.ONOS1cli.feature_install("onos-app-metrics")
andrewonlabadd2fd62014-11-11 18:37:35 -0500124
125 utilities.assert_equals(expect=main.TRUE,
126 actual= cell_file_result and cell_apply_result and\
127 verify_cell_result and checkout_result and\
128 pull_result and mvn_result and\
andrewonlaba036b402014-11-17 13:47:46 -0500129 install1_result and install2_result and\
130 install3_result,
andrewonlabadd2fd62014-11-11 18:37:35 -0500131 onpass="Test Environment setup successful",
132 onfail="Failed to setup test environment")
133
134 def CASE2(self, main):
135 '''
136 100 Switch discovery latency
137
138 Important:
139 This test case can be potentially dangerous if
140 your machine has previously set iptables rules.
141 One of the steps of the test case will flush
142 all existing iptables rules.
143 Note:
144 You can specify the number of switches in the
145 params file to adjust the switch discovery size
146 (and specify the corresponding topology in Mininet1
147 .topo file)
148 '''
149 import time
150 import subprocess
151 import os
152 import requests
153 import json
andrewonlab51b180b2014-11-12 18:19:28 -0500154 import numpy
andrewonlabadd2fd62014-11-11 18:37:35 -0500155
156 ONOS_ip_list = []
andrewonlab51b180b2014-11-12 18:19:28 -0500157 ONOS_ip_list.append('0')
andrewonlab54cec4b2014-11-12 13:30:23 -0500158 ONOS_ip_list.append(main.params['CTRL']['ip1'])
159 ONOS_ip_list.append(main.params['CTRL']['ip2'])
160 ONOS_ip_list.append(main.params['CTRL']['ip3'])
161 ONOS_ip_list.append(main.params['CTRL']['ip4'])
162 ONOS_ip_list.append(main.params['CTRL']['ip5'])
163 ONOS_ip_list.append(main.params['CTRL']['ip6'])
164 ONOS_ip_list.append(main.params['CTRL']['ip7'])
andrewonlabadd2fd62014-11-11 18:37:35 -0500165 MN1_ip = main.params['MN']['ip1']
166 ONOS_user = main.params['CTRL']['user']
167
168 default_sw_port = main.params['CTRL']['port1']
169
170 #Number of iterations of case
171 num_iter = main.params['TEST']['numIter']
andrewonlab0e1825c2014-11-20 20:07:00 -0500172 iter_ignore = int(main.params['TEST']['iterIgnore'])
173
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500174 #***********
175 #Global number of switches that change
176 #throughout the test
177 global num_sw
178 global topo_iteration
179 if topo_iteration == 1:
180 num_sw = main.params['TEST']['numSwitch1']
181 elif topo_iteration == 2:
182 num_sw = main.params['TEST']['numSwitch2']
183 elif topo_iteration == 3:
184 num_sw = main.params['TEST']['numSwitch3']
185 #***********
andrewonlabadd2fd62014-11-11 18:37:35 -0500186
187 #Timestamp 'keys' for json metrics output.
188 #These are subject to change, hence moved into params
189 deviceTimestamp = main.params['JSON']['deviceTimestamp']
190 graphTimestamp = main.params['JSON']['graphTimestamp']
191
andrewonlabadd2fd62014-11-11 18:37:35 -0500192 #Threshold for this test case
193 sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
194 sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
195 sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
196 sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
197
andrewonlab51b180b2014-11-12 18:19:28 -0500198 assertion = main.TRUE
andrewonlabadd2fd62014-11-11 18:37:35 -0500199 sw_discovery_lat_list = []
andrewonlaba1272172014-11-17 17:30:35 -0500200 syn_ack_delta_list = []
andrewonlabadd2fd62014-11-11 18:37:35 -0500201
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500202 main.case(str(num_sw)+" switches distributed across "+
203 str(cluster_count)+" nodes convergence latency")
andrewonlab0d4478f2014-11-11 20:31:20 -0500204
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500205 main.log.report("Large topology convergence and scale-out test")
andrewonlab0d4478f2014-11-11 20:31:20 -0500206 main.log.report("Currently active ONOS node(s): ")
207 report_str = "Node "
andrewonlab51b180b2014-11-12 18:19:28 -0500208 for node in range(1, cluster_count+1):
209 report_str += (str(node) + " ")
andrewonlab0d4478f2014-11-11 20:31:20 -0500210 main.log.report(report_str)
andrewonlab0e1825c2014-11-20 20:07:00 -0500211 main.log.report("Topology size: "+str(num_sw)+" switches")
212
andrewonlab62749022014-11-19 19:19:58 -0500213 main.step("Distributing "+num_sw+" switches to each ONOS")
andrewonlab0d4478f2014-11-11 20:31:20 -0500214 index = 1
andrewonlab51b180b2014-11-12 18:19:28 -0500215 for node in range(1, cluster_count+1):
andrewonlab62749022014-11-19 19:19:58 -0500216 for i in range(index, (int(num_sw)/cluster_count)+index):
andrewonlab0d4478f2014-11-11 20:31:20 -0500217 main.Mininet1.assign_sw_controller(
218 sw=str(i),
219 ip1=ONOS_ip_list[node],
220 port1=default_sw_port)
andrewonlab54cec4b2014-11-12 13:30:23 -0500221 index = i+1
222
223 main.log.info("Please check ptpd configuration to ensure "+\
224 "all nodes' system times are in sync")
andrewonlab54cec4b2014-11-12 13:30:23 -0500225
andrewonlab54cec4b2014-11-12 13:30:23 -0500226 time.sleep(10)
227
andrewonlab51b180b2014-11-12 18:19:28 -0500228 for i in range(0, int(num_iter)):
229 main.step("Set iptables rule to block sw connections")
230
231 #INPUT rules
232 main.ONOS1.handle.sendline(
233 "sudo iptables -A INPUT -p tcp -s "+
234 MN1_ip+" --dport "+default_sw_port+" -j DROP")
235 main.ONOS2.handle.sendline(
236 "sudo iptables -A INPUT -p tcp -s "+
237 MN1_ip+" --dport "+default_sw_port+" -j DROP")
238 main.ONOS3.handle.sendline(
239 "sudo iptables -A INPUT -p tcp -s "+
240 MN1_ip+" --dport "+default_sw_port+" -j DROP")
241 main.ONOS4.handle.sendline(
242 "sudo iptables -A INPUT -p tcp -s "+
243 MN1_ip+" --dport "+default_sw_port+" -j DROP")
244 main.ONOS5.handle.sendline(
245 "sudo iptables -A INPUT -p tcp -s "+
246 MN1_ip+" --dport "+default_sw_port+" -j DROP")
247 main.ONOS6.handle.sendline(
248 "sudo iptables -A INPUT -p tcp -s "+
249 MN1_ip+" --dport "+default_sw_port+" -j DROP")
250 main.ONOS7.handle.sendline(
251 "sudo iptables -A INPUT -p tcp -s "+
252 MN1_ip+" --dport "+default_sw_port+" -j DROP")
253
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500254 #OUTPUT rules
andrewonlab51b180b2014-11-12 18:19:28 -0500255 main.ONOS1.handle.sendline(
256 "sudo iptables -A OUTPUT -p tcp -s "+
257 MN1_ip+" --dport "+default_sw_port+" -j DROP")
258 main.ONOS2.handle.sendline(
259 "sudo iptables -A OUTPUT -p tcp -s "+
260 MN1_ip+" --dport "+default_sw_port+" -j DROP")
261 main.ONOS3.handle.sendline(
262 "sudo iptables -A OUTPUT -p tcp -s "+
263 MN1_ip+" --dport "+default_sw_port+" -j DROP")
264 main.ONOS4.handle.sendline(
265 "sudo iptables -A OUTPUT -p tcp -s "+
266 MN1_ip+" --dport "+default_sw_port+" -j DROP")
267 main.ONOS5.handle.sendline(
268 "sudo iptables -A OUTPUT -p tcp -s "+
269 MN1_ip+" --dport "+default_sw_port+" -j DROP")
270 main.ONOS6.handle.sendline(
271 "sudo iptables -A OUTPUT -p tcp -s "+
272 MN1_ip+" --dport "+default_sw_port+" -j DROP")
273 main.ONOS7.handle.sendline(
274 "sudo iptables -A OUTPUT -p tcp -s "+
275 MN1_ip+" --dport "+default_sw_port+" -j DROP")
andrewonlab0d4478f2014-11-11 20:31:20 -0500276
andrewonlab51b180b2014-11-12 18:19:28 -0500277 main.log.info("Please wait for switch connection to timeout")
andrewonlab62749022014-11-19 19:19:58 -0500278
279
280 #time.sleep(60)
281 #if cluster_count >= 3:
282 # time.sleep(60)
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500283 #if cluster_count >= 5:
284 # time.sleep(30)
285 #if cluster_count >= 6:
286 # time.sleep(30)
andrewonlaba036b402014-11-17 13:47:46 -0500287
288 if cluster_count >= 3:
289 main.ONOS1.tshark_grep("SYN, ACK",
290 "/tmp/syn_ack_onos1_iter"+str(i)+".txt")
291 main.ONOS2.tshark_grep("SYN, ACK",
292 "/tmp/syn_ack_onos2_iter"+str(i)+".txt")
293 main.ONOS3.tshark_grep("SYN, ACK",
294 "/tmp/syn_ack_onos3_iter"+str(i)+".txt")
295 if cluster_count >= 4:
296 main.ONOS4.tshark_grep("SYN, ACK",
297 "/tmp/syn_ack_onos4_iter"+str(i)+".txt")
298 if cluster_count >= 5:
299 main.ONOS5.tshark_grep("SYN, ACK",
300 "/tmp/syn_ack_onos5_iter"+str(i)+".txt")
301 if cluster_count >= 6:
302 main.ONOS6.tshark_grep("SYN, ACK",
303 "/tmp/syn_ack_onos6_iter"+str(i)+".txt")
304 if cluster_count == 7:
305 main.ONOS7.tshark_grep("SYN, ACK",
306 "/tmp/syn_ack_onos7_iter"+str(i)+".txt")
andrewonlab62749022014-11-19 19:19:58 -0500307
308 loop_count = 0
309 device_count = 0
310 while loop_count < 60:
311 main.log.info("Checking devices for device down")
312 device_str = main.ONOS1cli.devices()
313 device_json = json.loads(device_str)
314 for device in device_json:
315 if device['available'] == False:
andrewonlab7b4e8ba2014-11-20 17:45:04 -0500316 #print device_count
andrewonlab62749022014-11-19 19:19:58 -0500317 device_count += 1
318 else:
319 device_count = 0
320 if device_count >= int(num_sw)*int(cluster_count):
321 main.step("Flushing iptables and obtaining t0")
322 t0_system = time.time()*1000
323 main.ONOS1.handle.sendline("sudo iptables -F")
324 main.ONOS2.handle.sendline("sudo iptables -F")
325 main.ONOS3.handle.sendline("sudo iptables -F")
326 main.ONOS4.handle.sendline("sudo iptables -F")
327 main.ONOS5.handle.sendline("sudo iptables -F")
328 main.ONOS6.handle.sendline("sudo iptables -F")
329 main.ONOS7.handle.sendline("sudo iptables -F")
330
331 break
332
333 time.sleep(1)
andrewonlabadd2fd62014-11-11 18:37:35 -0500334
andrewonlab62749022014-11-19 19:19:58 -0500335 main.log.info("System time t0: "+str(t0_system))
andrewonlab51b180b2014-11-12 18:19:28 -0500336
337 counter_loop = 0
338 counter_avail1 = 0
339 counter_avail2 = 0
340 counter_avail3 = 0
341 counter_avail4 = 0
342 counter_avail5 = 0
343 counter_avail6 = 0
344 counter_avail7 = 0
345 onos1_dev = False
346 onos2_dev = False
347 onos3_dev = False
348 onos4_dev = False
349 onos5_dev = False
350 onos6_dev = False
351 onos7_dev = False
352
353 #TODO: Think of a more elegant way to check all
354 # switches across all nodes
355 #Goodluck debugging this loop
356 while counter_loop < 60:
357 for node in range(1, cluster_count+1):
358 if node == 1 and not onos1_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500359 main.log.info("Checking node 1 for device "+
360 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500361 device_str_obj1 = main.ONOS1cli.devices()
andrewonlab51b180b2014-11-12 18:19:28 -0500362 device_json1 = json.loads(device_str_obj1)
363 for device1 in device_json1:
364 if device1['available'] == True:
365 counter_avail1 += 1
366 if counter_avail1 == int(num_sw):
367 onos1_dev = True
368 main.log.info("All devices have been"+
369 " discovered on ONOS1")
andrewonlabfd8325f2014-11-12 19:14:06 -0500370 else:
371 counter_avail1 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500372 if node == 2 and not onos2_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500373 main.log.info("Checking node 2 for device "+
374 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500375 device_str_obj2 = main.ONOS2cli.devices()
376 device_json2 = json.loads(device_str_obj2)
377 for device2 in device_json2:
378 if device2['available'] == True:
379 counter_avail2 += 1
380 if counter_avail2 == int(num_sw):
381 onos2_dev = True
382 main.log.info("All devices have been"+
383 " discovered on ONOS2")
andrewonlabfd8325f2014-11-12 19:14:06 -0500384 else:
385 counter_avail2 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500386 if node == 3 and not onos3_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500387 main.log.info("Checking node 3 for device "+
388 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500389 device_str_obj3 = main.ONOS3cli.devices()
390 device_json3 = json.loads(device_str_obj3)
391 for device3 in device_json3:
392 if device3['available'] == True:
393 counter_avail3 += 1
394 if counter_avail3 == int(num_sw):
395 onos3_dev = True
396 main.log.info("All devices have been"+
397 " discovered on ONOS3")
andrewonlabfd8325f2014-11-12 19:14:06 -0500398 else:
399 counter_avail3 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500400 if node == 4 and not onos4_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500401 main.log.info("Checking node 4 for device "+
402 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500403 device_str_obj4 = main.ONOS4cli.devices()
404 device_json4 = json.loads(device_str_obj4)
405 for device4 in device_json4:
406 if device4['available'] == True:
407 counter_avail4 += 1
408 if counter_avail4 == int(num_sw):
409 onos4_dev = True
410 main.log.info("All devices have been"+
411 " discovered on ONOS4")
andrewonlabfd8325f2014-11-12 19:14:06 -0500412 else:
413 counter_avail4 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500414 if node == 5 and not onos5_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500415 main.log.info("Checking node 5 for device "+
416 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500417 device_str_obj5 = main.ONOS5cli.devices()
418 device_json5 = json.loads(device_str_obj5)
419 for device5 in device_json5:
420 if device5['available'] == True:
421 counter_avail5 += 1
422 if counter_avail5 == int(num_sw):
423 onos5_dev = True
424 main.log.info("All devices have been"+
425 " discovered on ONOS5")
andrewonlabfd8325f2014-11-12 19:14:06 -0500426 else:
427 counter_avail5 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500428 if node == 6 and not onos6_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500429 main.log.info("Checking node 6 for device "+
430 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500431 device_str_obj6 = main.ONOS6cli.devices()
432 device_json6 = json.loads(device_str_obj6)
433 for device6 in device_json6:
434 if device6['available'] == True:
435 counter_avail6 += 1
436 if counter_avail6 == int(num_sw):
437 onos6_dev = True
438 main.log.info("All devices have been"+
439 " discovered on ONOS6")
andrewonlabfd8325f2014-11-12 19:14:06 -0500440 else:
441 counter_avail6 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500442 if node == 7 and not onos7_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500443 main.log.info("Checking node 7 for device "+
444 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500445 device_str_obj7 = main.ONOS7cli.devices()
446 device_json7 = json.loads(device_str_obj7)
447 for device7 in device_json7:
448 if device7['available'] == True:
449 counter_avail7 += 1
450 if counter_avail7 == int(num_sw):
451 onos7_dev = True
452 main.log.info("All devices have been"+
453 " discovered on ONOS7")
andrewonlabfd8325f2014-11-12 19:14:06 -0500454 else:
455 counter_avail7 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500456 #END node loop
457
458 #TODO: clean up this mess of an if statements if possible
459 #Treat each if as a separate test case with the given
460 # cluster count. Hence when the cluster count changes
461 # the desired calculations will be made
462 if cluster_count == 1:
463 if onos1_dev:
464 main.log.info("All devices have been discovered"+
465 " on all ONOS instances")
466 json_str_metrics_1 =\
467 main.ONOS1cli.topology_events_metrics()
468 json_obj_1 = json.loads(json_str_metrics_1)
469 graph_timestamp_1 =\
470 json_obj_1[graphTimestamp]['value']
471
472 graph_lat_1 = \
473 int(graph_timestamp_1) - int(t0_system)
474
475 if graph_lat_1 > sw_disc_threshold_min\
andrewonlab0e1825c2014-11-20 20:07:00 -0500476 and graph_lat_1 < sw_disc_threshold_max\
477 and int(i) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500478 sw_discovery_lat_list.append(
479 graph_lat_1)
andrewonlabfd8325f2014-11-12 19:14:06 -0500480 main.log.info("Sw discovery latency of "+
481 str(cluster_count)+" node(s): "+
482 str(graph_lat_1)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500483 else:
484 main.log.info("Switch discovery latency "+
485 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500486 main.log.info(graph_lat_1)
andrewonlab51b180b2014-11-12 18:19:28 -0500487 #Break while loop
488 break
489 if cluster_count == 2:
490 if onos1_dev and onos2_dev:
491 main.log.info("All devices have been discovered"+
andrewonlaba036b402014-11-17 13:47:46 -0500492 " on all "+str(cluster_count)+
493 " ONOS instances")
andrewonlab51b180b2014-11-12 18:19:28 -0500494 json_str_metrics_1 =\
495 main.ONOS1cli.topology_events_metrics()
496 json_str_metrics_2 =\
497 main.ONOS2cli.topology_events_metrics()
498 json_obj_1 = json.loads(json_str_metrics_1)
499 json_obj_2 = json.loads(json_str_metrics_2)
500 graph_timestamp_1 =\
501 json_obj_1[graphTimestamp]['value']
502 graph_timestamp_2 =\
503 json_obj_2[graphTimestamp]['value']
504
505 graph_lat_1 = \
506 int(graph_timestamp_1) - int(t0_system)
507 graph_lat_2 = \
508 int(graph_timestamp_2) - int(t0_system)
509
510 avg_graph_lat = \
511 (int(graph_lat_1) +\
512 int(graph_lat_2)) / 2
513
514 if avg_graph_lat > sw_disc_threshold_min\
andrewonlab0e1825c2014-11-20 20:07:00 -0500515 and avg_graph_lat < sw_disc_threshold_max\
516 and int(i) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500517 sw_discovery_lat_list.append(
518 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500519 main.log.info("Sw discovery latency of "+
520 str(cluster_count)+" node(s): "+
521 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500522 else:
523 main.log.info("Switch discovery latency "+
524 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500525 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500526 break
527 if cluster_count == 3:
528 if onos1_dev and onos2_dev and onos3_dev:
529 main.log.info("All devices have been discovered"+
andrewonlaba036b402014-11-17 13:47:46 -0500530 " on all "+str(cluster_count)+
531 " ONOS instances")
532
533 #TODO: Investigate this sleep
534 # added to 'pad' the results with
535 # plenty of time to 'catch up'
andrewonlab62749022014-11-19 19:19:58 -0500536 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500537
andrewonlab51b180b2014-11-12 18:19:28 -0500538 json_str_metrics_1 =\
539 main.ONOS1cli.topology_events_metrics()
540 json_str_metrics_2 =\
541 main.ONOS2cli.topology_events_metrics()
542 json_str_metrics_3 =\
543 main.ONOS3cli.topology_events_metrics()
544 json_obj_1 = json.loads(json_str_metrics_1)
545 json_obj_2 = json.loads(json_str_metrics_2)
546 json_obj_3 = json.loads(json_str_metrics_3)
547 graph_timestamp_1 =\
548 json_obj_1[graphTimestamp]['value']
549 graph_timestamp_2 =\
550 json_obj_2[graphTimestamp]['value']
551 graph_timestamp_3 =\
552 json_obj_3[graphTimestamp]['value']
553
554 graph_lat_1 = \
555 int(graph_timestamp_1) - int(t0_system)
556 graph_lat_2 = \
557 int(graph_timestamp_2) - int(t0_system)
558 graph_lat_3 = \
559 int(graph_timestamp_3) - int(t0_system)
560
andrewonlab62749022014-11-19 19:19:58 -0500561 main.log.info("DEBUG: graph_timestamp_1: "+
562 str(graph_timestamp_1))
563
andrewonlab51b180b2014-11-12 18:19:28 -0500564 avg_graph_lat = \
565 (int(graph_lat_1) +\
566 int(graph_lat_2) +\
567 int(graph_lat_3)) / 3
568
569 if avg_graph_lat > sw_disc_threshold_min\
andrewonlab0e1825c2014-11-20 20:07:00 -0500570 and avg_graph_lat < sw_disc_threshold_max\
571 and int(i) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500572 sw_discovery_lat_list.append(
573 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500574 main.log.info("Sw discovery latency of "+
575 str(cluster_count)+" node(s): "+
576 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500577 else:
578 main.log.info("Switch discovery latency "+
579 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500580 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500581
582 break
583 if cluster_count == 4:
584 if onos1_dev and onos2_dev and onos3_dev and\
585 onos4_dev:
586 main.log.info("All devices have been discovered"+
587 " on all ONOS instances")
588 json_str_metrics_1 =\
589 main.ONOS1cli.topology_events_metrics()
590 json_str_metrics_2 =\
591 main.ONOS2cli.topology_events_metrics()
592 json_str_metrics_3 =\
593 main.ONOS3cli.topology_events_metrics()
594 json_str_metrics_4 =\
595 main.ONOS4cli.topology_events_metrics()
596 json_obj_1 = json.loads(json_str_metrics_1)
597 json_obj_2 = json.loads(json_str_metrics_2)
598 json_obj_3 = json.loads(json_str_metrics_3)
599 json_obj_4 = json.loads(json_str_metrics_4)
600 graph_timestamp_1 =\
601 json_obj_1[graphTimestamp]['value']
602 graph_timestamp_2 =\
603 json_obj_2[graphTimestamp]['value']
604 graph_timestamp_3 =\
605 json_obj_3[graphTimestamp]['value']
606 graph_timestamp_4 =\
607 json_obj_4[graphTimestamp]['value']
608
609 graph_lat_1 = \
610 int(graph_timestamp_1) - int(t0_system)
611 graph_lat_2 = \
612 int(graph_timestamp_2) - int(t0_system)
613 graph_lat_3 = \
614 int(graph_timestamp_3) - int(t0_system)
615 graph_lat_4 = \
616 int(graph_timestamp_4) - int(t0_system)
617
618 avg_graph_lat = \
619 (int(graph_lat_1) +\
620 int(graph_lat_2) +\
621 int(graph_lat_3) +\
622 int(graph_lat_4)) / 4
623
624 if avg_graph_lat > sw_disc_threshold_min\
andrewonlab0e1825c2014-11-20 20:07:00 -0500625 and avg_graph_lat < sw_disc_threshold_max\
626 and int(i) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500627 sw_discovery_lat_list.append(
628 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500629 main.log.info("Sw discovery latency of "+
630 str(cluster_count)+" node(s): "+
631 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500632 else:
633 main.log.info("Switch discovery latency "+
634 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500635 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500636
637 break
638 if cluster_count == 5:
639 if onos1_dev and onos2_dev and onos3_dev and\
640 onos4_dev and onos5_dev:
641 main.log.info("All devices have been discovered"+
642 " on all ONOS instances")
andrewonlaba036b402014-11-17 13:47:46 -0500643
644 #TODO: Investigate this sleep
645 # added to 'pad' the results with
646 # plenty of time to 'catch up'
andrewonlab62749022014-11-19 19:19:58 -0500647 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500648
andrewonlab51b180b2014-11-12 18:19:28 -0500649 json_str_metrics_1 =\
650 main.ONOS1cli.topology_events_metrics()
651 json_str_metrics_2 =\
652 main.ONOS2cli.topology_events_metrics()
653 json_str_metrics_3 =\
654 main.ONOS3cli.topology_events_metrics()
655 json_str_metrics_4 =\
656 main.ONOS4cli.topology_events_metrics()
657 json_str_metrics_5 =\
658 main.ONOS5cli.topology_events_metrics()
659 json_obj_1 = json.loads(json_str_metrics_1)
660 json_obj_2 = json.loads(json_str_metrics_2)
661 json_obj_3 = json.loads(json_str_metrics_3)
662 json_obj_4 = json.loads(json_str_metrics_4)
663 json_obj_5 = json.loads(json_str_metrics_5)
664 graph_timestamp_1 =\
665 json_obj_1[graphTimestamp]['value']
666 graph_timestamp_2 =\
667 json_obj_2[graphTimestamp]['value']
668 graph_timestamp_3 =\
669 json_obj_3[graphTimestamp]['value']
670 graph_timestamp_4 =\
671 json_obj_4[graphTimestamp]['value']
672 graph_timestamp_5 =\
673 json_obj_5[graphTimestamp]['value']
674
675 graph_lat_1 = \
676 int(graph_timestamp_1) - int(t0_system)
677 graph_lat_2 = \
678 int(graph_timestamp_2) - int(t0_system)
679 graph_lat_3 = \
680 int(graph_timestamp_3) - int(t0_system)
681 graph_lat_4 = \
682 int(graph_timestamp_4) - int(t0_system)
683 graph_lat_5 = \
684 int(graph_timestamp_5) - int(t0_system)
685
686 avg_graph_lat = \
687 (int(graph_lat_1) +\
688 int(graph_lat_2) +\
689 int(graph_lat_3) +\
690 int(graph_lat_4) +\
691 int(graph_lat_5)) / 5
692
693 if avg_graph_lat > sw_disc_threshold_min\
andrewonlab0e1825c2014-11-20 20:07:00 -0500694 and avg_graph_lat < sw_disc_threshold_max\
695 and int(i) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500696 sw_discovery_lat_list.append(
697 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500698 main.log.info("Sw discovery latency of "+
699 str(cluster_count)+" node(s): "+
700 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500701 else:
702 main.log.info("Switch discovery latency "+
703 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500704 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500705
706 break
707 if cluster_count == 6:
708 if onos1_dev and onos2_dev and onos3_dev and\
709 onos4_dev and onos5_dev and onos6_dev:
710 main.log.info("All devices have been discovered"+
711 " on all ONOS instances")
712 json_str_metrics_1 =\
713 main.ONOS1cli.topology_events_metrics()
714 json_str_metrics_2 =\
715 main.ONOS2cli.topology_events_metrics()
716 json_str_metrics_3 =\
717 main.ONOS3cli.topology_events_metrics()
718 json_str_metrics_4 =\
719 main.ONOS4cli.topology_events_metrics()
720 json_str_metrics_5 =\
721 main.ONOS5cli.topology_events_metrics()
722 json_str_metrics_6 =\
723 main.ONOS6cli.topology_events_metrics()
724 json_obj_1 = json.loads(json_str_metrics_1)
725 json_obj_2 = json.loads(json_str_metrics_2)
726 json_obj_3 = json.loads(json_str_metrics_3)
727 json_obj_4 = json.loads(json_str_metrics_4)
728 json_obj_5 = json.loads(json_str_metrics_5)
729 json_obj_6 = json.loads(json_str_metrics_6)
730 graph_timestamp_1 =\
731 json_obj_1[graphTimestamp]['value']
732 graph_timestamp_2 =\
733 json_obj_2[graphTimestamp]['value']
734 graph_timestamp_3 =\
735 json_obj_3[graphTimestamp]['value']
736 graph_timestamp_4 =\
737 json_obj_4[graphTimestamp]['value']
738 graph_timestamp_5 =\
739 json_obj_5[graphTimestamp]['value']
740 graph_timestamp_6 =\
741 json_obj_6[graphTimestamp]['value']
742
743 graph_lat_1 = \
744 int(graph_timestamp_1) - int(t0_system)
745 graph_lat_2 = \
746 int(graph_timestamp_2) - int(t0_system)
747 graph_lat_3 = \
748 int(graph_timestamp_3) - int(t0_system)
749 graph_lat_4 = \
750 int(graph_timestamp_4) - int(t0_system)
751 graph_lat_5 = \
752 int(graph_timestamp_5) - int(t0_system)
753 graph_lat_6 = \
754 int(graph_timestamp_6) - int(t0_system)
755
756 avg_graph_lat = \
757 (int(graph_lat_1) +\
758 int(graph_lat_2) +\
759 int(graph_lat_3) +\
760 int(graph_lat_4) +\
761 int(graph_lat_5) +\
762 int(graph_lat_6)) / 6
763
764 if avg_graph_lat > sw_disc_threshold_min\
andrewonlab0e1825c2014-11-20 20:07:00 -0500765 and avg_graph_lat < sw_disc_threshold_max\
766 and int(i) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500767 sw_discovery_lat_list.append(
768 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500769 main.log.info("Sw discovery latency of "+
770 str(cluster_count)+" node(s): "+
771 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500772 else:
773 main.log.info("Switch discovery latency "+
774 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500775 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500776
777 break
778 if cluster_count == 7:
779 if onos1_dev and onos2_dev and onos3_dev and\
780 onos4_dev and onos5_dev and onos6_dev and\
781 onos7_dev:
782 main.log.info("All devices have been discovered"+
783 " on all ONOS instances")
andrewonlaba036b402014-11-17 13:47:46 -0500784
785 #TODO: Investigate this sleep
786 # added to 'pad' the results with
787 # plenty of time to 'catch up'
andrewonlab62749022014-11-19 19:19:58 -0500788 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500789
andrewonlab51b180b2014-11-12 18:19:28 -0500790 json_str_metrics_1 =\
791 main.ONOS1cli.topology_events_metrics()
792 json_str_metrics_2 =\
793 main.ONOS2cli.topology_events_metrics()
794 json_str_metrics_3 =\
795 main.ONOS3cli.topology_events_metrics()
796 json_str_metrics_4 =\
797 main.ONOS4cli.topology_events_metrics()
798 json_str_metrics_5 =\
799 main.ONOS5cli.topology_events_metrics()
800 json_str_metrics_6 =\
801 main.ONOS6cli.topology_events_metrics()
802 json_str_metrics_7 =\
803 main.ONOS7cli.topology_events_metrics()
804 json_obj_1 = json.loads(json_str_metrics_1)
805 json_obj_2 = json.loads(json_str_metrics_2)
806 json_obj_3 = json.loads(json_str_metrics_3)
807 json_obj_4 = json.loads(json_str_metrics_4)
808 json_obj_5 = json.loads(json_str_metrics_5)
809 json_obj_6 = json.loads(json_str_metrics_6)
810 json_obj_7 = json.loads(json_str_metrics_7)
811 graph_timestamp_1 =\
812 json_obj_1[graphTimestamp]['value']
813 graph_timestamp_2 =\
814 json_obj_2[graphTimestamp]['value']
815 graph_timestamp_3 =\
816 json_obj_3[graphTimestamp]['value']
817 graph_timestamp_4 =\
818 json_obj_4[graphTimestamp]['value']
819 graph_timestamp_5 =\
820 json_obj_5[graphTimestamp]['value']
821 graph_timestamp_6 =\
822 json_obj_6[graphTimestamp]['value']
823 graph_timestamp_7 =\
824 json_obj_7[graphTimestamp]['value']
825
826 graph_lat_1 = \
827 int(graph_timestamp_1) - int(t0_system)
828 graph_lat_2 = \
829 int(graph_timestamp_2) - int(t0_system)
830 graph_lat_3 = \
831 int(graph_timestamp_3) - int(t0_system)
832 graph_lat_4 = \
833 int(graph_timestamp_4) - int(t0_system)
834 graph_lat_5 = \
835 int(graph_timestamp_5) - int(t0_system)
836 graph_lat_6 = \
837 int(graph_timestamp_6) - int(t0_system)
838 graph_lat_7 = \
839 int(graph_timestamp_7) - int(t0_system)
840
841 avg_graph_lat = \
842 (int(graph_lat_1) +\
843 int(graph_lat_2) +\
844 int(graph_lat_3) +\
845 int(graph_lat_4) +\
846 int(graph_lat_5) +\
847 int(graph_lat_6) +\
848 int(graph_lat_7)) / 7
849
850 if avg_graph_lat > sw_disc_threshold_min\
andrewonlab0e1825c2014-11-20 20:07:00 -0500851 and avg_graph_lat < sw_disc_threshold_max\
852 and int(i) > iter_ignore:
andrewonlab51b180b2014-11-12 18:19:28 -0500853 sw_discovery_lat_list.append(
854 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500855 main.log.info("Sw discovery latency of "+
856 str(cluster_count)+" node(s): "+
857 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500858 else:
859 main.log.info("Switch discovery latency "+
860 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500861 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500862
863 break
864
865 counter_loop += 1
866 time.sleep(3)
867 #END WHILE LOOP
andrewonlaba036b402014-11-17 13:47:46 -0500868
869 main.ONOS1.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500870 syn_ack_timestamp_list = []
andrewonlaba036b402014-11-17 13:47:46 -0500871
872 if cluster_count >= 3:
873 main.ONOS2.tshark_stop()
874 main.ONOS3.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500875 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500876 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500877 "/tmp/syn_ack_onos1_iter"+str(i)+".txt /tmp/")
andrewonlaba036b402014-11-17 13:47:46 -0500878 os.system("scp "+ONOS_user+"@"+ONOS2_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500879 "/tmp/syn_ack_onos2_iter"+str(i)+".txt /tmp/")
andrewonlaba036b402014-11-17 13:47:46 -0500880 os.system("scp "+ONOS_user+"@"+ONOS3_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500881 "/tmp/syn_ack_onos3_iter"+str(i)+".txt /tmp/")
882 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500883 #Read each of the files and append all
884 #SYN / ACK timestamps to the list
andrewonlaba1272172014-11-17 17:30:35 -0500885 with open("/tmp/syn_ack_onos1_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500886 f_onos1:
887 for line in f_onos1:
888 line = line.split(" ")
889 syn_ack_timestamp_list.append(line[1])
andrewonlaba1272172014-11-17 17:30:35 -0500890 with open("/tmp/syn_ack_onos2_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500891 f_onos2:
892 for line in f_onos2:
893 line = line.split(" ")
894 syn_ack_timestamp_list.append(line[1])
andrewonlaba1272172014-11-17 17:30:35 -0500895 with open("/tmp/syn_ack_onos3_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500896 f_onos3:
897 for line in f_onos3:
898 line = line.split(" ")
899 syn_ack_timestamp_list.append(line[1])
900 if cluster_count >= 4:
901 main.ONOS4.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500902 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500903 os.system("scp "+ONOS_user+"@"+ONOS4_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500904 "/tmp/syn_ack_onos4_iter"+str(i)+".txt /tmp/")
905 time.sleep(5)
906 with open("/tmp/syn_ack_onos4_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500907 f_onos4:
908 for line in f_onos4:
909 line = line.split(" ")
910 syn_ack_timestamp_list.append(line[1])
911 if cluster_count >= 5:
912 main.ONOS5.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500913 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500914 os.system("scp "+ONOS_user+"@"+ONOS5_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500915 "/tmp/syn_ack_onos5_iter"+str(i)+".txt /tmp/")
916 time.sleep(5)
917 with open("/tmp/syn_ack_onos5_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500918 f_onos5:
919 for line in f_onos5:
920 line = line.split(" ")
921 syn_ack_timestamp_list.append(line[1])
922 if cluster_count >= 6:
923 main.ONOS6.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500924 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500925 os.system("scp "+ONOS_user+"@"+ONOS6_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500926 "/tmp/syn_ack_onos6_iter"+str(i)+".txt /tmp/")
927 time.sleep(5)
928 with open("/tmp/syn_ack_onos6_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500929 f_onos6:
930 for line in f_onos6:
931 line = line.split(" ")
932 syn_ack_timestamp_list.append(line[1])
933 if cluster_count == 7:
934 main.ONOS7.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500935 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500936 os.system("scp "+ONOS_user+"@"+ONOS7_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500937 "/tmp/syn_ack_onos7_iter"+str(i)+".txt /tmp/")
938 time.sleep(5)
939 with open("/tmp/syn_ack_onos7_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500940 f_onos7:
941 for line in f_onos7:
942 line = line.split(" ")
943 syn_ack_timestamp_list.append(line[1])
944
945 #Sort the list by timestamp
946 syn_ack_timestamp_list = sorted(syn_ack_timestamp_list)
andrewonlaba1272172014-11-17 17:30:35 -0500947
948 syn_ack_delta =\
949 int(float(syn_ack_timestamp_list[-1])*1000) -\
950 int(float(syn_ack_timestamp_list[0])*1000)
andrewonlaba036b402014-11-17 13:47:46 -0500951
andrewonlaba1272172014-11-17 17:30:35 -0500952 main.log.info("Switch connection attempt delta iteration "+
953 str(i)+": "+str(syn_ack_delta))
954 syn_ack_delta_list.append(syn_ack_delta)
andrewonlab51b180b2014-11-12 18:19:28 -0500955 #END ITERATION LOOP
956 #REPORT HERE
957
958 if len(sw_discovery_lat_list) > 0:
959 sw_lat_avg = sum(sw_discovery_lat_list) / \
960 len(sw_discovery_lat_list)
andrewonlabfd8325f2014-11-12 19:14:06 -0500961 sw_lat_dev = numpy.std(sw_discovery_lat_list)
andrewonlab51b180b2014-11-12 18:19:28 -0500962 else:
963 assertion = main.FALSE
andrewonlaba1272172014-11-17 17:30:35 -0500964
965 main.log.report("Switch connection attempt time avg "+
andrewonlabd784d4f2014-11-17 17:47:32 -0500966 "(last sw SYN/ACK time - first sw SYN/ACK time) "+
andrewonlaba1272172014-11-17 17:30:35 -0500967 str(sum(syn_ack_delta_list)/len(syn_ack_delta_list)) +
968 " ms")
andrewonlab0e1825c2014-11-20 20:07:00 -0500969 main.log.report(str(num_sw)+" Switch discovery lat for "+\
970 str(cluster_count)+" instance(s): ")
971 main.log.report("Avg: "+str(sw_lat_avg)+" ms "+
972 "Std Deviation: "+str(round(sw_lat_dev,1))+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500973
974 utilities.assert_equals(expect=main.TRUE, actual=assertion,
975 onpass="Switch discovery convergence latency" +\
andrewonlabfd8325f2014-11-12 19:14:06 -0500976 " for "+str(cluster_count)+" nodes successful",
andrewonlab51b180b2014-11-12 18:19:28 -0500977 onfail="Switch discovery convergence latency" +\
978 " test failed")
979
andrewonlabadd2fd62014-11-11 18:37:35 -0500980 def CASE3(self, main):
981 '''
andrewonlab54cec4b2014-11-12 13:30:23 -0500982 Increase number of nodes and initiate CLI
andrewonlabadd2fd62014-11-11 18:37:35 -0500983 '''
984 import time
985 import subprocess
986 import os
987 import requests
988 import json
989
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500990 ONOS1_ip = main.params['CTRL']['ip1']
991 ONOS2_ip = main.params['CTRL']['ip2']
992 ONOS3_ip = main.params['CTRL']['ip3']
993 ONOS4_ip = main.params['CTRL']['ip4']
994 ONOS5_ip = main.params['CTRL']['ip5']
995 ONOS6_ip = main.params['CTRL']['ip6']
996 ONOS7_ip = main.params['CTRL']['ip7']
997
998 cell_name = main.params['ENV']['cellName']
999
andrewonlabadd2fd62014-11-11 18:37:35 -05001000 MN1_ip = main.params['MN']['ip1']
1001 BENCH_ip = main.params['BENCH']['ip']
andrewonlab0cfc7ad2014-11-13 16:29:26 -05001002
andrewonlaba036b402014-11-17 13:47:46 -05001003 #NOTE:We start with cluster_count at 3. The first
andrewonlabadd2fd62014-11-11 18:37:35 -05001004 #case already initialized ONOS1. Increase the
andrewonlaba036b402014-11-17 13:47:46 -05001005 #cluster count and start from 3.
andrewonlabadd2fd62014-11-11 18:37:35 -05001006 #You can optionally change the increment to
andrewonlaba036b402014-11-17 13:47:46 -05001007 #test steps of node sizes, such as 3,5,7
andrewonlab0e1825c2014-11-20 20:07:00 -05001008
andrewonlabadd2fd62014-11-11 18:37:35 -05001009 global cluster_count
andrewonlab54cec4b2014-11-12 13:30:23 -05001010 cluster_count += 2
andrewonlab0e1825c2014-11-20 20:07:00 -05001011 main.log.report("Increasing cluster size to "+
1012 str(cluster_count))
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001013
andrewonlaba036b402014-11-17 13:47:46 -05001014 install_result = main.FALSE
andrewonlabadd2fd62014-11-11 18:37:35 -05001015 #Supports up to 7 node configuration
andrewonlab81763ee2014-11-13 17:31:34 -05001016 #TODO: Cleanup this ridiculous repetitive code
andrewonlaba036b402014-11-17 13:47:46 -05001017 if cluster_count == 4:
1018 main.log.info("Installing ONOS on node 4")
1019 install_result = \
1020 main.ONOSbench.onos_install(node=ONOS4_ip)
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001021 time.sleep(5)
andrewonlab81763ee2014-11-13 17:31:34 -05001022 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -05001023 main.ONOS4cli.start_onos_cli(ONOS4_ip)
andrewonlaba036b402014-11-17 13:47:46 -05001024 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
1025
andrewonlab81763ee2014-11-13 17:31:34 -05001026 elif cluster_count == 5:
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001027 main.log.info("Installing ONOS on nodes 4 and 5")
andrewonlaba036b402014-11-17 13:47:46 -05001028 install_result1 = \
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001029 main.ONOSbench.onos_install(node=ONOS4_ip)
andrewonlaba036b402014-11-17 13:47:46 -05001030 install_result2 = \
1031 main.ONOSbench.onos_install(node=ONOS5_ip)
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001032 time.sleep(5)
andrewonlab81763ee2014-11-13 17:31:34 -05001033 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -05001034 main.ONOS4cli.start_onos_cli(ONOS4_ip)
1035 main.ONOS5cli.start_onos_cli(ONOS5_ip)
andrewonlaba036b402014-11-17 13:47:46 -05001036 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
1037 main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
1038 install_result = install_result1 and install_result2
1039
andrewonlab81763ee2014-11-13 17:31:34 -05001040 elif cluster_count == 6:
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001041 main.log.info("Installing ONOS on nodes 4, 5,and 6")
andrewonlaba036b402014-11-17 13:47:46 -05001042 install_result1 = \
1043 main.ONOSbench.onos_install(options="",node=ONOS4_ip)
1044 install_result2 = \
1045 main.ONOSbench.onos_install(options="",node=ONOS5_ip)
1046 install_result3 = \
1047 main.ONOSbench.onos_install(node=ONOS6_ip)
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001048 time.sleep(5)
andrewonlab81763ee2014-11-13 17:31:34 -05001049 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -05001050 main.ONOS4cli.start_onos_cli(ONOS4_ip)
1051 main.ONOS5cli.start_onos_cli(ONOS5_ip)
1052 main.ONOS6cli.start_onos_cli(ONOS6_ip)
andrewonlaba036b402014-11-17 13:47:46 -05001053 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
1054 main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
1055 main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
1056 install_result = install_result1 and install_result2 and\
1057 install_result3
1058
andrewonlab81763ee2014-11-13 17:31:34 -05001059 elif cluster_count == 7:
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001060 main.log.info("Installing ONOS on nodes 4, 5, 6,and 7")
andrewonlaba036b402014-11-17 13:47:46 -05001061 install_result1 = \
1062 main.ONOSbench.onos_install(options="",node=ONOS4_ip)
1063 install_result2 = \
1064 main.ONOSbench.onos_install(options="",node=ONOS5_ip)
1065 install_result3 = \
1066 main.ONOSbench.onos_install(options="",node=ONOS6_ip)
1067 install_result4 = \
1068 main.ONOSbench.onos_install(node=ONOS7_ip)
andrewonlab81763ee2014-11-13 17:31:34 -05001069 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -05001070 main.ONOS4cli.start_onos_cli(ONOS4_ip)
1071 main.ONOS5cli.start_onos_cli(ONOS5_ip)
1072 main.ONOS6cli.start_onos_cli(ONOS6_ip)
1073 main.ONOS7cli.start_onos_cli(ONOS7_ip)
andrewonlaba036b402014-11-17 13:47:46 -05001074 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
1075 main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
1076 main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
1077 main.ONOS1cli.add_node(ONOS7_ip, ONOS7_ip)
andrewonlab81763ee2014-11-13 17:31:34 -05001078
andrewonlaba036b402014-11-17 13:47:46 -05001079 install_result = install_result1 and install_result2 and\
1080 install_result3 and install_result4
andrewonlab81763ee2014-11-13 17:31:34 -05001081
1082 time.sleep(5)
andrewonlabadd2fd62014-11-11 18:37:35 -05001083
andrewonlab0cfc7ad2014-11-13 16:29:26 -05001084 if install_result == main.TRUE:
1085 assertion = main.TRUE
1086 else:
1087 assertion = main.FALSE
1088
1089 utilities.assert_equals(expect=main.TRUE, actual=assertion,
1090 onpass="Scale out to "+str(cluster_count)+\
1091 " nodes successful",
1092 onfail="Scale out to "+str(cluster_count)+\
1093 " nodes failed")
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001094
1095
1096 def CASE4(self, main):
1097 '''
1098 Cleanup ONOS nodes and Increase topology size
1099 '''
andrewonlab0e1825c2014-11-20 20:07:00 -05001100 #TODO: use meaningful assertion
1101 assertion=main.TRUE
andrewonlab7b4e8ba2014-11-20 17:45:04 -05001102
1103 ONOS1_ip = main.params['CTRL']['ip1']
1104 ONOS2_ip = main.params['CTRL']['ip2']
1105 ONOS3_ip = main.params['CTRL']['ip3']
1106 ONOS4_ip = main.params['CTRL']['ip4']
1107 ONOS5_ip = main.params['CTRL']['ip5']
1108 ONOS6_ip = main.params['CTRL']['ip6']
1109 ONOS7_ip = main.params['CTRL']['ip7']
1110 MN1_ip = main.params['MN']['ip1']
1111 BENCH_ip = main.params['BENCH']['ip']
1112
1113 main.log.info("Uninstalling previous instances")
1114 main.ONOSbench.onos_uninstall(node_ip = ONOS4_ip)
1115 main.ONOSbench.onos_uninstall(node_ip = ONOS5_ip)
1116 main.ONOSbench.onos_uninstall(node_ip = ONOS6_ip)
1117 main.ONOSbench.onos_uninstall(node_ip = ONOS7_ip)
1118
1119 global topo_iteration
1120 global cluster_count
1121 cluster_count = 3
1122 topo_iteration += 1
1123
andrewonlab0e1825c2014-11-20 20:07:00 -05001124 main.log.report("Increasing topology size")
1125 utilities.assert_equals(expect=main.TRUE, actual=assertion,
1126 onpass="Topology size increased successfully",
1127 onfail="Topology size was not increased")