blob: c212e9e2c09f3f9b38a8fd9c14ad7ef034499f3b [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
241 main.log.report("Single intent add latency - \n"+
andrewonlabeb1d0542014-12-03 20:12:01 -0500242 "Avg: "+str(intent_add_lat_avg)+" ms\n"+
243 "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
andrewonlab70decc02014-11-19 18:50:23 -0500284 print device_id_list
285
andrewonlab4cf9dd22014-11-18 21:28:38 -0500286 for i in range(0, int(num_iter)):
287 #add_point_intent(ingr_device, ingr_port,
288 # egr_device, egr_port)
andrewonlabeb1d0542014-12-03 20:12:01 -0500289 if len(device_id_list) > 0:
290 main.ONOS1cli.add_point_intent(
291 device_id_list[0]+"/2", device_id_list[4]+"/1")
292 else:
293 main.log.info("Failed to fetch devices from ONOS")
294
andrewonlab4cf9dd22014-11-18 21:28:38 -0500295 time.sleep(5)
296
andrewonlab70decc02014-11-19 18:50:23 -0500297 intents_str = main.ONOS1cli.intents(json_format=True)
298 intents_obj = json.loads(intents_str)
299 for intent in intents_obj:
300 if intent['state'] == "INSTALLED":
301 main.log.info("Intent installed successfully")
302 intent_id = intent['id']
303 else:
304 #TODO: Add error handling
305 main.log.info("Intent installation failed")
306 intent_id = ""
307
andrewonlab4cf9dd22014-11-18 21:28:38 -0500308 #NOTE: this interface is specific to
309 # topo-intentFlower.py topology
310 # reroute case.
andrewonlab70decc02014-11-19 18:50:23 -0500311 main.log.info("Disabling interface s2-eth3 <--> s4")
andrewonlab4cf9dd22014-11-18 21:28:38 -0500312 main.Mininet1.handle.sendline(
313 "sh ifconfig s2-eth3 down")
314 t0_system = time.time()*1000
315
316 #TODO: Check for correct intent reroute
317 time.sleep(5)
318
319 #Obtain metrics from ONOS 1, 2, 3
320 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
321 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
322 intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
323
324 intents_json_obj_1 = json.loads(intents_json_str_1)
325 intents_json_obj_2 = json.loads(intents_json_str_2)
326 intents_json_obj_3 = json.loads(intents_json_str_3)
327
328 #Parse values from the json object
329 intent_install_1 = \
330 intents_json_obj_1[install_time]['value']
331 intent_install_2 = \
332 intents_json_obj_2[install_time]['value']
333 intent_install_3 = \
334 intents_json_obj_3[install_time]['value']
335
336 intent_reroute_lat_1 = \
337 int(intent_install_1) - int(t0_system)
338 intent_reroute_lat_2 = \
339 int(intent_install_2) - int(t0_system)
340 intent_reroute_lat_3 = \
341 int(intent_install_3) - int(t0_system)
342
343 intent_reroute_lat_avg = \
344 (intent_reroute_lat_1 +
345 intent_reroute_lat_2 +
346 intent_reroute_lat_3 ) / 3
347
348 main.log.info("Intent reroute latency avg for iteration "+
349 str(i)+": "+str(intent_reroute_lat_avg))
350
351 if intent_reroute_lat_avg > 0.0 and \
andrewonlabeb1d0542014-12-03 20:12:01 -0500352 intent_reroute_lat_avg < 1000 and i > num_ignore:
andrewonlab4cf9dd22014-11-18 21:28:38 -0500353 intent_reroute_lat_list.append(intent_reroute_lat_avg)
354 else:
355 main.log.info("Intent reroute latency exceeded "+
356 "threshold. Skipping iteration "+str(i))
357
andrewonlab70decc02014-11-19 18:50:23 -0500358 #TODO: Possibly put this in the driver function
359 main.log.info("Removing intents for next iteration")
360
361 #NOTE: TODO: Currently, the remove intent will
362 # not trigger the intent request
363 # timestamp. Thus we cannot use the same
364 # intent to get the latency over iterations.
365 # we can 1) install different intents every
366 # time, or 2) look into state machine and
367 # determine what timestsamp to get
368 main.ONOS1cli.remove_intent(intent_id)
369
andrewonlabeb1d0542014-12-03 20:12:01 -0500370 main.log.info("Bringing Mininet interface up for next "+
371 "iteration")
372 main.Mininet1.handle.sendline(
373 "sh ifconfig s2-eth3 up")
374
375 intent_reroute_lat_avg = sum(intent_reroute_lat_list) /\
376 len(intent_reroute_lat_list)
377 intent_reroute_lat_std = \
378 round(numpy.std(intent_reroute_lat_list),1)
379 #END ITERATION FOR LOOP
380 main.log.report("Single intent reroute latency - \n"+
381 "Avg: "+str(intent_reroute_lat_avg)+" ms\n"+
382 "Std Deviation: "+str(intent_reroute_lat_std)+" ms")
383
andrewonlab70decc02014-11-19 18:50:23 -0500384 def CASE4(self, main):
385 import time
386 import json
387 import requests
388 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500389 import numpy
andrewonlab70decc02014-11-19 18:50:23 -0500390
391 ONOS1_ip = main.params['CTRL']['ip1']
392 ONOS2_ip = main.params['CTRL']['ip2']
393 ONOS3_ip = main.params['CTRL']['ip3']
andrewonlab4293dcb2014-12-02 15:48:05 -0500394 ONOS4_ip = main.params['CTRL']['ip4']
395 ONOS5_ip = main.params['CTRL']['ip5']
396 ONOS6_ip = main.params['CTRL']['ip6']
397 ONOS7_ip = main.params['CTRL']['ip7']
398
399 ONOS_ip_list = []
400 for i in range(1, 8):
401 ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)])
402
andrewonlab70decc02014-11-19 18:50:23 -0500403 ONOS_user = main.params['CTRL']['user']
404
405 default_sw_port = main.params['CTRL']['port1']
406
407 batch_intent_size = main.params['TEST']['batchIntentSize']
andrewonlab4293dcb2014-12-02 15:48:05 -0500408 batch_thresh_min = int(main.params['TEST']['batchThresholdMin'])
409 batch_thresh_max = int(main.params['TEST']['batchThresholdMax'])
andrewonlab70decc02014-11-19 18:50:23 -0500410
411 #number of iterations of case
412 num_iter = main.params['TEST']['numIter']
andrewonlabeb1d0542014-12-03 20:12:01 -0500413 num_ignore = int(main.params['TEST']['numIgnore'])
andrewonlab4293dcb2014-12-02 15:48:05 -0500414 num_switch = int(main.params['TEST']['numSwitch'])
415 n_thread = main.params['TEST']['numMult']
andrewonlabeb1d0542014-12-03 20:12:01 -0500416 #n_thread = 105
andrewonlab4293dcb2014-12-02 15:48:05 -0500417
418 #*****
419 global cluster_count
420 #*****
421
422 #Switch assignment NOTE: hardcoded
423 if cluster_count == 1:
424 for i in range(1, num_switch+1):
425 main.Mininet1.assign_sw_controller(
426 sw=str(i),
427 ip1=ONOS1_ip,
428 port1=default_sw_port)
429 if cluster_count == 3:
430 for i in range(1, 3):
431 main.Mininet1.assign_sw_controller(
432 sw=str(i),
433 ip1=ONOS1_ip,
434 port1=default_sw_port)
435 for i in range(3, 6):
436 main.Mininet1.assign_sw_controller(
437 sw=str(i),
438 ip1=ONOS2_ip,
439 port1=default_sw_port)
440 for i in range(6, 9):
441 main.Mininet1.assign_sw_controller(
442 sw=str(i),
443 ip1=ONOS3_ip,
444 port1=default_sw_port)
445 if cluster_count == 5:
446 main.Mininet1.assign_sw_controller(
447 sw="1",
448 ip1=ONOS1_ip,
449 port1=default_sw_port)
450 main.Mininet1.assign_sw_controller(
451 sw="2",
452 ip1=ONOS2_ip,
453 port1=default_sw_port)
454 for i in range(3, 6):
455 main.Mininet1.assign_sw_controller(
456 sw=str(i),
457 ip1=ONOS3_ip,
458 port1=default_sw_port)
459 main.Mininet1.assign_sw_controller(
460 sw="6",
461 ip1=ONOS4_ip,
462 port1=default_sw_port)
463 main.Mininet1.assign_sw_controller(
464 sw="7",
465 ip1=ONOS5_ip,
466 port1=default_sw_port)
467 main.Mininet1.assign_sw_controller(
468 sw="8",
469 ip1=ONOS5_ip,
470 port1=default_sw_port)
andrewonlab70decc02014-11-19 18:50:23 -0500471
andrewonlab4293dcb2014-12-02 15:48:05 -0500472 if cluster_count == 7:
473 for i in range(1,9):
andrewonlabeb1d0542014-12-03 20:12:01 -0500474 if i < 8:
andrewonlab4293dcb2014-12-02 15:48:05 -0500475 main.Mininet1.assign_sw_controller(
476 sw=str(i),
477 ip1=ONOS_ip_list[i-1],
478 port1=default_sw_port)
479 elif i >= 8:
480 main.Mininet1.assign_sw_controller(
481 sw=str(i),
482 ip1=ONOS_ip_list[6],
483 port1=default_sw_port)
andrewonlab70decc02014-11-19 18:50:23 -0500484
andrewonlabeb1d0542014-12-03 20:12:01 -0500485 time.sleep(30)
486
andrewonlab70decc02014-11-19 18:50:23 -0500487 main.log.report("Batch intent installation test of "+
andrewonlab4293dcb2014-12-02 15:48:05 -0500488 batch_intent_size +" intents")
489
490 batch_result_list = []
andrewonlab70decc02014-11-19 18:50:23 -0500491
492 main.log.info("Getting list of available devices")
493 device_id_list = []
494 json_str = main.ONOS1cli.devices()
495 json_obj = json.loads(json_str)
496 for device in json_obj:
497 device_id_list.append(device['id'])
498
andrewonlab4293dcb2014-12-02 15:48:05 -0500499 batch_install_lat = []
500 batch_withdraw_lat = []
andrewonlabeb1d0542014-12-03 20:12:01 -0500501 sleep_time = 10
andrewonlab4293dcb2014-12-02 15:48:05 -0500502
503 base_dir = "/tmp/"
andrewonlabeb1d0542014-12-03 20:12:01 -0500504 max_install_lat = []
andrewonlab70decc02014-11-19 18:50:23 -0500505
andrewonlab4293dcb2014-12-02 15:48:05 -0500506 for i in range(0, int(num_iter)):
507 main.log.info("Pushing "+
508 str(int(batch_intent_size)*int(n_thread))+
509 " intents. Iteration "+str(i))
andrewonlabeb1d0542014-12-03 20:12:01 -0500510
andrewonlab4293dcb2014-12-02 15:48:05 -0500511 for node in range(1, cluster_count+1):
512 save_dir = base_dir + "batch_intent_"+str(node)+".txt"
513 main.ONOSbench.push_test_intents_shell(
514 "of:0000000000000001/"+str(node),
515 "of:0000000000000008/"+str(node),
andrewonlabeb1d0542014-12-03 20:12:01 -0500516 int(batch_intent_size),
517 save_dir, ONOS_ip_list[node-1],
andrewonlab4293dcb2014-12-02 15:48:05 -0500518 num_mult=n_thread, app_id=node)
andrewonlabeb1d0542014-12-03 20:12:01 -0500519
520 #Wait sufficient time for intents to start
521 #installing
522
523 time.sleep(sleep_time)
524 print sleep_time
525
526 intent = ""
527 counter = 300
528 while len(intent) > 0 and counter > 0:
529 main.ONOS1cli.handle.sendline(
530 "intents | wc -l")
531 main.ONOS1cli.handle.expect(
532 "intents | wc -l")
533 main.ONOS1cli.handle.expect(
534 "onos>")
535 intent_temp = main.ONOS1cli.handle.before()
536 print intent_temp
537
538 intent = main.ONOS1cli.intents()
539 intent = json.loads(intent)
540 counter = counter-1
541 time.sleep(1)
542
543 time.sleep(5)
544
andrewonlab4293dcb2014-12-02 15:48:05 -0500545 for node in range(1, cluster_count+1):
andrewonlabeb1d0542014-12-03 20:12:01 -0500546 save_dir = base_dir + "batch_intent_"+str(node)+".txt"
andrewonlab4293dcb2014-12-02 15:48:05 -0500547 with open(save_dir) as f_onos:
andrewonlab28b84eb2014-12-02 15:53:35 -0500548 line_count = 0
andrewonlab4293dcb2014-12-02 15:48:05 -0500549 for line in f_onos:
550 line = line[1:]
551 line = line.split(": ")
552 result = line[1].split(" ")[0]
553 #TODO: add parameters before appending latency
554 if line_count == 0:
andrewonlabeb1d0542014-12-03 20:12:01 -0500555 batch_install_lat.append(int(result))
andrewonlab4293dcb2014-12-02 15:48:05 -0500556 elif line_count == 1:
andrewonlabeb1d0542014-12-03 20:12:01 -0500557 batch_withdraw_lat.append(int(result))
andrewonlab4293dcb2014-12-02 15:48:05 -0500558 line_count += 1
559 main.log.info("Batch install latency for ONOS"+
560 str(node)+" with "+\
561 str(batch_intent_size) + "intents: "+\
562 str(batch_install_lat))
andrewonlabeb1d0542014-12-03 20:12:01 -0500563
564 if len(batch_install_lat) > 0 and int(i) > num_ignore:
565 max_install_lat.append(max(batch_install_lat))
566 elif len(batch_install_lat) == 0:
567 #If I failed to read anything from the file,
568 #increase the wait time before checking intents
569 sleep_time += 30
570 batch_install_lat = []
571
572 #Sleep in between iterations
andrewonlab70decc02014-11-19 18:50:23 -0500573 time.sleep(5)
574
andrewonlabeb1d0542014-12-03 20:12:01 -0500575 main.log.report("Avg of batch installation latency "+
576 ": "+
577 str(sum(max_install_lat) / len(max_install_lat)))
578 main.log.report("Std Deviation of batch installation latency "+
579 ": "+
580 str(numpy.std(max_install_lat)))
581
andrewonlab4293dcb2014-12-02 15:48:05 -0500582 def CASE5(self,main):
583 '''
584 Increase number of nodes and initiate CLI
585 '''
586 import time
587 import json
588
589 ONOS1_ip = main.params['CTRL']['ip1']
590 ONOS2_ip = main.params['CTRL']['ip2']
591 ONOS3_ip = main.params['CTRL']['ip3']
592 ONOS4_ip = main.params['CTRL']['ip4']
593 ONOS5_ip = main.params['CTRL']['ip5']
594 ONOS6_ip = main.params['CTRL']['ip6']
595 ONOS7_ip = main.params['CTRL']['ip7']
596
597 global cluster_count
598 cluster_count += 2
599 main.log.info("Increasing cluster size to "+
600 str(cluster_count))
601
602 install_result = main.FALSE
603
604 if cluster_count == 3:
605 install_result1 = \
606 main.ONOSbench.onos_install(node=ONOS2_ip)
607 install_result2 = \
608 main.ONOSbench.onos_install(node=ONOS3_ip)
609 time.sleep(5)
610
611 main.log.info("Starting ONOS CLI")
612 main.ONOS2cli.start_onos_cli(ONOS2_ip)
613 main.ONOS3cli.start_onos_cli(ONOS3_ip)
614
615 install_result = install_result1 and install_result2
616
617 if cluster_count == 5:
618 main.log.info("Installing ONOS on node 4 and 5")
619 install_result1 = \
620 main.ONOSbench.onos_install(node=ONOS4_ip)
621 install_result2 = \
622 main.ONOSbench.onos_install(node=ONOS5_ip)
623
624 main.log.info("Starting ONOS CLI")
625 main.ONOS4cli.start_onos_cli(ONOS4_ip)
626 main.ONOS5cli.start_onos_cli(ONOS5_ip)
627
628 install_result = install_result1 and install_result2
629
630 if cluster_count == 7:
631 main.log.info("Installing ONOS on node 6 and 7")
632 install_result1 = \
633 main.ONOSbench.onos_install(node=ONOS6_ip)
634 install_result2 = \
635 main.ONOSbench.onos_install(node=ONOS7_ip)
636
637 main.log.info("Starting ONOS CLI")
638 main.ONOS6cli.start_onos_cli(ONOS6_ip)
639 main.ONOS7cli.start_onos_cli(ONOS7_ip)
640
641 install_result = install_result1 and install_result2
642
643 time.sleep(5)
644
645 if install_result == main.TRUE:
646 assertion = main.TRUE
647 else:
648 assertion = main.FALSE
649
650 utilities.assert_equals(expect=main.TRUE, actual=assertion,
651 onpass="Scale out to "+str(cluster_count)+\
652 " nodes successful",
653 onfail="Scale out to "+str(cluster_count)+\
654 " nodes failed")
655
andrewonlabeb1d0542014-12-03 20:12:01 -0500656 def CASE9(self, main):
657 count = 0
658 sw_num1 = 1
659 sw_num2 = 1
660 appid = 0
661 port_num1 = 1
662 port_num2 = 1
663
664 time.sleep(30)
andrewonlab4cf9dd22014-11-18 21:28:38 -0500665
andrewonlabeb1d0542014-12-03 20:12:01 -0500666 while True:
667 #main.ONOS1cli.push_test_intents(
668 #"of:0000000000001001/1",
669 #"of:0000000000002001/1",
670 # 100, num_mult="10", app_id="1")
671 #main.ONOS2cli.push_test_intents(
672 # "of:0000000000001002/1",
673 # "of:0000000000002002/1",
674 # 100, num_mult="10", app_id="2")
675 #main.ONOS2cli.push_test_intents(
676 # "of:0000000000001003/1",
677 # "of:0000000000002003/1",
678 # 100, num_mult="10", app_id="3")
679 count += 1
680
681 if count >= 100:
682 main.ONOSbench.handle.sendline(
683 "onos 10.128.174.1 intents-events-metrics >>"+\
684 " /tmp/metrics_intents_temp.txt &")
685 count = 0
686
687 arg1 = "of:000000000000100"+str(sw_num1)+"/"+str(port_num1)
688 arg2 = "of:000000000000200"+str(sw_num2)+"/"+str(port_num2)
689
690 sw_num1 += 1
691
692 if sw_num1 > 7:
693 sw_num1 = 1
694 sw_num2 += 1
695 if sw_num2 > 7:
696 appid += 1
697
698 if sw_num2 > 7:
699 sw_num2 = 1
700
701 main.ONOSbench.push_test_intents_shell(
702 arg1,
703 arg2,
704 150, "/tmp/temp.txt", "10.128.174.1",
705 num_mult="10", app_id=appid,report=False)
706 #main.ONOSbench.push_test_intents_shell(
707 # "of:0000000000001002/1",
708 # "of:0000000000002002/1",
709 # 133, "/tmp/temp2.txt", "10.128.174.2",
710 # num_mult="6", app_id="2",report=False)
711 #main.ONOSbench.push_test_intents_shell(
712 # "of:0000000000001003/1",
713 # "of:0000000000002003/1",
714 # 133, "/tmp/temp3.txt", "10.128.174.3",
715 # num_mult="6", app_id="3",report=False)
716
717 time.sleep(0.1)
andrewonlab92ea3672014-11-04 20:22:14 -0500718