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( |
| 34 | BENCH_ip, cell_name, MN1_ip, "onos-core", |
| 35 | ONOS1_ip, ONOS2_ip, ONOS3_ip) |
| 36 | |
| 37 | main.step("Applying cell file to environment") |
| 38 | cell_apply_result = main.ONOSbench.set_cell(cell_name) |
| 39 | verify_cell_result = main.ONOSbench.verify_cell() |
| 40 | |
| 41 | main.step("Git checkout and pull "+checkout_branch) |
| 42 | if git_pull == 'on': |
| 43 | checkout_result = \ |
| 44 | main.ONOSbench.git_checkout(checkout_branch) |
| 45 | pull_result = main.ONOSbench.git_pull() |
| 46 | |
| 47 | #If you used git pull, auto compile |
| 48 | main.step("Using onos-build to compile ONOS") |
| 49 | build_result = main.ONOSbench.onos_build() |
| 50 | else: |
| 51 | checkout_result = main.TRUE |
| 52 | pull_result = main.TRUE |
| 53 | build_result = main.TRUE |
| 54 | main.log.info("Git pull skipped by configuration") |
| 55 | |
| 56 | main.step("Creating ONOS package") |
| 57 | package_result = main.ONOSbench.onos_package() |
| 58 | |
| 59 | main.step("Installing ONOS package") |
| 60 | install1_result = main.ONOSbench.onos_install(node=ONOS1_ip) |
| 61 | install2_result = main.ONOSbench.onos_install(node=ONOS2_ip) |
| 62 | install3_result = main.ONOSbench.onos_install(node=ONOS3_ip) |
| 63 | |
| 64 | main.step("Set cell for ONOScli env") |
| 65 | main.ONOS1cli.set_cell(cell_name) |
| 66 | main.ONOS2cli.set_cell(cell_name) |
| 67 | main.ONOS3cli.set_cell(cell_name) |
| 68 | |
| 69 | time.sleep(5) |
| 70 | |
| 71 | main.step("Start onos cli") |
| 72 | cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 73 | cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 74 | cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 75 | |
| 76 | main.step("Enable metrics feature") |
| 77 | main.ONOS1cli.feature_install("onos-app-metrics") |
| 78 | main.ONOS2cli.feature_install("onos-app-metrics") |
| 79 | main.ONOS3cli.feature_install("onos-app-metrics") |
| 80 | |
| 81 | utilities.assert_equals(expect=main.TRUE, |
| 82 | actual = cell_file_result and cell_apply_result and\ |
| 83 | verify_cell_result and checkout_result and\ |
| 84 | pull_result and build_result and\ |
| 85 | install1_result and install2_result and\ |
| 86 | install3_result, |
| 87 | onpass="ONOS started successfully", |
| 88 | onfail="Failed to start ONOS") |
| 89 | |
| 90 | def CASE2(self, main): |
| 91 | ''' |
| 92 | Single intent add latency |
| 93 | |
| 94 | ''' |
| 95 | import time |
| 96 | import json |
| 97 | import requests |
| 98 | import os |
| 99 | |
| 100 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 101 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 102 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 103 | ONOS_user = main.params['CTRL']['user'] |
| 104 | |
| 105 | default_sw_port = main.params['CTRL']['port1'] |
| 106 | |
| 107 | #number of iterations of case |
| 108 | num_iter = main.params['TEST']['numIter'] |
| 109 | |
| 110 | #Timestamp keys for json metrics output |
| 111 | submit_time = main.params['JSON']['submittedTime'] |
| 112 | install_time = main.params['JSON']['installedTime'] |
| 113 | wdRequest_time = main.params['JSON']['wdRequestTime'] |
| 114 | withdrawn_time = main.params['JSON']['withdrawnTime'] |
| 115 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 116 | devices_json_str = main.ONOS1cli.devices() |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 117 | devices_json_obj = json.loads(devices_json_str) |
| 118 | |
| 119 | device_id_list = [] |
| 120 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 121 | #Obtain device id list in ONOS format. |
| 122 | #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] | 123 | for device in devices_json_obj: |
| 124 | device_id_list.append(device['id']) |
| 125 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 126 | intent_add_lat_list = [] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 127 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 128 | for i in range(0, int(num_iter)): |
| 129 | #add_point_intent(ingr_device, ingr_port, |
| 130 | # egr_device, egr_port) |
| 131 | main.ONOS1cli.add_point_intent( |
| 132 | device_id_list[0], 2, |
| 133 | device_id_list[2], 1) |
| 134 | |
| 135 | #Allow some time for intents to propagate |
| 136 | time.sleep(5) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 137 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 138 | #Obtain metrics from ONOS 1, 2, 3 |
| 139 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
| 140 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 141 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 142 | |
| 143 | intents_json_obj_1 = json.loads(intents_json_str_1) |
| 144 | intents_json_obj_2 = json.loads(intents_json_str_2) |
| 145 | intents_json_obj_3 = json.loads(intents_json_str_3) |
| 146 | |
| 147 | #Parse values from the json object |
| 148 | intent_submit_1 = \ |
| 149 | intents_json_obj_1[submit_time]['value'] |
| 150 | intent_submit_2 = \ |
| 151 | intents_json_obj_2[submit_time]['value'] |
| 152 | intent_submit_3 = \ |
| 153 | intents_json_obj_3[submit_time]['value'] |
| 154 | |
| 155 | intent_install_1 = \ |
| 156 | intents_json_obj_1[install_time]['value'] |
| 157 | intent_install_2 = \ |
| 158 | intents_json_obj_2[install_time]['value'] |
| 159 | intent_install_3 = \ |
| 160 | intents_json_obj_3[install_time]['value'] |
| 161 | |
| 162 | intent_install_lat_1 = \ |
| 163 | int(intent_install_1) - int(intent_submit_1) |
| 164 | intent_install_lat_2 = \ |
| 165 | int(intent_install_2) - int(intent_submit_2) |
| 166 | intent_install_lat_3 = \ |
| 167 | int(intent_install_3) - int(intent_submit_3) |
| 168 | |
| 169 | intent_install_lat_avg = \ |
| 170 | (intent_install_lat_1 + |
| 171 | intent_install_lat_2 + |
| 172 | intent_install_lat_3 ) / 3 |
| 173 | |
| 174 | main.log.info("Intent add latency avg for iteration "+str(i)+ |
| 175 | ": "+str(intent_install_lat_avg)) |
| 176 | |
| 177 | if intent_install_lat_avg > 0.0 and \ |
| 178 | intent_install_lat_avg < 1000: |
| 179 | intent_add_lat_list.append(intent_install_lat_avg) |
| 180 | else: |
| 181 | main.log.info("Intent add latency exceeded "+ |
| 182 | "threshold. Skipping iteration "+str(i)) |
| 183 | |
| 184 | time.sleep(3) |
| 185 | |
| 186 | #TODO: Possibly put this in the driver function |
| 187 | main.log.info("Removing intents for next iteration") |
| 188 | json_temp = \ |
| 189 | main.ONOS1cli.intents(json_format=True) |
| 190 | json_obj_intents = json.loads(json_temp) |
| 191 | if json_obj_intents: |
| 192 | for intents in json_obj_intents: |
| 193 | temp_id = intents['id'] |
| 194 | main.ONOS1cli.remove_intent(temp_id) |
| 195 | main.log.info("Removing intent id: "+ |
| 196 | str(temp_id)) |
| 197 | main.ONOS1cli.remove_intent(temp_id) |
| 198 | else: |
| 199 | main.log.info("Intents were not installed correctly") |
| 200 | |
| 201 | time.sleep(5) |
| 202 | |
| 203 | intent_add_lat_min = min(intent_add_lat_list) |
| 204 | intent_add_lat_max = max(intent_add_lat_list) |
| 205 | intent_add_lat_avg = sum(intent_add_lat_list) /\ |
| 206 | len(intent_add_lat_list) |
| 207 | #END ITERATION FOR LOOP |
| 208 | main.log.report("Single intent add latency - \n"+ |
| 209 | "Min: "+str(intent_add_lat_min)+" ms\n"+ |
| 210 | "Max: "+str(intent_add_lat_max)+" ms\n"+ |
| 211 | "Avg: "+str(intent_add_lat_avg)+" ms\n") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 212 | |
| 213 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 214 | def CASE3(self, main): |
| 215 | ''' |
| 216 | CASE3 coming soon |
| 217 | ''' |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 218 | |