blob: bc11ba8e973e1d1d96cfc82732560ea831cbddb4 [file] [log] [blame]
andrewonlab92ea3672014-11-04 20:22:14 -05001#Intent Performance Test for ONOS-next
2#
3#andrew@onlab.us
andrewonlab8790abb2014-11-06 13:51:54 -05004#
5#November 5, 2014
andrewonlab92ea3672014-11-04 20:22:14 -05006
7class IntentPerfNext:
8 def __init__(self):
9 self.default = ""
10
11 def CASE1(self, main):
12 '''
13 ONOS startup sequence
14 '''
15
16 import time
17
18 cell_name = main.params['ENV']['cellName']
19
20 git_pull = main.params['GIT']['autoPull']
21 checkout_branch = main.params['GIT']['checkout']
22
23 ONOS1_ip = main.params['CTRL']['ip1']
24 ONOS2_ip = main.params['CTRL']['ip2']
25 ONOS3_ip = main.params['CTRL']['ip3']
26
27 MN1_ip = main.params['MN']['ip1']
28 BENCH_ip = main.params['BENCH']['ip']
29
30 main.case("Setting up test environment")
31
32 main.step("Creating cell file")
33 cell_file_result = main.ONOSbench.create_cell_file(
andrewonlab4cf9dd22014-11-18 21:28:38 -050034 BENCH_ip, cell_name, MN1_ip,
35 "onos-core,onos-app-metrics,onos-gui",
andrewonlab92ea3672014-11-04 20:22:14 -050036 ONOS1_ip, ONOS2_ip, ONOS3_ip)
37
38 main.step("Applying cell file to environment")
39 cell_apply_result = main.ONOSbench.set_cell(cell_name)
40 verify_cell_result = main.ONOSbench.verify_cell()
41
42 main.step("Git checkout and pull "+checkout_branch)
43 if git_pull == 'on':
44 checkout_result = \
45 main.ONOSbench.git_checkout(checkout_branch)
46 pull_result = main.ONOSbench.git_pull()
47
48 #If you used git pull, auto compile
49 main.step("Using onos-build to compile ONOS")
50 build_result = main.ONOSbench.onos_build()
51 else:
52 checkout_result = main.TRUE
53 pull_result = main.TRUE
54 build_result = main.TRUE
55 main.log.info("Git pull skipped by configuration")
56
andrewonlab4cf9dd22014-11-18 21:28:38 -050057 main.log.report("Commit information - ")
58 main.ONOSbench.get_version(report=True)
59
andrewonlab92ea3672014-11-04 20:22:14 -050060 main.step("Creating ONOS package")
61 package_result = main.ONOSbench.onos_package()
62
63 main.step("Installing ONOS package")
64 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
65 install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
66 install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
67
68 main.step("Set cell for ONOScli env")
69 main.ONOS1cli.set_cell(cell_name)
70 main.ONOS2cli.set_cell(cell_name)
71 main.ONOS3cli.set_cell(cell_name)
72
73 time.sleep(5)
74
75 main.step("Start onos cli")
76 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
77 cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
78 cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
79
andrewonlab92ea3672014-11-04 20:22:14 -050080 utilities.assert_equals(expect=main.TRUE,
81 actual = cell_file_result and cell_apply_result and\
82 verify_cell_result and checkout_result and\
83 pull_result and build_result and\
84 install1_result and install2_result and\
85 install3_result,
86 onpass="ONOS started successfully",
87 onfail="Failed to start ONOS")
88
89 def CASE2(self, main):
90 '''
91 Single intent add latency
92
93 '''
94 import time
95 import json
96 import requests
97 import os
98
99 ONOS1_ip = main.params['CTRL']['ip1']
100 ONOS2_ip = main.params['CTRL']['ip2']
101 ONOS3_ip = main.params['CTRL']['ip3']
102 ONOS_user = main.params['CTRL']['user']
103
104 default_sw_port = main.params['CTRL']['port1']
105
106 #number of iterations of case
107 num_iter = main.params['TEST']['numIter']
108
109 #Timestamp keys for json metrics output
110 submit_time = main.params['JSON']['submittedTime']
111 install_time = main.params['JSON']['installedTime']
112 wdRequest_time = main.params['JSON']['wdRequestTime']
113 withdrawn_time = main.params['JSON']['withdrawnTime']
114
andrewonlab8790abb2014-11-06 13:51:54 -0500115 devices_json_str = main.ONOS1cli.devices()
andrewonlab92ea3672014-11-04 20:22:14 -0500116 devices_json_obj = json.loads(devices_json_str)
117
118 device_id_list = []
119
andrewonlab8790abb2014-11-06 13:51:54 -0500120 #Obtain device id list in ONOS format.
121 #They should already be in order (1,2,3,10,11,12,13, etc)
andrewonlab92ea3672014-11-04 20:22:14 -0500122 for device in devices_json_obj:
123 device_id_list.append(device['id'])
124
andrewonlab8790abb2014-11-06 13:51:54 -0500125 intent_add_lat_list = []
andrewonlab92ea3672014-11-04 20:22:14 -0500126
andrewonlab4cf9dd22014-11-18 21:28:38 -0500127 #Assign 'linear' switch format for basic intent testing
128 main.Mininet1.assign_sw_controller(
129 sw="1", ip=ONOS1_ip,port1=default_sw_port)
130 main.Mininet1.assign_sw_controller(
131 sw="3", ip=ONOS2_ip,port1=default_sw_port)
132 main.Mininet1.assign_sw_controller(
133 sw="5", ip=ONOS3_ip,port1=default_sw_port)
134
andrewonlab8790abb2014-11-06 13:51:54 -0500135 for i in range(0, int(num_iter)):
andrewonlab4cf9dd22014-11-18 21:28:38 -0500136 #add_point_intent(ingr_device, egr_device,
137 # ingr_port, egr_port)
andrewonlab8790abb2014-11-06 13:51:54 -0500138 main.ONOS1cli.add_point_intent(
andrewonlab4cf9dd22014-11-18 21:28:38 -0500139 device_id_list[0]+"/2", device_id_list[2]+"/1")
andrewonlab8790abb2014-11-06 13:51:54 -0500140
141 #Allow some time for intents to propagate
142 time.sleep(5)
andrewonlab92ea3672014-11-04 20:22:14 -0500143
andrewonlab8790abb2014-11-06 13:51:54 -0500144 #Obtain metrics from ONOS 1, 2, 3
145 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
146 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
147 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
148
149 intents_json_obj_1 = json.loads(intents_json_str_1)
150 intents_json_obj_2 = json.loads(intents_json_str_2)
151 intents_json_obj_3 = json.loads(intents_json_str_3)
152
153 #Parse values from the json object
154 intent_submit_1 = \
155 intents_json_obj_1[submit_time]['value']
156 intent_submit_2 = \
157 intents_json_obj_2[submit_time]['value']
158 intent_submit_3 = \
159 intents_json_obj_3[submit_time]['value']
160
161 intent_install_1 = \
162 intents_json_obj_1[install_time]['value']
163 intent_install_2 = \
164 intents_json_obj_2[install_time]['value']
165 intent_install_3 = \
166 intents_json_obj_3[install_time]['value']
167
168 intent_install_lat_1 = \
169 int(intent_install_1) - int(intent_submit_1)
170 intent_install_lat_2 = \
171 int(intent_install_2) - int(intent_submit_2)
172 intent_install_lat_3 = \
173 int(intent_install_3) - int(intent_submit_3)
174
175 intent_install_lat_avg = \
176 (intent_install_lat_1 +
177 intent_install_lat_2 +
178 intent_install_lat_3 ) / 3
179
180 main.log.info("Intent add latency avg for iteration "+str(i)+
181 ": "+str(intent_install_lat_avg))
182
183 if intent_install_lat_avg > 0.0 and \
184 intent_install_lat_avg < 1000:
185 intent_add_lat_list.append(intent_install_lat_avg)
186 else:
187 main.log.info("Intent add latency exceeded "+
188 "threshold. Skipping iteration "+str(i))
189
190 time.sleep(3)
191
192 #TODO: Possibly put this in the driver function
193 main.log.info("Removing intents for next iteration")
194 json_temp = \
195 main.ONOS1cli.intents(json_format=True)
196 json_obj_intents = json.loads(json_temp)
197 if json_obj_intents:
198 for intents in json_obj_intents:
199 temp_id = intents['id']
200 main.ONOS1cli.remove_intent(temp_id)
201 main.log.info("Removing intent id: "+
202 str(temp_id))
203 main.ONOS1cli.remove_intent(temp_id)
204 else:
205 main.log.info("Intents were not installed correctly")
206
207 time.sleep(5)
208
209 intent_add_lat_min = min(intent_add_lat_list)
210 intent_add_lat_max = max(intent_add_lat_list)
211 intent_add_lat_avg = sum(intent_add_lat_list) /\
212 len(intent_add_lat_list)
213 #END ITERATION FOR LOOP
214 main.log.report("Single intent add latency - \n"+
215 "Min: "+str(intent_add_lat_min)+" ms\n"+
216 "Max: "+str(intent_add_lat_max)+" ms\n"+
217 "Avg: "+str(intent_add_lat_avg)+" ms\n")
andrewonlab92ea3672014-11-04 20:22:14 -0500218
219
andrewonlab8790abb2014-11-06 13:51:54 -0500220 def CASE3(self, main):
221 '''
andrewonlab4cf9dd22014-11-18 21:28:38 -0500222 Intent Reroute latency
andrewonlab8790abb2014-11-06 13:51:54 -0500223 '''
andrewonlab4cf9dd22014-11-18 21:28:38 -0500224 import time
225 import json
226 import requests
227 import os
228
229 ONOS1_ip = main.params['CTRL']['ip1']
230 ONOS2_ip = main.params['CTRL']['ip2']
231 ONOS3_ip = main.params['CTRL']['ip3']
232 ONOS_user = main.params['CTRL']['user']
233
234 default_sw_port = main.params['CTRL']['port1']
235
236 #number of iterations of case
237 num_iter = main.params['TEST']['numIter']
238
239 #Timestamp keys for json metrics output
240 submit_time = main.params['JSON']['submittedTime']
241 install_time = main.params['JSON']['installedTime']
242 wdRequest_time = main.params['JSON']['wdRequestTime']
243 withdrawn_time = main.params['JSON']['withdrawnTime']
244 devices_json_str = main.ONOS1cli.devices()
245 devices_json_obj = json.loads(devices_json_str)
246
247 device_id_list = []
248
249 #Obtain device id list in ONOS format.
250 #They should already be in order (1,2,3,10,11,12,13, etc)
251 for device in devices_json_obj:
252 device_id_list.append(device['id'])
253
254 #Completes the re-route path by assigning
255 #additional switches to the topology assigned in case1
256 main.Mininet1.assign_sw_controller(
257 sw="s2",ip1=ONOS2_ip,port1=default_sw_port)
258 main.Mininet1.assign_sw_controller(
259 sw="s4",ip1=ONOS2_ip,port1=default_sw_port)
260
261 intent_reroute_lat_list = []
262
263 for i in range(0, int(num_iter)):
264 #add_point_intent(ingr_device, ingr_port,
265 # egr_device, egr_port)
266 main.ONOS1cli.add_point_intent(
267 device_id_list[0]+"/2", device_id_list[2]+"/1")
268
269 #TODO: check for correct intent installation
270 time.sleep(5)
271
272 #NOTE: this interface is specific to
273 # topo-intentFlower.py topology
274 # reroute case.
275 main.Mininet1.handle.sendline(
276 "sh ifconfig s2-eth3 down")
277 t0_system = time.time()*1000
278
279 #TODO: Check for correct intent reroute
280 time.sleep(5)
281
282 #Obtain metrics from ONOS 1, 2, 3
283 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
284 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
285 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
286
287 intents_json_obj_1 = json.loads(intents_json_str_1)
288 intents_json_obj_2 = json.loads(intents_json_str_2)
289 intents_json_obj_3 = json.loads(intents_json_str_3)
290
291 #Parse values from the json object
292 intent_install_1 = \
293 intents_json_obj_1[install_time]['value']
294 intent_install_2 = \
295 intents_json_obj_2[install_time]['value']
296 intent_install_3 = \
297 intents_json_obj_3[install_time]['value']
298
299 intent_reroute_lat_1 = \
300 int(intent_install_1) - int(t0_system)
301 intent_reroute_lat_2 = \
302 int(intent_install_2) - int(t0_system)
303 intent_reroute_lat_3 = \
304 int(intent_install_3) - int(t0_system)
305
306 intent_reroute_lat_avg = \
307 (intent_reroute_lat_1 +
308 intent_reroute_lat_2 +
309 intent_reroute_lat_3 ) / 3
310
311 main.log.info("Intent reroute latency avg for iteration "+
312 str(i)+": "+str(intent_reroute_lat_avg))
313
314 if intent_reroute_lat_avg > 0.0 and \
315 intent_reroute_lat_avg < 1000:
316 intent_reroute_lat_list.append(intent_reroute_lat_avg)
317 else:
318 main.log.info("Intent reroute latency exceeded "+
319 "threshold. Skipping iteration "+str(i))
320
321
andrewonlab92ea3672014-11-04 20:22:14 -0500322