andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 1 | #Intent Performance Test for ONOS-next |
| 2 | # |
| 3 | #andrew@onlab.us |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 4 | # |
| 5 | #November 5, 2014 |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 6 | |
| 7 | class IntentPerfNext: |
| 8 | def __init__(self): |
| 9 | self.default = "" |
| 10 | |
| 11 | def CASE1(self, main): |
| 12 | ''' |
| 13 | ONOS startup sequence |
| 14 | ''' |
| 15 | |
| 16 | import time |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 17 | global cluster_count |
| 18 | cluster_count = 1 |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 19 | |
| 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'] |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 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'] |
| 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 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 41 | 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( |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 48 | BENCH_ip, cell_name, MN1_ip, |
| 49 | "onos-core,onos-app-metrics,onos-gui", |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 50 | #ONOS1_ip, ONOS2_ip, ONOS3_ip) |
| 51 | ONOS1_ip) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 52 | |
| 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 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 57 | main.step("Removing raft logs") |
| 58 | main.ONOSbench.onos_remove_raft_logs() |
| 59 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 60 | 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 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 75 | main.log.report("Commit information - ") |
| 76 | main.ONOSbench.get_version(report=True) |
| 77 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 78 | 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) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 83 | #install2_result = main.ONOSbench.onos_install(node=ONOS2_ip) |
| 84 | #install3_result = main.ONOSbench.onos_install(node=ONOS3_ip) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 85 | |
| 86 | main.step("Set cell for ONOScli env") |
| 87 | main.ONOS1cli.set_cell(cell_name) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 88 | #main.ONOS2cli.set_cell(cell_name) |
| 89 | #main.ONOS3cli.set_cell(cell_name) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 90 | |
| 91 | time.sleep(5) |
| 92 | |
| 93 | main.step("Start onos cli") |
| 94 | cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 95 | #cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 96 | #cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 97 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 98 | 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\ |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 102 | install1_result, #and install2_result and\ |
| 103 | #install3_result, |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 104 | 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 |
| 116 | |
| 117 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 118 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 119 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 120 | ONOS_user = main.params['CTRL']['user'] |
| 121 | |
| 122 | default_sw_port = main.params['CTRL']['port1'] |
| 123 | |
| 124 | #number of iterations of case |
| 125 | num_iter = main.params['TEST']['numIter'] |
| 126 | |
| 127 | #Timestamp keys for json metrics output |
| 128 | submit_time = main.params['JSON']['submittedTime'] |
| 129 | install_time = main.params['JSON']['installedTime'] |
| 130 | wdRequest_time = main.params['JSON']['wdRequestTime'] |
| 131 | withdrawn_time = main.params['JSON']['withdrawnTime'] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 132 | |
| 133 | intent_add_lat_list = [] |
| 134 | |
| 135 | #Assign 'linear' switch format for basic intent testing |
| 136 | main.Mininet1.assign_sw_controller( |
| 137 | sw="1", ip1=ONOS1_ip,port1=default_sw_port) |
| 138 | main.Mininet1.assign_sw_controller( |
| 139 | sw="2", ip1=ONOS2_ip,port1=default_sw_port) |
| 140 | main.Mininet1.assign_sw_controller( |
| 141 | sw="3", ip1=ONOS2_ip,port1=default_sw_port) |
| 142 | main.Mininet1.assign_sw_controller( |
| 143 | sw="4", ip1=ONOS2_ip,port1=default_sw_port) |
| 144 | main.Mininet1.assign_sw_controller( |
| 145 | sw="5", ip1=ONOS3_ip,port1=default_sw_port) |
| 146 | |
| 147 | time.sleep(10) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 148 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 149 | devices_json_str = main.ONOS1cli.devices() |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 150 | devices_json_obj = json.loads(devices_json_str) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 151 | device_id_list = [] |
| 152 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 153 | #Obtain device id list in ONOS format. |
| 154 | #They should already be in order (1,2,3,10,11,12,13, etc) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 155 | for device in devices_json_obj: |
| 156 | device_id_list.append(device['id']) |
| 157 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 158 | for i in range(0, int(num_iter)): |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 159 | #add_point_intent(ingr_device, egr_device, |
| 160 | # ingr_port, egr_port) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 161 | main.ONOS1cli.add_point_intent( |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 162 | device_id_list[0]+"/1", device_id_list[4]+"/1") |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 163 | |
| 164 | #Allow some time for intents to propagate |
| 165 | time.sleep(5) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 166 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 167 | #Obtain metrics from ONOS 1, 2, 3 |
| 168 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
| 169 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 170 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 171 | |
| 172 | intents_json_obj_1 = json.loads(intents_json_str_1) |
| 173 | intents_json_obj_2 = json.loads(intents_json_str_2) |
| 174 | intents_json_obj_3 = json.loads(intents_json_str_3) |
| 175 | |
| 176 | #Parse values from the json object |
| 177 | intent_submit_1 = \ |
| 178 | intents_json_obj_1[submit_time]['value'] |
| 179 | intent_submit_2 = \ |
| 180 | intents_json_obj_2[submit_time]['value'] |
| 181 | intent_submit_3 = \ |
| 182 | intents_json_obj_3[submit_time]['value'] |
| 183 | |
| 184 | intent_install_1 = \ |
| 185 | intents_json_obj_1[install_time]['value'] |
| 186 | intent_install_2 = \ |
| 187 | intents_json_obj_2[install_time]['value'] |
| 188 | intent_install_3 = \ |
| 189 | intents_json_obj_3[install_time]['value'] |
| 190 | |
| 191 | intent_install_lat_1 = \ |
| 192 | int(intent_install_1) - int(intent_submit_1) |
| 193 | intent_install_lat_2 = \ |
| 194 | int(intent_install_2) - int(intent_submit_2) |
| 195 | intent_install_lat_3 = \ |
| 196 | int(intent_install_3) - int(intent_submit_3) |
| 197 | |
| 198 | intent_install_lat_avg = \ |
| 199 | (intent_install_lat_1 + |
| 200 | intent_install_lat_2 + |
| 201 | intent_install_lat_3 ) / 3 |
| 202 | |
| 203 | main.log.info("Intent add latency avg for iteration "+str(i)+ |
| 204 | ": "+str(intent_install_lat_avg)) |
| 205 | |
| 206 | if intent_install_lat_avg > 0.0 and \ |
| 207 | intent_install_lat_avg < 1000: |
| 208 | intent_add_lat_list.append(intent_install_lat_avg) |
| 209 | else: |
| 210 | main.log.info("Intent add latency exceeded "+ |
| 211 | "threshold. Skipping iteration "+str(i)) |
| 212 | |
| 213 | time.sleep(3) |
| 214 | |
| 215 | #TODO: Possibly put this in the driver function |
| 216 | main.log.info("Removing intents for next iteration") |
| 217 | json_temp = \ |
| 218 | main.ONOS1cli.intents(json_format=True) |
| 219 | json_obj_intents = json.loads(json_temp) |
| 220 | if json_obj_intents: |
| 221 | for intents in json_obj_intents: |
| 222 | temp_id = intents['id'] |
| 223 | main.ONOS1cli.remove_intent(temp_id) |
| 224 | main.log.info("Removing intent id: "+ |
| 225 | str(temp_id)) |
| 226 | main.ONOS1cli.remove_intent(temp_id) |
| 227 | else: |
| 228 | main.log.info("Intents were not installed correctly") |
| 229 | |
| 230 | time.sleep(5) |
| 231 | |
| 232 | intent_add_lat_min = min(intent_add_lat_list) |
| 233 | intent_add_lat_max = max(intent_add_lat_list) |
| 234 | intent_add_lat_avg = sum(intent_add_lat_list) /\ |
| 235 | len(intent_add_lat_list) |
| 236 | #END ITERATION FOR LOOP |
| 237 | main.log.report("Single intent add latency - \n"+ |
| 238 | "Min: "+str(intent_add_lat_min)+" ms\n"+ |
| 239 | "Max: "+str(intent_add_lat_max)+" ms\n"+ |
| 240 | "Avg: "+str(intent_add_lat_avg)+" ms\n") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 241 | |
| 242 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 243 | def CASE3(self, main): |
| 244 | ''' |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 245 | Intent Reroute latency |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 246 | ''' |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 247 | import time |
| 248 | import json |
| 249 | import requests |
| 250 | import os |
| 251 | |
| 252 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 253 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 254 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 255 | ONOS_user = main.params['CTRL']['user'] |
| 256 | |
| 257 | default_sw_port = main.params['CTRL']['port1'] |
| 258 | |
| 259 | #number of iterations of case |
| 260 | num_iter = main.params['TEST']['numIter'] |
| 261 | |
| 262 | #Timestamp keys for json metrics output |
| 263 | submit_time = main.params['JSON']['submittedTime'] |
| 264 | install_time = main.params['JSON']['installedTime'] |
| 265 | wdRequest_time = main.params['JSON']['wdRequestTime'] |
| 266 | withdrawn_time = main.params['JSON']['withdrawnTime'] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 267 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 268 | devices_json_str = main.ONOS1cli.devices() |
| 269 | devices_json_obj = json.loads(devices_json_str) |
| 270 | |
| 271 | device_id_list = [] |
| 272 | |
| 273 | #Obtain device id list in ONOS format. |
| 274 | #They should already be in order (1,2,3,10,11,12,13, etc) |
| 275 | for device in devices_json_obj: |
| 276 | device_id_list.append(device['id']) |
| 277 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 278 | intent_reroute_lat_list = [] |
| 279 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 280 | print device_id_list |
| 281 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 282 | for i in range(0, int(num_iter)): |
| 283 | #add_point_intent(ingr_device, ingr_port, |
| 284 | # egr_device, egr_port) |
| 285 | main.ONOS1cli.add_point_intent( |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 286 | device_id_list[0]+"/2", device_id_list[4]+"/1") |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 287 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 288 | time.sleep(5) |
| 289 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 290 | intents_str = main.ONOS1cli.intents(json_format=True) |
| 291 | intents_obj = json.loads(intents_str) |
| 292 | for intent in intents_obj: |
| 293 | if intent['state'] == "INSTALLED": |
| 294 | main.log.info("Intent installed successfully") |
| 295 | intent_id = intent['id'] |
| 296 | else: |
| 297 | #TODO: Add error handling |
| 298 | main.log.info("Intent installation failed") |
| 299 | intent_id = "" |
| 300 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 301 | #NOTE: this interface is specific to |
| 302 | # topo-intentFlower.py topology |
| 303 | # reroute case. |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 304 | main.log.info("Disabling interface s2-eth3 <--> s4") |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 305 | main.Mininet1.handle.sendline( |
| 306 | "sh ifconfig s2-eth3 down") |
| 307 | t0_system = time.time()*1000 |
| 308 | |
| 309 | #TODO: Check for correct intent reroute |
| 310 | time.sleep(5) |
| 311 | |
| 312 | #Obtain metrics from ONOS 1, 2, 3 |
| 313 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
| 314 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 315 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 316 | |
| 317 | intents_json_obj_1 = json.loads(intents_json_str_1) |
| 318 | intents_json_obj_2 = json.loads(intents_json_str_2) |
| 319 | intents_json_obj_3 = json.loads(intents_json_str_3) |
| 320 | |
| 321 | #Parse values from the json object |
| 322 | intent_install_1 = \ |
| 323 | intents_json_obj_1[install_time]['value'] |
| 324 | intent_install_2 = \ |
| 325 | intents_json_obj_2[install_time]['value'] |
| 326 | intent_install_3 = \ |
| 327 | intents_json_obj_3[install_time]['value'] |
| 328 | |
| 329 | intent_reroute_lat_1 = \ |
| 330 | int(intent_install_1) - int(t0_system) |
| 331 | intent_reroute_lat_2 = \ |
| 332 | int(intent_install_2) - int(t0_system) |
| 333 | intent_reroute_lat_3 = \ |
| 334 | int(intent_install_3) - int(t0_system) |
| 335 | |
| 336 | intent_reroute_lat_avg = \ |
| 337 | (intent_reroute_lat_1 + |
| 338 | intent_reroute_lat_2 + |
| 339 | intent_reroute_lat_3 ) / 3 |
| 340 | |
| 341 | main.log.info("Intent reroute latency avg for iteration "+ |
| 342 | str(i)+": "+str(intent_reroute_lat_avg)) |
| 343 | |
| 344 | if intent_reroute_lat_avg > 0.0 and \ |
| 345 | intent_reroute_lat_avg < 1000: |
| 346 | intent_reroute_lat_list.append(intent_reroute_lat_avg) |
| 347 | else: |
| 348 | main.log.info("Intent reroute latency exceeded "+ |
| 349 | "threshold. Skipping iteration "+str(i)) |
| 350 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 351 | #TODO: Possibly put this in the driver function |
| 352 | main.log.info("Removing intents for next iteration") |
| 353 | |
| 354 | #NOTE: TODO: Currently, the remove intent will |
| 355 | # not trigger the intent request |
| 356 | # timestamp. Thus we cannot use the same |
| 357 | # intent to get the latency over iterations. |
| 358 | # we can 1) install different intents every |
| 359 | # time, or 2) look into state machine and |
| 360 | # determine what timestsamp to get |
| 361 | main.ONOS1cli.remove_intent(intent_id) |
| 362 | |
| 363 | #TODO: Report framework |
| 364 | print intent_reroute_lat_list |
| 365 | |
| 366 | |
| 367 | def CASE4(self, main): |
| 368 | import time |
| 369 | import json |
| 370 | import requests |
| 371 | import os |
| 372 | |
| 373 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 374 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 375 | ONOS3_ip = main.params['CTRL']['ip3'] |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 376 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 377 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 378 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 379 | ONOS7_ip = main.params['CTRL']['ip7'] |
| 380 | |
| 381 | ONOS_ip_list = [] |
| 382 | for i in range(1, 8): |
| 383 | ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)]) |
| 384 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 385 | ONOS_user = main.params['CTRL']['user'] |
| 386 | |
| 387 | default_sw_port = main.params['CTRL']['port1'] |
| 388 | |
| 389 | batch_intent_size = main.params['TEST']['batchIntentSize'] |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 390 | batch_thresh_min = int(main.params['TEST']['batchThresholdMin']) |
| 391 | batch_thresh_max = int(main.params['TEST']['batchThresholdMax']) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 392 | |
| 393 | #number of iterations of case |
| 394 | num_iter = main.params['TEST']['numIter'] |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 395 | num_switch = int(main.params['TEST']['numSwitch']) |
| 396 | n_thread = main.params['TEST']['numMult'] |
| 397 | |
| 398 | #***** |
| 399 | global cluster_count |
| 400 | #***** |
| 401 | |
| 402 | #Switch assignment NOTE: hardcoded |
| 403 | if cluster_count == 1: |
| 404 | for i in range(1, num_switch+1): |
| 405 | main.Mininet1.assign_sw_controller( |
| 406 | sw=str(i), |
| 407 | ip1=ONOS1_ip, |
| 408 | port1=default_sw_port) |
| 409 | if cluster_count == 3: |
| 410 | for i in range(1, 3): |
| 411 | main.Mininet1.assign_sw_controller( |
| 412 | sw=str(i), |
| 413 | ip1=ONOS1_ip, |
| 414 | port1=default_sw_port) |
| 415 | for i in range(3, 6): |
| 416 | main.Mininet1.assign_sw_controller( |
| 417 | sw=str(i), |
| 418 | ip1=ONOS2_ip, |
| 419 | port1=default_sw_port) |
| 420 | for i in range(6, 9): |
| 421 | main.Mininet1.assign_sw_controller( |
| 422 | sw=str(i), |
| 423 | ip1=ONOS3_ip, |
| 424 | port1=default_sw_port) |
| 425 | if cluster_count == 5: |
| 426 | main.Mininet1.assign_sw_controller( |
| 427 | sw="1", |
| 428 | ip1=ONOS1_ip, |
| 429 | port1=default_sw_port) |
| 430 | main.Mininet1.assign_sw_controller( |
| 431 | sw="2", |
| 432 | ip1=ONOS2_ip, |
| 433 | port1=default_sw_port) |
| 434 | for i in range(3, 6): |
| 435 | main.Mininet1.assign_sw_controller( |
| 436 | sw=str(i), |
| 437 | ip1=ONOS3_ip, |
| 438 | port1=default_sw_port) |
| 439 | main.Mininet1.assign_sw_controller( |
| 440 | sw="6", |
| 441 | ip1=ONOS4_ip, |
| 442 | port1=default_sw_port) |
| 443 | main.Mininet1.assign_sw_controller( |
| 444 | sw="7", |
| 445 | ip1=ONOS5_ip, |
| 446 | port1=default_sw_port) |
| 447 | main.Mininet1.assign_sw_controller( |
| 448 | sw="8", |
| 449 | ip1=ONOS5_ip, |
| 450 | port1=default_sw_port) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 451 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 452 | if cluster_count == 7: |
| 453 | for i in range(1,9): |
| 454 | if i < 7: |
| 455 | main.Mininet1.assign_sw_controller( |
| 456 | sw=str(i), |
| 457 | ip1=ONOS_ip_list[i-1], |
| 458 | port1=default_sw_port) |
| 459 | elif i >= 8: |
| 460 | main.Mininet1.assign_sw_controller( |
| 461 | sw=str(i), |
| 462 | ip1=ONOS_ip_list[6], |
| 463 | port1=default_sw_port) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 464 | |
| 465 | main.log.report("Batch intent installation test of "+ |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 466 | batch_intent_size +" intents") |
| 467 | |
| 468 | batch_result_list = [] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 469 | |
| 470 | main.log.info("Getting list of available devices") |
| 471 | device_id_list = [] |
| 472 | json_str = main.ONOS1cli.devices() |
| 473 | json_obj = json.loads(json_str) |
| 474 | for device in json_obj: |
| 475 | device_id_list.append(device['id']) |
| 476 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 477 | batch_install_lat = [] |
| 478 | batch_withdraw_lat = [] |
| 479 | |
| 480 | base_dir = "/tmp/" |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 481 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 482 | for i in range(0, int(num_iter)): |
| 483 | main.log.info("Pushing "+ |
| 484 | str(int(batch_intent_size)*int(n_thread))+ |
| 485 | " intents. Iteration "+str(i)) |
| 486 | |
| 487 | for node in range(1, cluster_count+1): |
| 488 | save_dir = base_dir + "batch_intent_"+str(node)+".txt" |
| 489 | main.ONOSbench.push_test_intents_shell( |
| 490 | "of:0000000000000001/"+str(node), |
| 491 | "of:0000000000000008/"+str(node), |
| 492 | batch_intent_size, save_dir, ONOS_ip_list[node-1], |
| 493 | num_mult=n_thread, app_id=node) |
| 494 | |
| 495 | time.sleep(120 / int(cluster_count)) |
| 496 | for node in range(1, cluster_count+1): |
| 497 | with open(save_dir) as f_onos: |
andrewonlab | 28b84eb | 2014-12-02 15:53:35 -0500 | [diff] [blame] | 498 | line_count = 0 |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 499 | for line in f_onos: |
| 500 | line = line[1:] |
| 501 | line = line.split(": ") |
| 502 | result = line[1].split(" ")[0] |
| 503 | #TODO: add parameters before appending latency |
| 504 | if line_count == 0: |
| 505 | batch_install_lat.append(result) |
| 506 | elif line_count == 1: |
| 507 | batch_withdraw_lat.append(result) |
| 508 | line_count += 1 |
| 509 | main.log.info("Batch install latency for ONOS"+ |
| 510 | str(node)+" with "+\ |
| 511 | str(batch_intent_size) + "intents: "+\ |
| 512 | str(batch_install_lat)) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 513 | time.sleep(5) |
| 514 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 515 | main.log.report("Max of batch installation latency "+ |
| 516 | "for ONOS" + str(node)+ ": "+ |
| 517 | str(max(batch_install_lat))) |
| 518 | |
| 519 | def CASE5(self,main): |
| 520 | ''' |
| 521 | Increase number of nodes and initiate CLI |
| 522 | ''' |
| 523 | import time |
| 524 | import json |
| 525 | |
| 526 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 527 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 528 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 529 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 530 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 531 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 532 | ONOS7_ip = main.params['CTRL']['ip7'] |
| 533 | |
| 534 | global cluster_count |
| 535 | cluster_count += 2 |
| 536 | main.log.info("Increasing cluster size to "+ |
| 537 | str(cluster_count)) |
| 538 | |
| 539 | install_result = main.FALSE |
| 540 | |
| 541 | if cluster_count == 3: |
| 542 | install_result1 = \ |
| 543 | main.ONOSbench.onos_install(node=ONOS2_ip) |
| 544 | install_result2 = \ |
| 545 | main.ONOSbench.onos_install(node=ONOS3_ip) |
| 546 | time.sleep(5) |
| 547 | |
| 548 | main.log.info("Starting ONOS CLI") |
| 549 | main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 550 | main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 551 | |
| 552 | install_result = install_result1 and install_result2 |
| 553 | |
| 554 | if cluster_count == 5: |
| 555 | main.log.info("Installing ONOS on node 4 and 5") |
| 556 | install_result1 = \ |
| 557 | main.ONOSbench.onos_install(node=ONOS4_ip) |
| 558 | install_result2 = \ |
| 559 | main.ONOSbench.onos_install(node=ONOS5_ip) |
| 560 | |
| 561 | main.log.info("Starting ONOS CLI") |
| 562 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 563 | main.ONOS5cli.start_onos_cli(ONOS5_ip) |
| 564 | |
| 565 | install_result = install_result1 and install_result2 |
| 566 | |
| 567 | if cluster_count == 7: |
| 568 | main.log.info("Installing ONOS on node 6 and 7") |
| 569 | install_result1 = \ |
| 570 | main.ONOSbench.onos_install(node=ONOS6_ip) |
| 571 | install_result2 = \ |
| 572 | main.ONOSbench.onos_install(node=ONOS7_ip) |
| 573 | |
| 574 | main.log.info("Starting ONOS CLI") |
| 575 | main.ONOS6cli.start_onos_cli(ONOS6_ip) |
| 576 | main.ONOS7cli.start_onos_cli(ONOS7_ip) |
| 577 | |
| 578 | install_result = install_result1 and install_result2 |
| 579 | |
| 580 | time.sleep(5) |
| 581 | |
| 582 | if install_result == main.TRUE: |
| 583 | assertion = main.TRUE |
| 584 | else: |
| 585 | assertion = main.FALSE |
| 586 | |
| 587 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 588 | onpass="Scale out to "+str(cluster_count)+\ |
| 589 | " nodes successful", |
| 590 | onfail="Scale out to "+str(cluster_count)+\ |
| 591 | " nodes failed") |
| 592 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 593 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 594 | |