blob: 5c8bb2fdf0ca6697646471ca71862752e3fd02e1 [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
andrewonlab4293dcb2014-12-02 15:48:05 -050017 global cluster_count
18 cluster_count = 1
andrewonlab92ea3672014-11-04 20:22:14 -050019
20 cell_name = main.params['ENV']['cellName']
21
22 git_pull = main.params['GIT']['autoPull']
23 checkout_branch = main.params['GIT']['checkout']
24
25 ONOS1_ip = main.params['CTRL']['ip1']
26 ONOS2_ip = main.params['CTRL']['ip2']
27 ONOS3_ip = main.params['CTRL']['ip3']
andrewonlab4293dcb2014-12-02 15:48:05 -050028 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']
32
33 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)
40
andrewonlab92ea3672014-11-04 20:22:14 -050041 MN1_ip = main.params['MN']['ip1']
42 BENCH_ip = main.params['BENCH']['ip']
43
44 main.case("Setting up test environment")
45
46 main.step("Creating cell file")
47 cell_file_result = main.ONOSbench.create_cell_file(
andrewonlab4cf9dd22014-11-18 21:28:38 -050048 BENCH_ip, cell_name, MN1_ip,
49 "onos-core,onos-app-metrics,onos-gui",
andrewonlab4293dcb2014-12-02 15:48:05 -050050 #ONOS1_ip, ONOS2_ip, ONOS3_ip)
51 ONOS1_ip)
andrewonlab92ea3672014-11-04 20:22:14 -050052
53 main.step("Applying cell file to environment")
54 cell_apply_result = main.ONOSbench.set_cell(cell_name)
55 verify_cell_result = main.ONOSbench.verify_cell()
56
andrewonlab4293dcb2014-12-02 15:48:05 -050057 main.step("Removing raft logs")
58 main.ONOSbench.onos_remove_raft_logs()
59
andrewonlab92ea3672014-11-04 20:22:14 -050060 main.step("Git checkout and pull "+checkout_branch)
61 if git_pull == 'on':
62 checkout_result = \
63 main.ONOSbench.git_checkout(checkout_branch)
64 pull_result = main.ONOSbench.git_pull()
65
66 #If you used git pull, auto compile
67 main.step("Using onos-build to compile ONOS")
68 build_result = main.ONOSbench.onos_build()
69 else:
70 checkout_result = main.TRUE
71 pull_result = main.TRUE
72 build_result = main.TRUE
73 main.log.info("Git pull skipped by configuration")
74
andrewonlab4cf9dd22014-11-18 21:28:38 -050075 main.log.report("Commit information - ")
76 main.ONOSbench.get_version(report=True)
77
andrewonlab92ea3672014-11-04 20:22:14 -050078 main.step("Creating ONOS package")
79 package_result = main.ONOSbench.onos_package()
80
81 main.step("Installing ONOS package")
82 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -050083 #install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
84 #install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
andrewonlab92ea3672014-11-04 20:22:14 -050085
86 main.step("Set cell for ONOScli env")
87 main.ONOS1cli.set_cell(cell_name)
andrewonlab4293dcb2014-12-02 15:48:05 -050088 #main.ONOS2cli.set_cell(cell_name)
89 #main.ONOS3cli.set_cell(cell_name)
andrewonlab92ea3672014-11-04 20:22:14 -050090
91 time.sleep(5)
92
93 main.step("Start onos cli")
94 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
andrewonlab4293dcb2014-12-02 15:48:05 -050095 #cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
96 #cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
andrewonlab92ea3672014-11-04 20:22:14 -050097
andrewonlab92ea3672014-11-04 20:22:14 -050098 utilities.assert_equals(expect=main.TRUE,
99 actual = cell_file_result and cell_apply_result and\
100 verify_cell_result and checkout_result and\
101 pull_result and build_result and\
andrewonlab4293dcb2014-12-02 15:48:05 -0500102 install1_result, #and install2_result and\
103 #install3_result,
andrewonlab92ea3672014-11-04 20:22:14 -0500104 onpass="ONOS started successfully",
105 onfail="Failed to start ONOS")
106
107 def CASE2(self, main):
108 '''
109 Single intent add latency
110
111 '''
112 import time
113 import json
114 import requests
115 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500116 import numpy
andrewonlab92ea3672014-11-04 20:22:14 -0500117
118 ONOS1_ip = main.params['CTRL']['ip1']
119 ONOS2_ip = main.params['CTRL']['ip2']
120 ONOS3_ip = main.params['CTRL']['ip3']
121 ONOS_user = main.params['CTRL']['user']
122
123 default_sw_port = main.params['CTRL']['port1']
124
125 #number of iterations of case
126 num_iter = main.params['TEST']['numIter']
andrewonlabeb1d0542014-12-03 20:12:01 -0500127 num_ignore = int(main.params['TEST']['numIgnore'])
andrewonlab92ea3672014-11-04 20:22:14 -0500128
129 #Timestamp keys for json metrics output
130 submit_time = main.params['JSON']['submittedTime']
131 install_time = main.params['JSON']['installedTime']
132 wdRequest_time = main.params['JSON']['wdRequestTime']
133 withdrawn_time = main.params['JSON']['withdrawnTime']
andrewonlab70decc02014-11-19 18:50:23 -0500134
135 intent_add_lat_list = []
136
137 #Assign 'linear' switch format for basic intent testing
138 main.Mininet1.assign_sw_controller(
139 sw="1", ip1=ONOS1_ip,port1=default_sw_port)
140 main.Mininet1.assign_sw_controller(
141 sw="2", ip1=ONOS2_ip,port1=default_sw_port)
142 main.Mininet1.assign_sw_controller(
143 sw="3", ip1=ONOS2_ip,port1=default_sw_port)
144 main.Mininet1.assign_sw_controller(
145 sw="4", ip1=ONOS2_ip,port1=default_sw_port)
146 main.Mininet1.assign_sw_controller(
147 sw="5", ip1=ONOS3_ip,port1=default_sw_port)
148
149 time.sleep(10)
andrewonlab92ea3672014-11-04 20:22:14 -0500150
andrewonlabeb1d0542014-12-03 20:12:01 -0500151 main.log.report("Single intent add latency test")
152
andrewonlab8790abb2014-11-06 13:51:54 -0500153 devices_json_str = main.ONOS1cli.devices()
andrewonlab92ea3672014-11-04 20:22:14 -0500154 devices_json_obj = json.loads(devices_json_str)
andrewonlab92ea3672014-11-04 20:22:14 -0500155 device_id_list = []
156
andrewonlab8790abb2014-11-06 13:51:54 -0500157 #Obtain device id list in ONOS format.
158 #They should already be in order (1,2,3,10,11,12,13, etc)
andrewonlab92ea3672014-11-04 20:22:14 -0500159 for device in devices_json_obj:
160 device_id_list.append(device['id'])
161
andrewonlab8790abb2014-11-06 13:51:54 -0500162 for i in range(0, int(num_iter)):
andrewonlab4cf9dd22014-11-18 21:28:38 -0500163 #add_point_intent(ingr_device, egr_device,
164 # ingr_port, egr_port)
andrewonlab8790abb2014-11-06 13:51:54 -0500165 main.ONOS1cli.add_point_intent(
andrewonlab70decc02014-11-19 18:50:23 -0500166 device_id_list[0]+"/1", device_id_list[4]+"/1")
andrewonlab8790abb2014-11-06 13:51:54 -0500167
168 #Allow some time for intents to propagate
169 time.sleep(5)
andrewonlab92ea3672014-11-04 20:22:14 -0500170
andrewonlab8790abb2014-11-06 13:51:54 -0500171 #Obtain metrics from ONOS 1, 2, 3
172 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
173 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
174 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
175
176 intents_json_obj_1 = json.loads(intents_json_str_1)
177 intents_json_obj_2 = json.loads(intents_json_str_2)
178 intents_json_obj_3 = json.loads(intents_json_str_3)
179
180 #Parse values from the json object
181 intent_submit_1 = \
182 intents_json_obj_1[submit_time]['value']
183 intent_submit_2 = \
184 intents_json_obj_2[submit_time]['value']
185 intent_submit_3 = \
186 intents_json_obj_3[submit_time]['value']
187
188 intent_install_1 = \
189 intents_json_obj_1[install_time]['value']
190 intent_install_2 = \
191 intents_json_obj_2[install_time]['value']
192 intent_install_3 = \
193 intents_json_obj_3[install_time]['value']
194
195 intent_install_lat_1 = \
196 int(intent_install_1) - int(intent_submit_1)
197 intent_install_lat_2 = \
198 int(intent_install_2) - int(intent_submit_2)
199 intent_install_lat_3 = \
200 int(intent_install_3) - int(intent_submit_3)
201
202 intent_install_lat_avg = \
203 (intent_install_lat_1 +
204 intent_install_lat_2 +
205 intent_install_lat_3 ) / 3
206
207 main.log.info("Intent add latency avg for iteration "+str(i)+
andrewonlabeb1d0542014-12-03 20:12:01 -0500208 ": "+str(intent_install_lat_avg)+" ms")
andrewonlab8790abb2014-11-06 13:51:54 -0500209
210 if intent_install_lat_avg > 0.0 and \
andrewonlabeb1d0542014-12-03 20:12:01 -0500211 intent_install_lat_avg < 1000 and i > num_ignore:
andrewonlab8790abb2014-11-06 13:51:54 -0500212 intent_add_lat_list.append(intent_install_lat_avg)
213 else:
214 main.log.info("Intent add latency exceeded "+
215 "threshold. Skipping iteration "+str(i))
216
217 time.sleep(3)
218
219 #TODO: Possibly put this in the driver function
220 main.log.info("Removing intents for next iteration")
221 json_temp = \
222 main.ONOS1cli.intents(json_format=True)
223 json_obj_intents = json.loads(json_temp)
224 if json_obj_intents:
225 for intents in json_obj_intents:
226 temp_id = intents['id']
227 main.ONOS1cli.remove_intent(temp_id)
228 main.log.info("Removing intent id: "+
229 str(temp_id))
230 main.ONOS1cli.remove_intent(temp_id)
231 else:
232 main.log.info("Intents were not installed correctly")
233
234 time.sleep(5)
235
andrewonlab8790abb2014-11-06 13:51:54 -0500236 intent_add_lat_avg = sum(intent_add_lat_list) /\
237 len(intent_add_lat_list)
andrewonlabeb1d0542014-12-03 20:12:01 -0500238 intent_add_lat_std = \
239 round(numpy.std(intent_add_lat_list),1)
andrewonlab8790abb2014-11-06 13:51:54 -0500240 #END ITERATION FOR LOOP
andrewonlab042b3912014-12-10 16:40:50 -0500241 main.log.report("Single intent add latency - ")
242 main.log.report("Avg: "+str(intent_add_lat_avg)+" ms")
243 main.log.report("Std Deviation: "+str(intent_add_lat_std)+" ms")
andrewonlab92ea3672014-11-04 20:22:14 -0500244
andrewonlab8790abb2014-11-06 13:51:54 -0500245 def CASE3(self, main):
246 '''
andrewonlab4cf9dd22014-11-18 21:28:38 -0500247 Intent Reroute latency
andrewonlab8790abb2014-11-06 13:51:54 -0500248 '''
andrewonlab4cf9dd22014-11-18 21:28:38 -0500249 import time
250 import json
251 import requests
252 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500253 import numpy
andrewonlab4cf9dd22014-11-18 21:28:38 -0500254
255 ONOS1_ip = main.params['CTRL']['ip1']
256 ONOS2_ip = main.params['CTRL']['ip2']
257 ONOS3_ip = main.params['CTRL']['ip3']
258 ONOS_user = main.params['CTRL']['user']
259
260 default_sw_port = main.params['CTRL']['port1']
261
262 #number of iterations of case
263 num_iter = main.params['TEST']['numIter']
andrewonlabeb1d0542014-12-03 20:12:01 -0500264 num_ignore = int(main.params['TEST']['numIgnore'])
andrewonlab4cf9dd22014-11-18 21:28:38 -0500265
266 #Timestamp keys for json metrics output
267 submit_time = main.params['JSON']['submittedTime']
268 install_time = main.params['JSON']['installedTime']
269 wdRequest_time = main.params['JSON']['wdRequestTime']
270 withdrawn_time = main.params['JSON']['withdrawnTime']
andrewonlab70decc02014-11-19 18:50:23 -0500271
andrewonlab4cf9dd22014-11-18 21:28:38 -0500272 devices_json_str = main.ONOS1cli.devices()
273 devices_json_obj = json.loads(devices_json_str)
274
275 device_id_list = []
276
277 #Obtain device id list in ONOS format.
278 #They should already be in order (1,2,3,10,11,12,13, etc)
279 for device in devices_json_obj:
280 device_id_list.append(device['id'])
281
andrewonlab4cf9dd22014-11-18 21:28:38 -0500282 intent_reroute_lat_list = []
283
284 for i in range(0, int(num_iter)):
285 #add_point_intent(ingr_device, ingr_port,
286 # egr_device, egr_port)
andrewonlabeb1d0542014-12-03 20:12:01 -0500287 if len(device_id_list) > 0:
288 main.ONOS1cli.add_point_intent(
289 device_id_list[0]+"/2", device_id_list[4]+"/1")
290 else:
291 main.log.info("Failed to fetch devices from ONOS")
292
andrewonlab4cf9dd22014-11-18 21:28:38 -0500293 time.sleep(5)
294
andrewonlab70decc02014-11-19 18:50:23 -0500295 intents_str = main.ONOS1cli.intents(json_format=True)
296 intents_obj = json.loads(intents_str)
297 for intent in intents_obj:
298 if intent['state'] == "INSTALLED":
299 main.log.info("Intent installed successfully")
300 intent_id = intent['id']
301 else:
302 #TODO: Add error handling
303 main.log.info("Intent installation failed")
304 intent_id = ""
305
andrewonlab4cf9dd22014-11-18 21:28:38 -0500306 #NOTE: this interface is specific to
307 # topo-intentFlower.py topology
308 # reroute case.
andrewonlab042b3912014-12-10 16:40:50 -0500309 main.log.info("Disabling interface s2-eth3")
andrewonlab4cf9dd22014-11-18 21:28:38 -0500310 main.Mininet1.handle.sendline(
311 "sh ifconfig s2-eth3 down")
312 t0_system = time.time()*1000
313
314 #TODO: Check for correct intent reroute
315 time.sleep(5)
316
317 #Obtain metrics from ONOS 1, 2, 3
318 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
319 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
320 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
321
322 intents_json_obj_1 = json.loads(intents_json_str_1)
323 intents_json_obj_2 = json.loads(intents_json_str_2)
324 intents_json_obj_3 = json.loads(intents_json_str_3)
325
326 #Parse values from the json object
327 intent_install_1 = \
328 intents_json_obj_1[install_time]['value']
329 intent_install_2 = \
330 intents_json_obj_2[install_time]['value']
331 intent_install_3 = \
332 intents_json_obj_3[install_time]['value']
333
334 intent_reroute_lat_1 = \
335 int(intent_install_1) - int(t0_system)
336 intent_reroute_lat_2 = \
337 int(intent_install_2) - int(t0_system)
338 intent_reroute_lat_3 = \
339 int(intent_install_3) - int(t0_system)
340
341 intent_reroute_lat_avg = \
342 (intent_reroute_lat_1 +
343 intent_reroute_lat_2 +
344 intent_reroute_lat_3 ) / 3
345
346 main.log.info("Intent reroute latency avg for iteration "+
347 str(i)+": "+str(intent_reroute_lat_avg))
348
349 if intent_reroute_lat_avg > 0.0 and \
andrewonlabeb1d0542014-12-03 20:12:01 -0500350 intent_reroute_lat_avg < 1000 and i > num_ignore:
andrewonlab4cf9dd22014-11-18 21:28:38 -0500351 intent_reroute_lat_list.append(intent_reroute_lat_avg)
352 else:
353 main.log.info("Intent reroute latency exceeded "+
354 "threshold. Skipping iteration "+str(i))
355
andrewonlab70decc02014-11-19 18:50:23 -0500356 main.log.info("Removing intents for next iteration")
andrewonlab70decc02014-11-19 18:50:23 -0500357 main.ONOS1cli.remove_intent(intent_id)
358
andrewonlabeb1d0542014-12-03 20:12:01 -0500359 main.log.info("Bringing Mininet interface up for next "+
360 "iteration")
361 main.Mininet1.handle.sendline(
362 "sh ifconfig s2-eth3 up")
363
364 intent_reroute_lat_avg = sum(intent_reroute_lat_list) /\
365 len(intent_reroute_lat_list)
366 intent_reroute_lat_std = \
367 round(numpy.std(intent_reroute_lat_list),1)
368 #END ITERATION FOR LOOP
andrewonlab042b3912014-12-10 16:40:50 -0500369 main.log.report("Single intent reroute latency - ")
370 main.log.report("Avg: "+str(intent_reroute_lat_avg)+" ms")
371 main.log.report("Std Deviation: "+str(intent_reroute_lat_std)+" ms")
372
373 def CASE7(self, main):
374 '''
375 Batch intent reroute latency
376 '''
377 import time
378 import json
379 import requests
380 import os
381 import numpy
382
383 ONOS_ip_list = []
384 for i in range(1, 8):
385 ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
386
387 ONOS_user = main.params['CTRL']['user']
388 default_sw_port = main.params['CTRL']['port1']
389
390 batch_intent_size = main.params['TEST']['batchIntentSize']
391 batch_thresh_min = int(main.params['TEST']['batchThresholdMin'])
392 batch_thresh_max = int(main.params['TEST']['batchThresholdMax'])
393 install_time = main.params['JSON']['installedTime']
394
395 #number of iterations of case
396 num_iter = main.params['TEST']['numIter']
397 num_ignore = int(main.params['TEST']['numIgnore'])
398 num_switch = int(main.params['TEST']['numSwitch'])
399 n_thread = main.params['TEST']['numMult']
400
401 main.log.report("Batch intent installation test of "+
402 batch_intent_size +" intents")
403
404 batch_result_list = []
405
406 #Assign 'linear' switch format for basic intent testing
407 main.Mininet1.assign_sw_controller(
408 sw="1", ip1=ONOS1_ip,port1=default_sw_port)
409 main.Mininet1.assign_sw_controller(
410 sw="2", ip1=ONOS2_ip,port1=default_sw_port)
411 main.Mininet1.assign_sw_controller(
412 sw="3", ip1=ONOS2_ip,port1=default_sw_port)
413 main.Mininet1.assign_sw_controller(
414 sw="4", ip1=ONOS2_ip,port1=default_sw_port)
415 main.Mininet1.assign_sw_controller(
416 sw="5", ip1=ONOS3_ip,port1=default_sw_port)
417
418 time.sleep(10)
419
420 main.log.info("Getting list of available devices")
421 device_id_list = []
422 json_str = main.ONOS1cli.devices()
423 json_obj = json.loads(json_str)
424 for device in json_obj:
425 device_id_list.append(device['id'])
426
427 batch_install_lat = []
428 batch_withdraw_lat = []
429 sleep_time = 10
430
431 base_dir = "/tmp/"
432 max_install_lat = []
433
434 for i in range(0, int(num_iter)):
435 main.log.info("Pushing "+
436 str(int(batch_intent_size)*int(n_thread))+
437 " intents. Iteration "+str(i))
andrewonlabeb1d0542014-12-03 20:12:01 -0500438
andrewonlab042b3912014-12-10 16:40:50 -0500439 main.ONOS1cli.push_test_intents(
440 "of:0000000000000001/1",
441 "of:0000000000000005/1",
442 1000, num_mult="1", app_id="1")
443
444 #TODO: Check for installation success then proceed
445 time.sleep(30)
446
447 #NOTE: this interface is specific to
448 # topo-intentFlower.py topology
449 # reroute case.
450 main.log.info("Disabling interface s2-eth3")
451 main.Mininet1.handle.sendline(
452 "sh ifconfig s2-eth3 down")
453 t0_system = time.time()*1000
454
455 #TODO: Wait sufficient time for intents to install
456 time.sleep(10)
457
458 #TODO: get intent installation time
459
460 #Obtain metrics from ONOS 1, 2, 3
461 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
462 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
463 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
464
465 intents_json_obj_1 = json.loads(intents_json_str_1)
466 intents_json_obj_2 = json.loads(intents_json_str_2)
467 intents_json_obj_3 = json.loads(intents_json_str_3)
468
469 #Parse values from the json object
470 intent_install_1 = \
471 intents_json_obj_1[install_time]['value']
472 intent_install_2 = \
473 intents_json_obj_2[install_time]['value']
474 intent_install_3 = \
475 intents_json_obj_3[install_time]['value']
476
477 intent_reroute_lat_1 = \
478 int(intent_install_1) - int(t0_system)
479 intent_reroute_lat_2 = \
480 int(intent_install_2) - int(t0_system)
481 intent_reroute_lat_3 = \
482 int(intent_install_3) - int(t0_system)
483
484 intent_reroute_lat_avg = \
485 (intent_reroute_lat_1 +
486 intent_reroute_lat_2 +
487 intent_reroute_lat_3 ) / 3
488
489 main.log.info("Intent reroute latency avg for iteration "+
490 str(i)+": "+str(intent_reroute_lat_avg))
491 #TODO: Remove intents for next iteration
492
493 time.sleep(5)
494
495 intents_str = main.ONOS1cli.intents()
496 intents_json = json.loads(intents_str)
497 for intents in intents_json:
498 intent_id = intents['id']
499 if intent_id:
500 main.ONOS1cli.remove_intent(intent_id)
501
502 main.Mininet1.handle.sendline(
503 "sh ifconfig s2-eth3 up")
504
505 main.log.info("Intents removed and port back up")
506
507
andrewonlab70decc02014-11-19 18:50:23 -0500508 def CASE4(self, main):
andrewonlab042b3912014-12-10 16:40:50 -0500509 '''
510 Batch intent install
511 '''
512
andrewonlab70decc02014-11-19 18:50:23 -0500513 import time
514 import json
515 import requests
516 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500517 import numpy
andrewonlab70decc02014-11-19 18:50:23 -0500518
519 ONOS1_ip = main.params['CTRL']['ip1']
520 ONOS2_ip = main.params['CTRL']['ip2']
521 ONOS3_ip = main.params['CTRL']['ip3']
andrewonlab4293dcb2014-12-02 15:48:05 -0500522 ONOS4_ip = main.params['CTRL']['ip4']
523 ONOS5_ip = main.params['CTRL']['ip5']
524 ONOS6_ip = main.params['CTRL']['ip6']
525 ONOS7_ip = main.params['CTRL']['ip7']
526
527 ONOS_ip_list = []
528 for i in range(1, 8):
529 ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
530
andrewonlab70decc02014-11-19 18:50:23 -0500531 ONOS_user = main.params['CTRL']['user']
532
533 default_sw_port = main.params['CTRL']['port1']
534
535 batch_intent_size = main.params['TEST']['batchIntentSize']
andrewonlab4293dcb2014-12-02 15:48:05 -0500536 batch_thresh_min = int(main.params['TEST']['batchThresholdMin'])
537 batch_thresh_max = int(main.params['TEST']['batchThresholdMax'])
andrewonlab70decc02014-11-19 18:50:23 -0500538
539 #number of iterations of case
540 num_iter = main.params['TEST']['numIter']
andrewonlabeb1d0542014-12-03 20:12:01 -0500541 num_ignore = int(main.params['TEST']['numIgnore'])
andrewonlab4293dcb2014-12-02 15:48:05 -0500542 num_switch = int(main.params['TEST']['numSwitch'])
543 n_thread = main.params['TEST']['numMult']
andrewonlabeb1d0542014-12-03 20:12:01 -0500544 #n_thread = 105
andrewonlab4293dcb2014-12-02 15:48:05 -0500545
546 #*****
547 global cluster_count
548 #*****
549
550 #Switch assignment NOTE: hardcoded
551 if cluster_count == 1:
552 for i in range(1, num_switch+1):
553 main.Mininet1.assign_sw_controller(
554 sw=str(i),
555 ip1=ONOS1_ip,
556 port1=default_sw_port)
557 if cluster_count == 3:
558 for i in range(1, 3):
559 main.Mininet1.assign_sw_controller(
560 sw=str(i),
561 ip1=ONOS1_ip,
562 port1=default_sw_port)
563 for i in range(3, 6):
564 main.Mininet1.assign_sw_controller(
565 sw=str(i),
566 ip1=ONOS2_ip,
567 port1=default_sw_port)
568 for i in range(6, 9):
569 main.Mininet1.assign_sw_controller(
570 sw=str(i),
571 ip1=ONOS3_ip,
572 port1=default_sw_port)
573 if cluster_count == 5:
574 main.Mininet1.assign_sw_controller(
575 sw="1",
576 ip1=ONOS1_ip,
577 port1=default_sw_port)
578 main.Mininet1.assign_sw_controller(
579 sw="2",
580 ip1=ONOS2_ip,
581 port1=default_sw_port)
582 for i in range(3, 6):
583 main.Mininet1.assign_sw_controller(
584 sw=str(i),
585 ip1=ONOS3_ip,
586 port1=default_sw_port)
587 main.Mininet1.assign_sw_controller(
588 sw="6",
589 ip1=ONOS4_ip,
590 port1=default_sw_port)
591 main.Mininet1.assign_sw_controller(
592 sw="7",
593 ip1=ONOS5_ip,
594 port1=default_sw_port)
595 main.Mininet1.assign_sw_controller(
596 sw="8",
597 ip1=ONOS5_ip,
598 port1=default_sw_port)
andrewonlab70decc02014-11-19 18:50:23 -0500599
andrewonlab4293dcb2014-12-02 15:48:05 -0500600 if cluster_count == 7:
601 for i in range(1,9):
andrewonlabeb1d0542014-12-03 20:12:01 -0500602 if i < 8:
andrewonlab4293dcb2014-12-02 15:48:05 -0500603 main.Mininet1.assign_sw_controller(
604 sw=str(i),
605 ip1=ONOS_ip_list[i-1],
606 port1=default_sw_port)
607 elif i >= 8:
608 main.Mininet1.assign_sw_controller(
609 sw=str(i),
610 ip1=ONOS_ip_list[6],
611 port1=default_sw_port)
andrewonlab70decc02014-11-19 18:50:23 -0500612
andrewonlabeb1d0542014-12-03 20:12:01 -0500613 time.sleep(30)
614
andrewonlab70decc02014-11-19 18:50:23 -0500615 main.log.report("Batch intent installation test of "+
andrewonlab4293dcb2014-12-02 15:48:05 -0500616 batch_intent_size +" intents")
617
618 batch_result_list = []
andrewonlab70decc02014-11-19 18:50:23 -0500619
620 main.log.info("Getting list of available devices")
621 device_id_list = []
622 json_str = main.ONOS1cli.devices()
623 json_obj = json.loads(json_str)
624 for device in json_obj:
625 device_id_list.append(device['id'])
626
andrewonlab4293dcb2014-12-02 15:48:05 -0500627 batch_install_lat = []
628 batch_withdraw_lat = []
andrewonlabeb1d0542014-12-03 20:12:01 -0500629 sleep_time = 10
andrewonlab4293dcb2014-12-02 15:48:05 -0500630
631 base_dir = "/tmp/"
andrewonlabeb1d0542014-12-03 20:12:01 -0500632 max_install_lat = []
andrewonlab70decc02014-11-19 18:50:23 -0500633
andrewonlab4293dcb2014-12-02 15:48:05 -0500634 for i in range(0, int(num_iter)):
635 main.log.info("Pushing "+
636 str(int(batch_intent_size)*int(n_thread))+
637 " intents. Iteration "+str(i))
andrewonlabeb1d0542014-12-03 20:12:01 -0500638
andrewonlab4293dcb2014-12-02 15:48:05 -0500639 for node in range(1, cluster_count+1):
640 save_dir = base_dir + "batch_intent_"+str(node)+".txt"
641 main.ONOSbench.push_test_intents_shell(
642 "of:0000000000000001/"+str(node),
643 "of:0000000000000008/"+str(node),
andrewonlabeb1d0542014-12-03 20:12:01 -0500644 int(batch_intent_size),
645 save_dir, ONOS_ip_list[node-1],
andrewonlab4293dcb2014-12-02 15:48:05 -0500646 num_mult=n_thread, app_id=node)
andrewonlabeb1d0542014-12-03 20:12:01 -0500647
648 #Wait sufficient time for intents to start
649 #installing
650
651 time.sleep(sleep_time)
652 print sleep_time
653
654 intent = ""
655 counter = 300
656 while len(intent) > 0 and counter > 0:
657 main.ONOS1cli.handle.sendline(
658 "intents | wc -l")
659 main.ONOS1cli.handle.expect(
660 "intents | wc -l")
661 main.ONOS1cli.handle.expect(
662 "onos>")
663 intent_temp = main.ONOS1cli.handle.before()
664 print intent_temp
665
666 intent = main.ONOS1cli.intents()
667 intent = json.loads(intent)
668 counter = counter-1
669 time.sleep(1)
670
671 time.sleep(5)
672
andrewonlab4293dcb2014-12-02 15:48:05 -0500673 for node in range(1, cluster_count+1):
andrewonlabeb1d0542014-12-03 20:12:01 -0500674 save_dir = base_dir + "batch_intent_"+str(node)+".txt"
andrewonlab4293dcb2014-12-02 15:48:05 -0500675 with open(save_dir) as f_onos:
andrewonlab28b84eb2014-12-02 15:53:35 -0500676 line_count = 0
andrewonlab4293dcb2014-12-02 15:48:05 -0500677 for line in f_onos:
678 line = line[1:]
679 line = line.split(": ")
680 result = line[1].split(" ")[0]
681 #TODO: add parameters before appending latency
682 if line_count == 0:
andrewonlabeb1d0542014-12-03 20:12:01 -0500683 batch_install_lat.append(int(result))
andrewonlab4293dcb2014-12-02 15:48:05 -0500684 elif line_count == 1:
andrewonlabeb1d0542014-12-03 20:12:01 -0500685 batch_withdraw_lat.append(int(result))
andrewonlab4293dcb2014-12-02 15:48:05 -0500686 line_count += 1
687 main.log.info("Batch install latency for ONOS"+
688 str(node)+" with "+\
689 str(batch_intent_size) + "intents: "+\
690 str(batch_install_lat))
andrewonlabeb1d0542014-12-03 20:12:01 -0500691
692 if len(batch_install_lat) > 0 and int(i) > num_ignore:
693 max_install_lat.append(max(batch_install_lat))
694 elif len(batch_install_lat) == 0:
695 #If I failed to read anything from the file,
696 #increase the wait time before checking intents
697 sleep_time += 30
698 batch_install_lat = []
699
700 #Sleep in between iterations
andrewonlab70decc02014-11-19 18:50:23 -0500701 time.sleep(5)
702
andrewonlabeb1d0542014-12-03 20:12:01 -0500703 main.log.report("Avg of batch installation latency "+
704 ": "+
705 str(sum(max_install_lat) / len(max_install_lat)))
706 main.log.report("Std Deviation of batch installation latency "+
707 ": "+
708 str(numpy.std(max_install_lat)))
709
andrewonlab4293dcb2014-12-02 15:48:05 -0500710 def CASE5(self,main):
711 '''
712 Increase number of nodes and initiate CLI
713 '''
714 import time
715 import json
716
717 ONOS1_ip = main.params['CTRL']['ip1']
718 ONOS2_ip = main.params['CTRL']['ip2']
719 ONOS3_ip = main.params['CTRL']['ip3']
720 ONOS4_ip = main.params['CTRL']['ip4']
721 ONOS5_ip = main.params['CTRL']['ip5']
722 ONOS6_ip = main.params['CTRL']['ip6']
723 ONOS7_ip = main.params['CTRL']['ip7']
724
725 global cluster_count
726 cluster_count += 2
andrewonlab042b3912014-12-10 16:40:50 -0500727 main.log.report("Increasing cluster size to "+
andrewonlab4293dcb2014-12-02 15:48:05 -0500728 str(cluster_count))
729
730 install_result = main.FALSE
731
732 if cluster_count == 3:
733 install_result1 = \
734 main.ONOSbench.onos_install(node=ONOS2_ip)
735 install_result2 = \
736 main.ONOSbench.onos_install(node=ONOS3_ip)
737 time.sleep(5)
738
739 main.log.info("Starting ONOS CLI")
740 main.ONOS2cli.start_onos_cli(ONOS2_ip)
741 main.ONOS3cli.start_onos_cli(ONOS3_ip)
742
743 install_result = install_result1 and install_result2
744
745 if cluster_count == 5:
746 main.log.info("Installing ONOS on node 4 and 5")
747 install_result1 = \
748 main.ONOSbench.onos_install(node=ONOS4_ip)
749 install_result2 = \
750 main.ONOSbench.onos_install(node=ONOS5_ip)
751
752 main.log.info("Starting ONOS CLI")
753 main.ONOS4cli.start_onos_cli(ONOS4_ip)
754 main.ONOS5cli.start_onos_cli(ONOS5_ip)
755
756 install_result = install_result1 and install_result2
757
758 if cluster_count == 7:
759 main.log.info("Installing ONOS on node 6 and 7")
760 install_result1 = \
761 main.ONOSbench.onos_install(node=ONOS6_ip)
762 install_result2 = \
763 main.ONOSbench.onos_install(node=ONOS7_ip)
764
765 main.log.info("Starting ONOS CLI")
766 main.ONOS6cli.start_onos_cli(ONOS6_ip)
767 main.ONOS7cli.start_onos_cli(ONOS7_ip)
768
769 install_result = install_result1 and install_result2
770
771 time.sleep(5)
772
773 if install_result == main.TRUE:
774 assertion = main.TRUE
775 else:
776 assertion = main.FALSE
777
778 utilities.assert_equals(expect=main.TRUE, actual=assertion,
779 onpass="Scale out to "+str(cluster_count)+\
780 " nodes successful",
781 onfail="Scale out to "+str(cluster_count)+\
782 " nodes failed")
783
andrewonlabeb1d0542014-12-03 20:12:01 -0500784 def CASE9(self, main):
785 count = 0
786 sw_num1 = 1
787 sw_num2 = 1
788 appid = 0
789 port_num1 = 1
790 port_num2 = 1
791
792 time.sleep(30)
andrewonlab4cf9dd22014-11-18 21:28:38 -0500793
andrewonlabeb1d0542014-12-03 20:12:01 -0500794 while True:
795 #main.ONOS1cli.push_test_intents(
796 #"of:0000000000001001/1",
797 #"of:0000000000002001/1",
798 # 100, num_mult="10", app_id="1")
799 #main.ONOS2cli.push_test_intents(
800 # "of:0000000000001002/1",
801 # "of:0000000000002002/1",
802 # 100, num_mult="10", app_id="2")
803 #main.ONOS2cli.push_test_intents(
804 # "of:0000000000001003/1",
805 # "of:0000000000002003/1",
806 # 100, num_mult="10", app_id="3")
807 count += 1
808
809 if count >= 100:
810 main.ONOSbench.handle.sendline(
811 "onos 10.128.174.1 intents-events-metrics >>"+\
812 " /tmp/metrics_intents_temp.txt &")
813 count = 0
814
815 arg1 = "of:000000000000100"+str(sw_num1)+"/"+str(port_num1)
816 arg2 = "of:000000000000200"+str(sw_num2)+"/"+str(port_num2)
817
818 sw_num1 += 1
819
820 if sw_num1 > 7:
821 sw_num1 = 1
822 sw_num2 += 1
823 if sw_num2 > 7:
824 appid += 1
825
826 if sw_num2 > 7:
827 sw_num2 = 1
828
829 main.ONOSbench.push_test_intents_shell(
830 arg1,
831 arg2,
andrewonlab042b3912014-12-10 16:40:50 -0500832 100, "/tmp/temp.txt", "10.128.174.1",
andrewonlabeb1d0542014-12-03 20:12:01 -0500833 num_mult="10", app_id=appid,report=False)
834 #main.ONOSbench.push_test_intents_shell(
835 # "of:0000000000001002/1",
836 # "of:0000000000002002/1",
837 # 133, "/tmp/temp2.txt", "10.128.174.2",
838 # num_mult="6", app_id="2",report=False)
839 #main.ONOSbench.push_test_intents_shell(
840 # "of:0000000000001003/1",
841 # "of:0000000000002003/1",
842 # 133, "/tmp/temp3.txt", "10.128.174.3",
843 # num_mult="6", app_id="3",report=False)
844
andrewonlab042b3912014-12-10 16:40:50 -0500845 time.sleep(0.2)
andrewonlab92ea3672014-11-04 20:22:14 -0500846