blob: 966dc41b7040cbe9cc30dc582c08859d352ff479 [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
andrewonlaba036b402014-11-17 13:47:46 -050030 cluster_count = 3
andrewonlab54cec4b2014-11-12 13:30:23 -050031 #******
andrewonlabadd2fd62014-11-11 18:37:35 -050032 cell_name = main.params['ENV']['cellName']
33
34 git_pull = main.params['GIT']['autoPull']
35 checkout_branch = main.params['GIT']['checkout']
36
37 ONOS1_ip = main.params['CTRL']['ip1']
andrewonlab54cec4b2014-11-12 13:30:23 -050038 ONOS2_ip = main.params['CTRL']['ip2']
39 ONOS3_ip = main.params['CTRL']['ip3']
40 ONOS4_ip = main.params['CTRL']['ip4']
41 ONOS5_ip = main.params['CTRL']['ip5']
42 ONOS6_ip = main.params['CTRL']['ip6']
43 ONOS7_ip = main.params['CTRL']['ip7']
andrewonlabadd2fd62014-11-11 18:37:35 -050044 MN1_ip = main.params['MN']['ip1']
45 BENCH_ip = main.params['BENCH']['ip']
46
47 main.case("Setting up test environment")
andrewonlaba036b402014-11-17 13:47:46 -050048 main.log.info("Uninstalling previous instances")
49 main.ONOSbench.onos_uninstall(node_ip = ONOS1_ip)
50 main.ONOSbench.onos_uninstall(node_ip = ONOS2_ip)
51 main.ONOSbench.onos_uninstall(node_ip = ONOS3_ip)
52 main.ONOSbench.onos_uninstall(node_ip = ONOS4_ip)
53 main.ONOSbench.onos_uninstall(node_ip = ONOS5_ip)
54 main.ONOSbench.onos_uninstall(node_ip = ONOS6_ip)
55 main.ONOSbench.onos_uninstall(node_ip = ONOS7_ip)
56
andrewonlabadd2fd62014-11-11 18:37:35 -050057 main.log.report("Setting up test environment")
58
59 main.step("Creating cell file")
60 cell_file_result = main.ONOSbench.create_cell_file(
andrewonlab81763ee2014-11-13 17:31:34 -050061 BENCH_ip, cell_name, MN1_ip,
andrewonlaba036b402014-11-17 13:47:46 -050062 "onos-core,onos-app-metrics",
63 ONOS1_ip, ONOS2_ip, ONOS3_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -050064
65 main.step("Applying cell file to environment")
66 cell_apply_result = main.ONOSbench.set_cell(cell_name)
67 verify_cell_result = main.ONOSbench.verify_cell()
68
andrewonlab62749022014-11-19 19:19:58 -050069 main.case("Removing raft logs")
70 main.ONOSbench.onos_remove_raft_logs()
71
andrewonlabadd2fd62014-11-11 18:37:35 -050072 main.step("Git checkout and pull "+checkout_branch)
73 if git_pull == 'on':
74 checkout_result = \
75 main.ONOSbench.git_checkout(checkout_branch)
76 pull_result = main.ONOSbench.git_pull()
77 else:
78 checkout_result = main.TRUE
79 pull_result = main.TRUE
80 main.log.info("Skipped git checkout and pull")
81
andrewonlab62749022014-11-19 19:19:58 -050082 main.log.report("Commit information - ")
83 main.ONOSbench.get_version()
84
andrewonlabadd2fd62014-11-11 18:37:35 -050085 main.step("Using mvn clean & install")
86 #mvn_result = main.ONOSbench.clean_install()
87 mvn_result = main.TRUE
88
89 main.step("Set cell for ONOS cli env")
90 main.ONOS1cli.set_cell(cell_name)
andrewonlab54cec4b2014-11-12 13:30:23 -050091 main.ONOS2cli.set_cell(cell_name)
92 main.ONOS3cli.set_cell(cell_name)
andrewonlab54cec4b2014-11-12 13:30:23 -050093
andrewonlabadd2fd62014-11-11 18:37:35 -050094 main.step("Creating ONOS package")
95 package_result = main.ONOSbench.onos_package()
96
andrewonlab54cec4b2014-11-12 13:30:23 -050097 #Start test with single node only
andrewonlabadd2fd62014-11-11 18:37:35 -050098 main.step("Installing ONOS package")
99 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
andrewonlaba036b402014-11-17 13:47:46 -0500100 install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
101 install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -0500102
103 time.sleep(10)
104
105 main.step("Start onos cli")
106 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
andrewonlaba036b402014-11-17 13:47:46 -0500107 cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
108 cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -0500109
110 main.step("Enable metrics feature")
andrewonlab81763ee2014-11-13 17:31:34 -0500111 #main.ONOS1cli.feature_install("onos-app-metrics")
andrewonlabadd2fd62014-11-11 18:37:35 -0500112
113 utilities.assert_equals(expect=main.TRUE,
114 actual= cell_file_result and cell_apply_result and\
115 verify_cell_result and checkout_result and\
116 pull_result and mvn_result and\
andrewonlaba036b402014-11-17 13:47:46 -0500117 install1_result and install2_result and\
118 install3_result,
andrewonlabadd2fd62014-11-11 18:37:35 -0500119 onpass="Test Environment setup successful",
120 onfail="Failed to setup test environment")
121
122 def CASE2(self, main):
123 '''
124 100 Switch discovery latency
125
126 Important:
127 This test case can be potentially dangerous if
128 your machine has previously set iptables rules.
129 One of the steps of the test case will flush
130 all existing iptables rules.
131 Note:
132 You can specify the number of switches in the
133 params file to adjust the switch discovery size
134 (and specify the corresponding topology in Mininet1
135 .topo file)
136 '''
137 import time
138 import subprocess
139 import os
140 import requests
141 import json
andrewonlab51b180b2014-11-12 18:19:28 -0500142 import numpy
andrewonlabadd2fd62014-11-11 18:37:35 -0500143
144 ONOS_ip_list = []
andrewonlab51b180b2014-11-12 18:19:28 -0500145 ONOS_ip_list.append('0')
andrewonlab54cec4b2014-11-12 13:30:23 -0500146 ONOS_ip_list.append(main.params['CTRL']['ip1'])
147 ONOS_ip_list.append(main.params['CTRL']['ip2'])
148 ONOS_ip_list.append(main.params['CTRL']['ip3'])
149 ONOS_ip_list.append(main.params['CTRL']['ip4'])
150 ONOS_ip_list.append(main.params['CTRL']['ip5'])
151 ONOS_ip_list.append(main.params['CTRL']['ip6'])
152 ONOS_ip_list.append(main.params['CTRL']['ip7'])
andrewonlabadd2fd62014-11-11 18:37:35 -0500153 MN1_ip = main.params['MN']['ip1']
154 ONOS_user = main.params['CTRL']['user']
155
156 default_sw_port = main.params['CTRL']['port1']
157
158 #Number of iterations of case
159 num_iter = main.params['TEST']['numIter']
160 num_sw = main.params['TEST']['numSwitch']
161
162 #Timestamp 'keys' for json metrics output.
163 #These are subject to change, hence moved into params
164 deviceTimestamp = main.params['JSON']['deviceTimestamp']
165 graphTimestamp = main.params['JSON']['graphTimestamp']
166
andrewonlabadd2fd62014-11-11 18:37:35 -0500167 #Threshold for this test case
168 sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
169 sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
170 sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
171 sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
172
andrewonlab51b180b2014-11-12 18:19:28 -0500173 assertion = main.TRUE
andrewonlabadd2fd62014-11-11 18:37:35 -0500174 sw_discovery_lat_list = []
andrewonlaba1272172014-11-17 17:30:35 -0500175 syn_ack_delta_list = []
andrewonlabadd2fd62014-11-11 18:37:35 -0500176
andrewonlab51b180b2014-11-12 18:19:28 -0500177 main.case(str(num_sw)+" switch per "+str(cluster_count)+
178 " nodes convergence latency")
andrewonlab0d4478f2014-11-11 20:31:20 -0500179
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500180 main.log.report("Large topology convergence and scale-out test")
andrewonlab0d4478f2014-11-11 20:31:20 -0500181 main.log.report("Currently active ONOS node(s): ")
182 report_str = "Node "
andrewonlab51b180b2014-11-12 18:19:28 -0500183 for node in range(1, cluster_count+1):
184 report_str += (str(node) + " ")
andrewonlab0d4478f2014-11-11 20:31:20 -0500185 main.log.report(report_str)
andrewonlabadd2fd62014-11-11 18:37:35 -0500186
andrewonlab62749022014-11-19 19:19:58 -0500187 main.step("Distributing "+num_sw+" switches to each ONOS")
andrewonlab0d4478f2014-11-11 20:31:20 -0500188 index = 1
andrewonlab51b180b2014-11-12 18:19:28 -0500189 for node in range(1, cluster_count+1):
andrewonlab62749022014-11-19 19:19:58 -0500190 for i in range(index, (int(num_sw)/cluster_count)+index):
andrewonlab0d4478f2014-11-11 20:31:20 -0500191 main.Mininet1.assign_sw_controller(
192 sw=str(i),
193 ip1=ONOS_ip_list[node],
194 port1=default_sw_port)
andrewonlab54cec4b2014-11-12 13:30:23 -0500195 index = i+1
196
197 main.log.info("Please check ptpd configuration to ensure "+\
198 "all nodes' system times are in sync")
andrewonlab54cec4b2014-11-12 13:30:23 -0500199
andrewonlab54cec4b2014-11-12 13:30:23 -0500200 time.sleep(10)
201
andrewonlab51b180b2014-11-12 18:19:28 -0500202 for i in range(0, int(num_iter)):
203 main.step("Set iptables rule to block sw connections")
204
205 #INPUT rules
206 main.ONOS1.handle.sendline(
207 "sudo iptables -A INPUT -p tcp -s "+
208 MN1_ip+" --dport "+default_sw_port+" -j DROP")
209 main.ONOS2.handle.sendline(
210 "sudo iptables -A INPUT -p tcp -s "+
211 MN1_ip+" --dport "+default_sw_port+" -j DROP")
212 main.ONOS3.handle.sendline(
213 "sudo iptables -A INPUT -p tcp -s "+
214 MN1_ip+" --dport "+default_sw_port+" -j DROP")
215 main.ONOS4.handle.sendline(
216 "sudo iptables -A INPUT -p tcp -s "+
217 MN1_ip+" --dport "+default_sw_port+" -j DROP")
218 main.ONOS5.handle.sendline(
219 "sudo iptables -A INPUT -p tcp -s "+
220 MN1_ip+" --dport "+default_sw_port+" -j DROP")
221 main.ONOS6.handle.sendline(
222 "sudo iptables -A INPUT -p tcp -s "+
223 MN1_ip+" --dport "+default_sw_port+" -j DROP")
224 main.ONOS7.handle.sendline(
225 "sudo iptables -A INPUT -p tcp -s "+
226 MN1_ip+" --dport "+default_sw_port+" -j DROP")
227
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500228 #OUTPUT rules
andrewonlab51b180b2014-11-12 18:19:28 -0500229 main.ONOS1.handle.sendline(
230 "sudo iptables -A OUTPUT -p tcp -s "+
231 MN1_ip+" --dport "+default_sw_port+" -j DROP")
232 main.ONOS2.handle.sendline(
233 "sudo iptables -A OUTPUT -p tcp -s "+
234 MN1_ip+" --dport "+default_sw_port+" -j DROP")
235 main.ONOS3.handle.sendline(
236 "sudo iptables -A OUTPUT -p tcp -s "+
237 MN1_ip+" --dport "+default_sw_port+" -j DROP")
238 main.ONOS4.handle.sendline(
239 "sudo iptables -A OUTPUT -p tcp -s "+
240 MN1_ip+" --dport "+default_sw_port+" -j DROP")
241 main.ONOS5.handle.sendline(
242 "sudo iptables -A OUTPUT -p tcp -s "+
243 MN1_ip+" --dport "+default_sw_port+" -j DROP")
244 main.ONOS6.handle.sendline(
245 "sudo iptables -A OUTPUT -p tcp -s "+
246 MN1_ip+" --dport "+default_sw_port+" -j DROP")
247 main.ONOS7.handle.sendline(
248 "sudo iptables -A OUTPUT -p tcp -s "+
249 MN1_ip+" --dport "+default_sw_port+" -j DROP")
andrewonlab0d4478f2014-11-11 20:31:20 -0500250
andrewonlab51b180b2014-11-12 18:19:28 -0500251 main.log.info("Please wait for switch connection to timeout")
andrewonlab62749022014-11-19 19:19:58 -0500252
253
254 #time.sleep(60)
255 #if cluster_count >= 3:
256 # time.sleep(60)
andrewonlaba036b402014-11-17 13:47:46 -0500257 if cluster_count >= 5:
258 time.sleep(30)
259 if cluster_count >= 6:
260 time.sleep(30)
261
262 if cluster_count >= 3:
263 main.ONOS1.tshark_grep("SYN, ACK",
264 "/tmp/syn_ack_onos1_iter"+str(i)+".txt")
265 main.ONOS2.tshark_grep("SYN, ACK",
266 "/tmp/syn_ack_onos2_iter"+str(i)+".txt")
267 main.ONOS3.tshark_grep("SYN, ACK",
268 "/tmp/syn_ack_onos3_iter"+str(i)+".txt")
269 if cluster_count >= 4:
270 main.ONOS4.tshark_grep("SYN, ACK",
271 "/tmp/syn_ack_onos4_iter"+str(i)+".txt")
272 if cluster_count >= 5:
273 main.ONOS5.tshark_grep("SYN, ACK",
274 "/tmp/syn_ack_onos5_iter"+str(i)+".txt")
275 if cluster_count >= 6:
276 main.ONOS6.tshark_grep("SYN, ACK",
277 "/tmp/syn_ack_onos6_iter"+str(i)+".txt")
278 if cluster_count == 7:
279 main.ONOS7.tshark_grep("SYN, ACK",
280 "/tmp/syn_ack_onos7_iter"+str(i)+".txt")
andrewonlab62749022014-11-19 19:19:58 -0500281
282 loop_count = 0
283 device_count = 0
284 while loop_count < 60:
285 main.log.info("Checking devices for device down")
286 device_str = main.ONOS1cli.devices()
287 device_json = json.loads(device_str)
288 for device in device_json:
289 if device['available'] == False:
290 print device_count
291 device_count += 1
292 else:
293 device_count = 0
294 if device_count >= int(num_sw)*int(cluster_count):
295 main.step("Flushing iptables and obtaining t0")
296 t0_system = time.time()*1000
297 main.ONOS1.handle.sendline("sudo iptables -F")
298 main.ONOS2.handle.sendline("sudo iptables -F")
299 main.ONOS3.handle.sendline("sudo iptables -F")
300 main.ONOS4.handle.sendline("sudo iptables -F")
301 main.ONOS5.handle.sendline("sudo iptables -F")
302 main.ONOS6.handle.sendline("sudo iptables -F")
303 main.ONOS7.handle.sendline("sudo iptables -F")
304
305 break
306
307 time.sleep(1)
andrewonlabadd2fd62014-11-11 18:37:35 -0500308
andrewonlab62749022014-11-19 19:19:58 -0500309 main.log.info("System time t0: "+str(t0_system))
andrewonlab51b180b2014-11-12 18:19:28 -0500310
311 counter_loop = 0
312 counter_avail1 = 0
313 counter_avail2 = 0
314 counter_avail3 = 0
315 counter_avail4 = 0
316 counter_avail5 = 0
317 counter_avail6 = 0
318 counter_avail7 = 0
319 onos1_dev = False
320 onos2_dev = False
321 onos3_dev = False
322 onos4_dev = False
323 onos5_dev = False
324 onos6_dev = False
325 onos7_dev = False
326
327 #TODO: Think of a more elegant way to check all
328 # switches across all nodes
329 #Goodluck debugging this loop
330 while counter_loop < 60:
331 for node in range(1, cluster_count+1):
332 if node == 1 and not onos1_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500333 main.log.info("Checking node 1 for device "+
334 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500335 device_str_obj1 = main.ONOS1cli.devices()
andrewonlab51b180b2014-11-12 18:19:28 -0500336 device_json1 = json.loads(device_str_obj1)
337 for device1 in device_json1:
338 if device1['available'] == True:
339 counter_avail1 += 1
340 if counter_avail1 == int(num_sw):
341 onos1_dev = True
342 main.log.info("All devices have been"+
343 " discovered on ONOS1")
andrewonlabfd8325f2014-11-12 19:14:06 -0500344 else:
345 counter_avail1 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500346 if node == 2 and not onos2_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500347 main.log.info("Checking node 2 for device "+
348 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500349 device_str_obj2 = main.ONOS2cli.devices()
350 device_json2 = json.loads(device_str_obj2)
351 for device2 in device_json2:
352 if device2['available'] == True:
353 counter_avail2 += 1
354 if counter_avail2 == int(num_sw):
355 onos2_dev = True
356 main.log.info("All devices have been"+
357 " discovered on ONOS2")
andrewonlabfd8325f2014-11-12 19:14:06 -0500358 else:
359 counter_avail2 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500360 if node == 3 and not onos3_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500361 main.log.info("Checking node 3 for device "+
362 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500363 device_str_obj3 = main.ONOS3cli.devices()
364 device_json3 = json.loads(device_str_obj3)
365 for device3 in device_json3:
366 if device3['available'] == True:
367 counter_avail3 += 1
368 if counter_avail3 == int(num_sw):
369 onos3_dev = True
370 main.log.info("All devices have been"+
371 " discovered on ONOS3")
andrewonlabfd8325f2014-11-12 19:14:06 -0500372 else:
373 counter_avail3 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500374 if node == 4 and not onos4_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500375 main.log.info("Checking node 4 for device "+
376 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500377 device_str_obj4 = main.ONOS4cli.devices()
378 device_json4 = json.loads(device_str_obj4)
379 for device4 in device_json4:
380 if device4['available'] == True:
381 counter_avail4 += 1
382 if counter_avail4 == int(num_sw):
383 onos4_dev = True
384 main.log.info("All devices have been"+
385 " discovered on ONOS4")
andrewonlabfd8325f2014-11-12 19:14:06 -0500386 else:
387 counter_avail4 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500388 if node == 5 and not onos5_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500389 main.log.info("Checking node 5 for device "+
390 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500391 device_str_obj5 = main.ONOS5cli.devices()
392 device_json5 = json.loads(device_str_obj5)
393 for device5 in device_json5:
394 if device5['available'] == True:
395 counter_avail5 += 1
396 if counter_avail5 == int(num_sw):
397 onos5_dev = True
398 main.log.info("All devices have been"+
399 " discovered on ONOS5")
andrewonlabfd8325f2014-11-12 19:14:06 -0500400 else:
401 counter_avail5 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500402 if node == 6 and not onos6_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500403 main.log.info("Checking node 6 for device "+
404 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500405 device_str_obj6 = main.ONOS6cli.devices()
406 device_json6 = json.loads(device_str_obj6)
407 for device6 in device_json6:
408 if device6['available'] == True:
409 counter_avail6 += 1
410 if counter_avail6 == int(num_sw):
411 onos6_dev = True
412 main.log.info("All devices have been"+
413 " discovered on ONOS6")
andrewonlabfd8325f2014-11-12 19:14:06 -0500414 else:
415 counter_avail6 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500416 if node == 7 and not onos7_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500417 main.log.info("Checking node 7 for device "+
418 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500419 device_str_obj7 = main.ONOS7cli.devices()
420 device_json7 = json.loads(device_str_obj7)
421 for device7 in device_json7:
422 if device7['available'] == True:
423 counter_avail7 += 1
424 if counter_avail7 == int(num_sw):
425 onos7_dev = True
426 main.log.info("All devices have been"+
427 " discovered on ONOS7")
andrewonlabfd8325f2014-11-12 19:14:06 -0500428 else:
429 counter_avail7 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500430 #END node loop
431
432 #TODO: clean up this mess of an if statements if possible
433 #Treat each if as a separate test case with the given
434 # cluster count. Hence when the cluster count changes
435 # the desired calculations will be made
436 if cluster_count == 1:
437 if onos1_dev:
438 main.log.info("All devices have been discovered"+
439 " on all ONOS instances")
440 json_str_metrics_1 =\
441 main.ONOS1cli.topology_events_metrics()
442 json_obj_1 = json.loads(json_str_metrics_1)
443 graph_timestamp_1 =\
444 json_obj_1[graphTimestamp]['value']
445
446 graph_lat_1 = \
447 int(graph_timestamp_1) - int(t0_system)
448
449 if graph_lat_1 > sw_disc_threshold_min\
450 and graph_lat_1 < sw_disc_threshold_max:
451 sw_discovery_lat_list.append(
452 graph_lat_1)
andrewonlabfd8325f2014-11-12 19:14:06 -0500453 main.log.info("Sw discovery latency of "+
454 str(cluster_count)+" node(s): "+
455 str(graph_lat_1)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500456 else:
457 main.log.info("Switch discovery latency "+
458 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500459 main.log.info(graph_lat_1)
andrewonlab51b180b2014-11-12 18:19:28 -0500460 #Break while loop
461 break
462 if cluster_count == 2:
463 if onos1_dev and onos2_dev:
464 main.log.info("All devices have been discovered"+
andrewonlaba036b402014-11-17 13:47:46 -0500465 " on all "+str(cluster_count)+
466 " ONOS instances")
andrewonlab51b180b2014-11-12 18:19:28 -0500467 json_str_metrics_1 =\
468 main.ONOS1cli.topology_events_metrics()
469 json_str_metrics_2 =\
470 main.ONOS2cli.topology_events_metrics()
471 json_obj_1 = json.loads(json_str_metrics_1)
472 json_obj_2 = json.loads(json_str_metrics_2)
473 graph_timestamp_1 =\
474 json_obj_1[graphTimestamp]['value']
475 graph_timestamp_2 =\
476 json_obj_2[graphTimestamp]['value']
477
478 graph_lat_1 = \
479 int(graph_timestamp_1) - int(t0_system)
480 graph_lat_2 = \
481 int(graph_timestamp_2) - int(t0_system)
482
483 avg_graph_lat = \
484 (int(graph_lat_1) +\
485 int(graph_lat_2)) / 2
486
487 if avg_graph_lat > sw_disc_threshold_min\
488 and avg_graph_lat < sw_disc_threshold_max:
489 sw_discovery_lat_list.append(
490 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500491 main.log.info("Sw discovery latency of "+
492 str(cluster_count)+" node(s): "+
493 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500494 else:
495 main.log.info("Switch discovery latency "+
496 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500497 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500498 break
499 if cluster_count == 3:
500 if onos1_dev and onos2_dev and onos3_dev:
501 main.log.info("All devices have been discovered"+
andrewonlaba036b402014-11-17 13:47:46 -0500502 " on all "+str(cluster_count)+
503 " ONOS instances")
504
505 #TODO: Investigate this sleep
506 # added to 'pad' the results with
507 # plenty of time to 'catch up'
andrewonlab62749022014-11-19 19:19:58 -0500508 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500509
andrewonlab51b180b2014-11-12 18:19:28 -0500510 json_str_metrics_1 =\
511 main.ONOS1cli.topology_events_metrics()
512 json_str_metrics_2 =\
513 main.ONOS2cli.topology_events_metrics()
514 json_str_metrics_3 =\
515 main.ONOS3cli.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 graph_timestamp_1 =\
520 json_obj_1[graphTimestamp]['value']
521 graph_timestamp_2 =\
522 json_obj_2[graphTimestamp]['value']
523 graph_timestamp_3 =\
524 json_obj_3[graphTimestamp]['value']
525
526 graph_lat_1 = \
527 int(graph_timestamp_1) - int(t0_system)
528 graph_lat_2 = \
529 int(graph_timestamp_2) - int(t0_system)
530 graph_lat_3 = \
531 int(graph_timestamp_3) - int(t0_system)
532
andrewonlab62749022014-11-19 19:19:58 -0500533 main.log.info("DEBUG: graph_timestamp_1: "+
534 str(graph_timestamp_1))
535
andrewonlab51b180b2014-11-12 18:19:28 -0500536 avg_graph_lat = \
537 (int(graph_lat_1) +\
538 int(graph_lat_2) +\
539 int(graph_lat_3)) / 3
540
541 if avg_graph_lat > sw_disc_threshold_min\
542 and avg_graph_lat < sw_disc_threshold_max:
543 sw_discovery_lat_list.append(
544 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500545 main.log.info("Sw discovery latency of "+
546 str(cluster_count)+" node(s): "+
547 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500548 else:
549 main.log.info("Switch discovery latency "+
550 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500551 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500552
553 break
554 if cluster_count == 4:
555 if onos1_dev and onos2_dev and onos3_dev and\
556 onos4_dev:
557 main.log.info("All devices have been discovered"+
558 " on all ONOS instances")
559 json_str_metrics_1 =\
560 main.ONOS1cli.topology_events_metrics()
561 json_str_metrics_2 =\
562 main.ONOS2cli.topology_events_metrics()
563 json_str_metrics_3 =\
564 main.ONOS3cli.topology_events_metrics()
565 json_str_metrics_4 =\
566 main.ONOS4cli.topology_events_metrics()
567 json_obj_1 = json.loads(json_str_metrics_1)
568 json_obj_2 = json.loads(json_str_metrics_2)
569 json_obj_3 = json.loads(json_str_metrics_3)
570 json_obj_4 = json.loads(json_str_metrics_4)
571 graph_timestamp_1 =\
572 json_obj_1[graphTimestamp]['value']
573 graph_timestamp_2 =\
574 json_obj_2[graphTimestamp]['value']
575 graph_timestamp_3 =\
576 json_obj_3[graphTimestamp]['value']
577 graph_timestamp_4 =\
578 json_obj_4[graphTimestamp]['value']
579
580 graph_lat_1 = \
581 int(graph_timestamp_1) - int(t0_system)
582 graph_lat_2 = \
583 int(graph_timestamp_2) - int(t0_system)
584 graph_lat_3 = \
585 int(graph_timestamp_3) - int(t0_system)
586 graph_lat_4 = \
587 int(graph_timestamp_4) - int(t0_system)
588
589 avg_graph_lat = \
590 (int(graph_lat_1) +\
591 int(graph_lat_2) +\
592 int(graph_lat_3) +\
593 int(graph_lat_4)) / 4
594
595 if avg_graph_lat > sw_disc_threshold_min\
596 and avg_graph_lat < sw_disc_threshold_max:
597 sw_discovery_lat_list.append(
598 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500599 main.log.info("Sw discovery latency of "+
600 str(cluster_count)+" node(s): "+
601 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500602 else:
603 main.log.info("Switch discovery latency "+
604 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500605 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500606
607 break
608 if cluster_count == 5:
609 if onos1_dev and onos2_dev and onos3_dev and\
610 onos4_dev and onos5_dev:
611 main.log.info("All devices have been discovered"+
612 " on all ONOS instances")
andrewonlaba036b402014-11-17 13:47:46 -0500613
614 #TODO: Investigate this sleep
615 # added to 'pad' the results with
616 # plenty of time to 'catch up'
andrewonlab62749022014-11-19 19:19:58 -0500617 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500618
andrewonlab51b180b2014-11-12 18:19:28 -0500619 json_str_metrics_1 =\
620 main.ONOS1cli.topology_events_metrics()
621 json_str_metrics_2 =\
622 main.ONOS2cli.topology_events_metrics()
623 json_str_metrics_3 =\
624 main.ONOS3cli.topology_events_metrics()
625 json_str_metrics_4 =\
626 main.ONOS4cli.topology_events_metrics()
627 json_str_metrics_5 =\
628 main.ONOS5cli.topology_events_metrics()
629 json_obj_1 = json.loads(json_str_metrics_1)
630 json_obj_2 = json.loads(json_str_metrics_2)
631 json_obj_3 = json.loads(json_str_metrics_3)
632 json_obj_4 = json.loads(json_str_metrics_4)
633 json_obj_5 = json.loads(json_str_metrics_5)
634 graph_timestamp_1 =\
635 json_obj_1[graphTimestamp]['value']
636 graph_timestamp_2 =\
637 json_obj_2[graphTimestamp]['value']
638 graph_timestamp_3 =\
639 json_obj_3[graphTimestamp]['value']
640 graph_timestamp_4 =\
641 json_obj_4[graphTimestamp]['value']
642 graph_timestamp_5 =\
643 json_obj_5[graphTimestamp]['value']
644
645 graph_lat_1 = \
646 int(graph_timestamp_1) - int(t0_system)
647 graph_lat_2 = \
648 int(graph_timestamp_2) - int(t0_system)
649 graph_lat_3 = \
650 int(graph_timestamp_3) - int(t0_system)
651 graph_lat_4 = \
652 int(graph_timestamp_4) - int(t0_system)
653 graph_lat_5 = \
654 int(graph_timestamp_5) - int(t0_system)
655
656 avg_graph_lat = \
657 (int(graph_lat_1) +\
658 int(graph_lat_2) +\
659 int(graph_lat_3) +\
660 int(graph_lat_4) +\
661 int(graph_lat_5)) / 5
662
663 if avg_graph_lat > sw_disc_threshold_min\
664 and avg_graph_lat < sw_disc_threshold_max:
665 sw_discovery_lat_list.append(
666 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500667 main.log.info("Sw discovery latency of "+
668 str(cluster_count)+" node(s): "+
669 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500670 else:
671 main.log.info("Switch discovery latency "+
672 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500673 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500674
675 break
676 if cluster_count == 6:
677 if onos1_dev and onos2_dev and onos3_dev and\
678 onos4_dev and onos5_dev and onos6_dev:
679 main.log.info("All devices have been discovered"+
680 " on all ONOS instances")
681 json_str_metrics_1 =\
682 main.ONOS1cli.topology_events_metrics()
683 json_str_metrics_2 =\
684 main.ONOS2cli.topology_events_metrics()
685 json_str_metrics_3 =\
686 main.ONOS3cli.topology_events_metrics()
687 json_str_metrics_4 =\
688 main.ONOS4cli.topology_events_metrics()
689 json_str_metrics_5 =\
690 main.ONOS5cli.topology_events_metrics()
691 json_str_metrics_6 =\
692 main.ONOS6cli.topology_events_metrics()
693 json_obj_1 = json.loads(json_str_metrics_1)
694 json_obj_2 = json.loads(json_str_metrics_2)
695 json_obj_3 = json.loads(json_str_metrics_3)
696 json_obj_4 = json.loads(json_str_metrics_4)
697 json_obj_5 = json.loads(json_str_metrics_5)
698 json_obj_6 = json.loads(json_str_metrics_6)
699 graph_timestamp_1 =\
700 json_obj_1[graphTimestamp]['value']
701 graph_timestamp_2 =\
702 json_obj_2[graphTimestamp]['value']
703 graph_timestamp_3 =\
704 json_obj_3[graphTimestamp]['value']
705 graph_timestamp_4 =\
706 json_obj_4[graphTimestamp]['value']
707 graph_timestamp_5 =\
708 json_obj_5[graphTimestamp]['value']
709 graph_timestamp_6 =\
710 json_obj_6[graphTimestamp]['value']
711
712 graph_lat_1 = \
713 int(graph_timestamp_1) - int(t0_system)
714 graph_lat_2 = \
715 int(graph_timestamp_2) - int(t0_system)
716 graph_lat_3 = \
717 int(graph_timestamp_3) - int(t0_system)
718 graph_lat_4 = \
719 int(graph_timestamp_4) - int(t0_system)
720 graph_lat_5 = \
721 int(graph_timestamp_5) - int(t0_system)
722 graph_lat_6 = \
723 int(graph_timestamp_6) - int(t0_system)
724
725 avg_graph_lat = \
726 (int(graph_lat_1) +\
727 int(graph_lat_2) +\
728 int(graph_lat_3) +\
729 int(graph_lat_4) +\
730 int(graph_lat_5) +\
731 int(graph_lat_6)) / 6
732
733 if avg_graph_lat > sw_disc_threshold_min\
734 and avg_graph_lat < sw_disc_threshold_max:
735 sw_discovery_lat_list.append(
736 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500737 main.log.info("Sw discovery latency of "+
738 str(cluster_count)+" node(s): "+
739 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500740 else:
741 main.log.info("Switch discovery latency "+
742 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500743 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500744
745 break
746 if cluster_count == 7:
747 if onos1_dev and onos2_dev and onos3_dev and\
748 onos4_dev and onos5_dev and onos6_dev and\
749 onos7_dev:
750 main.log.info("All devices have been discovered"+
751 " on all ONOS instances")
andrewonlaba036b402014-11-17 13:47:46 -0500752
753 #TODO: Investigate this sleep
754 # added to 'pad' the results with
755 # plenty of time to 'catch up'
andrewonlab62749022014-11-19 19:19:58 -0500756 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500757
andrewonlab51b180b2014-11-12 18:19:28 -0500758 json_str_metrics_1 =\
759 main.ONOS1cli.topology_events_metrics()
760 json_str_metrics_2 =\
761 main.ONOS2cli.topology_events_metrics()
762 json_str_metrics_3 =\
763 main.ONOS3cli.topology_events_metrics()
764 json_str_metrics_4 =\
765 main.ONOS4cli.topology_events_metrics()
766 json_str_metrics_5 =\
767 main.ONOS5cli.topology_events_metrics()
768 json_str_metrics_6 =\
769 main.ONOS6cli.topology_events_metrics()
770 json_str_metrics_7 =\
771 main.ONOS7cli.topology_events_metrics()
772 json_obj_1 = json.loads(json_str_metrics_1)
773 json_obj_2 = json.loads(json_str_metrics_2)
774 json_obj_3 = json.loads(json_str_metrics_3)
775 json_obj_4 = json.loads(json_str_metrics_4)
776 json_obj_5 = json.loads(json_str_metrics_5)
777 json_obj_6 = json.loads(json_str_metrics_6)
778 json_obj_7 = json.loads(json_str_metrics_7)
779 graph_timestamp_1 =\
780 json_obj_1[graphTimestamp]['value']
781 graph_timestamp_2 =\
782 json_obj_2[graphTimestamp]['value']
783 graph_timestamp_3 =\
784 json_obj_3[graphTimestamp]['value']
785 graph_timestamp_4 =\
786 json_obj_4[graphTimestamp]['value']
787 graph_timestamp_5 =\
788 json_obj_5[graphTimestamp]['value']
789 graph_timestamp_6 =\
790 json_obj_6[graphTimestamp]['value']
791 graph_timestamp_7 =\
792 json_obj_7[graphTimestamp]['value']
793
794 graph_lat_1 = \
795 int(graph_timestamp_1) - int(t0_system)
796 graph_lat_2 = \
797 int(graph_timestamp_2) - int(t0_system)
798 graph_lat_3 = \
799 int(graph_timestamp_3) - int(t0_system)
800 graph_lat_4 = \
801 int(graph_timestamp_4) - int(t0_system)
802 graph_lat_5 = \
803 int(graph_timestamp_5) - int(t0_system)
804 graph_lat_6 = \
805 int(graph_timestamp_6) - int(t0_system)
806 graph_lat_7 = \
807 int(graph_timestamp_7) - int(t0_system)
808
809 avg_graph_lat = \
810 (int(graph_lat_1) +\
811 int(graph_lat_2) +\
812 int(graph_lat_3) +\
813 int(graph_lat_4) +\
814 int(graph_lat_5) +\
815 int(graph_lat_6) +\
816 int(graph_lat_7)) / 7
817
818 if avg_graph_lat > sw_disc_threshold_min\
819 and avg_graph_lat < sw_disc_threshold_max:
820 sw_discovery_lat_list.append(
821 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500822 main.log.info("Sw discovery latency of "+
823 str(cluster_count)+" node(s): "+
824 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500825 else:
826 main.log.info("Switch discovery latency "+
827 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500828 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500829
830 break
831
832 counter_loop += 1
833 time.sleep(3)
834 #END WHILE LOOP
andrewonlaba036b402014-11-17 13:47:46 -0500835
836 main.ONOS1.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500837 syn_ack_timestamp_list = []
andrewonlaba036b402014-11-17 13:47:46 -0500838
839 if cluster_count >= 3:
840 main.ONOS2.tshark_stop()
841 main.ONOS3.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500842 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500843 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500844 "/tmp/syn_ack_onos1_iter"+str(i)+".txt /tmp/")
andrewonlaba036b402014-11-17 13:47:46 -0500845 os.system("scp "+ONOS_user+"@"+ONOS2_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500846 "/tmp/syn_ack_onos2_iter"+str(i)+".txt /tmp/")
andrewonlaba036b402014-11-17 13:47:46 -0500847 os.system("scp "+ONOS_user+"@"+ONOS3_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500848 "/tmp/syn_ack_onos3_iter"+str(i)+".txt /tmp/")
849 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500850 #Read each of the files and append all
851 #SYN / ACK timestamps to the list
andrewonlaba1272172014-11-17 17:30:35 -0500852 with open("/tmp/syn_ack_onos1_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500853 f_onos1:
854 for line in f_onos1:
855 line = line.split(" ")
856 syn_ack_timestamp_list.append(line[1])
andrewonlaba1272172014-11-17 17:30:35 -0500857 with open("/tmp/syn_ack_onos2_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500858 f_onos2:
859 for line in f_onos2:
860 line = line.split(" ")
861 syn_ack_timestamp_list.append(line[1])
andrewonlaba1272172014-11-17 17:30:35 -0500862 with open("/tmp/syn_ack_onos3_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500863 f_onos3:
864 for line in f_onos3:
865 line = line.split(" ")
866 syn_ack_timestamp_list.append(line[1])
867 if cluster_count >= 4:
868 main.ONOS4.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500869 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500870 os.system("scp "+ONOS_user+"@"+ONOS4_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500871 "/tmp/syn_ack_onos4_iter"+str(i)+".txt /tmp/")
872 time.sleep(5)
873 with open("/tmp/syn_ack_onos4_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500874 f_onos4:
875 for line in f_onos4:
876 line = line.split(" ")
877 syn_ack_timestamp_list.append(line[1])
878 if cluster_count >= 5:
879 main.ONOS5.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500880 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500881 os.system("scp "+ONOS_user+"@"+ONOS5_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500882 "/tmp/syn_ack_onos5_iter"+str(i)+".txt /tmp/")
883 time.sleep(5)
884 with open("/tmp/syn_ack_onos5_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500885 f_onos5:
886 for line in f_onos5:
887 line = line.split(" ")
888 syn_ack_timestamp_list.append(line[1])
889 if cluster_count >= 6:
890 main.ONOS6.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500891 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500892 os.system("scp "+ONOS_user+"@"+ONOS6_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500893 "/tmp/syn_ack_onos6_iter"+str(i)+".txt /tmp/")
894 time.sleep(5)
895 with open("/tmp/syn_ack_onos6_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500896 f_onos6:
897 for line in f_onos6:
898 line = line.split(" ")
899 syn_ack_timestamp_list.append(line[1])
900 if cluster_count == 7:
901 main.ONOS7.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500902 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500903 os.system("scp "+ONOS_user+"@"+ONOS7_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500904 "/tmp/syn_ack_onos7_iter"+str(i)+".txt /tmp/")
905 time.sleep(5)
906 with open("/tmp/syn_ack_onos7_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500907 f_onos7:
908 for line in f_onos7:
909 line = line.split(" ")
910 syn_ack_timestamp_list.append(line[1])
911
912 #Sort the list by timestamp
913 syn_ack_timestamp_list = sorted(syn_ack_timestamp_list)
andrewonlaba1272172014-11-17 17:30:35 -0500914
915 syn_ack_delta =\
916 int(float(syn_ack_timestamp_list[-1])*1000) -\
917 int(float(syn_ack_timestamp_list[0])*1000)
andrewonlaba036b402014-11-17 13:47:46 -0500918
andrewonlaba1272172014-11-17 17:30:35 -0500919 main.log.info("Switch connection attempt delta iteration "+
920 str(i)+": "+str(syn_ack_delta))
921 syn_ack_delta_list.append(syn_ack_delta)
andrewonlab51b180b2014-11-12 18:19:28 -0500922 #END ITERATION LOOP
923 #REPORT HERE
924
925 if len(sw_discovery_lat_list) > 0:
926 sw_lat_avg = sum(sw_discovery_lat_list) / \
927 len(sw_discovery_lat_list)
andrewonlabfd8325f2014-11-12 19:14:06 -0500928 sw_lat_dev = numpy.std(sw_discovery_lat_list)
andrewonlab51b180b2014-11-12 18:19:28 -0500929 else:
930 assertion = main.FALSE
andrewonlaba1272172014-11-17 17:30:35 -0500931
932 main.log.report("Switch connection attempt time avg "+
andrewonlabd784d4f2014-11-17 17:47:32 -0500933 "(last sw SYN/ACK time - first sw SYN/ACK time) "+
andrewonlaba1272172014-11-17 17:30:35 -0500934 str(sum(syn_ack_delta_list)/len(syn_ack_delta_list)) +
935 " ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500936 main.log.report("Switch discovery lat for "+\
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500937 str(cluster_count)+" instance(s), 100 sw each: ")
andrewonlab51b180b2014-11-12 18:19:28 -0500938 main.log.report("Avg: "+str(sw_lat_avg)+" ms")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500939 main.log.report("Std Deviation: "+
940 str(round(sw_lat_dev,1))+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500941
942 utilities.assert_equals(expect=main.TRUE, actual=assertion,
943 onpass="Switch discovery convergence latency" +\
andrewonlabfd8325f2014-11-12 19:14:06 -0500944 " for "+str(cluster_count)+" nodes successful",
andrewonlab51b180b2014-11-12 18:19:28 -0500945 onfail="Switch discovery convergence latency" +\
946 " test failed")
947
andrewonlabadd2fd62014-11-11 18:37:35 -0500948 def CASE3(self, main):
949 '''
andrewonlab54cec4b2014-11-12 13:30:23 -0500950 Increase number of nodes and initiate CLI
andrewonlabadd2fd62014-11-11 18:37:35 -0500951 '''
952 import time
953 import subprocess
954 import os
955 import requests
956 import json
957
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500958 ONOS1_ip = main.params['CTRL']['ip1']
959 ONOS2_ip = main.params['CTRL']['ip2']
960 ONOS3_ip = main.params['CTRL']['ip3']
961 ONOS4_ip = main.params['CTRL']['ip4']
962 ONOS5_ip = main.params['CTRL']['ip5']
963 ONOS6_ip = main.params['CTRL']['ip6']
964 ONOS7_ip = main.params['CTRL']['ip7']
965
966 cell_name = main.params['ENV']['cellName']
967
andrewonlabadd2fd62014-11-11 18:37:35 -0500968 MN1_ip = main.params['MN']['ip1']
969 BENCH_ip = main.params['BENCH']['ip']
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500970
andrewonlaba036b402014-11-17 13:47:46 -0500971 #NOTE:We start with cluster_count at 3. The first
andrewonlabadd2fd62014-11-11 18:37:35 -0500972 #case already initialized ONOS1. Increase the
andrewonlaba036b402014-11-17 13:47:46 -0500973 #cluster count and start from 3.
andrewonlabadd2fd62014-11-11 18:37:35 -0500974 #You can optionally change the increment to
andrewonlaba036b402014-11-17 13:47:46 -0500975 #test steps of node sizes, such as 3,5,7
andrewonlabadd2fd62014-11-11 18:37:35 -0500976
977 global cluster_count
andrewonlab54cec4b2014-11-12 13:30:23 -0500978 cluster_count += 2
andrewonlaba036b402014-11-17 13:47:46 -0500979
980 install_result = main.FALSE
andrewonlabadd2fd62014-11-11 18:37:35 -0500981 #Supports up to 7 node configuration
andrewonlab81763ee2014-11-13 17:31:34 -0500982 #TODO: Cleanup this ridiculous repetitive code
andrewonlaba036b402014-11-17 13:47:46 -0500983 if cluster_count == 4:
984 main.log.info("Installing ONOS on node 4")
985 install_result = \
986 main.ONOSbench.onos_install(node=ONOS4_ip)
andrewonlab81763ee2014-11-13 17:31:34 -0500987 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -0500988 main.ONOS4cli.start_onos_cli(ONOS4_ip)
andrewonlaba036b402014-11-17 13:47:46 -0500989 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
990
andrewonlab81763ee2014-11-13 17:31:34 -0500991 elif cluster_count == 5:
andrewonlaba036b402014-11-17 13:47:46 -0500992 main.log.info("Installing ONOS on node 5")
993 install_result1 = \
994 main.ONOSbench.onos_install(options="",node=ONOS4_ip)
995 install_result2 = \
996 main.ONOSbench.onos_install(node=ONOS5_ip)
andrewonlab81763ee2014-11-13 17:31:34 -0500997 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -0500998 main.ONOS4cli.start_onos_cli(ONOS4_ip)
999 main.ONOS5cli.start_onos_cli(ONOS5_ip)
andrewonlaba036b402014-11-17 13:47:46 -05001000 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
1001 main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
1002 install_result = install_result1 and install_result2
1003
andrewonlab81763ee2014-11-13 17:31:34 -05001004 elif cluster_count == 6:
andrewonlaba036b402014-11-17 13:47:46 -05001005 main.log.info("Installing ONOS on node 6")
1006 install_result1 = \
1007 main.ONOSbench.onos_install(options="",node=ONOS4_ip)
1008 install_result2 = \
1009 main.ONOSbench.onos_install(options="",node=ONOS5_ip)
1010 install_result3 = \
1011 main.ONOSbench.onos_install(node=ONOS6_ip)
andrewonlab81763ee2014-11-13 17:31:34 -05001012 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -05001013 main.ONOS4cli.start_onos_cli(ONOS4_ip)
1014 main.ONOS5cli.start_onos_cli(ONOS5_ip)
1015 main.ONOS6cli.start_onos_cli(ONOS6_ip)
andrewonlaba036b402014-11-17 13:47:46 -05001016 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
1017 main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
1018 main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
1019 install_result = install_result1 and install_result2 and\
1020 install_result3
1021
andrewonlab81763ee2014-11-13 17:31:34 -05001022 elif cluster_count == 7:
andrewonlaba036b402014-11-17 13:47:46 -05001023 main.log.info("Installing ONOS on node 7")
1024 install_result1 = \
1025 main.ONOSbench.onos_install(options="",node=ONOS4_ip)
1026 install_result2 = \
1027 main.ONOSbench.onos_install(options="",node=ONOS5_ip)
1028 install_result3 = \
1029 main.ONOSbench.onos_install(options="",node=ONOS6_ip)
1030 install_result4 = \
1031 main.ONOSbench.onos_install(node=ONOS7_ip)
andrewonlab81763ee2014-11-13 17:31:34 -05001032 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -05001033 main.ONOS4cli.start_onos_cli(ONOS4_ip)
1034 main.ONOS5cli.start_onos_cli(ONOS5_ip)
1035 main.ONOS6cli.start_onos_cli(ONOS6_ip)
1036 main.ONOS7cli.start_onos_cli(ONOS7_ip)
andrewonlaba036b402014-11-17 13:47:46 -05001037 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
1038 main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
1039 main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
1040 main.ONOS1cli.add_node(ONOS7_ip, ONOS7_ip)
andrewonlab81763ee2014-11-13 17:31:34 -05001041
andrewonlaba036b402014-11-17 13:47:46 -05001042 install_result = install_result1 and install_result2 and\
1043 install_result3 and install_result4
andrewonlab81763ee2014-11-13 17:31:34 -05001044
1045 time.sleep(5)
andrewonlabadd2fd62014-11-11 18:37:35 -05001046
andrewonlab0cfc7ad2014-11-13 16:29:26 -05001047 if install_result == main.TRUE:
1048 assertion = main.TRUE
1049 else:
1050 assertion = main.FALSE
1051
1052 utilities.assert_equals(expect=main.TRUE, actual=assertion,
1053 onpass="Scale out to "+str(cluster_count)+\
1054 " nodes successful",
1055 onfail="Scale out to "+str(cluster_count)+\
1056 " nodes failed")