blob: 74ce298299bc0f711896bf9076edba16e4d619c8 [file] [log] [blame]
andrewonlaba57a3042015-01-23 13:53:05 -05001#Intent Performance Test for ONOS-next
andrewonlab92ea3672014-11-04 20:22:14 -05002#
andrewonlaba57a3042015-01-23 13:53:05 -05003#andrew@onlab.us
andrewonlab8790abb2014-11-06 13:51:54 -05004#
andrewonlaba57a3042015-01-23 13:53:05 -05005#November 5, 2014
andrewonlab92ea3672014-11-04 20:22:14 -05006
7class IntentPerfNext:
andrewonlaba57a3042015-01-23 13:53:05 -05008 def __init__(self):
andrewonlab92ea3672014-11-04 20:22:14 -05009 self.default = ""
10
andrewonlaba57a3042015-01-23 13:53:05 -050011 def CASE1(self, main):
12 '''
andrewonlab92ea3672014-11-04 20:22:14 -050013 ONOS startup sequence
andrewonlaba57a3042015-01-23 13:53:05 -050014 '''
15
andrewonlab92ea3672014-11-04 20:22:14 -050016 import time
andrewonlab4293dcb2014-12-02 15:48:05 -050017 global cluster_count
andrewonlaba57a3042015-01-23 13:53:05 -050018 cluster_count = 1
andrewonlab92ea3672014-11-04 20:22:14 -050019
andrewonlaba57a3042015-01-23 13:53:05 -050020 cell_name = main.params['ENV']['cellName']
andrewonlab92ea3672014-11-04 20:22:14 -050021
andrewonlaba57a3042015-01-23 13:53:05 -050022 git_pull = main.params['GIT']['autoPull']
23 checkout_branch = main.params['GIT']['checkout']
andrewonlab92ea3672014-11-04 20:22:14 -050024
andrewonlaba57a3042015-01-23 13:53:05 -050025 ONOS1_ip = main.params['CTRL']['ip1']
26 ONOS2_ip = main.params['CTRL']['ip2']
27 ONOS3_ip = main.params['CTRL']['ip3']
28 ONOS4_ip = main.params['CTRL']['ip4']
29 ONOS5_ip = main.params['CTRL']['ip5']
30 ONOS6_ip = main.params['CTRL']['ip6']
31 ONOS7_ip = main.params['CTRL']['ip7']
andrewonlab4293dcb2014-12-02 15:48:05 -050032
andrewonlaba57a3042015-01-23 13:53:05 -050033 main.ONOSbench.onos_uninstall(node_ip=ONOS1_ip)
34 main.ONOSbench.onos_uninstall(node_ip=ONOS2_ip)
35 main.ONOSbench.onos_uninstall(node_ip=ONOS3_ip)
36 main.ONOSbench.onos_uninstall(node_ip=ONOS4_ip)
37 main.ONOSbench.onos_uninstall(node_ip=ONOS5_ip)
38 main.ONOSbench.onos_uninstall(node_ip=ONOS6_ip)
39 main.ONOSbench.onos_uninstall(node_ip=ONOS7_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -050040
andrewonlaba57a3042015-01-23 13:53:05 -050041 MN1_ip = main.params['MN']['ip1']
42 BENCH_ip = main.params['BENCH']['ip']
43
44 main.case("Setting up test environment")
andrewonlab92ea3672014-11-04 20:22:14 -050045
andrewonlaba57a3042015-01-23 13:53:05 -050046 main.step("Creating cell file")
andrewonlab92ea3672014-11-04 20:22:14 -050047 cell_file_result = main.ONOSbench.create_cell_file(
andrewonlaba57a3042015-01-23 13:53:05 -050048 BENCH_ip, cell_name, MN1_ip,
49 "onos-core,onos-app-metrics,onos-gui",
50 ONOS1_ip)
andrewonlab92ea3672014-11-04 20:22:14 -050051
andrewonlaba57a3042015-01-23 13:53:05 -050052 main.step("Applying cell file to environment")
53 cell_apply_result = main.ONOSbench.set_cell(cell_name)
andrewonlab92ea3672014-11-04 20:22:14 -050054 verify_cell_result = main.ONOSbench.verify_cell()
55
andrewonlaba57a3042015-01-23 13:53:05 -050056 main.step("Removing raft logs")
andrewonlab4293dcb2014-12-02 15:48:05 -050057 main.ONOSbench.onos_remove_raft_logs()
58
andrewonlaba57a3042015-01-23 13:53:05 -050059 main.step("Git checkout and pull "+checkout_branch)
andrewonlab92ea3672014-11-04 20:22:14 -050060 if git_pull == 'on':
61 checkout_result = \
andrewonlaba57a3042015-01-23 13:53:05 -050062 main.ONOSbench.git_checkout(checkout_branch)
andrewonlab92ea3672014-11-04 20:22:14 -050063 pull_result = main.ONOSbench.git_pull()
andrewonlaba57a3042015-01-23 13:53:05 -050064
65 #If you used git pull, auto compile
66 main.step("Using onos-build to compile ONOS")
andrewonlab92ea3672014-11-04 20:22:14 -050067 build_result = main.ONOSbench.onos_build()
68 else:
69 checkout_result = main.TRUE
70 pull_result = main.TRUE
71 build_result = main.TRUE
andrewonlaba57a3042015-01-23 13:53:05 -050072 main.log.info("Git pull skipped by configuration")
andrewonlab92ea3672014-11-04 20:22:14 -050073
andrewonlaba57a3042015-01-23 13:53:05 -050074 main.log.report("Commit information - ")
75 main.ONOSbench.get_version(report=True)
andrewonlab4cf9dd22014-11-18 21:28:38 -050076
andrewonlaba57a3042015-01-23 13:53:05 -050077 main.step("Creating ONOS package")
andrewonlab92ea3672014-11-04 20:22:14 -050078 package_result = main.ONOSbench.onos_package()
79
andrewonlaba57a3042015-01-23 13:53:05 -050080 main.step("Installing ONOS package")
81 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
82 #install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
83 #install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
andrewonlab92ea3672014-11-04 20:22:14 -050084
andrewonlaba57a3042015-01-23 13:53:05 -050085 main.step("Set cell for ONOScli env")
86 main.ONOS1cli.set_cell(cell_name)
87 #main.ONOS2cli.set_cell(cell_name)
88 #main.ONOS3cli.set_cell(cell_name)
andrewonlab92ea3672014-11-04 20:22:14 -050089
andrewonlaba57a3042015-01-23 13:53:05 -050090 time.sleep(5)
andrewonlab92ea3672014-11-04 20:22:14 -050091
andrewonlaba57a3042015-01-23 13:53:05 -050092 main.step("Start onos cli")
93 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
94 #cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
95 #cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
andrewonlab92ea3672014-11-04 20:22:14 -050096
andrewonlaba57a3042015-01-23 13:53:05 -050097 utilities.assert_equals(expect=main.TRUE,
98 actual = cell_file_result and cell_apply_result and\
99 verify_cell_result and checkout_result and\
100 pull_result and build_result and\
101 install1_result, #and install2_result and\
102 #install3_result,
103 onpass="ONOS started successfully",
104 onfail="Failed to start ONOS")
andrewonlab92ea3672014-11-04 20:22:14 -0500105
andrewonlaba57a3042015-01-23 13:53:05 -0500106 def CASE2(self, main):
107 '''
andrewonlab92ea3672014-11-04 20:22:14 -0500108 Single intent add latency
109
andrewonlaba57a3042015-01-23 13:53:05 -0500110 '''
andrewonlab92ea3672014-11-04 20:22:14 -0500111 import time
112 import json
113 import requests
114 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500115 import numpy
andrewonlaba57a3042015-01-23 13:53:05 -0500116 global cluster_count
andrewonlab92ea3672014-11-04 20:22:14 -0500117
andrewonlaba57a3042015-01-23 13:53:05 -0500118 ONOS1_ip = main.params['CTRL']['ip1']
119 ONOS2_ip = main.params['CTRL']['ip2']
120 ONOS3_ip = main.params['CTRL']['ip3']
121 ONOS_ip_list = []
122 for i in range(1, 8):
123 ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
124
125 ONOS_user = main.params['CTRL']['user']
andrewonlab92ea3672014-11-04 20:22:14 -0500126
andrewonlaba57a3042015-01-23 13:53:05 -0500127 default_sw_port = main.params['CTRL']['port1']
andrewonlab92ea3672014-11-04 20:22:14 -0500128
andrewonlaba57a3042015-01-23 13:53:05 -0500129 #number of iterations of case
130 num_iter = main.params['TEST']['numIter']
131 num_ignore = int(main.params['TEST']['numIgnore'])
andrewonlab92ea3672014-11-04 20:22:14 -0500132
andrewonlaba57a3042015-01-23 13:53:05 -0500133 #Timestamp keys for json metrics output
134 submit_time = main.params['JSON']['submittedTime']
135 install_time = main.params['JSON']['installedTime']
136 wdRequest_time = main.params['JSON']['wdRequestTime']
137 withdrawn_time = main.params['JSON']['withdrawnTime']
138
139 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800140
andrewonlab70decc02014-11-19 18:50:23 -0500141 intent_add_lat_list = []
andrewonlaba57a3042015-01-23 13:53:05 -0500142
143 #Distribute switches according to cluster count
144 for i in range(1, 9):
145 if cluster_count == 1:
146 main.Mininet1.assign_sw_controller(
147 sw=str(i), ip1=ONOS_ip_list[0],
148 port1=default_sw_port
149 )
150 elif cluster_count == 3:
151 if i < 3:
152 index = 0
153 elif i < 6 and i >= 3:
154 index = 1
155 else:
156 index = 2
157 main.Mininet1.assign_sw_controller(
158 sw=str(i), ip1=ONOS_ip_list[index],
159 port1=default_sw_port
160 )
161 elif cluster_count == 5:
162 if i < 3:
163 index = 0
164 elif i < 5 and i >= 3:
165 index = 1
166 elif i < 7 and i >= 5:
167 index = 2
168 elif i == 7:
169 index = 3
170 else:
171 index = 4
172 main.Mininet1.assign_sw_controller(
173 sw=str(i), ip1=ONOS_ip_list[index],
174 port1=default_sw_port
175 )
176 elif cluster_count == 7:
177 if i < 6:
178 index = i
179 else:
180 index = 6
181 main.Mininet1.assign_sw_controller(
182 sw=str(i), ip1=ONOS_ip_list[index],
183 port1=default_sw_port
184 )
andrewonlab70decc02014-11-19 18:50:23 -0500185
andrewonlaba57a3042015-01-23 13:53:05 -0500186 time.sleep(10)
andrewonlab70decc02014-11-19 18:50:23 -0500187
andrewonlaba57a3042015-01-23 13:53:05 -0500188 main.log.report("Single intent add latency test")
andrewonlabeb1d0542014-12-03 20:12:01 -0500189
andrewonlab8790abb2014-11-06 13:51:54 -0500190 devices_json_str = main.ONOS1cli.devices()
andrewonlaba57a3042015-01-23 13:53:05 -0500191 devices_json_obj = json.loads(devices_json_str)
192
193 if not devices_json_obj:
194 main.log.report("Devices not discovered")
195 main.log.report("Aborting test")
196 main.exit()
197 else:
198 main.log.info("Devices discovered successfully")
199
andrewonlab92ea3672014-11-04 20:22:14 -0500200 device_id_list = []
201
andrewonlaba57a3042015-01-23 13:53:05 -0500202 #Obtain device id list in ONOS format.
203 #They should already be in order (1,2,3,10,11,12,13, etc)
andrewonlab92ea3672014-11-04 20:22:14 -0500204 for device in devices_json_obj:
andrewonlaba57a3042015-01-23 13:53:05 -0500205 device_id_list.append(device['id'])
andrewonlab92ea3672014-11-04 20:22:14 -0500206
andrewonlaba57a3042015-01-23 13:53:05 -0500207 for i in range(0, int(num_iter)):
208 #add_point_intent(ingr_device, egr_device,
209 # ingr_port, egr_port)
andrewonlab8790abb2014-11-06 13:51:54 -0500210 main.ONOS1cli.add_point_intent(
andrewonlaba57a3042015-01-23 13:53:05 -0500211 device_id_list[0]+"/2", device_id_list[7]+"/2")
212
213 #Allow some time for intents to propagate
214 time.sleep(5)
215
216 intents_str = main.ONOS1cli.intents(json_format=True)
217 intents_obj = json.loads(intents_str)
218 for intent in intents_obj:
219 if intent['state'] == "INSTALLED":
220 main.log.info("Intent installed successfully")
221 intent_id = intent['id']
222 main.log.info("Intent id: "+str(intent_id))
223 else:
224 #TODO: Add error handling
225 main.log.info("Intent installation failed")
226 intent_id = ""
andrewonlab92ea3672014-11-04 20:22:14 -0500227
andrewonlaba57a3042015-01-23 13:53:05 -0500228 #Obtain metrics from ONOS 1, 2, 3
andrewonlab8790abb2014-11-06 13:51:54 -0500229 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500230 intents_json_obj_1 = json.loads(intents_json_str_1)
231 #Parse values from the json object
andrewonlab8790abb2014-11-06 13:51:54 -0500232 intent_submit_1 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500233 intents_json_obj_1[submit_time]['value']
andrewonlab8790abb2014-11-06 13:51:54 -0500234 intent_install_1 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500235 intents_json_obj_1[install_time]['value']
andrewonlab8790abb2014-11-06 13:51:54 -0500236 intent_install_lat_1 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500237 int(intent_install_1) - int(intent_submit_1)
238
239 if cluster_count == 3:
240 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
241 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
242 intents_json_obj_2 = json.loads(intents_json_str_2)
243 intents_json_obj_3 = json.loads(intents_json_str_3)
244 intent_submit_2 = \
245 intents_json_obj_2[submit_time]['value']
246 intent_submit_3 = \
247 intents_json_obj_3[submit_time]['value']
248 intent_install_2 = \
249 intents_json_obj_2[install_time]['value']
250 intent_install_3 = \
251 intents_json_obj_3[install_time]['value']
252 intent_install_lat_2 = \
253 int(intent_install_2) - int(intent_submit_2)
254 intent_install_lat_3 = \
255 int(intent_install_3) - int(intent_submit_3)
256 else:
257 intent_install_lat_2 = 0
258 intent_install_lat_3 = 0
259
260 if cluster_count == 5:
261 intents_json_str_4 = main.ONOS4cli.intents_events_metrics()
262 intents_json_str_5 = main.ONOS5cli.intents_events_metrics()
263 intents_json_obj_4 = json.loads(intents_json_str_4)
264 intents_json_obj_5 = json.loads(intents_json_str_5)
265 intent_submit_4 = \
266 intents_json_obj_4[submit_time]['value']
267 intent_submit_5 = \
268 intents_json_obj_5[submit_time]['value']
269 intent_install_4 = \
270 intents_json_obj_5[install_time]['value']
271 intent_install_5 = \
272 intents_json_obj_5[install_time]['value']
273 intent_install_lat_4 = \
274 int(intent_install_4) - int(intent_submit_4)
275 intent_install_lat_5 = \
276 int(intent_install_5) - int(intent_submit_5)
277 else:
278 intent_install_lat_4 = 0
279 intent_install_lat_5 = 0
280
281 if cluster_count == 7:
282 intents_json_str_6 = main.ONOS6cli.intents_events_metrics()
283 intents_json_str_7 = main.ONOS7cli.intents_events_metrics()
284 intents_json_obj_6 = json.loads(intents_json_str_6)
285 intents_json_obj_7 = json.loads(intents_json_str_7)
286 intent_submit_6 = \
287 intents_json_obj_6[submit_time]['value']
288 intent_submit_7 = \
289 intents_json_obj_6[submit_time]['value']
290 intent_install_6 = \
291 intents_json_obj_6[install_time]['value']
292 intent_install_7 = \
293 intents_json_obj_7[install_time]['value']
294 intent_install_lat_6 = \
295 int(intent_install_6) - int(intent_submit_6)
296 intent_install_lat_7 = \
297 int(intent_install_7) - int(intent_submit_7)
298 else:
299 intent_install_lat_6 = 0
300 intent_install_lat_7 = 0
andrewonlab8790abb2014-11-06 13:51:54 -0500301
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800302 intent_install_lat_avg = \
andrewonlaba57a3042015-01-23 13:53:05 -0500303 (intent_install_lat_1 +
304 intent_install_lat_2 +
305 intent_install_lat_3 +
306 intent_install_lat_4 +
307 intent_install_lat_5 +
308 intent_install_lat_6 +
309 intent_install_lat_7) / cluster_count
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800310
andrewonlaba57a3042015-01-23 13:53:05 -0500311 main.log.info("Intent add latency avg for iteration "+str(i)+
312 ": "+str(intent_install_lat_avg)+" ms")
andrewonlab8790abb2014-11-06 13:51:54 -0500313
314 if intent_install_lat_avg > 0.0 and \
andrewonlabeb1d0542014-12-03 20:12:01 -0500315 intent_install_lat_avg < 1000 and i > num_ignore:
andrewonlaba57a3042015-01-23 13:53:05 -0500316 intent_add_lat_list.append(intent_install_lat_avg)
andrewonlab8790abb2014-11-06 13:51:54 -0500317 else:
andrewonlaba57a3042015-01-23 13:53:05 -0500318 main.log.info("Intent add latency exceeded "+
319 "threshold. Skipping iteration "+str(i))
andrewonlab8790abb2014-11-06 13:51:54 -0500320
andrewonlaba57a3042015-01-23 13:53:05 -0500321 time.sleep(3)
322
323 #TODO: Only remove intents that were installed
324 # in this case... Otherwise many other intents
325 # may show up distorting the results
326 main.log.info("Removing intents for next iteration")
andrewonlab8790abb2014-11-06 13:51:54 -0500327 json_temp = \
andrewonlaba57a3042015-01-23 13:53:05 -0500328 main.ONOS1cli.intents(json_format=True)
329 json_obj_intents = json.loads(json_temp)
andrewonlab8790abb2014-11-06 13:51:54 -0500330 if json_obj_intents:
331 for intents in json_obj_intents:
andrewonlaba57a3042015-01-23 13:53:05 -0500332 temp_id = intents['id']
333 #main.ONOS1cli.remove_intent(temp_id)
334 main.log.info("Removing intent id: "+
335 str(temp_id))
336 main.ONOS1cli.remove_intent(temp_id)
andrewonlab8790abb2014-11-06 13:51:54 -0500337 else:
andrewonlaba57a3042015-01-23 13:53:05 -0500338 main.log.info("Intents were not installed correctly")
andrewonlab8790abb2014-11-06 13:51:54 -0500339
andrewonlaba57a3042015-01-23 13:53:05 -0500340 time.sleep(5)
andrewonlab8790abb2014-11-06 13:51:54 -0500341
andrewonlaba57a3042015-01-23 13:53:05 -0500342 if intent_add_lat_list:
343 intent_add_lat_avg = sum(intent_add_lat_list) /\
344 len(intent_add_lat_list)
345 else:
346 main.log.report("Intent installation latency test failed")
347 intent_add_lat_avg = "NA"
348 assertion = main.FALSE
349
andrewonlabeb1d0542014-12-03 20:12:01 -0500350 intent_add_lat_std = \
andrewonlaba57a3042015-01-23 13:53:05 -0500351 round(numpy.std(intent_add_lat_list),1)
352 #END ITERATION FOR LOOP
353 main.log.report("Single intent add latency - ")
354 main.log.report("Avg: "+str(intent_add_lat_avg)+" ms")
355 main.log.report("Std Deviation: "+str(intent_add_lat_std)+" ms")
356
357 utilities.assert_equals(expect=main.TRUE, actual=assertion,
358 onpass="Single intent install latency test successful",
359 onfail="Single intent install latency test failed")
andrewonlab92ea3672014-11-04 20:22:14 -0500360
andrewonlaba57a3042015-01-23 13:53:05 -0500361 def CASE3(self, main):
362 '''
andrewonlab4cf9dd22014-11-18 21:28:38 -0500363 Intent Reroute latency
andrewonlaba57a3042015-01-23 13:53:05 -0500364 '''
andrewonlab4cf9dd22014-11-18 21:28:38 -0500365 import time
366 import json
367 import requests
368 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500369 import numpy
andrewonlaba57a3042015-01-23 13:53:05 -0500370 global cluster_count
andrewonlab4cf9dd22014-11-18 21:28:38 -0500371
andrewonlaba57a3042015-01-23 13:53:05 -0500372 ONOS1_ip = main.params['CTRL']['ip1']
373 ONOS2_ip = main.params['CTRL']['ip2']
374 ONOS3_ip = main.params['CTRL']['ip3']
375 ONOS_user = main.params['CTRL']['user']
andrewonlab4cf9dd22014-11-18 21:28:38 -0500376
andrewonlaba57a3042015-01-23 13:53:05 -0500377 default_sw_port = main.params['CTRL']['port1']
andrewonlab4cf9dd22014-11-18 21:28:38 -0500378
andrewonlaba57a3042015-01-23 13:53:05 -0500379 #number of iterations of case
380 num_iter = main.params['TEST']['numIter']
381 num_ignore = int(main.params['TEST']['numIgnore'])
382 assertion = main.TRUE
andrewonlab4cf9dd22014-11-18 21:28:38 -0500383
andrewonlaba57a3042015-01-23 13:53:05 -0500384 #Timestamp keys for json metrics output
385 submit_time = main.params['JSON']['submittedTime']
386 install_time = main.params['JSON']['installedTime']
387 wdRequest_time = main.params['JSON']['wdRequestTime']
388 withdrawn_time = main.params['JSON']['withdrawnTime']
389
390 #NOTE: May need to configure interface depending on topology
391 intfs = main.params['TEST']['intfs']
andrewonlab70decc02014-11-19 18:50:23 -0500392
andrewonlab4cf9dd22014-11-18 21:28:38 -0500393 devices_json_str = main.ONOS1cli.devices()
andrewonlaba57a3042015-01-23 13:53:05 -0500394 devices_json_obj = json.loads(devices_json_str)
andrewonlab4cf9dd22014-11-18 21:28:38 -0500395
396 device_id_list = []
397
andrewonlaba57a3042015-01-23 13:53:05 -0500398 #Obtain device id list in ONOS format.
399 #They should already be in order (1,2,3,10,11,12,13, etc)
andrewonlab4cf9dd22014-11-18 21:28:38 -0500400 for device in devices_json_obj:
andrewonlaba57a3042015-01-23 13:53:05 -0500401 device_id_list.append(device['id'])
andrewonlab4cf9dd22014-11-18 21:28:38 -0500402
andrewonlab4cf9dd22014-11-18 21:28:38 -0500403 intent_reroute_lat_list = []
404
andrewonlaba57a3042015-01-23 13:53:05 -0500405 for i in range(0, int(num_iter)):
406 #add_point_intent(ingr_device, ingr_port,
407 # egr_device, egr_port)
408 if len(device_id_list) > 0:
andrewonlabeb1d0542014-12-03 20:12:01 -0500409 main.ONOS1cli.add_point_intent(
andrewonlaba57a3042015-01-23 13:53:05 -0500410 device_id_list[0]+"/2", device_id_list[7]+"/2")
andrewonlabeb1d0542014-12-03 20:12:01 -0500411 else:
andrewonlaba57a3042015-01-23 13:53:05 -0500412 main.log.info("Failed to fetch devices from ONOS")
andrewonlabeb1d0542014-12-03 20:12:01 -0500413
andrewonlaba57a3042015-01-23 13:53:05 -0500414 time.sleep(5)
andrewonlab4cf9dd22014-11-18 21:28:38 -0500415
andrewonlaba57a3042015-01-23 13:53:05 -0500416 intents_str = main.ONOS1cli.intents(json_format=True)
417 intents_obj = json.loads(intents_str)
andrewonlab70decc02014-11-19 18:50:23 -0500418 for intent in intents_obj:
andrewonlaba57a3042015-01-23 13:53:05 -0500419 if intent['state'] == "INSTALLED":
420 main.log.info("Intent installed successfully")
421 intent_id = intent['id']
422 main.log.info("Intent id: "+str(intent_id))
andrewonlab70decc02014-11-19 18:50:23 -0500423 else:
andrewonlaba57a3042015-01-23 13:53:05 -0500424 #TODO: Add error handling
425 main.log.info("Intent installation failed")
andrewonlab70decc02014-11-19 18:50:23 -0500426 intent_id = ""
andrewonlaba57a3042015-01-23 13:53:05 -0500427
428 main.log.info("Disabling interface "+intfs)
429 t0_system = time.time()*1000
andrewonlab4cf9dd22014-11-18 21:28:38 -0500430 main.Mininet1.handle.sendline(
andrewonlaba57a3042015-01-23 13:53:05 -0500431 "sh ifconfig "+intfs+" down")
432 main.Mininet1.handle.expect("mininet>")
andrewonlab4cf9dd22014-11-18 21:28:38 -0500433
andrewonlaba57a3042015-01-23 13:53:05 -0500434 #TODO: Check for correct intent reroute
435 time.sleep(1)
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800436
andrewonlaba57a3042015-01-23 13:53:05 -0500437 #Obtain metrics from ONOS 1, 2, 3
andrewonlab4cf9dd22014-11-18 21:28:38 -0500438 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500439 intents_json_obj_1 = json.loads(intents_json_str_1)
440 #Parse values from the json object
andrewonlab4cf9dd22014-11-18 21:28:38 -0500441 intent_install_1 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500442 intents_json_obj_1[install_time]['value']
andrewonlab4cf9dd22014-11-18 21:28:38 -0500443 intent_reroute_lat_1 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500444 int(intent_install_1) - int(t0_system)
445
446 if cluster_count == 3:
447 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
448 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
449
450 intents_json_obj_2 = json.loads(intents_json_str_2)
451 intents_json_obj_3 = json.loads(intents_json_str_3)
452 intent_install_2 = \
453 intents_json_obj_2[install_time]['value']
454 intent_install_3 = \
455 intents_json_obj_3[install_time]['value']
456 intent_reroute_lat_2 = \
457 int(intent_install_2) - int(t0_system)
458 intent_reroute_lat_3 = \
459 int(intent_install_3) - int(t0_system)
460 else:
461 intent_reroute_lat_2 = 0
462 intent_reroute_lat_3 = 0
463
464 if cluster_count == 5:
465 intents_json_str_4 = main.ONOS4cli.intents_events_metrics()
466 intents_json_str_5 = main.ONOS5cli.intents_events_metrics()
467
468 intents_json_obj_4 = json.loads(intents_json_str_4)
469 intents_json_obj_5 = json.loads(intents_json_str_5)
470 intent_install_4 = \
471 intents_json_obj_4[install_time]['value']
472 intent_install_5 = \
473 intents_json_obj_5[install_time]['value']
474 intent_reroute_lat_4 = \
475 int(intent_install_4) - int(t0_system)
476 intent_reroute_lat_5 = \
477 int(intent_install_5) - int(t0_system)
478 else:
479 intent_reroute_lat_4 = 0
480 intent_reroute_lat_5 = 0
481
482 if cluster_count == 7:
483 intents_json_str_6 = main.ONOS6cli.intents_events_metrics()
484 intents_json_str_7 = main.ONOS7cli.intents_events_metrics()
485
486 intents_json_obj_6 = json.loads(intents_json_str_6)
487 intents_json_obj_7 = json.loads(intents_json_str_7)
488 intent_install_6 = \
489 intents_json_obj_6[install_time]['value']
490 intent_install_7 = \
491 intents_json_obj_7[install_time]['value']
492 intent_reroute_lat_6 = \
493 int(intent_install_6) - int(t0_system)
494 intent_reroute_lat_7 = \
495 int(intent_install_7) - int(t0_system)
496 else:
497 intent_reroute_lat_6 = 0
498 intent_reroute_lat_7 = 0
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800499
andrewonlab4cf9dd22014-11-18 21:28:38 -0500500 intent_reroute_lat_avg = \
andrewonlaba57a3042015-01-23 13:53:05 -0500501 (intent_reroute_lat_1 +
502 intent_reroute_lat_2 +
503 intent_reroute_lat_3 +
504 intent_reroute_lat_4 +
505 intent_reroute_lat_5 +
506 intent_reroute_lat_6 +
507 intent_reroute_lat_7) / cluster_count
508
509 main.log.info("Intent reroute latency avg for iteration "+
510 str(i)+": "+str(intent_reroute_lat_avg))
andrewonlab4cf9dd22014-11-18 21:28:38 -0500511
512 if intent_reroute_lat_avg > 0.0 and \
andrewonlabeb1d0542014-12-03 20:12:01 -0500513 intent_reroute_lat_avg < 1000 and i > num_ignore:
andrewonlaba57a3042015-01-23 13:53:05 -0500514 intent_reroute_lat_list.append(intent_reroute_lat_avg)
andrewonlab4cf9dd22014-11-18 21:28:38 -0500515 else:
andrewonlaba57a3042015-01-23 13:53:05 -0500516 main.log.info("Intent reroute latency exceeded "+
517 "threshold. Skipping iteration "+str(i))
andrewonlab4cf9dd22014-11-18 21:28:38 -0500518
andrewonlaba57a3042015-01-23 13:53:05 -0500519 main.log.info("Removing intents for next iteration")
520 main.ONOS1cli.remove_intent(intent_id)
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800521
andrewonlaba57a3042015-01-23 13:53:05 -0500522 main.log.info("Bringing Mininet interface up for next "+
523 "iteration")
andrewonlabeb1d0542014-12-03 20:12:01 -0500524 main.Mininet1.handle.sendline(
andrewonlaba57a3042015-01-23 13:53:05 -0500525 "sh ifconfig "+intfs+" up")
526 main.Mininet1.handle.expect("mininet>")
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800527
andrewonlaba57a3042015-01-23 13:53:05 -0500528 if intent_reroute_lat_list:
529 intent_reroute_lat_avg = sum(intent_reroute_lat_list) /\
530 len(intent_reroute_lat_list)
531 else:
532 main.log.report("Intent reroute test failed. Results NA")
533 intent_reroute_lat_avg = "NA"
534 #NOTE: fails test when list is empty
535 assertion = main.FALSE
536
andrewonlabeb1d0542014-12-03 20:12:01 -0500537 intent_reroute_lat_std = \
andrewonlaba57a3042015-01-23 13:53:05 -0500538 round(numpy.std(intent_reroute_lat_list),1)
539 #END ITERATION FOR LOOP
540 main.log.report("Single intent reroute latency - ")
541 main.log.report("Avg: "+str(intent_reroute_lat_avg)+" ms")
542 main.log.report("Std Deviation: "+str(intent_reroute_lat_std)+" ms")
543
544 utilities.assert_equals(expect=main.TRUE, actual=assertion,
545 onpass="Single intent reroute latency test successful",
546 onfail="Single intent reroute latency test failed")
547
548 def CASE4(self, main):
549 '''
andrewonlab042b3912014-12-10 16:40:50 -0500550 Batch intent install
andrewonlaba57a3042015-01-23 13:53:05 -0500551 '''
552
andrewonlab70decc02014-11-19 18:50:23 -0500553 import time
554 import json
555 import requests
556 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500557 import numpy
andrewonlaba57a3042015-01-23 13:53:05 -0500558 global cluster_count
andrewonlab70decc02014-11-19 18:50:23 -0500559
andrewonlaba57a3042015-01-23 13:53:05 -0500560 ONOS1_ip = main.params['CTRL']['ip1']
561 ONOS2_ip = main.params['CTRL']['ip2']
562 ONOS3_ip = main.params['CTRL']['ip3']
563 ONOS4_ip = main.params['CTRL']['ip4']
564 ONOS5_ip = main.params['CTRL']['ip5']
565 ONOS6_ip = main.params['CTRL']['ip6']
566 ONOS7_ip = main.params['CTRL']['ip7']
567
568 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800569
andrewonlab4293dcb2014-12-02 15:48:05 -0500570 ONOS_ip_list = []
andrewonlaba57a3042015-01-23 13:53:05 -0500571 for i in range(1, 8):
572 ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
andrewonlab4293dcb2014-12-02 15:48:05 -0500573
andrewonlaba57a3042015-01-23 13:53:05 -0500574 ONOS_user = main.params['CTRL']['user']
andrewonlab70decc02014-11-19 18:50:23 -0500575
andrewonlaba57a3042015-01-23 13:53:05 -0500576 default_sw_port = main.params['CTRL']['port1']
577
578 batch_intent_size = main.params['TEST']['batchIntentSize']
579 batch_thresh_min = int(main.params['TEST']['batchThresholdMin'])
580 batch_thresh_max = int(main.params['TEST']['batchThresholdMax'])
andrewonlab70decc02014-11-19 18:50:23 -0500581
andrewonlaba57a3042015-01-23 13:53:05 -0500582 #number of iterations of case
583 num_iter = main.params['TEST']['numIter']
584 num_ignore = int(main.params['TEST']['numIgnore'])
585 num_switch = int(main.params['TEST']['numSwitch'])
586 n_thread = main.params['TEST']['numMult']
andrewonlabeb1d0542014-12-03 20:12:01 -0500587 #n_thread = 105
andrewonlab4293dcb2014-12-02 15:48:05 -0500588
andrewonlaba57a3042015-01-23 13:53:05 -0500589 #Switch assignment NOTE: hardcoded
andrewonlab4293dcb2014-12-02 15:48:05 -0500590 if cluster_count == 1:
andrewonlaba57a3042015-01-23 13:53:05 -0500591 for i in range(1, num_switch+1):
andrewonlab4293dcb2014-12-02 15:48:05 -0500592 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500593 sw=str(i),
andrewonlab4293dcb2014-12-02 15:48:05 -0500594 ip1=ONOS1_ip,
andrewonlaba57a3042015-01-23 13:53:05 -0500595 port1=default_sw_port)
andrewonlab4293dcb2014-12-02 15:48:05 -0500596 if cluster_count == 3:
andrewonlaba57a3042015-01-23 13:53:05 -0500597 for i in range(1, 3):
andrewonlab4293dcb2014-12-02 15:48:05 -0500598 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500599 sw=str(i),
andrewonlab4293dcb2014-12-02 15:48:05 -0500600 ip1=ONOS1_ip,
andrewonlaba57a3042015-01-23 13:53:05 -0500601 port1=default_sw_port)
602 for i in range(3, 6):
andrewonlab4293dcb2014-12-02 15:48:05 -0500603 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500604 sw=str(i),
andrewonlab4293dcb2014-12-02 15:48:05 -0500605 ip1=ONOS2_ip,
andrewonlaba57a3042015-01-23 13:53:05 -0500606 port1=default_sw_port)
607 for i in range(6, 9):
andrewonlab4293dcb2014-12-02 15:48:05 -0500608 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500609 sw=str(i),
andrewonlab4293dcb2014-12-02 15:48:05 -0500610 ip1=ONOS3_ip,
andrewonlaba57a3042015-01-23 13:53:05 -0500611 port1=default_sw_port)
andrewonlab4293dcb2014-12-02 15:48:05 -0500612 if cluster_count == 5:
613 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500614 sw="1",
615 ip1=ONOS1_ip,
616 port1=default_sw_port)
andrewonlab4293dcb2014-12-02 15:48:05 -0500617 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500618 sw="2",
619 ip1=ONOS2_ip,
620 port1=default_sw_port)
621 for i in range(3, 6):
andrewonlab4293dcb2014-12-02 15:48:05 -0500622 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500623 sw=str(i),
andrewonlab4293dcb2014-12-02 15:48:05 -0500624 ip1=ONOS3_ip,
andrewonlaba57a3042015-01-23 13:53:05 -0500625 port1=default_sw_port)
andrewonlab4293dcb2014-12-02 15:48:05 -0500626 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500627 sw="6",
628 ip1=ONOS4_ip,
629 port1=default_sw_port)
andrewonlab4293dcb2014-12-02 15:48:05 -0500630 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500631 sw="7",
632 ip1=ONOS5_ip,
633 port1=default_sw_port)
andrewonlab4293dcb2014-12-02 15:48:05 -0500634 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500635 sw="8",
636 ip1=ONOS5_ip,
637 port1=default_sw_port)
638
andrewonlab4293dcb2014-12-02 15:48:05 -0500639 if cluster_count == 7:
andrewonlaba57a3042015-01-23 13:53:05 -0500640 for i in range(1,9):
andrewonlabeb1d0542014-12-03 20:12:01 -0500641 if i < 8:
andrewonlab4293dcb2014-12-02 15:48:05 -0500642 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500643 sw=str(i),
644 ip1=ONOS_ip_list[i-1],
645 port1=default_sw_port)
646 elif i >= 8:
andrewonlab4293dcb2014-12-02 15:48:05 -0500647 main.Mininet1.assign_sw_controller(
andrewonlaba57a3042015-01-23 13:53:05 -0500648 sw=str(i),
649 ip1=ONOS_ip_list[6],
650 port1=default_sw_port)
andrewonlab70decc02014-11-19 18:50:23 -0500651
andrewonlaba57a3042015-01-23 13:53:05 -0500652 time.sleep(20)
andrewonlabeb1d0542014-12-03 20:12:01 -0500653
andrewonlaba57a3042015-01-23 13:53:05 -0500654 main.log.report("Batch intent installation test of "+
655 batch_intent_size +" intent(s)")
andrewonlab4293dcb2014-12-02 15:48:05 -0500656
657 batch_result_list = []
andrewonlab70decc02014-11-19 18:50:23 -0500658
andrewonlaba57a3042015-01-23 13:53:05 -0500659 main.log.info("Getting list of available devices")
andrewonlab70decc02014-11-19 18:50:23 -0500660 device_id_list = []
661 json_str = main.ONOS1cli.devices()
andrewonlaba57a3042015-01-23 13:53:05 -0500662 json_obj = json.loads(json_str)
andrewonlab70decc02014-11-19 18:50:23 -0500663 for device in json_obj:
andrewonlaba57a3042015-01-23 13:53:05 -0500664 device_id_list.append(device['id'])
andrewonlab70decc02014-11-19 18:50:23 -0500665
andrewonlab4293dcb2014-12-02 15:48:05 -0500666 batch_install_lat = []
667 batch_withdraw_lat = []
andrewonlaba57a3042015-01-23 13:53:05 -0500668
669 #Max intent install measurement of all nodes
andrewonlabeb1d0542014-12-03 20:12:01 -0500670 max_install_lat = []
andrewonlaba57a3042015-01-23 13:53:05 -0500671 max_withdraw_lat = []
672 sleep_time = 10
673
674 base_dir = "/tmp/"
andrewonlab70decc02014-11-19 18:50:23 -0500675
andrewonlaba57a3042015-01-23 13:53:05 -0500676 for batch in range(0, 5):
677 for i in range(0, int(num_iter)):
678 main.log.info("Pushing "+
679 str(int(batch_intent_size)*int(n_thread))+
680 " intents. Iteration "+str(i))
681
682 for node in range(1, cluster_count+1):
683 save_dir = base_dir + "batch_intent_"+str(node)+".txt"
684 main.ONOSbench.push_test_intents_shell(
685 device_id_list[0]+"/2",
686 device_id_list[7]+"/2",
687 int(batch_intent_size),
688 save_dir, ONOS_ip_list[node-1],
689 num_mult=n_thread, app_id=node)
690
691 #Wait sufficient time for intents to start
692 #installing
693 time.sleep(sleep_time)
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800694
andrewonlaba57a3042015-01-23 13:53:05 -0500695 intent = ""
696 counter = 300
697 while len(intent) > 0 and counter > 0:
698 main.ONOS1cli.handle.sendline(
699 "intents | wc -l")
700 main.ONOS1cli.handle.expect(
701 "intents | wc -l")
702 main.ONOS1cli.handle.expect(
703 "onos>")
704 intent_temp = main.ONOS1cli.handle.before()
705 intent = main.ONOS1cli.intents()
706 intent = json.loads(intent)
707 counter = counter-1
708 time.sleep(1)
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800709
andrewonlaba57a3042015-01-23 13:53:05 -0500710 time.sleep(5)
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800711
andrewonlaba57a3042015-01-23 13:53:05 -0500712 for node in range(1, cluster_count+1):
713 save_dir = base_dir + "batch_intent_"+str(node)+".txt"
714 with open(save_dir) as f_onos:
715 line_count = 0
716 for line in f_onos:
717 line = line[1:]
718 line = line.split(": ")
719 main.log.info("Line read: "+str(line))
720 result = line[1].split(" ")[0]
721 #TODO: add parameters before appending latency
722 if line_count == 0:
723 batch_install_lat.append(int(result))
724 install_result = result
725 elif line_count == 1:
726 batch_withdraw_lat.append(int(result))
727 withdraw_result = result
728 line_count += 1
729 main.log.info("Batch install latency for ONOS"+
730 str(node)+" with "+\
731 str(batch_intent_size) + "intents: "+\
732 str(install_result)+" ms")
733 main.log.info("Batch withdraw latency for ONOS"+
734 str(node)+" with "+
735 str(batch_intent_size) + "intents: "+
736 str(withdraw_result)+" ms")
andrewonlabeb1d0542014-12-03 20:12:01 -0500737
andrewonlaba57a3042015-01-23 13:53:05 -0500738 if len(batch_install_lat) > 0 and int(i) > num_ignore:
739 max_install_lat.append(max(batch_install_lat))
740 elif len(batch_install_lat) == 0:
741 #If I failed to read anything from the file,
742 #increase the wait time before checking intents
743 sleep_time += 30
744 if len(batch_withdraw_lat) > 0 and int(i) > num_ignore:
745 max_withdraw_lat.append(max(batch_withdraw_lat))
746 batch_install_lat = []
747 batch_withdraw_lat = []
748
749 #Sleep in between iterations
750 time.sleep(5)
751
752 if max_install_lat:
753 avg_install_lat = str(sum(max_install_lat) /\
754 len(max_install_lat))
755 else:
756 avg_install_lat = "NA"
757 main.log.report("Batch installation failed")
758 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500759
andrewonlaba57a3042015-01-23 13:53:05 -0500760 if max_withdraw_lat:
761 avg_withdraw_lat = str(sum(max_withdraw_lat) /\
762 len(max_withdraw_lat))
763 else:
764 avg_withdraw_lat = "NA"
765 main.log.report("Batch withdraw failed")
766 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500767
andrewonlaba57a3042015-01-23 13:53:05 -0500768 main.log.report("Avg of batch installation latency "+
769 "of size "+batch_intent_size+": "+
770 str(avg_install_lat)+" ms")
771 main.log.report("Std Deviation of batch installation latency "+
772 ": "+str(numpy.std(max_install_lat))+" ms")
andrewonlabeb1d0542014-12-03 20:12:01 -0500773
andrewonlaba57a3042015-01-23 13:53:05 -0500774 main.log.report("Avg of batch withdraw latency "+
775 "of size "+batch_intent_size+": "+
776 str(avg_withdraw_lat)+" ms")
777 main.log.report("Std Deviation of batch withdraw latency "+
778 ": "+str(numpy.std(max_withdraw_lat))+" ms")
779
780 batch_intent_size += 1000
781 main.log.report("Increasing batch intent size to "+
782 batch_intent_size)
783
784 #main.log.info("Removing all intents for next test case")
785 #json_temp = main.ONOS1cli.intents(json_format=True)
786 #json_obj_intents = json.loads(json_temp)
787 #if json_obj_intents:
788 # for intents in json_obj_intents:
789 # temp_id = intents['id']
790 #main.ONOS1cli.remove_intent(temp_id)
791 # main.ONOS1cli.remove_intent(temp_id)
792
793 utilities.assert_equals(expect=main.TRUE, actual=assertion,
794 onpass="Batch intent install/withdraw test successful",
795 onfail="Batch intent install/withdraw test failed")
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800796
andrewonlaba57a3042015-01-23 13:53:05 -0500797 def CASE5(self,main):
798 '''
andrewonlab4293dcb2014-12-02 15:48:05 -0500799 Increase number of nodes and initiate CLI
andrewonlaba57a3042015-01-23 13:53:05 -0500800 '''
andrewonlab4293dcb2014-12-02 15:48:05 -0500801 import time
802 import json
803
andrewonlaba57a3042015-01-23 13:53:05 -0500804 ONOS1_ip = main.params['CTRL']['ip1']
805 ONOS2_ip = main.params['CTRL']['ip2']
806 ONOS3_ip = main.params['CTRL']['ip3']
807 ONOS4_ip = main.params['CTRL']['ip4']
808 ONOS5_ip = main.params['CTRL']['ip5']
809 ONOS6_ip = main.params['CTRL']['ip6']
810 ONOS7_ip = main.params['CTRL']['ip7']
andrewonlab4293dcb2014-12-02 15:48:05 -0500811
812 global cluster_count
813 cluster_count += 2
andrewonlaba57a3042015-01-23 13:53:05 -0500814 main.log.report("Increasing cluster size to "+
815 str(cluster_count))
andrewonlab4293dcb2014-12-02 15:48:05 -0500816
817 install_result = main.FALSE
818
819 if cluster_count == 3:
820 install_result1 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500821 main.ONOSbench.onos_install(node=ONOS2_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -0500822 install_result2 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500823 main.ONOSbench.onos_install(node=ONOS3_ip)
824 time.sleep(5)
andrewonlab4293dcb2014-12-02 15:48:05 -0500825
andrewonlaba57a3042015-01-23 13:53:05 -0500826 main.log.info("Starting ONOS CLI")
827 main.ONOS2cli.start_onos_cli(ONOS2_ip)
828 main.ONOS3cli.start_onos_cli(ONOS3_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -0500829
830 install_result = install_result1 and install_result2
831
832 if cluster_count == 5:
andrewonlaba57a3042015-01-23 13:53:05 -0500833 main.log.info("Installing ONOS on node 4 and 5")
andrewonlab4293dcb2014-12-02 15:48:05 -0500834 install_result1 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500835 main.ONOSbench.onos_install(node=ONOS4_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -0500836 install_result2 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500837 main.ONOSbench.onos_install(node=ONOS5_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -0500838
andrewonlaba57a3042015-01-23 13:53:05 -0500839 main.log.info("Starting ONOS CLI")
840 main.ONOS4cli.start_onos_cli(ONOS4_ip)
841 main.ONOS5cli.start_onos_cli(ONOS5_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -0500842
843 install_result = install_result1 and install_result2
844
845 if cluster_count == 7:
andrewonlaba57a3042015-01-23 13:53:05 -0500846 main.log.info("Installing ONOS on node 6 and 7")
andrewonlab4293dcb2014-12-02 15:48:05 -0500847 install_result1 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500848 main.ONOSbench.onos_install(node=ONOS6_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -0500849 install_result2 = \
andrewonlaba57a3042015-01-23 13:53:05 -0500850 main.ONOSbench.onos_install(node=ONOS7_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -0500851
andrewonlaba57a3042015-01-23 13:53:05 -0500852 main.log.info("Starting ONOS CLI")
853 main.ONOS6cli.start_onos_cli(ONOS6_ip)
854 main.ONOS7cli.start_onos_cli(ONOS7_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -0500855
856 install_result = install_result1 and install_result2
857
andrewonlaba57a3042015-01-23 13:53:05 -0500858 time.sleep(5)
andrewonlab4293dcb2014-12-02 15:48:05 -0500859
860 if install_result == main.TRUE:
861 assertion = main.TRUE
862 else:
863 assertion = main.FALSE
864
andrewonlaba57a3042015-01-23 13:53:05 -0500865 utilities.assert_equals(expect=main.TRUE, actual=assertion,
866 onpass="Scale out to "+str(cluster_count)+\
867 " nodes successful",
868 onfail="Scale out to "+str(cluster_count)+\
869 " nodes failed")
870
871 def CASE7(self, main):
872 #TODO: Fix for scale-out scenario
andrewonlab4293dcb2014-12-02 15:48:05 -0500873
andrewonlaba57a3042015-01-23 13:53:05 -0500874 '''
875 Batch intent reroute latency
876 '''
877 import time
878 import json
879 import requests
880 import os
881 import numpy
882 global cluster_count
883
884 ONOS_ip_list = []
885 for i in range(1, 8):
886 ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
887
888 ONOS_user = main.params['CTRL']['user']
889 default_sw_port = main.params['CTRL']['port1']
890
891 batch_intent_size = main.params['TEST']['batchIntentSize']
892 batch_thresh_min = int(main.params['TEST']['batchThresholdMin'])
893 batch_thresh_max = int(main.params['TEST']['batchThresholdMax'])
894 intfs = main.params['TEST']['intfs']
895 install_time = main.params['JSON']['installedTime']
896
897 #number of iterations of case
898 num_iter = main.params['TEST']['numIter']
899 num_ignore = int(main.params['TEST']['numIgnore'])
900 num_switch = int(main.params['TEST']['numSwitch'])
901 n_thread = main.params['TEST']['numMult']
902
903 main.log.report("Batch intent installation test of "+
904 batch_intent_size +" intents")
905
906 batch_result_list = []
907
908 time.sleep(10)
909
910 main.log.info("Getting list of available devices")
911 device_id_list = []
912 json_str = main.ONOS1cli.devices()
913 json_obj = json.loads(json_str)
914 for device in json_obj:
915 device_id_list.append(device['id'])
916
917 batch_install_lat = []
918 batch_withdraw_lat = []
919 sleep_time = 10
920
921 base_dir = "/tmp/"
922 max_install_lat = []
923
924 for i in range(0, int(num_iter)):
925 main.log.info("Pushing "+
926 str(int(batch_intent_size)*int(n_thread))+
927 " intents. Iteration "+str(i))
928
929 main.ONOSbench.push_test_intents_shell(
930 device_id_list[0]+"/2",
931 device_id_list[7]+"/2",
932 batch_intent_size, "/tmp/batch_install.txt",
933 ONOS_ip_list[0], num_mult="1", app_id="1",
934 report=False, options="--install")
935 #main.ONOSbench.push_test_intents_shell(
936 # "of:0000000000001002/1",
937 # "of:0000000000002002/1",
938 # 133, "/tmp/temp2.txt", "10.128.174.2",
939 # num_mult="6", app_id="2",report=False)
940
941 #TODO: Check for installation success then proceed
942 time.sleep(30)
943
944 #NOTE: this interface is specific to
945 # topo-intentFlower.py topology
946 # reroute case.
947 main.log.info("Disabling interface "+intfs)
948 main.Mininet1.handle.sendline(
949 "sh ifconfig "+intfs+" down")
950 t0_system = time.time()*1000
951
952 #TODO: Wait sufficient time for intents to install
953 time.sleep(10)
954
955 #TODO: get intent installation time
956
957 #Obtain metrics from ONOS 1, 2, 3
958 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
959 intents_json_obj_1 = json.loads(intents_json_str_1)
960 #Parse values from the json object
961 intent_install_1 = \
962 intents_json_obj_1[install_time]['value']
963 intent_reroute_lat_1 = \
964 int(intent_install_1) - int(t0_system)
965
966
967 if cluster_count == 3:
968 intents_json_str_2 =\
969 main.ONOS2cli.intents_events_metrics()
970 intents_json_str_3 =\
971 main.ONOS3cli.intents_events_metrics()
972 intents_json_obj_2 = json.loads(intents_json_str_2)
973 intents_json_obj_3 = json.loads(intents_json_str_3)
974 intent_install_2 = \
975 intents_json_obj_2[install_time]['value']
976 intent_install_3 = \
977 intents_json_obj_3[install_time]['value']
978 intent_reroute_lat_2 = \
979 int(intent_install_2) - int(t0_system)
980 intent_reroute_lat_3 = \
981 int(intent_install_3) - int(t0_system)
982 else:
983 intent_reroute_lat_2 = 0
984 intent_reroute_lat_3 = 0
985
986 if cluster_count == 5:
987 intents_json_str_4 =\
988 main.ONOS4cli.intents_events_metrics()
989 intents_json_str_5 =\
990 main.ONOS5cli.intents_events_metrics()
991 intents_json_obj_4 = json.loads(intents_json_str_4)
992 intents_json_obj_5 = json.loads(intents_json_str_5)
993 intent_install_4 = \
994 intents_json_obj_4[install_time]['value']
995 intent_install_5 = \
996 intents_json_obj_5[install_time]['value']
997 intent_reroute_lat_4 = \
998 int(intent_install_4) - int(t0_system)
999 intent_reroute_lat_5 = \
1000 int(intent_install_5) - int(t0_system)
1001 else:
1002 intent_reroute_lat_4 = 0
1003 intent_reroute_lat_5 = 0
1004
1005 if cluster_count == 7:
1006 intents_json_str_6 =\
1007 main.ONOS6cli.intents_events_metrics()
1008 intents_json_str_7 =\
1009 main.ONOS7cli.intents_events_metrics()
1010 intents_json_obj_6 = json.loads(intents_json_str_6)
1011 intents_json_obj_7 = json.loads(intents_json_str_7)
1012 intent_install_6 = \
1013 intents_json_obj_6[install_time]['value']
1014 intent_install_7 = \
1015 intents_json_obj_7[install_time]['value']
1016 intent_reroute_lat_6 = \
1017 int(intent_install_6) - int(t0_system)
1018 intent_reroute_lat_7 = \
1019 int(intent_install_7) - int(t0_system)
1020 else:
1021 intent_reroute_lat_6 = 0
1022 intent_reroute_lat_7 = 0
1023
1024 intent_reroute_lat_avg = \
1025 (intent_reroute_lat_1 +
1026 intent_reroute_lat_2 +
1027 intent_reroute_lat_3 +
1028 intent_reroute_lat_4 +
1029 intent_reroute_lat_5 +
1030 intent_reroute_lat_6 +
1031 intent_reroute_lat_7) / cluster_count
1032
1033 main.log.info("Intent reroute latency avg for iteration "+
1034 str(i)+": "+str(intent_reroute_lat_avg))
1035 #TODO: Remove intents for next iteration
1036
1037 time.sleep(5)
1038
1039 intents_str = main.ONOS1cli.intents()
1040 intents_json = json.loads(intents_str)
1041 for intents in intents_json:
1042 intent_id = intents['id']
1043 #TODO: make sure this removes all intents
1044 #print intent_id
1045 if intent_id:
1046 main.ONOS1cli.remove_intent(intent_id)
1047
1048 main.Mininet1.handle.sendline(
1049 "sh ifconfig "+intfs+" up")
1050
1051 main.log.info("Intents removed and port back up")
1052
1053 def CASE9(self, main):
andrewonlabeb1d0542014-12-03 20:12:01 -05001054 count = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001055 sw_num1 = 1
andrewonlabeb1d0542014-12-03 20:12:01 -05001056 sw_num2 = 1
1057 appid = 0
1058 port_num1 = 1
1059 port_num2 = 1
andrewonlaba57a3042015-01-23 13:53:05 -05001060
1061 time.sleep(30)
andrewonlab4cf9dd22014-11-18 21:28:38 -05001062
andrewonlabeb1d0542014-12-03 20:12:01 -05001063 while True:
andrewonlaba57a3042015-01-23 13:53:05 -05001064 #main.ONOS1cli.push_test_intents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001065 #"of:0000000000001001/1",
1066 #"of:0000000000002001/1",
andrewonlaba57a3042015-01-23 13:53:05 -05001067 # 100, num_mult="10", app_id="1")
1068 #main.ONOS2cli.push_test_intents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001069 # "of:0000000000001002/1",
1070 # "of:0000000000002002/1",
andrewonlaba57a3042015-01-23 13:53:05 -05001071 # 100, num_mult="10", app_id="2")
1072 #main.ONOS2cli.push_test_intents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001073 # "of:0000000000001003/1",
1074 # "of:0000000000002003/1",
andrewonlaba57a3042015-01-23 13:53:05 -05001075 # 100, num_mult="10", app_id="3")
andrewonlabeb1d0542014-12-03 20:12:01 -05001076 count += 1
andrewonlaba57a3042015-01-23 13:53:05 -05001077
andrewonlabeb1d0542014-12-03 20:12:01 -05001078 if count >= 100:
1079 main.ONOSbench.handle.sendline(
andrewonlaba57a3042015-01-23 13:53:05 -05001080 "onos 10.128.174.1 intents-events-metrics >>"+\
1081 " /tmp/metrics_intents_temp.txt &")
andrewonlabeb1d0542014-12-03 20:12:01 -05001082 count = 0
1083
andrewonlaba57a3042015-01-23 13:53:05 -05001084 arg1 = "of:000000000000100"+str(sw_num1)+"/"+str(port_num1)
1085 arg2 = "of:000000000000200"+str(sw_num2)+"/"+str(port_num2)
1086
andrewonlabeb1d0542014-12-03 20:12:01 -05001087 sw_num1 += 1
1088
1089 if sw_num1 > 7:
1090 sw_num1 = 1
1091 sw_num2 += 1
1092 if sw_num2 > 7:
1093 appid += 1
1094
1095 if sw_num2 > 7:
1096 sw_num2 = 1
andrewonlaba57a3042015-01-23 13:53:05 -05001097
andrewonlabeb1d0542014-12-03 20:12:01 -05001098 main.ONOSbench.push_test_intents_shell(
1099 arg1,
andrewonlaba57a3042015-01-23 13:53:05 -05001100 arg2,
andrewonlab042b3912014-12-10 16:40:50 -05001101 100, "/tmp/temp.txt", "10.128.174.1",
andrewonlaba57a3042015-01-23 13:53:05 -05001102 num_mult="10", app_id=appid,report=False)
1103 #main.ONOSbench.push_test_intents_shell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001104 # "of:0000000000001002/1",
1105 # "of:0000000000002002/1",
1106 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlaba57a3042015-01-23 13:53:05 -05001107 # num_mult="6", app_id="2",report=False)
1108 #main.ONOSbench.push_test_intents_shell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001109 # "of:0000000000001003/1",
1110 # "of:0000000000002003/1",
1111 # 133, "/tmp/temp3.txt", "10.128.174.3",
andrewonlaba57a3042015-01-23 13:53:05 -05001112 # num_mult="6", app_id="3",report=False)
1113
1114 time.sleep(0.2)
andrewonlab92ea3672014-11-04 20:22:14 -05001115