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 |
| 17 | |
| 18 | cell_name = main.params['ENV']['cellName'] |
| 19 | |
| 20 | git_pull = main.params['GIT']['autoPull'] |
| 21 | checkout_branch = main.params['GIT']['checkout'] |
| 22 | |
| 23 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 24 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 25 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 26 | |
| 27 | MN1_ip = main.params['MN']['ip1'] |
| 28 | BENCH_ip = main.params['BENCH']['ip'] |
| 29 | |
| 30 | main.case("Setting up test environment") |
| 31 | |
| 32 | main.step("Creating cell file") |
| 33 | cell_file_result = main.ONOSbench.create_cell_file( |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 34 | BENCH_ip, cell_name, MN1_ip, |
| 35 | "onos-core,onos-app-metrics,onos-gui", |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 36 | ONOS1_ip, ONOS2_ip, ONOS3_ip) |
| 37 | |
| 38 | main.step("Applying cell file to environment") |
| 39 | cell_apply_result = main.ONOSbench.set_cell(cell_name) |
| 40 | verify_cell_result = main.ONOSbench.verify_cell() |
| 41 | |
| 42 | main.step("Git checkout and pull "+checkout_branch) |
| 43 | if git_pull == 'on': |
| 44 | checkout_result = \ |
| 45 | main.ONOSbench.git_checkout(checkout_branch) |
| 46 | pull_result = main.ONOSbench.git_pull() |
| 47 | |
| 48 | #If you used git pull, auto compile |
| 49 | main.step("Using onos-build to compile ONOS") |
| 50 | build_result = main.ONOSbench.onos_build() |
| 51 | else: |
| 52 | checkout_result = main.TRUE |
| 53 | pull_result = main.TRUE |
| 54 | build_result = main.TRUE |
| 55 | main.log.info("Git pull skipped by configuration") |
| 56 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 57 | main.log.report("Commit information - ") |
| 58 | main.ONOSbench.get_version(report=True) |
| 59 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 60 | main.step("Creating ONOS package") |
| 61 | package_result = main.ONOSbench.onos_package() |
| 62 | |
| 63 | main.step("Installing ONOS package") |
| 64 | install1_result = main.ONOSbench.onos_install(node=ONOS1_ip) |
| 65 | install2_result = main.ONOSbench.onos_install(node=ONOS2_ip) |
| 66 | install3_result = main.ONOSbench.onos_install(node=ONOS3_ip) |
| 67 | |
| 68 | main.step("Set cell for ONOScli env") |
| 69 | main.ONOS1cli.set_cell(cell_name) |
| 70 | main.ONOS2cli.set_cell(cell_name) |
| 71 | main.ONOS3cli.set_cell(cell_name) |
| 72 | |
| 73 | time.sleep(5) |
| 74 | |
| 75 | main.step("Start onos cli") |
| 76 | cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 77 | cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 78 | cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 79 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 80 | utilities.assert_equals(expect=main.TRUE, |
| 81 | actual = cell_file_result and cell_apply_result and\ |
| 82 | verify_cell_result and checkout_result and\ |
| 83 | pull_result and build_result and\ |
| 84 | install1_result and install2_result and\ |
| 85 | install3_result, |
| 86 | onpass="ONOS started successfully", |
| 87 | onfail="Failed to start ONOS") |
| 88 | |
| 89 | def CASE2(self, main): |
| 90 | ''' |
| 91 | Single intent add latency |
| 92 | |
| 93 | ''' |
| 94 | import time |
| 95 | import json |
| 96 | import requests |
| 97 | import os |
| 98 | |
| 99 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 100 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 101 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 102 | ONOS_user = main.params['CTRL']['user'] |
| 103 | |
| 104 | default_sw_port = main.params['CTRL']['port1'] |
| 105 | |
| 106 | #number of iterations of case |
| 107 | num_iter = main.params['TEST']['numIter'] |
| 108 | |
| 109 | #Timestamp keys for json metrics output |
| 110 | submit_time = main.params['JSON']['submittedTime'] |
| 111 | install_time = main.params['JSON']['installedTime'] |
| 112 | wdRequest_time = main.params['JSON']['wdRequestTime'] |
| 113 | withdrawn_time = main.params['JSON']['withdrawnTime'] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 114 | |
| 115 | intent_add_lat_list = [] |
| 116 | |
| 117 | #Assign 'linear' switch format for basic intent testing |
| 118 | main.Mininet1.assign_sw_controller( |
| 119 | sw="1", ip1=ONOS1_ip,port1=default_sw_port) |
| 120 | main.Mininet1.assign_sw_controller( |
| 121 | sw="2", ip1=ONOS2_ip,port1=default_sw_port) |
| 122 | main.Mininet1.assign_sw_controller( |
| 123 | sw="3", ip1=ONOS2_ip,port1=default_sw_port) |
| 124 | main.Mininet1.assign_sw_controller( |
| 125 | sw="4", ip1=ONOS2_ip,port1=default_sw_port) |
| 126 | main.Mininet1.assign_sw_controller( |
| 127 | sw="5", ip1=ONOS3_ip,port1=default_sw_port) |
| 128 | |
| 129 | time.sleep(10) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 130 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 131 | devices_json_str = main.ONOS1cli.devices() |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 132 | devices_json_obj = json.loads(devices_json_str) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 133 | device_id_list = [] |
| 134 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 135 | #Obtain device id list in ONOS format. |
| 136 | #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] | 137 | for device in devices_json_obj: |
| 138 | device_id_list.append(device['id']) |
| 139 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 140 | for i in range(0, int(num_iter)): |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 141 | #add_point_intent(ingr_device, egr_device, |
| 142 | # ingr_port, egr_port) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 143 | main.ONOS1cli.add_point_intent( |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 144 | device_id_list[0]+"/1", device_id_list[4]+"/1") |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 145 | |
| 146 | #Allow some time for intents to propagate |
| 147 | time.sleep(5) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 148 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 149 | #Obtain metrics from ONOS 1, 2, 3 |
| 150 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
| 151 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 152 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 153 | |
| 154 | intents_json_obj_1 = json.loads(intents_json_str_1) |
| 155 | intents_json_obj_2 = json.loads(intents_json_str_2) |
| 156 | intents_json_obj_3 = json.loads(intents_json_str_3) |
| 157 | |
| 158 | #Parse values from the json object |
| 159 | intent_submit_1 = \ |
| 160 | intents_json_obj_1[submit_time]['value'] |
| 161 | intent_submit_2 = \ |
| 162 | intents_json_obj_2[submit_time]['value'] |
| 163 | intent_submit_3 = \ |
| 164 | intents_json_obj_3[submit_time]['value'] |
| 165 | |
| 166 | intent_install_1 = \ |
| 167 | intents_json_obj_1[install_time]['value'] |
| 168 | intent_install_2 = \ |
| 169 | intents_json_obj_2[install_time]['value'] |
| 170 | intent_install_3 = \ |
| 171 | intents_json_obj_3[install_time]['value'] |
| 172 | |
| 173 | intent_install_lat_1 = \ |
| 174 | int(intent_install_1) - int(intent_submit_1) |
| 175 | intent_install_lat_2 = \ |
| 176 | int(intent_install_2) - int(intent_submit_2) |
| 177 | intent_install_lat_3 = \ |
| 178 | int(intent_install_3) - int(intent_submit_3) |
| 179 | |
| 180 | intent_install_lat_avg = \ |
| 181 | (intent_install_lat_1 + |
| 182 | intent_install_lat_2 + |
| 183 | intent_install_lat_3 ) / 3 |
| 184 | |
| 185 | main.log.info("Intent add latency avg for iteration "+str(i)+ |
| 186 | ": "+str(intent_install_lat_avg)) |
| 187 | |
| 188 | if intent_install_lat_avg > 0.0 and \ |
| 189 | intent_install_lat_avg < 1000: |
| 190 | intent_add_lat_list.append(intent_install_lat_avg) |
| 191 | else: |
| 192 | main.log.info("Intent add latency exceeded "+ |
| 193 | "threshold. Skipping iteration "+str(i)) |
| 194 | |
| 195 | time.sleep(3) |
| 196 | |
| 197 | #TODO: Possibly put this in the driver function |
| 198 | main.log.info("Removing intents for next iteration") |
| 199 | json_temp = \ |
| 200 | main.ONOS1cli.intents(json_format=True) |
| 201 | json_obj_intents = json.loads(json_temp) |
| 202 | if json_obj_intents: |
| 203 | for intents in json_obj_intents: |
| 204 | temp_id = intents['id'] |
| 205 | main.ONOS1cli.remove_intent(temp_id) |
| 206 | main.log.info("Removing intent id: "+ |
| 207 | str(temp_id)) |
| 208 | main.ONOS1cli.remove_intent(temp_id) |
| 209 | else: |
| 210 | main.log.info("Intents were not installed correctly") |
| 211 | |
| 212 | time.sleep(5) |
| 213 | |
| 214 | intent_add_lat_min = min(intent_add_lat_list) |
| 215 | intent_add_lat_max = max(intent_add_lat_list) |
| 216 | intent_add_lat_avg = sum(intent_add_lat_list) /\ |
| 217 | len(intent_add_lat_list) |
| 218 | #END ITERATION FOR LOOP |
| 219 | main.log.report("Single intent add latency - \n"+ |
| 220 | "Min: "+str(intent_add_lat_min)+" ms\n"+ |
| 221 | "Max: "+str(intent_add_lat_max)+" ms\n"+ |
| 222 | "Avg: "+str(intent_add_lat_avg)+" ms\n") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 223 | |
| 224 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 225 | def CASE3(self, main): |
| 226 | ''' |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 227 | Intent Reroute latency |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 228 | ''' |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 229 | import time |
| 230 | import json |
| 231 | import requests |
| 232 | import os |
| 233 | |
| 234 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 235 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 236 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 237 | ONOS_user = main.params['CTRL']['user'] |
| 238 | |
| 239 | default_sw_port = main.params['CTRL']['port1'] |
| 240 | |
| 241 | #number of iterations of case |
| 242 | num_iter = main.params['TEST']['numIter'] |
| 243 | |
| 244 | #Timestamp keys for json metrics output |
| 245 | submit_time = main.params['JSON']['submittedTime'] |
| 246 | install_time = main.params['JSON']['installedTime'] |
| 247 | wdRequest_time = main.params['JSON']['wdRequestTime'] |
| 248 | withdrawn_time = main.params['JSON']['withdrawnTime'] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 249 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 250 | devices_json_str = main.ONOS1cli.devices() |
| 251 | devices_json_obj = json.loads(devices_json_str) |
| 252 | |
| 253 | device_id_list = [] |
| 254 | |
| 255 | #Obtain device id list in ONOS format. |
| 256 | #They should already be in order (1,2,3,10,11,12,13, etc) |
| 257 | for device in devices_json_obj: |
| 258 | device_id_list.append(device['id']) |
| 259 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 260 | intent_reroute_lat_list = [] |
| 261 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 262 | print device_id_list |
| 263 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 264 | for i in range(0, int(num_iter)): |
| 265 | #add_point_intent(ingr_device, ingr_port, |
| 266 | # egr_device, egr_port) |
| 267 | main.ONOS1cli.add_point_intent( |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 268 | device_id_list[0]+"/2", device_id_list[4]+"/1") |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 269 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 270 | time.sleep(5) |
| 271 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 272 | intents_str = main.ONOS1cli.intents(json_format=True) |
| 273 | intents_obj = json.loads(intents_str) |
| 274 | for intent in intents_obj: |
| 275 | if intent['state'] == "INSTALLED": |
| 276 | main.log.info("Intent installed successfully") |
| 277 | intent_id = intent['id'] |
| 278 | else: |
| 279 | #TODO: Add error handling |
| 280 | main.log.info("Intent installation failed") |
| 281 | intent_id = "" |
| 282 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 283 | #NOTE: this interface is specific to |
| 284 | # topo-intentFlower.py topology |
| 285 | # reroute case. |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 286 | main.log.info("Disabling interface s2-eth3 <--> s4") |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 287 | main.Mininet1.handle.sendline( |
| 288 | "sh ifconfig s2-eth3 down") |
| 289 | t0_system = time.time()*1000 |
| 290 | |
| 291 | #TODO: Check for correct intent reroute |
| 292 | time.sleep(5) |
| 293 | |
| 294 | #Obtain metrics from ONOS 1, 2, 3 |
| 295 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
| 296 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 297 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 298 | |
| 299 | intents_json_obj_1 = json.loads(intents_json_str_1) |
| 300 | intents_json_obj_2 = json.loads(intents_json_str_2) |
| 301 | intents_json_obj_3 = json.loads(intents_json_str_3) |
| 302 | |
| 303 | #Parse values from the json object |
| 304 | intent_install_1 = \ |
| 305 | intents_json_obj_1[install_time]['value'] |
| 306 | intent_install_2 = \ |
| 307 | intents_json_obj_2[install_time]['value'] |
| 308 | intent_install_3 = \ |
| 309 | intents_json_obj_3[install_time]['value'] |
| 310 | |
| 311 | intent_reroute_lat_1 = \ |
| 312 | int(intent_install_1) - int(t0_system) |
| 313 | intent_reroute_lat_2 = \ |
| 314 | int(intent_install_2) - int(t0_system) |
| 315 | intent_reroute_lat_3 = \ |
| 316 | int(intent_install_3) - int(t0_system) |
| 317 | |
| 318 | intent_reroute_lat_avg = \ |
| 319 | (intent_reroute_lat_1 + |
| 320 | intent_reroute_lat_2 + |
| 321 | intent_reroute_lat_3 ) / 3 |
| 322 | |
| 323 | main.log.info("Intent reroute latency avg for iteration "+ |
| 324 | str(i)+": "+str(intent_reroute_lat_avg)) |
| 325 | |
| 326 | if intent_reroute_lat_avg > 0.0 and \ |
| 327 | intent_reroute_lat_avg < 1000: |
| 328 | intent_reroute_lat_list.append(intent_reroute_lat_avg) |
| 329 | else: |
| 330 | main.log.info("Intent reroute latency exceeded "+ |
| 331 | "threshold. Skipping iteration "+str(i)) |
| 332 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 333 | #TODO: Possibly put this in the driver function |
| 334 | main.log.info("Removing intents for next iteration") |
| 335 | |
| 336 | #NOTE: TODO: Currently, the remove intent will |
| 337 | # not trigger the intent request |
| 338 | # timestamp. Thus we cannot use the same |
| 339 | # intent to get the latency over iterations. |
| 340 | # we can 1) install different intents every |
| 341 | # time, or 2) look into state machine and |
| 342 | # determine what timestsamp to get |
| 343 | main.ONOS1cli.remove_intent(intent_id) |
| 344 | |
| 345 | #TODO: Report framework |
| 346 | print intent_reroute_lat_list |
| 347 | |
| 348 | |
| 349 | def CASE4(self, main): |
| 350 | import time |
| 351 | import json |
| 352 | import requests |
| 353 | import os |
| 354 | |
| 355 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 356 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 357 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 358 | ONOS_user = main.params['CTRL']['user'] |
| 359 | |
| 360 | default_sw_port = main.params['CTRL']['port1'] |
| 361 | |
| 362 | batch_intent_size = main.params['TEST']['batchIntentSize'] |
| 363 | |
| 364 | #number of iterations of case |
| 365 | num_iter = main.params['TEST']['numIter'] |
| 366 | |
| 367 | main.Mininet1.assign_sw_controller( |
| 368 | sw="1", ip1=ONOS1_ip,port1=default_sw_port) |
| 369 | main.Mininet1.assign_sw_controller( |
| 370 | sw="2", ip1=ONOS2_ip,port1=default_sw_port) |
| 371 | main.Mininet1.assign_sw_controller( |
| 372 | sw="3", ip1=ONOS2_ip,port1=default_sw_port) |
| 373 | main.Mininet1.assign_sw_controller( |
| 374 | sw="4", ip1=ONOS2_ip,port1=default_sw_port) |
| 375 | main.Mininet1.assign_sw_controller( |
| 376 | sw="5", ip1=ONOS3_ip,port1=default_sw_port) |
| 377 | |
| 378 | main.log.report("Batch intent installation test of "+ |
| 379 | str(batch_intent_size) +" intents") |
| 380 | |
| 381 | main.log.info("Getting list of available devices") |
| 382 | device_id_list = [] |
| 383 | json_str = main.ONOS1cli.devices() |
| 384 | json_obj = json.loads(json_str) |
| 385 | for device in json_obj: |
| 386 | device_id_list.append(device['id']) |
| 387 | |
| 388 | for i in range(0, int(num_iter)): |
| 389 | main.log.info("Pushing "+batch_intent_size+" intents") |
| 390 | |
| 391 | batch_result = main.ONOS1cli.push_test_intents( |
| 392 | "of:0000000000000001/1", "of:0000000000000005/2", |
| 393 | batch_intent_size) |
| 394 | |
| 395 | time.sleep(5) |
| 396 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 397 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 398 | |