andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1 | #Intent Performance Test for ONOS-next |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 2 | # |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 3 | #andrew@onlab.us |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 4 | # |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 5 | #November 5, 2014 |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 6 | |
| 7 | class IntentPerfNext: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 8 | def __init__(self): |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 9 | self.default = "" |
| 10 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 11 | def CASE1(self, main): |
| 12 | ''' |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 13 | ONOS startup sequence |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 14 | ''' |
| 15 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 16 | import time |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 17 | global cluster_count |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 18 | cluster_count = 1 |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 19 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 20 | cell_name = main.params['ENV']['cellName'] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 21 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 22 | git_pull = main.params['GIT']['autoPull'] |
| 23 | checkout_branch = main.params['GIT']['checkout'] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 24 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 25 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 26 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 27 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 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'] |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 32 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 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) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 40 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -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") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 45 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 46 | main.step("Creating cell file") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 47 | cell_file_result = main.ONOSbench.create_cell_file( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 48 | BENCH_ip, cell_name, MN1_ip, |
| 49 | "onos-core,onos-app-metrics,onos-gui", |
| 50 | ONOS1_ip) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 51 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 52 | main.step("Applying cell file to environment") |
| 53 | cell_apply_result = main.ONOSbench.set_cell(cell_name) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 54 | verify_cell_result = main.ONOSbench.verify_cell() |
| 55 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 56 | main.step("Removing raft logs") |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 57 | main.ONOSbench.onos_remove_raft_logs() |
| 58 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 59 | main.step("Git checkout and pull "+checkout_branch) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 60 | if git_pull == 'on': |
| 61 | checkout_result = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 62 | main.ONOSbench.git_checkout(checkout_branch) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 63 | pull_result = main.ONOSbench.git_pull() |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 64 | |
| 65 | #If you used git pull, auto compile |
| 66 | main.step("Using onos-build to compile ONOS") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 67 | build_result = main.ONOSbench.onos_build() |
| 68 | else: |
| 69 | checkout_result = main.TRUE |
| 70 | pull_result = main.TRUE |
| 71 | build_result = main.TRUE |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 72 | main.log.info("Git pull skipped by configuration") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 73 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 74 | main.log.report("Commit information - ") |
| 75 | main.ONOSbench.get_version(report=True) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 76 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 77 | main.step("Creating ONOS package") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 78 | package_result = main.ONOSbench.onos_package() |
| 79 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 80 | main.step("Installing ONOS package") |
| 81 | install1_result = main.ONOSbench.onos_install(node=ONOS1_ip) |
| 82 | #install2_result = main.ONOSbench.onos_install(node=ONOS2_ip) |
| 83 | #install3_result = main.ONOSbench.onos_install(node=ONOS3_ip) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 84 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 85 | main.step("Set cell for ONOScli env") |
| 86 | main.ONOS1cli.set_cell(cell_name) |
| 87 | #main.ONOS2cli.set_cell(cell_name) |
| 88 | #main.ONOS3cli.set_cell(cell_name) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 89 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 90 | time.sleep(5) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 91 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 92 | main.step("Start onos cli") |
| 93 | cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 94 | #cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 95 | #cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 96 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 97 | utilities.assert_equals(expect=main.TRUE, |
| 98 | actual = cell_file_result and cell_apply_result and\ |
| 99 | verify_cell_result and checkout_result and\ |
| 100 | pull_result and build_result and\ |
| 101 | install1_result, #and install2_result and\ |
| 102 | #install3_result, |
| 103 | onpass="ONOS started successfully", |
| 104 | onfail="Failed to start ONOS") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 105 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 106 | def CASE2(self, main): |
| 107 | ''' |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 108 | Single intent add latency |
| 109 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 110 | ''' |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 111 | import time |
| 112 | import json |
| 113 | import requests |
| 114 | import os |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 115 | import numpy |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 116 | global cluster_count |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 117 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 118 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 119 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 120 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 121 | ONOS_ip_list = [] |
| 122 | for i in range(1, 8): |
| 123 | ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)]) |
| 124 | |
| 125 | ONOS_user = main.params['CTRL']['user'] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 126 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 127 | default_sw_port = main.params['CTRL']['port1'] |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 128 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 129 | #number of iterations of case |
| 130 | num_iter = main.params['TEST']['numIter'] |
| 131 | num_ignore = int(main.params['TEST']['numIgnore']) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 132 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 133 | #Timestamp keys for json metrics output |
| 134 | submit_time = main.params['JSON']['submittedTime'] |
| 135 | install_time = main.params['JSON']['installedTime'] |
| 136 | wdRequest_time = main.params['JSON']['wdRequestTime'] |
| 137 | withdrawn_time = main.params['JSON']['withdrawnTime'] |
| 138 | |
| 139 | assertion = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 140 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 141 | intent_add_lat_list = [] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 142 | |
| 143 | #Distribute switches according to cluster count |
| 144 | for i in range(1, 9): |
| 145 | if cluster_count == 1: |
| 146 | main.Mininet1.assign_sw_controller( |
| 147 | sw=str(i), ip1=ONOS_ip_list[0], |
| 148 | port1=default_sw_port |
| 149 | ) |
| 150 | elif cluster_count == 3: |
| 151 | if i < 3: |
| 152 | index = 0 |
| 153 | elif i < 6 and i >= 3: |
| 154 | index = 1 |
| 155 | else: |
| 156 | index = 2 |
| 157 | main.Mininet1.assign_sw_controller( |
| 158 | sw=str(i), ip1=ONOS_ip_list[index], |
| 159 | port1=default_sw_port |
| 160 | ) |
| 161 | elif cluster_count == 5: |
| 162 | if i < 3: |
| 163 | index = 0 |
| 164 | elif i < 5 and i >= 3: |
| 165 | index = 1 |
| 166 | elif i < 7 and i >= 5: |
| 167 | index = 2 |
| 168 | elif i == 7: |
| 169 | index = 3 |
| 170 | else: |
| 171 | index = 4 |
| 172 | main.Mininet1.assign_sw_controller( |
| 173 | sw=str(i), ip1=ONOS_ip_list[index], |
| 174 | port1=default_sw_port |
| 175 | ) |
| 176 | elif cluster_count == 7: |
| 177 | if i < 6: |
| 178 | index = i |
| 179 | else: |
| 180 | index = 6 |
| 181 | main.Mininet1.assign_sw_controller( |
| 182 | sw=str(i), ip1=ONOS_ip_list[index], |
| 183 | port1=default_sw_port |
| 184 | ) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 185 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 186 | time.sleep(10) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 187 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 188 | main.log.report("Single intent add latency test") |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 189 | |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 190 | devices_json_str = main.ONOS1cli.devices() |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 191 | devices_json_obj = json.loads(devices_json_str) |
| 192 | |
| 193 | if not devices_json_obj: |
| 194 | main.log.report("Devices not discovered") |
| 195 | main.log.report("Aborting test") |
| 196 | main.exit() |
| 197 | else: |
| 198 | main.log.info("Devices discovered successfully") |
| 199 | |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 200 | device_id_list = [] |
| 201 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 202 | #Obtain device id list in ONOS format. |
| 203 | #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] | 204 | for device in devices_json_obj: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 205 | device_id_list.append(device['id']) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 206 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 207 | for i in range(0, int(num_iter)): |
| 208 | #add_point_intent(ingr_device, egr_device, |
| 209 | # ingr_port, egr_port) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 210 | main.ONOS1cli.add_point_intent( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 211 | device_id_list[0]+"/2", device_id_list[7]+"/2") |
| 212 | |
| 213 | #Allow some time for intents to propagate |
| 214 | time.sleep(5) |
| 215 | |
| 216 | intents_str = main.ONOS1cli.intents(json_format=True) |
| 217 | intents_obj = json.loads(intents_str) |
| 218 | for intent in intents_obj: |
| 219 | if intent['state'] == "INSTALLED": |
| 220 | main.log.info("Intent installed successfully") |
| 221 | intent_id = intent['id'] |
| 222 | main.log.info("Intent id: "+str(intent_id)) |
| 223 | else: |
| 224 | #TODO: Add error handling |
| 225 | main.log.info("Intent installation failed") |
| 226 | intent_id = "" |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 227 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 228 | #Obtain metrics from ONOS 1, 2, 3 |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 229 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 230 | intents_json_obj_1 = json.loads(intents_json_str_1) |
| 231 | #Parse values from the json object |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 232 | intent_submit_1 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 233 | intents_json_obj_1[submit_time]['value'] |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 234 | intent_install_1 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 235 | intents_json_obj_1[install_time]['value'] |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 236 | intent_install_lat_1 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 237 | int(intent_install_1) - int(intent_submit_1) |
| 238 | |
| 239 | if cluster_count == 3: |
| 240 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 241 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 242 | intents_json_obj_2 = json.loads(intents_json_str_2) |
| 243 | intents_json_obj_3 = json.loads(intents_json_str_3) |
| 244 | intent_submit_2 = \ |
| 245 | intents_json_obj_2[submit_time]['value'] |
| 246 | intent_submit_3 = \ |
| 247 | intents_json_obj_3[submit_time]['value'] |
| 248 | intent_install_2 = \ |
| 249 | intents_json_obj_2[install_time]['value'] |
| 250 | intent_install_3 = \ |
| 251 | intents_json_obj_3[install_time]['value'] |
| 252 | intent_install_lat_2 = \ |
| 253 | int(intent_install_2) - int(intent_submit_2) |
| 254 | intent_install_lat_3 = \ |
| 255 | int(intent_install_3) - int(intent_submit_3) |
| 256 | else: |
| 257 | intent_install_lat_2 = 0 |
| 258 | intent_install_lat_3 = 0 |
| 259 | |
| 260 | if cluster_count == 5: |
| 261 | intents_json_str_4 = main.ONOS4cli.intents_events_metrics() |
| 262 | intents_json_str_5 = main.ONOS5cli.intents_events_metrics() |
| 263 | intents_json_obj_4 = json.loads(intents_json_str_4) |
| 264 | intents_json_obj_5 = json.loads(intents_json_str_5) |
| 265 | intent_submit_4 = \ |
| 266 | intents_json_obj_4[submit_time]['value'] |
| 267 | intent_submit_5 = \ |
| 268 | intents_json_obj_5[submit_time]['value'] |
| 269 | intent_install_4 = \ |
| 270 | intents_json_obj_5[install_time]['value'] |
| 271 | intent_install_5 = \ |
| 272 | intents_json_obj_5[install_time]['value'] |
| 273 | intent_install_lat_4 = \ |
| 274 | int(intent_install_4) - int(intent_submit_4) |
| 275 | intent_install_lat_5 = \ |
| 276 | int(intent_install_5) - int(intent_submit_5) |
| 277 | else: |
| 278 | intent_install_lat_4 = 0 |
| 279 | intent_install_lat_5 = 0 |
| 280 | |
| 281 | if cluster_count == 7: |
| 282 | intents_json_str_6 = main.ONOS6cli.intents_events_metrics() |
| 283 | intents_json_str_7 = main.ONOS7cli.intents_events_metrics() |
| 284 | intents_json_obj_6 = json.loads(intents_json_str_6) |
| 285 | intents_json_obj_7 = json.loads(intents_json_str_7) |
| 286 | intent_submit_6 = \ |
| 287 | intents_json_obj_6[submit_time]['value'] |
| 288 | intent_submit_7 = \ |
| 289 | intents_json_obj_6[submit_time]['value'] |
| 290 | intent_install_6 = \ |
| 291 | intents_json_obj_6[install_time]['value'] |
| 292 | intent_install_7 = \ |
| 293 | intents_json_obj_7[install_time]['value'] |
| 294 | intent_install_lat_6 = \ |
| 295 | int(intent_install_6) - int(intent_submit_6) |
| 296 | intent_install_lat_7 = \ |
| 297 | int(intent_install_7) - int(intent_submit_7) |
| 298 | else: |
| 299 | intent_install_lat_6 = 0 |
| 300 | intent_install_lat_7 = 0 |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 301 | |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 302 | intent_install_lat_avg = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 303 | (intent_install_lat_1 + |
| 304 | intent_install_lat_2 + |
| 305 | intent_install_lat_3 + |
| 306 | intent_install_lat_4 + |
| 307 | intent_install_lat_5 + |
| 308 | intent_install_lat_6 + |
| 309 | intent_install_lat_7) / cluster_count |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 310 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 311 | main.log.info("Intent add latency avg for iteration "+str(i)+ |
| 312 | ": "+str(intent_install_lat_avg)+" ms") |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 313 | |
| 314 | if intent_install_lat_avg > 0.0 and \ |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 315 | intent_install_lat_avg < 1000 and i > num_ignore: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 316 | intent_add_lat_list.append(intent_install_lat_avg) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 317 | else: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 318 | main.log.info("Intent add latency exceeded "+ |
| 319 | "threshold. Skipping iteration "+str(i)) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 320 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 321 | time.sleep(3) |
| 322 | |
| 323 | #TODO: Only remove intents that were installed |
| 324 | # in this case... Otherwise many other intents |
| 325 | # may show up distorting the results |
| 326 | main.log.info("Removing intents for next iteration") |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 327 | json_temp = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 328 | main.ONOS1cli.intents(json_format=True) |
| 329 | json_obj_intents = json.loads(json_temp) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 330 | if json_obj_intents: |
| 331 | for intents in json_obj_intents: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 332 | temp_id = intents['id'] |
| 333 | #main.ONOS1cli.remove_intent(temp_id) |
| 334 | main.log.info("Removing intent id: "+ |
| 335 | str(temp_id)) |
| 336 | main.ONOS1cli.remove_intent(temp_id) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 337 | else: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 338 | main.log.info("Intents were not installed correctly") |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 339 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 340 | time.sleep(5) |
andrewonlab | 8790abb | 2014-11-06 13:51:54 -0500 | [diff] [blame] | 341 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 342 | if intent_add_lat_list: |
| 343 | intent_add_lat_avg = sum(intent_add_lat_list) /\ |
| 344 | len(intent_add_lat_list) |
| 345 | else: |
| 346 | main.log.report("Intent installation latency test failed") |
| 347 | intent_add_lat_avg = "NA" |
| 348 | assertion = main.FALSE |
| 349 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 350 | intent_add_lat_std = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 351 | round(numpy.std(intent_add_lat_list),1) |
| 352 | #END ITERATION FOR LOOP |
| 353 | main.log.report("Single intent add latency - ") |
| 354 | main.log.report("Avg: "+str(intent_add_lat_avg)+" ms") |
| 355 | main.log.report("Std Deviation: "+str(intent_add_lat_std)+" ms") |
| 356 | |
| 357 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 358 | onpass="Single intent install latency test successful", |
| 359 | onfail="Single intent install latency test failed") |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 360 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 361 | def CASE3(self, main): |
| 362 | ''' |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 363 | Intent Reroute latency |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 364 | ''' |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 365 | import time |
| 366 | import json |
| 367 | import requests |
| 368 | import os |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 369 | import numpy |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 370 | global cluster_count |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 371 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 372 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 373 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 374 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 375 | ONOS_user = main.params['CTRL']['user'] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 376 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 377 | default_sw_port = main.params['CTRL']['port1'] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 378 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 379 | #number of iterations of case |
| 380 | num_iter = main.params['TEST']['numIter'] |
| 381 | num_ignore = int(main.params['TEST']['numIgnore']) |
| 382 | assertion = main.TRUE |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 383 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 384 | #Timestamp keys for json metrics output |
| 385 | submit_time = main.params['JSON']['submittedTime'] |
| 386 | install_time = main.params['JSON']['installedTime'] |
| 387 | wdRequest_time = main.params['JSON']['wdRequestTime'] |
| 388 | withdrawn_time = main.params['JSON']['withdrawnTime'] |
| 389 | |
| 390 | #NOTE: May need to configure interface depending on topology |
| 391 | intfs = main.params['TEST']['intfs'] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 392 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 393 | devices_json_str = main.ONOS1cli.devices() |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 394 | devices_json_obj = json.loads(devices_json_str) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 395 | |
| 396 | device_id_list = [] |
| 397 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 398 | #Obtain device id list in ONOS format. |
| 399 | #They should already be in order (1,2,3,10,11,12,13, etc) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 400 | for device in devices_json_obj: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 401 | device_id_list.append(device['id']) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 402 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 403 | intent_reroute_lat_list = [] |
| 404 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 405 | for i in range(0, int(num_iter)): |
| 406 | #add_point_intent(ingr_device, ingr_port, |
| 407 | # egr_device, egr_port) |
| 408 | if len(device_id_list) > 0: |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 409 | main.ONOS1cli.add_point_intent( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 410 | device_id_list[0]+"/2", device_id_list[7]+"/2") |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 411 | else: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 412 | main.log.info("Failed to fetch devices from ONOS") |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 413 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 414 | time.sleep(5) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 415 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 416 | intents_str = main.ONOS1cli.intents(json_format=True) |
| 417 | intents_obj = json.loads(intents_str) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 418 | for intent in intents_obj: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 419 | if intent['state'] == "INSTALLED": |
| 420 | main.log.info("Intent installed successfully") |
| 421 | intent_id = intent['id'] |
| 422 | main.log.info("Intent id: "+str(intent_id)) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 423 | else: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 424 | #TODO: Add error handling |
| 425 | main.log.info("Intent installation failed") |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 426 | intent_id = "" |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 427 | |
| 428 | main.log.info("Disabling interface "+intfs) |
| 429 | t0_system = time.time()*1000 |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 430 | main.Mininet1.handle.sendline( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 431 | "sh ifconfig "+intfs+" down") |
| 432 | main.Mininet1.handle.expect("mininet>") |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 433 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 434 | #TODO: Check for correct intent reroute |
| 435 | time.sleep(1) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 436 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 437 | #Obtain metrics from ONOS 1, 2, 3 |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 438 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 439 | intents_json_obj_1 = json.loads(intents_json_str_1) |
| 440 | #Parse values from the json object |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 441 | intent_install_1 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 442 | intents_json_obj_1[install_time]['value'] |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 443 | intent_reroute_lat_1 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 444 | int(intent_install_1) - int(t0_system) |
| 445 | |
| 446 | if cluster_count == 3: |
| 447 | intents_json_str_2 = main.ONOS2cli.intents_events_metrics() |
| 448 | intents_json_str_3 = main.ONOS3cli.intents_events_metrics() |
| 449 | |
| 450 | intents_json_obj_2 = json.loads(intents_json_str_2) |
| 451 | intents_json_obj_3 = json.loads(intents_json_str_3) |
| 452 | intent_install_2 = \ |
| 453 | intents_json_obj_2[install_time]['value'] |
| 454 | intent_install_3 = \ |
| 455 | intents_json_obj_3[install_time]['value'] |
| 456 | intent_reroute_lat_2 = \ |
| 457 | int(intent_install_2) - int(t0_system) |
| 458 | intent_reroute_lat_3 = \ |
| 459 | int(intent_install_3) - int(t0_system) |
| 460 | else: |
| 461 | intent_reroute_lat_2 = 0 |
| 462 | intent_reroute_lat_3 = 0 |
| 463 | |
| 464 | if cluster_count == 5: |
| 465 | intents_json_str_4 = main.ONOS4cli.intents_events_metrics() |
| 466 | intents_json_str_5 = main.ONOS5cli.intents_events_metrics() |
| 467 | |
| 468 | intents_json_obj_4 = json.loads(intents_json_str_4) |
| 469 | intents_json_obj_5 = json.loads(intents_json_str_5) |
| 470 | intent_install_4 = \ |
| 471 | intents_json_obj_4[install_time]['value'] |
| 472 | intent_install_5 = \ |
| 473 | intents_json_obj_5[install_time]['value'] |
| 474 | intent_reroute_lat_4 = \ |
| 475 | int(intent_install_4) - int(t0_system) |
| 476 | intent_reroute_lat_5 = \ |
| 477 | int(intent_install_5) - int(t0_system) |
| 478 | else: |
| 479 | intent_reroute_lat_4 = 0 |
| 480 | intent_reroute_lat_5 = 0 |
| 481 | |
| 482 | if cluster_count == 7: |
| 483 | intents_json_str_6 = main.ONOS6cli.intents_events_metrics() |
| 484 | intents_json_str_7 = main.ONOS7cli.intents_events_metrics() |
| 485 | |
| 486 | intents_json_obj_6 = json.loads(intents_json_str_6) |
| 487 | intents_json_obj_7 = json.loads(intents_json_str_7) |
| 488 | intent_install_6 = \ |
| 489 | intents_json_obj_6[install_time]['value'] |
| 490 | intent_install_7 = \ |
| 491 | intents_json_obj_7[install_time]['value'] |
| 492 | intent_reroute_lat_6 = \ |
| 493 | int(intent_install_6) - int(t0_system) |
| 494 | intent_reroute_lat_7 = \ |
| 495 | int(intent_install_7) - int(t0_system) |
| 496 | else: |
| 497 | intent_reroute_lat_6 = 0 |
| 498 | intent_reroute_lat_7 = 0 |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 499 | |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 500 | intent_reroute_lat_avg = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 501 | (intent_reroute_lat_1 + |
| 502 | intent_reroute_lat_2 + |
| 503 | intent_reroute_lat_3 + |
| 504 | intent_reroute_lat_4 + |
| 505 | intent_reroute_lat_5 + |
| 506 | intent_reroute_lat_6 + |
| 507 | intent_reroute_lat_7) / cluster_count |
| 508 | |
| 509 | main.log.info("Intent reroute latency avg for iteration "+ |
| 510 | str(i)+": "+str(intent_reroute_lat_avg)) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 511 | |
| 512 | if intent_reroute_lat_avg > 0.0 and \ |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 513 | intent_reroute_lat_avg < 1000 and i > num_ignore: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 514 | intent_reroute_lat_list.append(intent_reroute_lat_avg) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 515 | else: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 516 | main.log.info("Intent reroute latency exceeded "+ |
| 517 | "threshold. Skipping iteration "+str(i)) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 518 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 519 | main.log.info("Removing intents for next iteration") |
| 520 | main.ONOS1cli.remove_intent(intent_id) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 521 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 522 | main.log.info("Bringing Mininet interface up for next "+ |
| 523 | "iteration") |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 524 | main.Mininet1.handle.sendline( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 525 | "sh ifconfig "+intfs+" up") |
| 526 | main.Mininet1.handle.expect("mininet>") |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 527 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 528 | if intent_reroute_lat_list: |
| 529 | intent_reroute_lat_avg = sum(intent_reroute_lat_list) /\ |
| 530 | len(intent_reroute_lat_list) |
| 531 | else: |
| 532 | main.log.report("Intent reroute test failed. Results NA") |
| 533 | intent_reroute_lat_avg = "NA" |
| 534 | #NOTE: fails test when list is empty |
| 535 | assertion = main.FALSE |
| 536 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 537 | intent_reroute_lat_std = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 538 | round(numpy.std(intent_reroute_lat_list),1) |
| 539 | #END ITERATION FOR LOOP |
| 540 | main.log.report("Single intent reroute latency - ") |
| 541 | main.log.report("Avg: "+str(intent_reroute_lat_avg)+" ms") |
| 542 | main.log.report("Std Deviation: "+str(intent_reroute_lat_std)+" ms") |
| 543 | |
| 544 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 545 | onpass="Single intent reroute latency test successful", |
| 546 | onfail="Single intent reroute latency test failed") |
| 547 | |
| 548 | def CASE4(self, main): |
| 549 | ''' |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 550 | Batch intent install |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 551 | ''' |
| 552 | |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 553 | import time |
| 554 | import json |
| 555 | import requests |
| 556 | import os |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 557 | import numpy |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 558 | global cluster_count |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 559 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 560 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 561 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 562 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 563 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 564 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 565 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 566 | ONOS7_ip = main.params['CTRL']['ip7'] |
| 567 | |
| 568 | assertion = main.TRUE |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 569 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 570 | ONOS_ip_list = [] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 571 | for i in range(1, 8): |
| 572 | ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)]) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 573 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 574 | ONOS_user = main.params['CTRL']['user'] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 575 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 576 | default_sw_port = main.params['CTRL']['port1'] |
| 577 | |
| 578 | batch_intent_size = main.params['TEST']['batchIntentSize'] |
| 579 | batch_thresh_min = int(main.params['TEST']['batchThresholdMin']) |
| 580 | batch_thresh_max = int(main.params['TEST']['batchThresholdMax']) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 581 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 582 | #number of iterations of case |
| 583 | num_iter = main.params['TEST']['numIter'] |
| 584 | num_ignore = int(main.params['TEST']['numIgnore']) |
| 585 | num_switch = int(main.params['TEST']['numSwitch']) |
| 586 | n_thread = main.params['TEST']['numMult'] |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 587 | #n_thread = 105 |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 588 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 589 | #Switch assignment NOTE: hardcoded |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 590 | if cluster_count == 1: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 591 | for i in range(1, num_switch+1): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 592 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 593 | sw=str(i), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 594 | ip1=ONOS1_ip, |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 595 | port1=default_sw_port) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 596 | if cluster_count == 3: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 597 | for i in range(1, 3): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 598 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 599 | sw=str(i), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 600 | ip1=ONOS1_ip, |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 601 | port1=default_sw_port) |
| 602 | for i in range(3, 6): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 603 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 604 | sw=str(i), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 605 | ip1=ONOS2_ip, |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 606 | port1=default_sw_port) |
| 607 | for i in range(6, 9): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 608 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 609 | sw=str(i), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 610 | ip1=ONOS3_ip, |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 611 | port1=default_sw_port) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 612 | if cluster_count == 5: |
| 613 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 614 | sw="1", |
| 615 | ip1=ONOS1_ip, |
| 616 | port1=default_sw_port) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 617 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 618 | sw="2", |
| 619 | ip1=ONOS2_ip, |
| 620 | port1=default_sw_port) |
| 621 | for i in range(3, 6): |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 622 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 623 | sw=str(i), |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 624 | ip1=ONOS3_ip, |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 625 | port1=default_sw_port) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 626 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 627 | sw="6", |
| 628 | ip1=ONOS4_ip, |
| 629 | port1=default_sw_port) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 630 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 631 | sw="7", |
| 632 | ip1=ONOS5_ip, |
| 633 | port1=default_sw_port) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 634 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 635 | sw="8", |
| 636 | ip1=ONOS5_ip, |
| 637 | port1=default_sw_port) |
| 638 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 639 | if cluster_count == 7: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 640 | for i in range(1,9): |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 641 | if i < 8: |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 642 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 643 | sw=str(i), |
| 644 | ip1=ONOS_ip_list[i-1], |
| 645 | port1=default_sw_port) |
| 646 | elif i >= 8: |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 647 | main.Mininet1.assign_sw_controller( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 648 | sw=str(i), |
| 649 | ip1=ONOS_ip_list[6], |
| 650 | port1=default_sw_port) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 651 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 652 | time.sleep(20) |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 653 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 654 | main.log.report("Batch intent installation test of "+ |
| 655 | batch_intent_size +" intent(s)") |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 656 | |
| 657 | batch_result_list = [] |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 658 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 659 | main.log.info("Getting list of available devices") |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 660 | device_id_list = [] |
| 661 | json_str = main.ONOS1cli.devices() |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 662 | json_obj = json.loads(json_str) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 663 | for device in json_obj: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 664 | device_id_list.append(device['id']) |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 665 | |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 666 | batch_install_lat = [] |
| 667 | batch_withdraw_lat = [] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 668 | |
| 669 | #Max intent install measurement of all nodes |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 670 | max_install_lat = [] |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 671 | max_withdraw_lat = [] |
| 672 | sleep_time = 10 |
| 673 | |
| 674 | base_dir = "/tmp/" |
andrewonlab | 70decc0 | 2014-11-19 18:50:23 -0500 | [diff] [blame] | 675 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 676 | for batch in range(0, 5): |
| 677 | for i in range(0, int(num_iter)): |
| 678 | main.log.info("Pushing "+ |
| 679 | str(int(batch_intent_size)*int(n_thread))+ |
| 680 | " intents. Iteration "+str(i)) |
| 681 | |
| 682 | for node in range(1, cluster_count+1): |
| 683 | save_dir = base_dir + "batch_intent_"+str(node)+".txt" |
| 684 | main.ONOSbench.push_test_intents_shell( |
| 685 | device_id_list[0]+"/2", |
| 686 | device_id_list[7]+"/2", |
| 687 | int(batch_intent_size), |
| 688 | save_dir, ONOS_ip_list[node-1], |
| 689 | num_mult=n_thread, app_id=node) |
| 690 | |
| 691 | #Wait sufficient time for intents to start |
| 692 | #installing |
| 693 | time.sleep(sleep_time) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 694 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 695 | intent = "" |
| 696 | counter = 300 |
| 697 | while len(intent) > 0 and counter > 0: |
| 698 | main.ONOS1cli.handle.sendline( |
| 699 | "intents | wc -l") |
| 700 | main.ONOS1cli.handle.expect( |
| 701 | "intents | wc -l") |
| 702 | main.ONOS1cli.handle.expect( |
| 703 | "onos>") |
| 704 | intent_temp = main.ONOS1cli.handle.before() |
| 705 | intent = main.ONOS1cli.intents() |
| 706 | intent = json.loads(intent) |
| 707 | counter = counter-1 |
| 708 | time.sleep(1) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 709 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 710 | time.sleep(5) |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 711 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 712 | for node in range(1, cluster_count+1): |
| 713 | save_dir = base_dir + "batch_intent_"+str(node)+".txt" |
| 714 | with open(save_dir) as f_onos: |
| 715 | line_count = 0 |
| 716 | for line in f_onos: |
| 717 | line = line[1:] |
| 718 | line = line.split(": ") |
| 719 | main.log.info("Line read: "+str(line)) |
| 720 | result = line[1].split(" ")[0] |
| 721 | #TODO: add parameters before appending latency |
| 722 | if line_count == 0: |
| 723 | batch_install_lat.append(int(result)) |
| 724 | install_result = result |
| 725 | elif line_count == 1: |
| 726 | batch_withdraw_lat.append(int(result)) |
| 727 | withdraw_result = result |
| 728 | line_count += 1 |
| 729 | main.log.info("Batch install latency for ONOS"+ |
| 730 | str(node)+" with "+\ |
| 731 | str(batch_intent_size) + "intents: "+\ |
| 732 | str(install_result)+" ms") |
| 733 | main.log.info("Batch withdraw latency for ONOS"+ |
| 734 | str(node)+" with "+ |
| 735 | str(batch_intent_size) + "intents: "+ |
| 736 | str(withdraw_result)+" ms") |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 737 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 738 | if len(batch_install_lat) > 0 and int(i) > num_ignore: |
| 739 | max_install_lat.append(max(batch_install_lat)) |
| 740 | elif len(batch_install_lat) == 0: |
| 741 | #If I failed to read anything from the file, |
| 742 | #increase the wait time before checking intents |
| 743 | sleep_time += 30 |
| 744 | if len(batch_withdraw_lat) > 0 and int(i) > num_ignore: |
| 745 | max_withdraw_lat.append(max(batch_withdraw_lat)) |
| 746 | batch_install_lat = [] |
| 747 | batch_withdraw_lat = [] |
| 748 | |
| 749 | #Sleep in between iterations |
| 750 | time.sleep(5) |
| 751 | |
| 752 | if max_install_lat: |
| 753 | avg_install_lat = str(sum(max_install_lat) /\ |
| 754 | len(max_install_lat)) |
| 755 | else: |
| 756 | avg_install_lat = "NA" |
| 757 | main.log.report("Batch installation failed") |
| 758 | assertion = main.FALSE |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 759 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 760 | if max_withdraw_lat: |
| 761 | avg_withdraw_lat = str(sum(max_withdraw_lat) /\ |
| 762 | len(max_withdraw_lat)) |
| 763 | else: |
| 764 | avg_withdraw_lat = "NA" |
| 765 | main.log.report("Batch withdraw failed") |
| 766 | assertion = main.FALSE |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 767 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 768 | main.log.report("Avg of batch installation latency "+ |
| 769 | "of size "+batch_intent_size+": "+ |
| 770 | str(avg_install_lat)+" ms") |
| 771 | main.log.report("Std Deviation of batch installation latency "+ |
| 772 | ": "+str(numpy.std(max_install_lat))+" ms") |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 773 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 774 | main.log.report("Avg of batch withdraw latency "+ |
| 775 | "of size "+batch_intent_size+": "+ |
| 776 | str(avg_withdraw_lat)+" ms") |
| 777 | main.log.report("Std Deviation of batch withdraw latency "+ |
| 778 | ": "+str(numpy.std(max_withdraw_lat))+" ms") |
| 779 | |
| 780 | batch_intent_size += 1000 |
| 781 | main.log.report("Increasing batch intent size to "+ |
| 782 | batch_intent_size) |
| 783 | |
| 784 | #main.log.info("Removing all intents for next test case") |
| 785 | #json_temp = main.ONOS1cli.intents(json_format=True) |
| 786 | #json_obj_intents = json.loads(json_temp) |
| 787 | #if json_obj_intents: |
| 788 | # for intents in json_obj_intents: |
| 789 | # temp_id = intents['id'] |
| 790 | #main.ONOS1cli.remove_intent(temp_id) |
| 791 | # main.ONOS1cli.remove_intent(temp_id) |
| 792 | |
| 793 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 794 | onpass="Batch intent install/withdraw test successful", |
| 795 | onfail="Batch intent install/withdraw test failed") |
kelvin-onlab | eaa2eb3 | 2015-01-16 15:58:18 -0800 | [diff] [blame] | 796 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 797 | def CASE5(self,main): |
| 798 | ''' |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 799 | Increase number of nodes and initiate CLI |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 800 | ''' |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 801 | import time |
| 802 | import json |
| 803 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 804 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 805 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 806 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 807 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 808 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 809 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 810 | ONOS7_ip = main.params['CTRL']['ip7'] |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 811 | |
| 812 | global cluster_count |
| 813 | cluster_count += 2 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 814 | main.log.report("Increasing cluster size to "+ |
| 815 | str(cluster_count)) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 816 | |
| 817 | install_result = main.FALSE |
| 818 | |
| 819 | if cluster_count == 3: |
| 820 | install_result1 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 821 | main.ONOSbench.onos_install(node=ONOS2_ip) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 822 | install_result2 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 823 | main.ONOSbench.onos_install(node=ONOS3_ip) |
| 824 | time.sleep(5) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 825 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 826 | main.log.info("Starting ONOS CLI") |
| 827 | main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 828 | main.ONOS3cli.start_onos_cli(ONOS3_ip) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 829 | |
| 830 | install_result = install_result1 and install_result2 |
| 831 | |
| 832 | if cluster_count == 5: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 833 | main.log.info("Installing ONOS on node 4 and 5") |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 834 | install_result1 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 835 | main.ONOSbench.onos_install(node=ONOS4_ip) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 836 | install_result2 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 837 | main.ONOSbench.onos_install(node=ONOS5_ip) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 838 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 839 | main.log.info("Starting ONOS CLI") |
| 840 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 841 | main.ONOS5cli.start_onos_cli(ONOS5_ip) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 842 | |
| 843 | install_result = install_result1 and install_result2 |
| 844 | |
| 845 | if cluster_count == 7: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 846 | main.log.info("Installing ONOS on node 6 and 7") |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 847 | install_result1 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 848 | main.ONOSbench.onos_install(node=ONOS6_ip) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 849 | install_result2 = \ |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 850 | main.ONOSbench.onos_install(node=ONOS7_ip) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 851 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 852 | main.log.info("Starting ONOS CLI") |
| 853 | main.ONOS6cli.start_onos_cli(ONOS6_ip) |
| 854 | main.ONOS7cli.start_onos_cli(ONOS7_ip) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 855 | |
| 856 | install_result = install_result1 and install_result2 |
| 857 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 858 | time.sleep(5) |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 859 | |
| 860 | if install_result == main.TRUE: |
| 861 | assertion = main.TRUE |
| 862 | else: |
| 863 | assertion = main.FALSE |
| 864 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 865 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 866 | onpass="Scale out to "+str(cluster_count)+\ |
| 867 | " nodes successful", |
| 868 | onfail="Scale out to "+str(cluster_count)+\ |
| 869 | " nodes failed") |
| 870 | |
| 871 | def CASE7(self, main): |
| 872 | #TODO: Fix for scale-out scenario |
andrewonlab | 4293dcb | 2014-12-02 15:48:05 -0500 | [diff] [blame] | 873 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 874 | ''' |
| 875 | Batch intent reroute latency |
| 876 | ''' |
| 877 | import time |
| 878 | import json |
| 879 | import requests |
| 880 | import os |
| 881 | import numpy |
| 882 | global cluster_count |
| 883 | |
| 884 | ONOS_ip_list = [] |
| 885 | for i in range(1, 8): |
| 886 | ONOS_ip_list.append(main.params['CTRL']['ip'+str(i)]) |
| 887 | |
| 888 | ONOS_user = main.params['CTRL']['user'] |
| 889 | default_sw_port = main.params['CTRL']['port1'] |
| 890 | |
| 891 | batch_intent_size = main.params['TEST']['batchIntentSize'] |
| 892 | batch_thresh_min = int(main.params['TEST']['batchThresholdMin']) |
| 893 | batch_thresh_max = int(main.params['TEST']['batchThresholdMax']) |
| 894 | intfs = main.params['TEST']['intfs'] |
| 895 | install_time = main.params['JSON']['installedTime'] |
| 896 | |
| 897 | #number of iterations of case |
| 898 | num_iter = main.params['TEST']['numIter'] |
| 899 | num_ignore = int(main.params['TEST']['numIgnore']) |
| 900 | num_switch = int(main.params['TEST']['numSwitch']) |
| 901 | n_thread = main.params['TEST']['numMult'] |
| 902 | |
| 903 | main.log.report("Batch intent installation test of "+ |
| 904 | batch_intent_size +" intents") |
| 905 | |
| 906 | batch_result_list = [] |
| 907 | |
| 908 | time.sleep(10) |
| 909 | |
| 910 | main.log.info("Getting list of available devices") |
| 911 | device_id_list = [] |
| 912 | json_str = main.ONOS1cli.devices() |
| 913 | json_obj = json.loads(json_str) |
| 914 | for device in json_obj: |
| 915 | device_id_list.append(device['id']) |
| 916 | |
| 917 | batch_install_lat = [] |
| 918 | batch_withdraw_lat = [] |
| 919 | sleep_time = 10 |
| 920 | |
| 921 | base_dir = "/tmp/" |
| 922 | max_install_lat = [] |
| 923 | |
| 924 | for i in range(0, int(num_iter)): |
| 925 | main.log.info("Pushing "+ |
| 926 | str(int(batch_intent_size)*int(n_thread))+ |
| 927 | " intents. Iteration "+str(i)) |
| 928 | |
| 929 | main.ONOSbench.push_test_intents_shell( |
| 930 | device_id_list[0]+"/2", |
| 931 | device_id_list[7]+"/2", |
| 932 | batch_intent_size, "/tmp/batch_install.txt", |
| 933 | ONOS_ip_list[0], num_mult="1", app_id="1", |
| 934 | report=False, options="--install") |
| 935 | #main.ONOSbench.push_test_intents_shell( |
| 936 | # "of:0000000000001002/1", |
| 937 | # "of:0000000000002002/1", |
| 938 | # 133, "/tmp/temp2.txt", "10.128.174.2", |
| 939 | # num_mult="6", app_id="2",report=False) |
| 940 | |
| 941 | #TODO: Check for installation success then proceed |
| 942 | time.sleep(30) |
| 943 | |
| 944 | #NOTE: this interface is specific to |
| 945 | # topo-intentFlower.py topology |
| 946 | # reroute case. |
| 947 | main.log.info("Disabling interface "+intfs) |
| 948 | main.Mininet1.handle.sendline( |
| 949 | "sh ifconfig "+intfs+" down") |
| 950 | t0_system = time.time()*1000 |
| 951 | |
| 952 | #TODO: Wait sufficient time for intents to install |
| 953 | time.sleep(10) |
| 954 | |
| 955 | #TODO: get intent installation time |
| 956 | |
| 957 | #Obtain metrics from ONOS 1, 2, 3 |
| 958 | intents_json_str_1 = main.ONOS1cli.intents_events_metrics() |
| 959 | intents_json_obj_1 = json.loads(intents_json_str_1) |
| 960 | #Parse values from the json object |
| 961 | intent_install_1 = \ |
| 962 | intents_json_obj_1[install_time]['value'] |
| 963 | intent_reroute_lat_1 = \ |
| 964 | int(intent_install_1) - int(t0_system) |
| 965 | |
| 966 | |
| 967 | if cluster_count == 3: |
| 968 | intents_json_str_2 =\ |
| 969 | main.ONOS2cli.intents_events_metrics() |
| 970 | intents_json_str_3 =\ |
| 971 | main.ONOS3cli.intents_events_metrics() |
| 972 | intents_json_obj_2 = json.loads(intents_json_str_2) |
| 973 | intents_json_obj_3 = json.loads(intents_json_str_3) |
| 974 | intent_install_2 = \ |
| 975 | intents_json_obj_2[install_time]['value'] |
| 976 | intent_install_3 = \ |
| 977 | intents_json_obj_3[install_time]['value'] |
| 978 | intent_reroute_lat_2 = \ |
| 979 | int(intent_install_2) - int(t0_system) |
| 980 | intent_reroute_lat_3 = \ |
| 981 | int(intent_install_3) - int(t0_system) |
| 982 | else: |
| 983 | intent_reroute_lat_2 = 0 |
| 984 | intent_reroute_lat_3 = 0 |
| 985 | |
| 986 | if cluster_count == 5: |
| 987 | intents_json_str_4 =\ |
| 988 | main.ONOS4cli.intents_events_metrics() |
| 989 | intents_json_str_5 =\ |
| 990 | main.ONOS5cli.intents_events_metrics() |
| 991 | intents_json_obj_4 = json.loads(intents_json_str_4) |
| 992 | intents_json_obj_5 = json.loads(intents_json_str_5) |
| 993 | intent_install_4 = \ |
| 994 | intents_json_obj_4[install_time]['value'] |
| 995 | intent_install_5 = \ |
| 996 | intents_json_obj_5[install_time]['value'] |
| 997 | intent_reroute_lat_4 = \ |
| 998 | int(intent_install_4) - int(t0_system) |
| 999 | intent_reroute_lat_5 = \ |
| 1000 | int(intent_install_5) - int(t0_system) |
| 1001 | else: |
| 1002 | intent_reroute_lat_4 = 0 |
| 1003 | intent_reroute_lat_5 = 0 |
| 1004 | |
| 1005 | if cluster_count == 7: |
| 1006 | intents_json_str_6 =\ |
| 1007 | main.ONOS6cli.intents_events_metrics() |
| 1008 | intents_json_str_7 =\ |
| 1009 | main.ONOS7cli.intents_events_metrics() |
| 1010 | intents_json_obj_6 = json.loads(intents_json_str_6) |
| 1011 | intents_json_obj_7 = json.loads(intents_json_str_7) |
| 1012 | intent_install_6 = \ |
| 1013 | intents_json_obj_6[install_time]['value'] |
| 1014 | intent_install_7 = \ |
| 1015 | intents_json_obj_7[install_time]['value'] |
| 1016 | intent_reroute_lat_6 = \ |
| 1017 | int(intent_install_6) - int(t0_system) |
| 1018 | intent_reroute_lat_7 = \ |
| 1019 | int(intent_install_7) - int(t0_system) |
| 1020 | else: |
| 1021 | intent_reroute_lat_6 = 0 |
| 1022 | intent_reroute_lat_7 = 0 |
| 1023 | |
| 1024 | intent_reroute_lat_avg = \ |
| 1025 | (intent_reroute_lat_1 + |
| 1026 | intent_reroute_lat_2 + |
| 1027 | intent_reroute_lat_3 + |
| 1028 | intent_reroute_lat_4 + |
| 1029 | intent_reroute_lat_5 + |
| 1030 | intent_reroute_lat_6 + |
| 1031 | intent_reroute_lat_7) / cluster_count |
| 1032 | |
| 1033 | main.log.info("Intent reroute latency avg for iteration "+ |
| 1034 | str(i)+": "+str(intent_reroute_lat_avg)) |
| 1035 | #TODO: Remove intents for next iteration |
| 1036 | |
| 1037 | time.sleep(5) |
| 1038 | |
| 1039 | intents_str = main.ONOS1cli.intents() |
| 1040 | intents_json = json.loads(intents_str) |
| 1041 | for intents in intents_json: |
| 1042 | intent_id = intents['id'] |
| 1043 | #TODO: make sure this removes all intents |
| 1044 | #print intent_id |
| 1045 | if intent_id: |
| 1046 | main.ONOS1cli.remove_intent(intent_id) |
| 1047 | |
| 1048 | main.Mininet1.handle.sendline( |
| 1049 | "sh ifconfig "+intfs+" up") |
| 1050 | |
| 1051 | main.log.info("Intents removed and port back up") |
| 1052 | |
| 1053 | def CASE9(self, main): |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1054 | count = 0 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1055 | sw_num1 = 1 |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1056 | sw_num2 = 1 |
| 1057 | appid = 0 |
| 1058 | port_num1 = 1 |
| 1059 | port_num2 = 1 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1060 | |
| 1061 | time.sleep(30) |
andrewonlab | 4cf9dd2 | 2014-11-18 21:28:38 -0500 | [diff] [blame] | 1062 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1063 | while True: |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1064 | #main.ONOS1cli.push_test_intents( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1065 | #"of:0000000000001001/1", |
| 1066 | #"of:0000000000002001/1", |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1067 | # 100, num_mult="10", app_id="1") |
| 1068 | #main.ONOS2cli.push_test_intents( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1069 | # "of:0000000000001002/1", |
| 1070 | # "of:0000000000002002/1", |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1071 | # 100, num_mult="10", app_id="2") |
| 1072 | #main.ONOS2cli.push_test_intents( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1073 | # "of:0000000000001003/1", |
| 1074 | # "of:0000000000002003/1", |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1075 | # 100, num_mult="10", app_id="3") |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1076 | count += 1 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1077 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1078 | if count >= 100: |
| 1079 | main.ONOSbench.handle.sendline( |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1080 | "onos 10.128.174.1 intents-events-metrics >>"+\ |
| 1081 | " /tmp/metrics_intents_temp.txt &") |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1082 | count = 0 |
| 1083 | |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1084 | arg1 = "of:000000000000100"+str(sw_num1)+"/"+str(port_num1) |
| 1085 | arg2 = "of:000000000000200"+str(sw_num2)+"/"+str(port_num2) |
| 1086 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1087 | sw_num1 += 1 |
| 1088 | |
| 1089 | if sw_num1 > 7: |
| 1090 | sw_num1 = 1 |
| 1091 | sw_num2 += 1 |
| 1092 | if sw_num2 > 7: |
| 1093 | appid += 1 |
| 1094 | |
| 1095 | if sw_num2 > 7: |
| 1096 | sw_num2 = 1 |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1097 | |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1098 | main.ONOSbench.push_test_intents_shell( |
| 1099 | arg1, |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1100 | arg2, |
andrewonlab | 042b391 | 2014-12-10 16:40:50 -0500 | [diff] [blame] | 1101 | 100, "/tmp/temp.txt", "10.128.174.1", |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1102 | num_mult="10", app_id=appid,report=False) |
| 1103 | #main.ONOSbench.push_test_intents_shell( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1104 | # "of:0000000000001002/1", |
| 1105 | # "of:0000000000002002/1", |
| 1106 | # 133, "/tmp/temp2.txt", "10.128.174.2", |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1107 | # num_mult="6", app_id="2",report=False) |
| 1108 | #main.ONOSbench.push_test_intents_shell( |
andrewonlab | eb1d054 | 2014-12-03 20:12:01 -0500 | [diff] [blame] | 1109 | # "of:0000000000001003/1", |
| 1110 | # "of:0000000000002003/1", |
| 1111 | # 133, "/tmp/temp3.txt", "10.128.174.3", |
andrewonlab | a57a304 | 2015-01-23 13:53:05 -0500 | [diff] [blame] | 1112 | # num_mult="6", app_id="3",report=False) |
| 1113 | |
| 1114 | time.sleep(0.2) |
andrewonlab | 92ea367 | 2014-11-04 20:22:14 -0500 | [diff] [blame] | 1115 | |