blob: 37fb24dcb68553cde922eeb16cdcbca22b678b8d [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
57 main.case("Removing raft logs")
58 main.ONOSbench.onos_remove_raft_logs()
59
andrewonlabadd2fd62014-11-11 18:37:35 -050060 main.log.report("Setting up test environment")
61
62 main.step("Creating cell file")
63 cell_file_result = main.ONOSbench.create_cell_file(
andrewonlab81763ee2014-11-13 17:31:34 -050064 BENCH_ip, cell_name, MN1_ip,
andrewonlaba036b402014-11-17 13:47:46 -050065 "onos-core,onos-app-metrics",
66 ONOS1_ip, ONOS2_ip, ONOS3_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -050067
68 main.step("Applying cell file to environment")
69 cell_apply_result = main.ONOSbench.set_cell(cell_name)
70 verify_cell_result = main.ONOSbench.verify_cell()
71
72 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
82 main.step("Using mvn clean & install")
83 #mvn_result = main.ONOSbench.clean_install()
84 mvn_result = main.TRUE
85
86 main.step("Set cell for ONOS cli env")
87 main.ONOS1cli.set_cell(cell_name)
andrewonlab54cec4b2014-11-12 13:30:23 -050088 main.ONOS2cli.set_cell(cell_name)
89 main.ONOS3cli.set_cell(cell_name)
andrewonlab54cec4b2014-11-12 13:30:23 -050090
andrewonlabadd2fd62014-11-11 18:37:35 -050091 main.step("Creating ONOS package")
92 package_result = main.ONOSbench.onos_package()
93
andrewonlab54cec4b2014-11-12 13:30:23 -050094 #Start test with single node only
andrewonlabadd2fd62014-11-11 18:37:35 -050095 main.step("Installing ONOS package")
96 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
andrewonlaba036b402014-11-17 13:47:46 -050097 install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
98 install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -050099
100 time.sleep(10)
101
102 main.step("Start onos cli")
103 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
andrewonlaba036b402014-11-17 13:47:46 -0500104 cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
105 cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -0500106
107 main.step("Enable metrics feature")
andrewonlab81763ee2014-11-13 17:31:34 -0500108 #main.ONOS1cli.feature_install("onos-app-metrics")
andrewonlabadd2fd62014-11-11 18:37:35 -0500109
110 utilities.assert_equals(expect=main.TRUE,
111 actual= cell_file_result and cell_apply_result and\
112 verify_cell_result and checkout_result and\
113 pull_result and mvn_result and\
andrewonlaba036b402014-11-17 13:47:46 -0500114 install1_result and install2_result and\
115 install3_result,
andrewonlabadd2fd62014-11-11 18:37:35 -0500116 onpass="Test Environment setup successful",
117 onfail="Failed to setup test environment")
118
119 def CASE2(self, main):
120 '''
121 100 Switch discovery latency
122
123 Important:
124 This test case can be potentially dangerous if
125 your machine has previously set iptables rules.
126 One of the steps of the test case will flush
127 all existing iptables rules.
128 Note:
129 You can specify the number of switches in the
130 params file to adjust the switch discovery size
131 (and specify the corresponding topology in Mininet1
132 .topo file)
133 '''
134 import time
135 import subprocess
136 import os
137 import requests
138 import json
andrewonlab51b180b2014-11-12 18:19:28 -0500139 import numpy
andrewonlabadd2fd62014-11-11 18:37:35 -0500140
141 ONOS_ip_list = []
andrewonlab51b180b2014-11-12 18:19:28 -0500142 ONOS_ip_list.append('0')
andrewonlab54cec4b2014-11-12 13:30:23 -0500143 ONOS_ip_list.append(main.params['CTRL']['ip1'])
144 ONOS_ip_list.append(main.params['CTRL']['ip2'])
145 ONOS_ip_list.append(main.params['CTRL']['ip3'])
146 ONOS_ip_list.append(main.params['CTRL']['ip4'])
147 ONOS_ip_list.append(main.params['CTRL']['ip5'])
148 ONOS_ip_list.append(main.params['CTRL']['ip6'])
149 ONOS_ip_list.append(main.params['CTRL']['ip7'])
andrewonlabadd2fd62014-11-11 18:37:35 -0500150 MN1_ip = main.params['MN']['ip1']
151 ONOS_user = main.params['CTRL']['user']
152
153 default_sw_port = main.params['CTRL']['port1']
154
155 #Number of iterations of case
156 num_iter = main.params['TEST']['numIter']
157 num_sw = main.params['TEST']['numSwitch']
158
159 #Timestamp 'keys' for json metrics output.
160 #These are subject to change, hence moved into params
161 deviceTimestamp = main.params['JSON']['deviceTimestamp']
162 graphTimestamp = main.params['JSON']['graphTimestamp']
163
andrewonlabadd2fd62014-11-11 18:37:35 -0500164 #Threshold for this test case
165 sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
166 sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
167 sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
168 sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
169
andrewonlab51b180b2014-11-12 18:19:28 -0500170 assertion = main.TRUE
andrewonlabadd2fd62014-11-11 18:37:35 -0500171 sw_discovery_lat_list = []
andrewonlaba1272172014-11-17 17:30:35 -0500172 syn_ack_delta_list = []
andrewonlabadd2fd62014-11-11 18:37:35 -0500173
andrewonlab51b180b2014-11-12 18:19:28 -0500174 main.case(str(num_sw)+" switch per "+str(cluster_count)+
175 " nodes convergence latency")
andrewonlab0d4478f2014-11-11 20:31:20 -0500176
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500177 main.log.report("Large topology convergence and scale-out test")
andrewonlab0d4478f2014-11-11 20:31:20 -0500178 main.log.report("Currently active ONOS node(s): ")
179 report_str = "Node "
andrewonlab51b180b2014-11-12 18:19:28 -0500180 for node in range(1, cluster_count+1):
181 report_str += (str(node) + " ")
andrewonlab0d4478f2014-11-11 20:31:20 -0500182 main.log.report(report_str)
andrewonlabadd2fd62014-11-11 18:37:35 -0500183
andrewonlab0d4478f2014-11-11 20:31:20 -0500184 main.step("Assigning "+num_sw+" switches to each ONOS")
185 index = 1
andrewonlab51b180b2014-11-12 18:19:28 -0500186 for node in range(1, cluster_count+1):
andrewonlab0d4478f2014-11-11 20:31:20 -0500187 for i in range(index, int(num_sw)+index):
188 main.Mininet1.assign_sw_controller(
189 sw=str(i),
190 ip1=ONOS_ip_list[node],
191 port1=default_sw_port)
andrewonlab54cec4b2014-11-12 13:30:23 -0500192 index = i+1
193
194 main.log.info("Please check ptpd configuration to ensure "+\
195 "all nodes' system times are in sync")
andrewonlab54cec4b2014-11-12 13:30:23 -0500196
andrewonlab54cec4b2014-11-12 13:30:23 -0500197 time.sleep(10)
198
andrewonlab51b180b2014-11-12 18:19:28 -0500199 for i in range(0, int(num_iter)):
200 main.step("Set iptables rule to block sw connections")
201
202 #INPUT rules
203 main.ONOS1.handle.sendline(
204 "sudo iptables -A INPUT -p tcp -s "+
205 MN1_ip+" --dport "+default_sw_port+" -j DROP")
206 main.ONOS2.handle.sendline(
207 "sudo iptables -A INPUT -p tcp -s "+
208 MN1_ip+" --dport "+default_sw_port+" -j DROP")
209 main.ONOS3.handle.sendline(
210 "sudo iptables -A INPUT -p tcp -s "+
211 MN1_ip+" --dport "+default_sw_port+" -j DROP")
212 main.ONOS4.handle.sendline(
213 "sudo iptables -A INPUT -p tcp -s "+
214 MN1_ip+" --dport "+default_sw_port+" -j DROP")
215 main.ONOS5.handle.sendline(
216 "sudo iptables -A INPUT -p tcp -s "+
217 MN1_ip+" --dport "+default_sw_port+" -j DROP")
218 main.ONOS6.handle.sendline(
219 "sudo iptables -A INPUT -p tcp -s "+
220 MN1_ip+" --dport "+default_sw_port+" -j DROP")
221 main.ONOS7.handle.sendline(
222 "sudo iptables -A INPUT -p tcp -s "+
223 MN1_ip+" --dport "+default_sw_port+" -j DROP")
224
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500225 #OUTPUT rules
andrewonlab51b180b2014-11-12 18:19:28 -0500226 main.ONOS1.handle.sendline(
227 "sudo iptables -A OUTPUT -p tcp -s "+
228 MN1_ip+" --dport "+default_sw_port+" -j DROP")
229 main.ONOS2.handle.sendline(
230 "sudo iptables -A OUTPUT -p tcp -s "+
231 MN1_ip+" --dport "+default_sw_port+" -j DROP")
232 main.ONOS3.handle.sendline(
233 "sudo iptables -A OUTPUT -p tcp -s "+
234 MN1_ip+" --dport "+default_sw_port+" -j DROP")
235 main.ONOS4.handle.sendline(
236 "sudo iptables -A OUTPUT -p tcp -s "+
237 MN1_ip+" --dport "+default_sw_port+" -j DROP")
238 main.ONOS5.handle.sendline(
239 "sudo iptables -A OUTPUT -p tcp -s "+
240 MN1_ip+" --dport "+default_sw_port+" -j DROP")
241 main.ONOS6.handle.sendline(
242 "sudo iptables -A OUTPUT -p tcp -s "+
243 MN1_ip+" --dport "+default_sw_port+" -j DROP")
244 main.ONOS7.handle.sendline(
245 "sudo iptables -A OUTPUT -p tcp -s "+
246 MN1_ip+" --dport "+default_sw_port+" -j DROP")
andrewonlab0d4478f2014-11-11 20:31:20 -0500247
andrewonlab51b180b2014-11-12 18:19:28 -0500248 main.log.info("Please wait for switch connection to timeout")
249 time.sleep(60)
andrewonlaba036b402014-11-17 13:47:46 -0500250 if cluster_count >= 3:
251 time.sleep(60)
252 if cluster_count >= 5:
253 time.sleep(30)
254 if cluster_count >= 6:
255 time.sleep(30)
256
257 if cluster_count >= 3:
258 main.ONOS1.tshark_grep("SYN, ACK",
259 "/tmp/syn_ack_onos1_iter"+str(i)+".txt")
260 main.ONOS2.tshark_grep("SYN, ACK",
261 "/tmp/syn_ack_onos2_iter"+str(i)+".txt")
262 main.ONOS3.tshark_grep("SYN, ACK",
263 "/tmp/syn_ack_onos3_iter"+str(i)+".txt")
264 if cluster_count >= 4:
265 main.ONOS4.tshark_grep("SYN, ACK",
266 "/tmp/syn_ack_onos4_iter"+str(i)+".txt")
267 if cluster_count >= 5:
268 main.ONOS5.tshark_grep("SYN, ACK",
269 "/tmp/syn_ack_onos5_iter"+str(i)+".txt")
270 if cluster_count >= 6:
271 main.ONOS6.tshark_grep("SYN, ACK",
272 "/tmp/syn_ack_onos6_iter"+str(i)+".txt")
273 if cluster_count == 7:
274 main.ONOS7.tshark_grep("SYN, ACK",
275 "/tmp/syn_ack_onos7_iter"+str(i)+".txt")
andrewonlabadd2fd62014-11-11 18:37:35 -0500276
andrewonlab51b180b2014-11-12 18:19:28 -0500277 main.step("Flushing iptables and obtaining t0")
278 t0_system = time.time()*1000
279 main.ONOS1.handle.sendline("sudo iptables -F")
280 main.ONOS2.handle.sendline("sudo iptables -F")
281 main.ONOS3.handle.sendline("sudo iptables -F")
282 main.ONOS4.handle.sendline("sudo iptables -F")
283 main.ONOS5.handle.sendline("sudo iptables -F")
284 main.ONOS6.handle.sendline("sudo iptables -F")
285 main.ONOS7.handle.sendline("sudo iptables -F")
286
287 counter_loop = 0
288 counter_avail1 = 0
289 counter_avail2 = 0
290 counter_avail3 = 0
291 counter_avail4 = 0
292 counter_avail5 = 0
293 counter_avail6 = 0
294 counter_avail7 = 0
295 onos1_dev = False
296 onos2_dev = False
297 onos3_dev = False
298 onos4_dev = False
299 onos5_dev = False
300 onos6_dev = False
301 onos7_dev = False
302
303 #TODO: Think of a more elegant way to check all
304 # switches across all nodes
305 #Goodluck debugging this loop
306 while counter_loop < 60:
307 for node in range(1, cluster_count+1):
308 if node == 1 and not onos1_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500309 main.log.info("Checking node 1 for device "+
310 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500311 device_str_obj1 = main.ONOS1cli.devices()
andrewonlab51b180b2014-11-12 18:19:28 -0500312 device_json1 = json.loads(device_str_obj1)
313 for device1 in device_json1:
314 if device1['available'] == True:
315 counter_avail1 += 1
316 if counter_avail1 == int(num_sw):
317 onos1_dev = True
318 main.log.info("All devices have been"+
319 " discovered on ONOS1")
andrewonlabfd8325f2014-11-12 19:14:06 -0500320 else:
321 counter_avail1 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500322 if node == 2 and not onos2_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500323 main.log.info("Checking node 2 for device "+
324 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500325 device_str_obj2 = main.ONOS2cli.devices()
326 device_json2 = json.loads(device_str_obj2)
327 for device2 in device_json2:
328 if device2['available'] == True:
329 counter_avail2 += 1
330 if counter_avail2 == int(num_sw):
331 onos2_dev = True
332 main.log.info("All devices have been"+
333 " discovered on ONOS2")
andrewonlabfd8325f2014-11-12 19:14:06 -0500334 else:
335 counter_avail2 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500336 if node == 3 and not onos3_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500337 main.log.info("Checking node 3 for device "+
338 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500339 device_str_obj3 = main.ONOS3cli.devices()
340 device_json3 = json.loads(device_str_obj3)
341 for device3 in device_json3:
342 if device3['available'] == True:
343 counter_avail3 += 1
344 if counter_avail3 == int(num_sw):
345 onos3_dev = True
346 main.log.info("All devices have been"+
347 " discovered on ONOS3")
andrewonlabfd8325f2014-11-12 19:14:06 -0500348 else:
349 counter_avail3 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500350 if node == 4 and not onos4_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500351 main.log.info("Checking node 4 for device "+
352 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500353 device_str_obj4 = main.ONOS4cli.devices()
354 device_json4 = json.loads(device_str_obj4)
355 for device4 in device_json4:
356 if device4['available'] == True:
357 counter_avail4 += 1
358 if counter_avail4 == int(num_sw):
359 onos4_dev = True
360 main.log.info("All devices have been"+
361 " discovered on ONOS4")
andrewonlabfd8325f2014-11-12 19:14:06 -0500362 else:
363 counter_avail4 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500364 if node == 5 and not onos5_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500365 main.log.info("Checking node 5 for device "+
366 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500367 device_str_obj5 = main.ONOS5cli.devices()
368 device_json5 = json.loads(device_str_obj5)
369 for device5 in device_json5:
370 if device5['available'] == True:
371 counter_avail5 += 1
372 if counter_avail5 == int(num_sw):
373 onos5_dev = True
374 main.log.info("All devices have been"+
375 " discovered on ONOS5")
andrewonlabfd8325f2014-11-12 19:14:06 -0500376 else:
377 counter_avail5 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500378 if node == 6 and not onos6_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500379 main.log.info("Checking node 6 for device "+
380 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500381 device_str_obj6 = main.ONOS6cli.devices()
382 device_json6 = json.loads(device_str_obj6)
383 for device6 in device_json6:
384 if device6['available'] == True:
385 counter_avail6 += 1
386 if counter_avail6 == int(num_sw):
387 onos6_dev = True
388 main.log.info("All devices have been"+
389 " discovered on ONOS6")
andrewonlabfd8325f2014-11-12 19:14:06 -0500390 else:
391 counter_avail6 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500392 if node == 7 and not onos7_dev:
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500393 main.log.info("Checking node 7 for device "+
394 "discovery")
andrewonlab51b180b2014-11-12 18:19:28 -0500395 device_str_obj7 = main.ONOS7cli.devices()
396 device_json7 = json.loads(device_str_obj7)
397 for device7 in device_json7:
398 if device7['available'] == True:
399 counter_avail7 += 1
400 if counter_avail7 == int(num_sw):
401 onos7_dev = True
402 main.log.info("All devices have been"+
403 " discovered on ONOS7")
andrewonlabfd8325f2014-11-12 19:14:06 -0500404 else:
405 counter_avail7 = 0
andrewonlab51b180b2014-11-12 18:19:28 -0500406 #END node loop
407
408 #TODO: clean up this mess of an if statements if possible
409 #Treat each if as a separate test case with the given
410 # cluster count. Hence when the cluster count changes
411 # the desired calculations will be made
412 if cluster_count == 1:
413 if onos1_dev:
414 main.log.info("All devices have been discovered"+
415 " on all ONOS instances")
416 json_str_metrics_1 =\
417 main.ONOS1cli.topology_events_metrics()
418 json_obj_1 = json.loads(json_str_metrics_1)
419 graph_timestamp_1 =\
420 json_obj_1[graphTimestamp]['value']
421
422 graph_lat_1 = \
423 int(graph_timestamp_1) - int(t0_system)
424
425 if graph_lat_1 > sw_disc_threshold_min\
426 and graph_lat_1 < sw_disc_threshold_max:
427 sw_discovery_lat_list.append(
428 graph_lat_1)
andrewonlabfd8325f2014-11-12 19:14:06 -0500429 main.log.info("Sw discovery latency of "+
430 str(cluster_count)+" node(s): "+
431 str(graph_lat_1)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500432 else:
433 main.log.info("Switch discovery latency "+
434 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500435 main.log.info(graph_lat_1)
andrewonlab51b180b2014-11-12 18:19:28 -0500436 #Break while loop
437 break
438 if cluster_count == 2:
439 if onos1_dev and onos2_dev:
440 main.log.info("All devices have been discovered"+
andrewonlaba036b402014-11-17 13:47:46 -0500441 " on all "+str(cluster_count)+
442 " ONOS instances")
andrewonlab51b180b2014-11-12 18:19:28 -0500443 json_str_metrics_1 =\
444 main.ONOS1cli.topology_events_metrics()
445 json_str_metrics_2 =\
446 main.ONOS2cli.topology_events_metrics()
447 json_obj_1 = json.loads(json_str_metrics_1)
448 json_obj_2 = json.loads(json_str_metrics_2)
449 graph_timestamp_1 =\
450 json_obj_1[graphTimestamp]['value']
451 graph_timestamp_2 =\
452 json_obj_2[graphTimestamp]['value']
453
454 graph_lat_1 = \
455 int(graph_timestamp_1) - int(t0_system)
456 graph_lat_2 = \
457 int(graph_timestamp_2) - int(t0_system)
458
459 avg_graph_lat = \
460 (int(graph_lat_1) +\
461 int(graph_lat_2)) / 2
462
463 if avg_graph_lat > sw_disc_threshold_min\
464 and avg_graph_lat < sw_disc_threshold_max:
465 sw_discovery_lat_list.append(
466 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500467 main.log.info("Sw discovery latency of "+
468 str(cluster_count)+" node(s): "+
469 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500470 else:
471 main.log.info("Switch discovery latency "+
472 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500473 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500474 break
475 if cluster_count == 3:
476 if onos1_dev and onos2_dev and onos3_dev:
477 main.log.info("All devices have been discovered"+
andrewonlaba036b402014-11-17 13:47:46 -0500478 " on all "+str(cluster_count)+
479 " ONOS instances")
480
481 #TODO: Investigate this sleep
482 # added to 'pad' the results with
483 # plenty of time to 'catch up'
484 time.sleep(20)
485
andrewonlab51b180b2014-11-12 18:19:28 -0500486 json_str_metrics_1 =\
487 main.ONOS1cli.topology_events_metrics()
488 json_str_metrics_2 =\
489 main.ONOS2cli.topology_events_metrics()
490 json_str_metrics_3 =\
491 main.ONOS3cli.topology_events_metrics()
492 json_obj_1 = json.loads(json_str_metrics_1)
493 json_obj_2 = json.loads(json_str_metrics_2)
494 json_obj_3 = json.loads(json_str_metrics_3)
495 graph_timestamp_1 =\
496 json_obj_1[graphTimestamp]['value']
497 graph_timestamp_2 =\
498 json_obj_2[graphTimestamp]['value']
499 graph_timestamp_3 =\
500 json_obj_3[graphTimestamp]['value']
501
502 graph_lat_1 = \
503 int(graph_timestamp_1) - int(t0_system)
504 graph_lat_2 = \
505 int(graph_timestamp_2) - int(t0_system)
506 graph_lat_3 = \
507 int(graph_timestamp_3) - int(t0_system)
508
509 avg_graph_lat = \
510 (int(graph_lat_1) +\
511 int(graph_lat_2) +\
512 int(graph_lat_3)) / 3
513
514 if avg_graph_lat > sw_disc_threshold_min\
515 and avg_graph_lat < sw_disc_threshold_max:
516 sw_discovery_lat_list.append(
517 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500518 main.log.info("Sw discovery latency of "+
519 str(cluster_count)+" node(s): "+
520 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500521 else:
522 main.log.info("Switch discovery latency "+
523 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500524 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500525
526 break
527 if cluster_count == 4:
528 if onos1_dev and onos2_dev and onos3_dev and\
529 onos4_dev:
530 main.log.info("All devices have been discovered"+
531 " on all ONOS instances")
532 json_str_metrics_1 =\
533 main.ONOS1cli.topology_events_metrics()
534 json_str_metrics_2 =\
535 main.ONOS2cli.topology_events_metrics()
536 json_str_metrics_3 =\
537 main.ONOS3cli.topology_events_metrics()
538 json_str_metrics_4 =\
539 main.ONOS4cli.topology_events_metrics()
540 json_obj_1 = json.loads(json_str_metrics_1)
541 json_obj_2 = json.loads(json_str_metrics_2)
542 json_obj_3 = json.loads(json_str_metrics_3)
543 json_obj_4 = json.loads(json_str_metrics_4)
544 graph_timestamp_1 =\
545 json_obj_1[graphTimestamp]['value']
546 graph_timestamp_2 =\
547 json_obj_2[graphTimestamp]['value']
548 graph_timestamp_3 =\
549 json_obj_3[graphTimestamp]['value']
550 graph_timestamp_4 =\
551 json_obj_4[graphTimestamp]['value']
552
553 graph_lat_1 = \
554 int(graph_timestamp_1) - int(t0_system)
555 graph_lat_2 = \
556 int(graph_timestamp_2) - int(t0_system)
557 graph_lat_3 = \
558 int(graph_timestamp_3) - int(t0_system)
559 graph_lat_4 = \
560 int(graph_timestamp_4) - int(t0_system)
561
562 avg_graph_lat = \
563 (int(graph_lat_1) +\
564 int(graph_lat_2) +\
565 int(graph_lat_3) +\
566 int(graph_lat_4)) / 4
567
568 if avg_graph_lat > sw_disc_threshold_min\
569 and avg_graph_lat < sw_disc_threshold_max:
570 sw_discovery_lat_list.append(
571 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500572 main.log.info("Sw discovery latency of "+
573 str(cluster_count)+" node(s): "+
574 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500575 else:
576 main.log.info("Switch discovery latency "+
577 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500578 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500579
580 break
581 if cluster_count == 5:
582 if onos1_dev and onos2_dev and onos3_dev and\
583 onos4_dev and onos5_dev:
584 main.log.info("All devices have been discovered"+
585 " on all ONOS instances")
andrewonlaba036b402014-11-17 13:47:46 -0500586
587 #TODO: Investigate this sleep
588 # added to 'pad' the results with
589 # plenty of time to 'catch up'
590 time.sleep(20)
591
andrewonlab51b180b2014-11-12 18:19:28 -0500592 json_str_metrics_1 =\
593 main.ONOS1cli.topology_events_metrics()
594 json_str_metrics_2 =\
595 main.ONOS2cli.topology_events_metrics()
596 json_str_metrics_3 =\
597 main.ONOS3cli.topology_events_metrics()
598 json_str_metrics_4 =\
599 main.ONOS4cli.topology_events_metrics()
600 json_str_metrics_5 =\
601 main.ONOS5cli.topology_events_metrics()
602 json_obj_1 = json.loads(json_str_metrics_1)
603 json_obj_2 = json.loads(json_str_metrics_2)
604 json_obj_3 = json.loads(json_str_metrics_3)
605 json_obj_4 = json.loads(json_str_metrics_4)
606 json_obj_5 = json.loads(json_str_metrics_5)
607 graph_timestamp_1 =\
608 json_obj_1[graphTimestamp]['value']
609 graph_timestamp_2 =\
610 json_obj_2[graphTimestamp]['value']
611 graph_timestamp_3 =\
612 json_obj_3[graphTimestamp]['value']
613 graph_timestamp_4 =\
614 json_obj_4[graphTimestamp]['value']
615 graph_timestamp_5 =\
616 json_obj_5[graphTimestamp]['value']
617
618 graph_lat_1 = \
619 int(graph_timestamp_1) - int(t0_system)
620 graph_lat_2 = \
621 int(graph_timestamp_2) - int(t0_system)
622 graph_lat_3 = \
623 int(graph_timestamp_3) - int(t0_system)
624 graph_lat_4 = \
625 int(graph_timestamp_4) - int(t0_system)
626 graph_lat_5 = \
627 int(graph_timestamp_5) - int(t0_system)
628
629 avg_graph_lat = \
630 (int(graph_lat_1) +\
631 int(graph_lat_2) +\
632 int(graph_lat_3) +\
633 int(graph_lat_4) +\
634 int(graph_lat_5)) / 5
635
636 if avg_graph_lat > sw_disc_threshold_min\
637 and avg_graph_lat < sw_disc_threshold_max:
638 sw_discovery_lat_list.append(
639 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500640 main.log.info("Sw discovery latency of "+
641 str(cluster_count)+" node(s): "+
642 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500643 else:
644 main.log.info("Switch discovery latency "+
645 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500646 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500647
648 break
649 if cluster_count == 6:
650 if onos1_dev and onos2_dev and onos3_dev and\
651 onos4_dev and onos5_dev and onos6_dev:
652 main.log.info("All devices have been discovered"+
653 " on all ONOS instances")
654 json_str_metrics_1 =\
655 main.ONOS1cli.topology_events_metrics()
656 json_str_metrics_2 =\
657 main.ONOS2cli.topology_events_metrics()
658 json_str_metrics_3 =\
659 main.ONOS3cli.topology_events_metrics()
660 json_str_metrics_4 =\
661 main.ONOS4cli.topology_events_metrics()
662 json_str_metrics_5 =\
663 main.ONOS5cli.topology_events_metrics()
664 json_str_metrics_6 =\
665 main.ONOS6cli.topology_events_metrics()
666 json_obj_1 = json.loads(json_str_metrics_1)
667 json_obj_2 = json.loads(json_str_metrics_2)
668 json_obj_3 = json.loads(json_str_metrics_3)
669 json_obj_4 = json.loads(json_str_metrics_4)
670 json_obj_5 = json.loads(json_str_metrics_5)
671 json_obj_6 = json.loads(json_str_metrics_6)
672 graph_timestamp_1 =\
673 json_obj_1[graphTimestamp]['value']
674 graph_timestamp_2 =\
675 json_obj_2[graphTimestamp]['value']
676 graph_timestamp_3 =\
677 json_obj_3[graphTimestamp]['value']
678 graph_timestamp_4 =\
679 json_obj_4[graphTimestamp]['value']
680 graph_timestamp_5 =\
681 json_obj_5[graphTimestamp]['value']
682 graph_timestamp_6 =\
683 json_obj_6[graphTimestamp]['value']
684
685 graph_lat_1 = \
686 int(graph_timestamp_1) - int(t0_system)
687 graph_lat_2 = \
688 int(graph_timestamp_2) - int(t0_system)
689 graph_lat_3 = \
690 int(graph_timestamp_3) - int(t0_system)
691 graph_lat_4 = \
692 int(graph_timestamp_4) - int(t0_system)
693 graph_lat_5 = \
694 int(graph_timestamp_5) - int(t0_system)
695 graph_lat_6 = \
696 int(graph_timestamp_6) - int(t0_system)
697
698 avg_graph_lat = \
699 (int(graph_lat_1) +\
700 int(graph_lat_2) +\
701 int(graph_lat_3) +\
702 int(graph_lat_4) +\
703 int(graph_lat_5) +\
704 int(graph_lat_6)) / 6
705
706 if avg_graph_lat > sw_disc_threshold_min\
707 and avg_graph_lat < sw_disc_threshold_max:
708 sw_discovery_lat_list.append(
709 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500710 main.log.info("Sw discovery latency of "+
711 str(cluster_count)+" node(s): "+
712 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500713 else:
714 main.log.info("Switch discovery latency "+
715 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500716 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500717
718 break
719 if cluster_count == 7:
720 if onos1_dev and onos2_dev and onos3_dev and\
721 onos4_dev and onos5_dev and onos6_dev and\
722 onos7_dev:
723 main.log.info("All devices have been discovered"+
724 " on all ONOS instances")
andrewonlaba036b402014-11-17 13:47:46 -0500725
726 #TODO: Investigate this sleep
727 # added to 'pad' the results with
728 # plenty of time to 'catch up'
729 time.sleep(20)
730
andrewonlab51b180b2014-11-12 18:19:28 -0500731 json_str_metrics_1 =\
732 main.ONOS1cli.topology_events_metrics()
733 json_str_metrics_2 =\
734 main.ONOS2cli.topology_events_metrics()
735 json_str_metrics_3 =\
736 main.ONOS3cli.topology_events_metrics()
737 json_str_metrics_4 =\
738 main.ONOS4cli.topology_events_metrics()
739 json_str_metrics_5 =\
740 main.ONOS5cli.topology_events_metrics()
741 json_str_metrics_6 =\
742 main.ONOS6cli.topology_events_metrics()
743 json_str_metrics_7 =\
744 main.ONOS7cli.topology_events_metrics()
745 json_obj_1 = json.loads(json_str_metrics_1)
746 json_obj_2 = json.loads(json_str_metrics_2)
747 json_obj_3 = json.loads(json_str_metrics_3)
748 json_obj_4 = json.loads(json_str_metrics_4)
749 json_obj_5 = json.loads(json_str_metrics_5)
750 json_obj_6 = json.loads(json_str_metrics_6)
751 json_obj_7 = json.loads(json_str_metrics_7)
752 graph_timestamp_1 =\
753 json_obj_1[graphTimestamp]['value']
754 graph_timestamp_2 =\
755 json_obj_2[graphTimestamp]['value']
756 graph_timestamp_3 =\
757 json_obj_3[graphTimestamp]['value']
758 graph_timestamp_4 =\
759 json_obj_4[graphTimestamp]['value']
760 graph_timestamp_5 =\
761 json_obj_5[graphTimestamp]['value']
762 graph_timestamp_6 =\
763 json_obj_6[graphTimestamp]['value']
764 graph_timestamp_7 =\
765 json_obj_7[graphTimestamp]['value']
766
767 graph_lat_1 = \
768 int(graph_timestamp_1) - int(t0_system)
769 graph_lat_2 = \
770 int(graph_timestamp_2) - int(t0_system)
771 graph_lat_3 = \
772 int(graph_timestamp_3) - int(t0_system)
773 graph_lat_4 = \
774 int(graph_timestamp_4) - int(t0_system)
775 graph_lat_5 = \
776 int(graph_timestamp_5) - int(t0_system)
777 graph_lat_6 = \
778 int(graph_timestamp_6) - int(t0_system)
779 graph_lat_7 = \
780 int(graph_timestamp_7) - int(t0_system)
781
782 avg_graph_lat = \
783 (int(graph_lat_1) +\
784 int(graph_lat_2) +\
785 int(graph_lat_3) +\
786 int(graph_lat_4) +\
787 int(graph_lat_5) +\
788 int(graph_lat_6) +\
789 int(graph_lat_7)) / 7
790
791 if avg_graph_lat > sw_disc_threshold_min\
792 and avg_graph_lat < sw_disc_threshold_max:
793 sw_discovery_lat_list.append(
794 avg_graph_lat)
andrewonlabfd8325f2014-11-12 19:14:06 -0500795 main.log.info("Sw discovery latency of "+
796 str(cluster_count)+" node(s): "+
797 str(avg_graph_lat)+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500798 else:
799 main.log.info("Switch discovery latency "+
800 "exceeded the threshold.")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500801 main.log.info(avg_graph_lat)
andrewonlab51b180b2014-11-12 18:19:28 -0500802
803 break
804
805 counter_loop += 1
806 time.sleep(3)
807 #END WHILE LOOP
andrewonlaba036b402014-11-17 13:47:46 -0500808
809 main.ONOS1.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500810 syn_ack_timestamp_list = []
andrewonlaba036b402014-11-17 13:47:46 -0500811
812 if cluster_count >= 3:
813 main.ONOS2.tshark_stop()
814 main.ONOS3.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500815 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500816 os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500817 "/tmp/syn_ack_onos1_iter"+str(i)+".txt /tmp/")
andrewonlaba036b402014-11-17 13:47:46 -0500818 os.system("scp "+ONOS_user+"@"+ONOS2_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500819 "/tmp/syn_ack_onos2_iter"+str(i)+".txt /tmp/")
andrewonlaba036b402014-11-17 13:47:46 -0500820 os.system("scp "+ONOS_user+"@"+ONOS3_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500821 "/tmp/syn_ack_onos3_iter"+str(i)+".txt /tmp/")
822 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500823 #Read each of the files and append all
824 #SYN / ACK timestamps to the list
andrewonlaba1272172014-11-17 17:30:35 -0500825 with open("/tmp/syn_ack_onos1_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500826 f_onos1:
827 for line in f_onos1:
828 line = line.split(" ")
829 syn_ack_timestamp_list.append(line[1])
andrewonlaba1272172014-11-17 17:30:35 -0500830 with open("/tmp/syn_ack_onos2_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500831 f_onos2:
832 for line in f_onos2:
833 line = line.split(" ")
834 syn_ack_timestamp_list.append(line[1])
andrewonlaba1272172014-11-17 17:30:35 -0500835 with open("/tmp/syn_ack_onos3_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500836 f_onos3:
837 for line in f_onos3:
838 line = line.split(" ")
839 syn_ack_timestamp_list.append(line[1])
840 if cluster_count >= 4:
841 main.ONOS4.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500842 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500843 os.system("scp "+ONOS_user+"@"+ONOS4_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500844 "/tmp/syn_ack_onos4_iter"+str(i)+".txt /tmp/")
845 time.sleep(5)
846 with open("/tmp/syn_ack_onos4_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500847 f_onos4:
848 for line in f_onos4:
849 line = line.split(" ")
850 syn_ack_timestamp_list.append(line[1])
851 if cluster_count >= 5:
852 main.ONOS5.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500853 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500854 os.system("scp "+ONOS_user+"@"+ONOS5_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500855 "/tmp/syn_ack_onos5_iter"+str(i)+".txt /tmp/")
856 time.sleep(5)
857 with open("/tmp/syn_ack_onos5_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500858 f_onos5:
859 for line in f_onos5:
860 line = line.split(" ")
861 syn_ack_timestamp_list.append(line[1])
862 if cluster_count >= 6:
863 main.ONOS6.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500864 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500865 os.system("scp "+ONOS_user+"@"+ONOS6_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500866 "/tmp/syn_ack_onos6_iter"+str(i)+".txt /tmp/")
867 time.sleep(5)
868 with open("/tmp/syn_ack_onos6_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500869 f_onos6:
870 for line in f_onos6:
871 line = line.split(" ")
872 syn_ack_timestamp_list.append(line[1])
873 if cluster_count == 7:
874 main.ONOS7.tshark_stop()
andrewonlaba1272172014-11-17 17:30:35 -0500875 time.sleep(5)
andrewonlaba036b402014-11-17 13:47:46 -0500876 os.system("scp "+ONOS_user+"@"+ONOS7_ip+":"+
andrewonlaba1272172014-11-17 17:30:35 -0500877 "/tmp/syn_ack_onos7_iter"+str(i)+".txt /tmp/")
878 time.sleep(5)
879 with open("/tmp/syn_ack_onos7_iter"+str(i)+".txt") as\
andrewonlaba036b402014-11-17 13:47:46 -0500880 f_onos7:
881 for line in f_onos7:
882 line = line.split(" ")
883 syn_ack_timestamp_list.append(line[1])
884
885 #Sort the list by timestamp
886 syn_ack_timestamp_list = sorted(syn_ack_timestamp_list)
andrewonlaba1272172014-11-17 17:30:35 -0500887
888 syn_ack_delta =\
889 int(float(syn_ack_timestamp_list[-1])*1000) -\
890 int(float(syn_ack_timestamp_list[0])*1000)
andrewonlaba036b402014-11-17 13:47:46 -0500891
andrewonlaba1272172014-11-17 17:30:35 -0500892 main.log.info("Switch connection attempt delta iteration "+
893 str(i)+": "+str(syn_ack_delta))
894 syn_ack_delta_list.append(syn_ack_delta)
andrewonlab51b180b2014-11-12 18:19:28 -0500895 #END ITERATION LOOP
896 #REPORT HERE
897
898 if len(sw_discovery_lat_list) > 0:
899 sw_lat_avg = sum(sw_discovery_lat_list) / \
900 len(sw_discovery_lat_list)
andrewonlabfd8325f2014-11-12 19:14:06 -0500901 sw_lat_dev = numpy.std(sw_discovery_lat_list)
andrewonlab51b180b2014-11-12 18:19:28 -0500902 else:
903 assertion = main.FALSE
andrewonlaba1272172014-11-17 17:30:35 -0500904
905 main.log.report("Switch connection attempt time avg "+
andrewonlabd784d4f2014-11-17 17:47:32 -0500906 "(last sw SYN/ACK time - first sw SYN/ACK time) "+
andrewonlaba1272172014-11-17 17:30:35 -0500907 str(sum(syn_ack_delta_list)/len(syn_ack_delta_list)) +
908 " ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500909 main.log.report("Switch discovery lat for "+\
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500910 str(cluster_count)+" instance(s), 100 sw each: ")
andrewonlab51b180b2014-11-12 18:19:28 -0500911 main.log.report("Avg: "+str(sw_lat_avg)+" ms")
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500912 main.log.report("Std Deviation: "+
913 str(round(sw_lat_dev,1))+" ms")
andrewonlab51b180b2014-11-12 18:19:28 -0500914
915 utilities.assert_equals(expect=main.TRUE, actual=assertion,
916 onpass="Switch discovery convergence latency" +\
andrewonlabfd8325f2014-11-12 19:14:06 -0500917 " for "+str(cluster_count)+" nodes successful",
andrewonlab51b180b2014-11-12 18:19:28 -0500918 onfail="Switch discovery convergence latency" +\
919 " test failed")
920
andrewonlabadd2fd62014-11-11 18:37:35 -0500921 def CASE3(self, main):
922 '''
andrewonlab54cec4b2014-11-12 13:30:23 -0500923 Increase number of nodes and initiate CLI
andrewonlabadd2fd62014-11-11 18:37:35 -0500924 '''
925 import time
926 import subprocess
927 import os
928 import requests
929 import json
930
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500931 ONOS1_ip = main.params['CTRL']['ip1']
932 ONOS2_ip = main.params['CTRL']['ip2']
933 ONOS3_ip = main.params['CTRL']['ip3']
934 ONOS4_ip = main.params['CTRL']['ip4']
935 ONOS5_ip = main.params['CTRL']['ip5']
936 ONOS6_ip = main.params['CTRL']['ip6']
937 ONOS7_ip = main.params['CTRL']['ip7']
938
939 cell_name = main.params['ENV']['cellName']
940
andrewonlabadd2fd62014-11-11 18:37:35 -0500941 MN1_ip = main.params['MN']['ip1']
942 BENCH_ip = main.params['BENCH']['ip']
andrewonlab0cfc7ad2014-11-13 16:29:26 -0500943
andrewonlaba036b402014-11-17 13:47:46 -0500944 #NOTE:We start with cluster_count at 3. The first
andrewonlabadd2fd62014-11-11 18:37:35 -0500945 #case already initialized ONOS1. Increase the
andrewonlaba036b402014-11-17 13:47:46 -0500946 #cluster count and start from 3.
andrewonlabadd2fd62014-11-11 18:37:35 -0500947 #You can optionally change the increment to
andrewonlaba036b402014-11-17 13:47:46 -0500948 #test steps of node sizes, such as 3,5,7
andrewonlabadd2fd62014-11-11 18:37:35 -0500949
950 global cluster_count
andrewonlab54cec4b2014-11-12 13:30:23 -0500951 cluster_count += 2
andrewonlaba036b402014-11-17 13:47:46 -0500952
953 install_result = main.FALSE
andrewonlabadd2fd62014-11-11 18:37:35 -0500954 #Supports up to 7 node configuration
andrewonlab81763ee2014-11-13 17:31:34 -0500955 #TODO: Cleanup this ridiculous repetitive code
andrewonlaba036b402014-11-17 13:47:46 -0500956 if cluster_count == 4:
957 main.log.info("Installing ONOS on node 4")
958 install_result = \
959 main.ONOSbench.onos_install(node=ONOS4_ip)
andrewonlab81763ee2014-11-13 17:31:34 -0500960 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -0500961 main.ONOS4cli.start_onos_cli(ONOS4_ip)
andrewonlaba036b402014-11-17 13:47:46 -0500962 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
963
andrewonlab81763ee2014-11-13 17:31:34 -0500964 elif cluster_count == 5:
andrewonlaba036b402014-11-17 13:47:46 -0500965 main.log.info("Installing ONOS on node 5")
966 install_result1 = \
967 main.ONOSbench.onos_install(options="",node=ONOS4_ip)
968 install_result2 = \
969 main.ONOSbench.onos_install(node=ONOS5_ip)
andrewonlab81763ee2014-11-13 17:31:34 -0500970 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -0500971 main.ONOS4cli.start_onos_cli(ONOS4_ip)
972 main.ONOS5cli.start_onos_cli(ONOS5_ip)
andrewonlaba036b402014-11-17 13:47:46 -0500973 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
974 main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
975 install_result = install_result1 and install_result2
976
andrewonlab81763ee2014-11-13 17:31:34 -0500977 elif cluster_count == 6:
andrewonlaba036b402014-11-17 13:47:46 -0500978 main.log.info("Installing ONOS on node 6")
979 install_result1 = \
980 main.ONOSbench.onos_install(options="",node=ONOS4_ip)
981 install_result2 = \
982 main.ONOSbench.onos_install(options="",node=ONOS5_ip)
983 install_result3 = \
984 main.ONOSbench.onos_install(node=ONOS6_ip)
andrewonlab81763ee2014-11-13 17:31:34 -0500985 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -0500986 main.ONOS4cli.start_onos_cli(ONOS4_ip)
987 main.ONOS5cli.start_onos_cli(ONOS5_ip)
988 main.ONOS6cli.start_onos_cli(ONOS6_ip)
andrewonlaba036b402014-11-17 13:47:46 -0500989 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
990 main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
991 main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
992 install_result = install_result1 and install_result2 and\
993 install_result3
994
andrewonlab81763ee2014-11-13 17:31:34 -0500995 elif cluster_count == 7:
andrewonlaba036b402014-11-17 13:47:46 -0500996 main.log.info("Installing ONOS on node 7")
997 install_result1 = \
998 main.ONOSbench.onos_install(options="",node=ONOS4_ip)
999 install_result2 = \
1000 main.ONOSbench.onos_install(options="",node=ONOS5_ip)
1001 install_result3 = \
1002 main.ONOSbench.onos_install(options="",node=ONOS6_ip)
1003 install_result4 = \
1004 main.ONOSbench.onos_install(node=ONOS7_ip)
andrewonlab81763ee2014-11-13 17:31:34 -05001005 main.log.info("Starting CLI")
andrewonlab81763ee2014-11-13 17:31:34 -05001006 main.ONOS4cli.start_onos_cli(ONOS4_ip)
1007 main.ONOS5cli.start_onos_cli(ONOS5_ip)
1008 main.ONOS6cli.start_onos_cli(ONOS6_ip)
1009 main.ONOS7cli.start_onos_cli(ONOS7_ip)
andrewonlaba036b402014-11-17 13:47:46 -05001010 main.ONOS1cli.add_node(ONOS4_ip, ONOS4_ip)
1011 main.ONOS1cli.add_node(ONOS5_ip, ONOS5_ip)
1012 main.ONOS1cli.add_node(ONOS6_ip, ONOS6_ip)
1013 main.ONOS1cli.add_node(ONOS7_ip, ONOS7_ip)
andrewonlab81763ee2014-11-13 17:31:34 -05001014
andrewonlaba036b402014-11-17 13:47:46 -05001015 install_result = install_result1 and install_result2 and\
1016 install_result3 and install_result4
andrewonlab81763ee2014-11-13 17:31:34 -05001017
1018 time.sleep(5)
andrewonlabadd2fd62014-11-11 18:37:35 -05001019
andrewonlab0cfc7ad2014-11-13 16:29:26 -05001020 if install_result == main.TRUE:
1021 assertion = main.TRUE
1022 else:
1023 assertion = main.FALSE
1024
1025 utilities.assert_equals(expect=main.TRUE, actual=assertion,
1026 onpass="Scale out to "+str(cluster_count)+\
1027 " nodes successful",
1028 onfail="Scale out to "+str(cluster_count)+\
1029 " nodes failed")