blob: 874eb4179b3805b6351d5437d20224a1f04ae4e1 [file] [log] [blame]
andrewonlabadd2fd62014-11-11 18:37:35 -05001#TopoPerfNext
2#
3#Topology Performance test for ONOS-next
4#
5#andrew@onlab.us
6
7import time
8import sys
9import os
10import re
11
12class TopoConvNext:
13 def __init__(self):
14 self.default = ''
15
andrewonlabadd2fd62014-11-11 18:37:35 -050016 def CASE1(self, main):
17 '''
18 ONOS startup sequence
19 '''
20 import time
andrewonlab54cec4b2014-11-12 13:30:23 -050021
22 #******
23 #Global cluster count for scale-out purposes
24 global cluster_count
25 cluster_count = 1
26 #******
andrewonlabadd2fd62014-11-11 18:37:35 -050027
28 cell_name = main.params['ENV']['cellName']
29
30 git_pull = main.params['GIT']['autoPull']
31 checkout_branch = main.params['GIT']['checkout']
32
33 ONOS1_ip = main.params['CTRL']['ip1']
andrewonlab54cec4b2014-11-12 13:30:23 -050034 ONOS2_ip = main.params['CTRL']['ip2']
35 ONOS3_ip = main.params['CTRL']['ip3']
36 ONOS4_ip = main.params['CTRL']['ip4']
37 ONOS5_ip = main.params['CTRL']['ip5']
38 ONOS6_ip = main.params['CTRL']['ip6']
39 ONOS7_ip = main.params['CTRL']['ip7']
andrewonlabadd2fd62014-11-11 18:37:35 -050040 MN1_ip = main.params['MN']['ip1']
41 BENCH_ip = main.params['BENCH']['ip']
42
43 main.case("Setting up test environment")
44 main.log.report("Setting up test environment")
45
46 main.step("Creating cell file")
47 cell_file_result = main.ONOSbench.create_cell_file(
48 BENCH_ip, cell_name, MN1_ip, "onos-core",
andrewonlab54cec4b2014-11-12 13:30:23 -050049 ONOS1_ip, ONOS2_ip, ONOS3_ip, ONOS4_ip,
50 ONOS5_ip, ONOS6_ip, ONOS7_ip)
andrewonlabadd2fd62014-11-11 18:37:35 -050051
52 main.step("Applying cell file to environment")
53 cell_apply_result = main.ONOSbench.set_cell(cell_name)
54 verify_cell_result = main.ONOSbench.verify_cell()
55
56 main.step("Git checkout and pull "+checkout_branch)
57 if git_pull == 'on':
58 checkout_result = \
59 main.ONOSbench.git_checkout(checkout_branch)
60 pull_result = main.ONOSbench.git_pull()
61 else:
62 checkout_result = main.TRUE
63 pull_result = main.TRUE
64 main.log.info("Skipped git checkout and pull")
65
66 main.step("Using mvn clean & install")
67 #mvn_result = main.ONOSbench.clean_install()
68 mvn_result = main.TRUE
69
70 main.step("Set cell for ONOS cli env")
71 main.ONOS1cli.set_cell(cell_name)
andrewonlab54cec4b2014-11-12 13:30:23 -050072 main.ONOS2cli.set_cell(cell_name)
73 main.ONOS3cli.set_cell(cell_name)
74 main.ONOS4cli.set_cell(cell_name)
75 main.ONOS5cli.set_cell(cell_name)
76 main.ONOS6cli.set_cell(cell_name)
77 main.ONOS7cli.set_cell(cell_name)
78
andrewonlabadd2fd62014-11-11 18:37:35 -050079 main.step("Creating ONOS package")
80 package_result = main.ONOSbench.onos_package()
81
andrewonlab54cec4b2014-11-12 13:30:23 -050082 #Start test with single node only
andrewonlabadd2fd62014-11-11 18:37:35 -050083 main.step("Installing ONOS package")
84 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
85
86 time.sleep(10)
87
88 main.step("Start onos cli")
89 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
90
91 main.step("Enable metrics feature")
92 main.ONOS1cli.feature_install("onos-app-metrics")
93
94 utilities.assert_equals(expect=main.TRUE,
95 actual= cell_file_result and cell_apply_result and\
96 verify_cell_result and checkout_result and\
97 pull_result and mvn_result and\
andrewonlab54cec4b2014-11-12 13:30:23 -050098 install1_result,
andrewonlabadd2fd62014-11-11 18:37:35 -050099 onpass="Test Environment setup successful",
100 onfail="Failed to setup test environment")
101
102 def CASE2(self, main):
103 '''
104 100 Switch discovery latency
105
106 Important:
107 This test case can be potentially dangerous if
108 your machine has previously set iptables rules.
109 One of the steps of the test case will flush
110 all existing iptables rules.
111 Note:
112 You can specify the number of switches in the
113 params file to adjust the switch discovery size
114 (and specify the corresponding topology in Mininet1
115 .topo file)
116 '''
117 import time
118 import subprocess
119 import os
120 import requests
121 import json
122
123 ONOS_ip_list = []
andrewonlab54cec4b2014-11-12 13:30:23 -0500124 ONOS_ip_list.append(main.params['CTRL']['ip1'])
125 ONOS_ip_list.append(main.params['CTRL']['ip2'])
126 ONOS_ip_list.append(main.params['CTRL']['ip3'])
127 ONOS_ip_list.append(main.params['CTRL']['ip4'])
128 ONOS_ip_list.append(main.params['CTRL']['ip5'])
129 ONOS_ip_list.append(main.params['CTRL']['ip6'])
130 ONOS_ip_list.append(main.params['CTRL']['ip7'])
andrewonlabadd2fd62014-11-11 18:37:35 -0500131 MN1_ip = main.params['MN']['ip1']
132 ONOS_user = main.params['CTRL']['user']
133
134 default_sw_port = main.params['CTRL']['port1']
135
136 #Number of iterations of case
137 num_iter = main.params['TEST']['numIter']
138 num_sw = main.params['TEST']['numSwitch']
139
140 #Timestamp 'keys' for json metrics output.
141 #These are subject to change, hence moved into params
142 deviceTimestamp = main.params['JSON']['deviceTimestamp']
143 graphTimestamp = main.params['JSON']['graphTimestamp']
144
andrewonlabadd2fd62014-11-11 18:37:35 -0500145 #Threshold for this test case
146 sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
147 sw_disc_threshold_obj = sw_disc_threshold_str.split(",")
148 sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
149 sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
150
andrewonlab54cec4b2014-11-12 13:30:23 -0500151 tshark_ofp_output = \
152 "/tmp/tshark_ofp_"+num_sw+"sw_"+cluster_count+".txt"
153 tshark_tcp_output = \
154 "/tmp/tshark_tcp_"+num_sw+"sw_"+cluster_count+".txt"
andrewonlabadd2fd62014-11-11 18:37:35 -0500155
156 tshark_ofp_result_list = []
157 tshark_tcp_result_list = []
158
159 sw_discovery_lat_list = []
160
161 main.case(num_sw+" Switch discovery latency")
andrewonlab0d4478f2014-11-11 20:31:20 -0500162
163 main.log.report("Currently active ONOS node(s): ")
164 report_str = "Node "
andrewonlab54cec4b2014-11-12 13:30:23 -0500165 for node in range(0, cluster_count):
andrewonlab0d4478f2014-11-11 20:31:20 -0500166 report_str += (str(node+1) + " ")
167 main.log.report(report_str)
andrewonlabadd2fd62014-11-11 18:37:35 -0500168
andrewonlab0d4478f2014-11-11 20:31:20 -0500169 main.step("Assigning "+num_sw+" switches to each ONOS")
170 index = 1
andrewonlab54cec4b2014-11-12 13:30:23 -0500171 for node in range(0, cluster_count):
andrewonlab0d4478f2014-11-11 20:31:20 -0500172 for i in range(index, int(num_sw)+index):
173 main.Mininet1.assign_sw_controller(
174 sw=str(i),
175 ip1=ONOS_ip_list[node],
176 port1=default_sw_port)
andrewonlab54cec4b2014-11-12 13:30:23 -0500177 index = i+1
178
179 main.log.info("Please check ptpd configuration to ensure "+\
180 "all nodes' system times are in sync")
181 main.log.info("Checking system time across nodes")
182 os.system("echo TestON system time: $(($(date +%s%N)/1000000))")
183 main.ONOS1.handle.sendline("echo $(($(date +%s%N)/1000000))")
184 main.ONOS2.handle.sendline("echo $(($(date +%s%N)/1000000))")
185 main.ONOS3.handle.sendline("echo $(($(date +%s%N)/1000000))")
186 main.ONOS4.handle.sendline("echo $(($(date +%s%N)/1000000))")
187 main.ONOS5.handle.sendline("echo $(($(date +%s%N)/1000000))")
188 main.ONOS6.handle.sendline("echo $(($(date +%s%N)/1000000))")
189 main.ONOS7.handle.sendline("echo $(($(date +%s%N)/1000000))")
190
191 main.ONOS1.handle.expect("0))")
192 main.log.info("ONOS1 time: "+main.ONOS1.handle.after)
193 main.ONOS2.handle.expect("0))")
194 main.log.info("ONOS2 time: "+main.ONOS2.handle.after)
195 main.ONOS3.handle.expect("0))")
196 main.log.info("ONOS3 time: "+main.ONOS3.handle.after)
197 main.ONOS4.handle.expect("0))")
198 main.log.info("ONOS4 time: "+main.ONOS4.handle.after)
199 main.ONOS5.handle.expect("0))")
200 main.log.info("ONOS5 time: "+main.ONOS5.handle.after)
201 main.ONOS6.handle.expect("0))")
202 main.log.info("ONOS6 time: "+main.ONOS6.handle.after)
203 main.ONOS7.handle.expect("0))")
204 main.log.info("ONOS7 time: "+main.ONOS7.handle.after)
205
206 time.sleep(10)
207
andrewonlab0d4478f2014-11-11 20:31:20 -0500208
andrewonlabadd2fd62014-11-11 18:37:35 -0500209 #TODO: Implement modular switch discovery measurements
210 #for scale-out scenario
211
212
213 def CASE3(self, main):
214 '''
andrewonlab54cec4b2014-11-12 13:30:23 -0500215 Increase number of nodes and initiate CLI
andrewonlabadd2fd62014-11-11 18:37:35 -0500216 '''
217 import time
218 import subprocess
219 import os
220 import requests
221 import json
222
223 ONOS_ip_list = []
andrewonlab54cec4b2014-11-12 13:30:23 -0500224 ONOS_ip_list.append(main.params['CTRL']['ip1'])
225 ONOS_ip_list.append(main.params['CTRL']['ip2'])
226 ONOS_ip_list.append(main.params['CTRL']['ip3'])
227 ONOS_ip_list.append(main.params['CTRL']['ip4'])
228 ONOS_ip_list.append(main.params['CTRL']['ip5'])
229 ONOS_ip_list.append(main.params['CTRL']['ip6'])
230 ONOS_ip_list.append(main.params['CTRL']['ip7'])
andrewonlabadd2fd62014-11-11 18:37:35 -0500231
232 MN1_ip = main.params['MN']['ip1']
233 BENCH_ip = main.params['BENCH']['ip']
234
235 #NOTE:We start with cluster_count at 1. The first
236 #case already initialized ONOS1. Increase the
237 #cluster count and start from 2.
238 #You can optionally change the increment to
239 #test steps of node sizes, such as 1,3,5,7
240
241 global cluster_count
andrewonlab54cec4b2014-11-12 13:30:23 -0500242 cluster_count += 2
andrewonlabadd2fd62014-11-11 18:37:35 -0500243
244 #Supports up to 7 node configuration
andrewonlab54cec4b2014-11-12 13:30:23 -0500245 for node in range(0, cluster_count):
andrewonlabadd2fd62014-11-11 18:37:35 -0500246 main.log.info("Installing ONOS instance: "+
247 ONOS_ip_list[node])
248 main.ONOSbench.onos_install(ONOS_ip_list[node])
249 time.sleep(5)
250 if node == 0:
251 main.log.info("Starting CLI for instance "+
252 ONOS_ip_list[node])
253 main.ONOS1cli.start_onos_cli(ONOS_ip_list[node])
254 elif node == 1:
255 main.log.info("Starting CLI for instance "+
256 ONOS_ip_list[node])
257 main.ONOS2cli.start_onos_cli(ONOS_ip_list[node])
258 elif node == 2:
259 main.log.info("Starting CLI for instance "+
260 ONOS_ip_list[node])
261 main.ONOS3cli.start_onos_cli(ONOS_ip_list[node])
262 elif node == 3:
263 main.log.info("Starting CLI for instance "+
264 ONOS_ip_list[node])
265 main.ONOS3cli.start_onos_cli(ONOS_ip_list[node])
266 elif node == 4:
267 main.log.info("Starting CLI for instance "+
268 ONOS_ip_list[node])
269 main.ONOS4cli.start_onos_cli(ONOS_ip_list[node])
270 elif node == 5:
271 main.log.info("Starting CLI for instance "+
272 ONOS_ip_list[node])
273 main.ONOS5cli.start_onos_cli(ONOS_ip_list[node])
274 elif node == 6:
275 main.log.info("Starting CLI for instance "+
276 ONOS_ip_list[node])
277 main.ONOS6cli.start_onos_cli(ONOS_ip_list[node])
278 elif node == 7:
279 main.log.info("Starting CLI for instance "+
280 ONOS_ip_list[node])
281 main.ONOS7cli.start_onos_cli(ONOS_ip_list[node])
282 time.sleep(5)
283
284
285
286
287