andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 1 | #TopoPerfNext |
| 2 | # |
| 3 | #Topology Performance test for ONOS-next |
| 4 | # |
| 5 | #andrew@onlab.us |
| 6 | |
| 7 | import time |
| 8 | import sys |
| 9 | import os |
| 10 | import re |
| 11 | |
| 12 | class TopoPerfNext: |
| 13 | def __init__(self): |
| 14 | self.default = '' |
| 15 | |
| 16 | def CASE1(self, main): |
| 17 | ''' |
| 18 | ONOS startup sequence |
| 19 | ''' |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 20 | import time |
| 21 | |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 22 | cell_name = main.params['ENV']['cellName'] |
| 23 | |
| 24 | git_pull = main.params['GIT']['autoPull'] |
| 25 | checkout_branch = main.params['GIT']['checkout'] |
| 26 | |
| 27 | ONOS1_ip = main.params['CTRL']['ip1'] |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 28 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 29 | ONOS3_ip = main.params['CTRL']['ip3'] |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 30 | MN1_ip = main.params['MN']['ip1'] |
| 31 | BENCH_ip = main.params['BENCH']['ip'] |
| 32 | |
| 33 | main.case("Setting up test environment") |
| 34 | |
| 35 | main.step("Creating cell file") |
| 36 | cell_file_result = main.ONOSbench.create_cell_file( |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 37 | BENCH_ip, cell_name, MN1_ip, "onos-core", |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 38 | ONOS1_ip, ONOS2_ip, ONOS3_ip) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 39 | |
| 40 | main.step("Applying cell file to environment") |
| 41 | cell_apply_result = main.ONOSbench.set_cell(cell_name) |
| 42 | verify_cell_result = main.ONOSbench.verify_cell() |
| 43 | |
| 44 | main.step("Git checkout and pull "+checkout_branch) |
| 45 | if git_pull == 'on': |
| 46 | checkout_result = \ |
| 47 | main.ONOSbench.git_checkout(checkout_branch) |
| 48 | pull_result = main.ONOSbench.git_pull() |
| 49 | else: |
| 50 | checkout_result = main.TRUE |
| 51 | pull_result = main.TRUE |
| 52 | main.log.info("Skipped git checkout and pull") |
| 53 | |
| 54 | main.step("Using mvn clean & install") |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 55 | #mvn_result = main.ONOSbench.clean_install() |
| 56 | mvn_result = main.TRUE |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 57 | |
| 58 | main.step("Creating ONOS package") |
| 59 | package_result = main.ONOSbench.onos_package() |
| 60 | |
| 61 | main.step("Installing ONOS package") |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 62 | install1_result = main.ONOSbench.onos_install(node=ONOS1_ip) |
| 63 | install2_result = main.ONOSbench.onos_install(node=ONOS2_ip) |
| 64 | install3_result = main.ONOSbench.onos_install(node=ONOS3_ip) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 65 | |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 66 | #NOTE: This step may be unnecessary |
| 67 | #main.step("Starting ONOS service") |
| 68 | #start_result = main.ONOSbench.onos_start(ONOS1_ip) |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 69 | |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 70 | main.step("Set cell for ONOS cli env") |
| 71 | main.ONOS1cli.set_cell(cell_name) |
| 72 | main.ONOS2cli.set_cell(cell_name) |
| 73 | main.ONOS3cli.set_cell(cell_name) |
| 74 | |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 75 | time.sleep(10) |
| 76 | |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 77 | main.step("Start onos cli") |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 78 | cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 79 | cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 80 | cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 81 | |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 82 | main.step("Enable metrics feature") |
| 83 | main.ONOS1cli.feature_install("onos-app-metrics-topology") |
| 84 | main.ONOS2cli.feature_install("onos-app-metrics-topology") |
| 85 | main.ONOS3cli.feature_install("onos-app-metrics-topology") |
| 86 | |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 87 | utilities.assert_equals(expect=main.TRUE, |
| 88 | actual= cell_file_result and cell_apply_result and\ |
| 89 | verify_cell_result and checkout_result and\ |
| 90 | pull_result and mvn_result and\ |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 91 | install1_result and install2_result and\ |
| 92 | install3_result, |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 93 | onpass="ONOS started successfully", |
| 94 | onfail="Failed to start ONOS") |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 95 | |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 96 | def CASE2(self, main): |
| 97 | ''' |
| 98 | Assign s1 to ONOS1 and measure latency |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 99 | |
| 100 | There are 4 levels of latency measurements to this test: |
| 101 | 1) End-to-end measurement: Complete end-to-end measurement |
| 102 | from TCP (SYN/ACK) handshake to Graph change |
| 103 | 2) OFP-to-graph measurement: 'ONOS processing' snippet of |
| 104 | measurement from OFP Vendor message to Graph change |
| 105 | 3) OFP-to-device measurement: 'ONOS processing without |
| 106 | graph change' snippet of measurement from OFP vendor |
| 107 | message to Device change timestamp |
| 108 | 4) T0-to-device measurement: Measurement that includes |
| 109 | the switch handshake to devices timestamp without |
| 110 | the graph view change. (TCP handshake -> Device |
| 111 | change) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 112 | ''' |
| 113 | import time |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 114 | import subprocess |
| 115 | import json |
| 116 | import requests |
| 117 | import os |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 118 | |
| 119 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 120 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 121 | ONOS3_ip = main.params['CTRL']['ip3'] |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 122 | ONOS_user = main.params['CTRL']['user'] |
| 123 | |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 124 | default_sw_port = main.params['CTRL']['port1'] |
| 125 | |
| 126 | #Number of iterations of case |
| 127 | num_iter = main.params['TEST']['numIter'] |
| 128 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 129 | #Timestamp 'keys' for json metrics output. |
| 130 | #These are subject to change, hence moved into params |
| 131 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
| 132 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
| 133 | |
| 134 | #List of switch add latency collected from |
| 135 | #all iterations |
| 136 | latency_end_to_end_list = [] |
| 137 | latency_ofp_to_graph_list = [] |
| 138 | latency_ofp_to_device_list = [] |
| 139 | latency_t0_to_device_list = [] |
| 140 | |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 141 | #Directory/file to store tshark results |
| 142 | tshark_of_output = "/tmp/tshark_of_topo.txt" |
| 143 | tshark_tcp_output = "/tmp/tshark_tcp_topo.txt" |
| 144 | |
| 145 | #String to grep in tshark output |
| 146 | tshark_tcp_string = "TCP 74 "+default_sw_port |
| 147 | tshark_of_string = "OFP 86 Vendor" |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 148 | |
| 149 | #Initialize assertion to TRUE |
| 150 | assertion = main.TRUE |
| 151 | |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 152 | main.log.report("Latency of adding one switch") |
| 153 | |
| 154 | for i in range(0, int(num_iter)): |
| 155 | main.log.info("Starting tshark capture") |
| 156 | |
| 157 | #* TCP [ACK, SYN] is used as t0_a, the |
| 158 | # very first "exchange" between ONOS and |
| 159 | # the switch for end-to-end measurement |
| 160 | #* OFP [Stats Reply] is used for t0_b |
| 161 | # the very last OFP message between ONOS |
| 162 | # and the switch for ONOS measurement |
| 163 | main.ONOS1.tshark_grep(tshark_tcp_string, |
| 164 | tshark_tcp_output) |
| 165 | main.ONOS1.tshark_grep(tshark_of_string, |
| 166 | tshark_of_output) |
| 167 | |
| 168 | #Wait and ensure tshark is started and |
| 169 | #capturing |
| 170 | time.sleep(10) |
| 171 | |
| 172 | main.log.info("Assigning s1 to controller") |
| 173 | |
| 174 | main.Mininet1.assign_sw_controller(sw="1", |
| 175 | ip1=ONOS1_ip, port1=default_sw_port) |
| 176 | |
| 177 | #Wait and ensure switch is assigned |
| 178 | #before stopping tshark |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 179 | time.sleep(30) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 180 | |
| 181 | main.log.info("Stopping all Tshark processes") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 182 | main.ONOS1.stop_tshark() |
| 183 | |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 184 | #tshark output is saved in ONOS. Use subprocess |
| 185 | #to copy over files to TestON for parsing |
| 186 | main.log.info("Copying over tshark files") |
| 187 | |
| 188 | #TCP CAPTURE **** |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 189 | #Copy the tshark output from ONOS machine to |
| 190 | #TestON machine in tshark_tcp_output directory>file |
| 191 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 192 | tshark_tcp_output+" /tmp/") |
| 193 | tcp_file = open(tshark_tcp_output, 'r') |
| 194 | temp_text = tcp_file.readline() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 195 | temp_text = temp_text.split(" ") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 196 | |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 197 | main.log.info("Object read in from TCP capture: "+ |
| 198 | str(temp_text)) |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 199 | if len(temp_text) > 1: |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 200 | t0_tcp = float(temp_text[1])*1000.0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 201 | else: |
| 202 | main.log.error("Tshark output file for TCP"+ |
| 203 | " returned unexpected results") |
| 204 | t0_tcp = 0 |
| 205 | assertion = main.FALSE |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 206 | |
| 207 | tcp_file.close() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 208 | #**************** |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 209 | |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 210 | #OF CAPTURE **** |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 211 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 212 | tshark_of_output+" /tmp/") |
| 213 | of_file = open(tshark_of_output, 'r') |
| 214 | |
| 215 | line_ofp = "" |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 216 | #Read until last line of file |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 217 | while True: |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 218 | temp_text = of_file.readline() |
| 219 | if temp_text !='': |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 220 | line_ofp = temp_text |
| 221 | else: |
| 222 | break |
| 223 | obj = line_ofp.split(" ") |
| 224 | |
| 225 | main.log.info("Object read in from OFP capture: "+ |
| 226 | str(line_ofp)) |
| 227 | |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 228 | if len(line_ofp) > 1: |
andrewonlab | 3a7c3c7 | 2014-10-24 17:21:03 -0400 | [diff] [blame] | 229 | t0_ofp = float(obj[1])*1000.0 |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 230 | else: |
| 231 | main.log.error("Tshark output file for OFP"+ |
| 232 | " returned unexpected results") |
| 233 | t0_ofp = 0 |
| 234 | assertion = main.FALSE |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 235 | |
| 236 | of_file.close() |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 237 | #**************** |
| 238 | |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 239 | json_str_1 = main.ONOS1cli.topology_events_metrics() |
| 240 | json_str_2 = main.ONOS2cli.topology_events_metrics() |
| 241 | json_str_3 = main.ONOS3cli.topology_events_metrics() |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 242 | |
| 243 | json_obj_1 = json.loads(json_str_1) |
| 244 | json_obj_2 = json.loads(json_str_2) |
| 245 | json_obj_3 = json.loads(json_str_3) |
| 246 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 247 | #Obtain graph timestamp. This timestsamp captures |
| 248 | #the epoch time at which the topology graph was updated. |
| 249 | graph_timestamp_1 = \ |
| 250 | json_obj_1[graphTimestamp]['value'] |
| 251 | graph_timestamp_2 = \ |
| 252 | json_obj_2[graphTimestamp]['value'] |
| 253 | graph_timestamp_3 = \ |
| 254 | json_obj_3[graphTimestamp]['value'] |
andrewonlab | 867212a | 2014-10-22 20:13:38 -0400 | [diff] [blame] | 255 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 256 | #Obtain device timestamp. This timestamp captures |
| 257 | #the epoch time at which the device event happened |
| 258 | device_timestamp_1 = \ |
| 259 | json_obj_1[deviceTimestamp]['value'] |
| 260 | device_timestamp_2 = \ |
| 261 | json_obj_2[deviceTimestamp]['value'] |
| 262 | device_timestamp_3 = \ |
| 263 | json_obj_3[deviceTimestamp]['value'] |
andrewonlab | e9fb672 | 2014-10-24 12:20:35 -0400 | [diff] [blame] | 264 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 265 | #t0 to device processing latency |
| 266 | delta_device_1 = int(device_timestamp_1) - int(t0_tcp) |
| 267 | delta_device_2 = int(device_timestamp_2) - int(t0_tcp) |
| 268 | delta_device_3 = int(device_timestamp_3) - int(t0_tcp) |
| 269 | |
| 270 | #Get average of delta from all instances |
| 271 | avg_delta_device = \ |
| 272 | (int(delta_device_1)+\ |
| 273 | int(delta_device_2)+\ |
| 274 | int(delta_device_3)) / 3 |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 275 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 276 | #Ensure avg delta meets the threshold before appending |
| 277 | if avg_delta_device > 0.0 and avg_delta_device < 10000: |
| 278 | latency_t0_to_device_list.append(avg_delta_device) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 279 | else: |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 280 | main.log.info("Results for t0-to-device ignored"+\ |
| 281 | "due to excess in threshold") |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 282 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 283 | #t0 to graph processing latency (end-to-end) |
| 284 | delta_graph_1 = int(graph_timestamp_1) - int(t0_tcp) |
| 285 | delta_graph_2 = int(graph_timestamp_2) - int(t0_tcp) |
| 286 | delta_graph_3 = int(graph_timestamp_3) - int(t0_tcp) |
| 287 | |
| 288 | #Get average of delta from all instances |
| 289 | avg_delta_graph = \ |
| 290 | (int(delta_graph_1)+\ |
| 291 | int(delta_graph_2)+\ |
| 292 | int(delta_graph_3)) / 3 |
| 293 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 294 | #Ensure avg delta meets the threshold before appending |
| 295 | if avg_delta_graph > 0.0 and avg_delta_graph < 10000: |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 296 | latency_end_to_end_list.append(avg_delta_graph) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 297 | else: |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 298 | main.log.info("Results for end-to-end ignored"+\ |
| 299 | "due to excess in threshold") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 300 | |
| 301 | #ofp to graph processing latency (ONOS processing) |
| 302 | delta_ofp_graph_1 = int(graph_timestamp_1) - int(t0_ofp) |
| 303 | delta_ofp_graph_2 = int(graph_timestamp_2) - int(t0_ofp) |
| 304 | delta_ofp_graph_3 = int(graph_timestamp_3) - int(t0_ofp) |
| 305 | |
| 306 | avg_delta_ofp_graph = \ |
| 307 | (int(delta_ofp_graph_1)+\ |
| 308 | int(delta_ofp_graph_2)+\ |
| 309 | int(delta_ofp_graph_3)) / 3 |
| 310 | |
| 311 | if avg_delta_ofp_graph > 0.0 and avg_delta_ofp_graph < 10000: |
| 312 | latency_ofp_to_graph_list.append(avg_delta_ofp_graph) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 313 | else: |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 314 | main.log.info("Results for ofp-to-graph "+\ |
| 315 | "ignored due to excess in threshold") |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 316 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 317 | #ofp to device processing latency (ONOS processing) |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 318 | delta_ofp_device_1 = float(device_timestamp_1) - float(t0_ofp) |
| 319 | delta_ofp_device_2 = float(device_timestamp_2) - float(t0_ofp) |
| 320 | delta_ofp_device_3 = float(device_timestamp_3) - float(t0_ofp) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 321 | |
| 322 | avg_delta_ofp_device = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 323 | (float(delta_ofp_device_1)+\ |
| 324 | float(delta_ofp_device_2)+\ |
| 325 | float(delta_ofp_device_3)) / 3.0 |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 326 | |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 327 | #NOTE: ofp - delta measurements are occasionally negative |
| 328 | # due to system time misalignment. |
| 329 | #TODO: Implement ptp across all clusters |
| 330 | #Just add the calculation to list for now |
| 331 | latency_ofp_to_device_list.append(avg_delta_ofp_device) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 332 | |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 333 | #TODO: |
| 334 | #Fetch logs upon threshold excess |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 335 | |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 336 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 337 | main.log.info("ONOS1 delta end-to-end: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 338 | str(delta_graph_1) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 339 | main.log.info("ONOS2 delta end-to-end: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 340 | str(delta_graph_2) + " ms") |
| 341 | main.log.info("ONOS3 delta end-to-end: "+ |
| 342 | str(delta_graph_3) + " ms") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 343 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 344 | main.log.info("ONOS1 delta OFP - graph: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 345 | str(delta_ofp_graph_1) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 346 | main.log.info("ONOS2 delta OFP - graph: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 347 | str(delta_ofp_graph_2) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 348 | main.log.info("ONOS3 delta OFP - graph: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 349 | str(delta_ofp_graph_3) + " ms") |
andrewonlab | e674534 | 2014-10-17 14:29:13 -0400 | [diff] [blame] | 350 | |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 351 | main.log.info("ONOS1 delta device - t0: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 352 | str(delta_device_1) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 353 | main.log.info("ONOS2 delta device - t0: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 354 | str(delta_device_2) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 355 | main.log.info("ONOS3 delta device - t0: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 356 | str(delta_device_3) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 357 | |
| 358 | main.log.info("ONOS1 delta OFP - device: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 359 | str(delta_ofp_device_1) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 360 | main.log.info("ONOS2 delta OFP - device: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 361 | str(delta_ofp_device_2) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 362 | main.log.info("ONOS3 delta OFP - device: "+ |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 363 | str(delta_ofp_device_3) + " ms") |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 364 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 365 | main.step("Remove switch from controller") |
| 366 | main.Mininet1.delete_sw_controller("s1") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 367 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 368 | time.sleep(5) |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 369 | |
andrewonlab | 09d973e | 2014-10-24 18:56:58 -0400 | [diff] [blame] | 370 | #END of for loop iteration |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 371 | |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 372 | #If there is at least 1 element in each list, |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 373 | #pass the test case |
| 374 | if len(latency_end_to_end_list) > 0 and\ |
| 375 | len(latency_ofp_to_graph_list) > 0 and\ |
| 376 | len(latency_ofp_to_device_list) > 0 and\ |
| 377 | len(latency_t0_to_device_list) > 0: |
| 378 | assertion = main.TRUE |
andrewonlab | f47993a | 2014-10-24 17:56:01 -0400 | [diff] [blame] | 379 | elif len(latency_end_to_end_list) == 0: |
| 380 | #The appending of 0 here is to prevent |
| 381 | #the min,max,sum functions from failing |
| 382 | #below |
| 383 | latency_end_to_end_list.append(0) |
| 384 | assertion = main.FALSE |
| 385 | elif len(latency_ofp_to_graph_list) == 0: |
| 386 | latency_ofp_to_graph_list.append(0) |
| 387 | assertion = main.FALSE |
| 388 | elif len(latency_ofp_to_device_list) == 0: |
| 389 | latency_ofp_to_device_list.append(0) |
| 390 | assertion = main.FALSE |
| 391 | elif len(latency_t0_to_device_list) == 0: |
| 392 | latency_t0_to_device_list.append(0) |
| 393 | assertion = main.FALSE |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 394 | |
| 395 | #Calculate min, max, avg of latency lists |
| 396 | latency_end_to_end_max = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 397 | int(max(latency_end_to_end_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 398 | latency_end_to_end_min = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 399 | int(min(latency_end_to_end_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 400 | latency_end_to_end_avg = \ |
andrewonlab | c90667c | 2014-10-24 16:48:28 -0400 | [diff] [blame] | 401 | (int(sum(latency_end_to_end_list)) / \ |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 402 | len(latency_end_to_end_list)) |
| 403 | |
| 404 | latency_ofp_to_graph_max = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 405 | int(max(latency_ofp_to_graph_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 406 | latency_ofp_to_graph_min = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 407 | int(min(latency_ofp_to_graph_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 408 | latency_ofp_to_graph_avg = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 409 | (int(sum(latency_ofp_to_graph_list)) / \ |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 410 | len(latency_ofp_to_graph_list)) |
| 411 | |
| 412 | latency_ofp_to_device_max = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 413 | int(max(latency_ofp_to_device_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 414 | latency_ofp_to_device_min = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 415 | int(min(latency_ofp_to_device_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 416 | latency_ofp_to_device_avg = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 417 | (int(sum(latency_ofp_to_device_list)) / \ |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 418 | len(latency_ofp_to_device_list)) |
| 419 | |
| 420 | latency_t0_to_device_max = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 421 | float(max(latency_t0_to_device_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 422 | latency_t0_to_device_min = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 423 | float(min(latency_t0_to_device_list)) |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 424 | latency_t0_to_device_avg = \ |
andrewonlab | ee4efeb | 2014-10-24 16:44:51 -0400 | [diff] [blame] | 425 | (float(sum(latency_t0_to_device_list)) / \ |
andrewonlab | c15c958 | 2014-10-24 16:35:52 -0400 | [diff] [blame] | 426 | len(latency_ofp_to_device_list)) |
| 427 | |
| 428 | main.log.report("Switch add - End-to-end latency: \n"+\ |
| 429 | "Min: "+str(latency_end_to_end_min)+"\n"+\ |
| 430 | "Max: "+str(latency_end_to_end_max)+"\n"+\ |
| 431 | "Avg: "+str(latency_end_to_end_avg)) |
| 432 | main.log.report("Switch add - OFP-to-Graph latency: \n"+\ |
| 433 | "Min: "+str(latency_ofp_to_graph_min)+"\n"+\ |
| 434 | "Max: "+str(latency_ofp_to_graph_max)+"\n"+\ |
| 435 | "Avg: "+str(latency_ofp_to_graph_avg)) |
| 436 | main.log.report("Switch add - OFP-to-Device latency: \n"+\ |
| 437 | "Min: "+str(latency_ofp_to_device_min)+"\n"+\ |
| 438 | "Max: "+str(latency_ofp_to_device_max)+"\n"+\ |
| 439 | "Avg: "+str(latency_ofp_to_device_avg)) |
| 440 | main.log.report("Switch add - t0-to-Device latency: \n"+\ |
| 441 | "Min: "+str(latency_t0_to_device_min)+"\n"+\ |
| 442 | "Max: "+str(latency_t0_to_device_max)+"\n"+\ |
| 443 | "Avg: "+str(latency_t0_to_device_avg)) |
andrewonlab | 226024e | 2014-10-24 16:01:32 -0400 | [diff] [blame] | 444 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 445 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 446 | onpass="Switch latency test successful", |
| 447 | onfail="Switch latency test failed") |
andrewonlab | ba44bcf | 2014-10-16 16:54:41 -0400 | [diff] [blame] | 448 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 449 | def CASE3(self, main): |
| 450 | ''' |
| 451 | Bring port up / down and measure latency. |
| 452 | Port enable / disable is simulated by ifconfig up / down |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 453 | |
| 454 | In ONOS-next, we must ensure that the port we are |
| 455 | manipulating is connected to another switch with a valid |
| 456 | connection. Otherwise, graph view will not be updated. |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 457 | ''' |
| 458 | import time |
| 459 | import subprocess |
| 460 | import os |
| 461 | import requests |
| 462 | import json |
andrewonlab | 2a6c934 | 2014-10-16 13:40:15 -0400 | [diff] [blame] | 463 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 464 | ONOS1_ip = main.params['CTRL']['ip1'] |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 465 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 466 | ONOS3_ip = main.params['CTRL']['ip3'] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 467 | ONOS_user = main.params['CTRL']['user'] |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 468 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 469 | default_sw_port = main.params['CTRL']['port1'] |
| 470 | |
| 471 | #Number of iterations of case |
| 472 | num_iter = main.params['TEST']['numIter'] |
| 473 | |
| 474 | #Timestamp 'keys' for json metrics output. |
| 475 | #These are subject to change, hence moved into params |
| 476 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
| 477 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
| 478 | |
| 479 | #NOTE: Some hardcoded variables you may need to configure |
| 480 | # besides the params |
| 481 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 482 | tshark_port_status = "OFP 130 Port Status" |
| 483 | |
| 484 | tshark_port_up = "/tmp/tshark_port_up.txt" |
| 485 | tshark_port_down = "/tmp/tshark_port_down.txt" |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 486 | interface_config = "s1-eth1" |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 487 | |
| 488 | main.log.report("Port enable / disable latency") |
| 489 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 490 | main.step("Assign switches s1 and s2 to controller 1") |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 491 | main.Mininet1.assign_sw_controller(sw="1",ip1=ONOS1_ip, |
| 492 | port1=default_sw_port) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 493 | main.Mininet1.assign_sw_controller(sw="2",ip1=ONOS1_ip, |
| 494 | port1=default_sw_port) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 495 | |
| 496 | main.step("Verify switch is assigned correctly") |
| 497 | result_s1 = main.Mininet1.get_sw_controller(sw="s1") |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 498 | result_s2 = main.Mininet1.get_sw_controller(sw="s2") |
| 499 | if result_s1 == main.FALSE or result_s2 == main.FALSE: |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 500 | main.log.info("Switch s1 was not assigned correctly") |
| 501 | assertion = main.FALSE |
| 502 | else: |
| 503 | main.log.info("Switch s1 was assigned correctly") |
| 504 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 505 | port_up_device_to_ofp_list = [] |
| 506 | port_up_graph_to_ofp_list = [] |
| 507 | port_down_device_to_ofp_list = [] |
| 508 | port_down_graph_to_ofp_list = [] |
| 509 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 510 | for i in range(0, int(num_iter)): |
| 511 | main.step("Starting wireshark capture for port status down") |
| 512 | main.ONOS1.tshark_grep(tshark_port_status, |
| 513 | tshark_port_down) |
| 514 | |
| 515 | time.sleep(10) |
| 516 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 517 | #Disable interface that is connected to switch 2 |
| 518 | main.step("Disable port: "+interface_config) |
| 519 | main.Mininet2.handle.sendline("sudo ifconfig "+ |
| 520 | interface_config+" down") |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 521 | main.Mininet2.handle.expect("\$") |
| 522 | time.sleep(20) |
| 523 | |
| 524 | main.ONOS1.tshark_stop() |
| 525 | time.sleep(5) |
| 526 | |
| 527 | #Copy tshark output file from ONOS to TestON instance |
| 528 | #/tmp directory |
| 529 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 530 | tshark_port_down+" /tmp/") |
| 531 | |
| 532 | f_port_down = open(tshark_port_down, 'r') |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 533 | #Get first line of port down event from tshark |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 534 | f_line = f_port_down.readline() |
| 535 | obj_down = f_line.split(" ") |
| 536 | if len(f_line) > 0: |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 537 | timestamp_begin_pt_down = int(float(obj_down[1]))*1000 |
| 538 | main.log.info("Port down begin timestamp: "+ |
| 539 | str(timestamp_begin_pt_down)) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 540 | else: |
| 541 | main.log.info("Tshark output file returned unexpected"+ |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 542 | " results: "+str(obj_down)) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 543 | timestamp_begin_pt_down = 0 |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 544 | |
| 545 | f_port_down.close() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 546 | |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 547 | main.log.info("TEST tshark obj: "+str(obj_down)) |
| 548 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 549 | main.step("Obtain t1 by REST call") |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 550 | json_str_1 = main.ONOS1cli.topology_events_metrics() |
| 551 | json_str_2 = main.ONOS2cli.topology_events_metrics() |
| 552 | json_str_3 = main.ONOS3cli.topology_events_metrics() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 553 | |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 554 | main.log.info("TEST json_str 1: "+str(json_str_1)) |
| 555 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 556 | json_obj_1 = json.loads(json_str_1) |
| 557 | json_obj_2 = json.loads(json_str_2) |
| 558 | json_obj_3 = json.loads(json_str_3) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 559 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 560 | time.sleep(5) |
| 561 | |
| 562 | #Obtain graph timestamp. This timestsamp captures |
| 563 | #the epoch time at which the topology graph was updated. |
| 564 | graph_timestamp_1 = \ |
| 565 | json_obj_1[graphTimestamp]['value'] |
| 566 | graph_timestamp_2 = \ |
| 567 | json_obj_2[graphTimestamp]['value'] |
| 568 | graph_timestamp_3 = \ |
| 569 | json_obj_3[graphTimestamp]['value'] |
| 570 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 571 | #Obtain device timestamp. This timestamp captures |
| 572 | #the epoch time at which the device event happened |
| 573 | device_timestamp_1 = \ |
| 574 | json_obj_1[deviceTimestamp]['value'] |
| 575 | device_timestamp_2 = \ |
| 576 | json_obj_2[deviceTimestamp]['value'] |
| 577 | device_timestamp_3 = \ |
| 578 | json_obj_3[deviceTimestamp]['value'] |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 579 | |
| 580 | #Get delta between graph event and OFP |
| 581 | pt_down_graph_to_ofp_1 = int(graph_timestamp_1) -\ |
| 582 | int(timestamp_begin_pt_down) |
| 583 | pt_down_graph_to_ofp_2 = int(graph_timestamp_2) -\ |
| 584 | int(timestamp_begin_pt_down) |
| 585 | pt_down_graph_to_ofp_3 = int(graph_timestamp_3) -\ |
| 586 | int(timestamp_begin_pt_down) |
| 587 | |
| 588 | #Get delta between device event and OFP |
| 589 | pt_down_device_to_ofp_1 = int(device_timestamp_1) -\ |
| 590 | int(timestamp_begin_pt_down) |
| 591 | pt_down_device_to_ofp_2 = int(device_timestamp_2) -\ |
| 592 | int(timestamp_begin_pt_down) |
| 593 | pt_down_device_to_ofp_3 = int(device_timestamp_3) -\ |
| 594 | int(timestamp_begin_pt_down) |
| 595 | |
| 596 | #Caluclate average across clusters |
| 597 | pt_down_graph_to_ofp_avg =\ |
| 598 | (int(pt_down_graph_to_ofp_1) + |
| 599 | int(pt_down_graph_to_ofp_2) + |
| 600 | int(pt_down_graph_to_ofp_3)) / 3 |
| 601 | pt_down_device_to_ofp_avg = \ |
| 602 | (int(pt_down_device_to_ofp_1) + |
| 603 | int(pt_down_device_to_ofp_2) + |
| 604 | int(pt_down_device_to_ofp_3)) / 3 |
| 605 | |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 606 | if pt_down_graph_to_ofp_avg > 0.0 and \ |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 607 | pt_down_graph_to_ofp_avg < 1000: |
| 608 | port_down_graph_to_ofp_list.append( |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 609 | pt_down_graph_to_ofp_avg) |
| 610 | main.log.info("Port down: graph to ofp avg: "+ |
| 611 | str(pt_down_graph_to_ofp_avg) + " ms") |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 612 | else: |
| 613 | main.log.info("Average port down graph-to-ofp result" + |
| 614 | " exceeded the threshold: "+ |
| 615 | str(pt_down_graph_to_ofp_avg)) |
| 616 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 617 | if pt_down_device_to_ofp_avg > 0 and \ |
| 618 | pt_down_device_to_ofp_avg < 1000: |
| 619 | port_down_device_to_ofp_list.append( |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 620 | pt_down_device_to_ofp_avg) |
| 621 | main.log.info("Port down: device to ofp avg: "+ |
| 622 | str(pt_down_device_to_ofp_avg) + " ms") |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 623 | else: |
| 624 | main.log.info("Average port down device-to-ofp result" + |
| 625 | " exceeded the threshold: "+ |
| 626 | str(pt_down_device_to_ofp_avg)) |
| 627 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 628 | #Port up events |
| 629 | main.step("Enable port and obtain timestamp") |
| 630 | main.step("Starting wireshark capture for port status up") |
| 631 | main.ONOS1.tshark_grep("OFP 130 Port Status", tshark_port_up) |
| 632 | time.sleep(10) |
| 633 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 634 | main.Mininet2.handle.sendline("sudo ifconfig "+ |
| 635 | interface_config+" up") |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 636 | main.Mininet2.handle.expect("\$") |
| 637 | time.sleep(20) |
| 638 | |
| 639 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 640 | tshark_port_up+" /tmp/") |
| 641 | |
| 642 | f_port_up = open(tshark_port_up, 'r') |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 643 | f_line = f_port_up.readline() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 644 | obj_up = f_line.split(" ") |
| 645 | if len(f_line) > 0: |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 646 | timestamp_begin_pt_up = int(float(obj_up[1]))*1000 |
| 647 | main.log.info("Port up begin timestamp: "+ |
| 648 | str(timestamp_begin_pt_up)) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 649 | else: |
| 650 | main.log.info("Tshark output file returned unexpected"+ |
| 651 | " results.") |
| 652 | timestamp_begin_pt_up = 0 |
| 653 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 654 | f_port_up.close() |
| 655 | |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 656 | main.step("Obtain t1 by REST call") |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 657 | json_str_1 = main.ONOS1cli.topology_events_metrics() |
| 658 | json_str_2 = main.ONOS2cli.topology_events_metrics() |
| 659 | json_str_3 = main.ONOS3cli.topology_events_metrics() |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 660 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 661 | json_obj_1 = json.loads(json_str_1) |
| 662 | json_obj_2 = json.loads(json_str_2) |
| 663 | json_obj_3 = json.loads(json_str_3) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 664 | |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 665 | #Obtain graph timestamp. This timestsamp captures |
| 666 | #the epoch time at which the topology graph was updated. |
| 667 | graph_timestamp_1 = \ |
| 668 | json_obj_1[graphTimestamp]['value'] |
| 669 | graph_timestamp_2 = \ |
| 670 | json_obj_2[graphTimestamp]['value'] |
| 671 | graph_timestamp_3 = \ |
| 672 | json_obj_3[graphTimestamp]['value'] |
| 673 | |
| 674 | #Obtain device timestamp. This timestamp captures |
| 675 | #the epoch time at which the device event happened |
| 676 | device_timestamp_1 = \ |
| 677 | json_obj_1[deviceTimestamp]['value'] |
| 678 | device_timestamp_2 = \ |
| 679 | json_obj_2[deviceTimestamp]['value'] |
| 680 | device_timestamp_3 = \ |
| 681 | json_obj_3[deviceTimestamp]['value'] |
| 682 | |
| 683 | #Get delta between graph event and OFP |
| 684 | pt_up_graph_to_ofp_1 = int(graph_timestamp_1) -\ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 685 | int(timestamp_begin_pt_up) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 686 | pt_up_graph_to_ofp_2 = int(graph_timestamp_2) -\ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 687 | int(timestamp_begin_pt_up) |
andrewonlab | 393531a | 2014-10-27 18:36:26 -0400 | [diff] [blame] | 688 | pt_up_graph_to_ofp_3 = int(graph_timestamp_3) -\ |
| 689 | int(timestamp_begin_pt_up) |
| 690 | |
| 691 | #Get delta between device event and OFP |
| 692 | pt_up_device_to_ofp_1 = int(device_timestamp_1) -\ |
| 693 | int(timestamp_begin_pt_up) |
| 694 | pt_up_device_to_ofp_2 = int(device_timestamp_2) -\ |
| 695 | int(timestamp_begin_pt_up) |
| 696 | pt_up_device_to_ofp_3 = int(device_timestamp_3) -\ |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 697 | int(timestamp_begin_pt_up) |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 698 | |
| 699 | pt_up_graph_to_ofp_avg = \ |
| 700 | (float(pt_up_graph_to_ofp_1) + |
| 701 | float(pt_up_graph_to_ofp_2) + |
| 702 | float(pt_up_graph_to_ofp_3)) / 3 |
| 703 | |
| 704 | pt_up_device_to_ofp_avg = \ |
| 705 | (float(pt_up_device_to_ofp_1) + |
| 706 | float(pt_up_device_to_ofp_2) + |
| 707 | float(pt_up_device_to_ofp_3)) / 3 |
| 708 | |
| 709 | if pt_up_graph_to_ofp_avg > 0 and \ |
| 710 | pt_up_graph_to_ofp_avg < 1000: |
| 711 | port_up_graph_to_ofp_list.append( |
| 712 | pt_up_graph_to_ofp_avg) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 713 | main.log.info("Port down: graph to ofp avg: "+ |
| 714 | str(pt_up_graph_to_ofp_avg) + " ms") |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 715 | else: |
| 716 | main.log.info("Average port up graph-to-ofp result"+ |
| 717 | " exceeded the threshold: "+ |
| 718 | str(pt_up_graph_to_ofp_avg)) |
| 719 | |
| 720 | if pt_up_device_to_ofp_avg > 0 and \ |
| 721 | pt_up_device_to_ofp_avg < 1000: |
| 722 | port_up_device_to_ofp_list.append( |
| 723 | pt_up_device_to_ofp_avg) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 724 | main.log.info("Port up: device to ofp avg: "+ |
| 725 | str(pt_up_device_to_ofp_avg) + " ms") |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 726 | else: |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 727 | main.log.info("Average port up device-to-ofp result"+ |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 728 | " exceeded the threshold: "+ |
| 729 | str(pt_up_device_to_ofp_avg)) |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 730 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 731 | #END ITERATION FOR LOOP |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 732 | |
| 733 | #Calculate and report latency measurements |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 734 | port_down_graph_to_ofp_min = min(port_down_graph_to_ofp_list) |
| 735 | port_down_graph_to_ofp_max = max(port_down_graph_to_ofp_list) |
| 736 | port_down_graph_to_ofp_avg = \ |
| 737 | (sum(port_down_graph_to_ofp_list) / |
| 738 | len(port_down_graph_to_ofp_list)) |
| 739 | |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 740 | main.log.report("Port down graph-to-ofp Min: "+ |
| 741 | str(port_down_graph_to_ofp_min)) |
| 742 | main.log.report("Port down graph-to-ofp Max: "+ |
| 743 | str(port_down_graph_to_ofp_max)) |
| 744 | main.log.report("Port down graph-to-ofp Avg: "+ |
| 745 | str(port_down_graph_to_ofp_avg)) |
| 746 | |
| 747 | port_down_device_to_ofp_min = min(port_down_device_to_ofp_list) |
| 748 | port_down_device_to_ofp_max = max(port_down_device_to_ofp_list) |
| 749 | port_down_device_to_ofp_avg = \ |
| 750 | (sum(port_down_device_to_ofp_list) /\ |
| 751 | len(port_down_device_to_ofp_list)) |
| 752 | |
| 753 | main.log.report("Port down device-to-ofp Min: "+ |
| 754 | str(port_down_device_to_ofp_min)) |
| 755 | main.log.report("Port down device-to-ofp Max: "+ |
| 756 | str(port_down_device_to_ofp_max)) |
| 757 | main.log.report("Port down device-to-ofp Avg: "+ |
| 758 | str(port_down_device_to_ofp_avg)) |
| 759 | |
| 760 | port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list) |
| 761 | port_up_graph_to_ofp_max = max(port_up_graph_to_ofp_list) |
| 762 | port_up_graph_to_ofp_avg = \ |
| 763 | (sum(port_up_graph_to_ofp_list) /\ |
| 764 | len(port_up_graph_to_ofp_list)) |
| 765 | |
| 766 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 767 | def CASE4(self, main): |
| 768 | ''' |
| 769 | Link down event using loss rate 100% |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 770 | |
| 771 | Important: |
| 772 | Use a simple 2 switch topology with 1 link between |
| 773 | the two switches. Ensure that mac addresses of the |
| 774 | switches are 1 / 2 respectively |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 775 | ''' |
| 776 | import time |
| 777 | import subprocess |
| 778 | import os |
| 779 | import requests |
| 780 | import json |
| 781 | |
| 782 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 783 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 784 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 785 | ONOS_user = main.params['CTRL']['user'] |
| 786 | |
| 787 | default_sw_port = main.params['CTRL']['port1'] |
| 788 | |
| 789 | #Number of iterations of case |
| 790 | num_iter = main.params['TEST']['numIter'] |
| 791 | |
| 792 | #Timestamp 'keys' for json metrics output. |
| 793 | #These are subject to change, hence moved into params |
| 794 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
| 795 | linkTimestamp = main.params['JSON']['linkTimestamp'] |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 796 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
| 797 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 798 | assertion = main.TRUE |
| 799 | #Link event timestamp to system time list |
| 800 | link_down_link_to_system_list = [] |
| 801 | link_up_link_to_system_list = [] |
| 802 | #Graph event timestamp to system time list |
| 803 | link_down_graph_to_system_list = [] |
| 804 | link_up_graph_to_system_list = [] |
| 805 | |
| 806 | main.log.report("Add / remove link latency between "+ |
| 807 | "two switches") |
| 808 | |
| 809 | main.step("Assign all switches") |
| 810 | main.Mininet1.assign_sw_controller(sw="1", |
| 811 | ip1=ONOS1_ip, port1=default_sw_port) |
| 812 | main.Mininet1.assign_sw_controller(sw="2", |
| 813 | ip1=ONOS1_ip, port1=default_sw_port) |
| 814 | |
| 815 | main.step("Verifying switch assignment") |
| 816 | result_s1 = main.Mininet1.get_sw_controller(sw="s1") |
| 817 | result_s2 = main.Mininet1.get_sw_controller(sw="s2") |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 818 | |
| 819 | #Allow time for events to finish before taking measurements |
| 820 | time.sleep(10) |
| 821 | |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 822 | link_down1 = False |
| 823 | link_down2 = False |
| 824 | link_down3 = False |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 825 | #Start iteration of link event test |
| 826 | for i in range(0, int(num_iter)): |
| 827 | main.step("Getting initial system time as t0") |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 828 | |
andrewonlab | 3622beb | 2014-10-28 16:07:56 -0400 | [diff] [blame] | 829 | timestamp_link_down_t0 = time.time() * 1000 |
| 830 | #Link down is simulated by 100% loss rate using traffic |
| 831 | #control command |
| 832 | main.Mininet1.handle.sendline( |
| 833 | "sh tc qdisc add dev s1-eth1 root netem loss 100%") |
| 834 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 835 | #TODO: Iterate through 'links' command to verify that |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 836 | # link s1 -> s2 went down (loop timeout 30 seconds) |
| 837 | # on all 3 ONOS instances |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 838 | main.log.info("Checking ONOS for link update") |
| 839 | loop_count = 0 |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 840 | while( not (link_down1 and link_down2 and link_down3)\ |
| 841 | and loop_count < 30 ): |
| 842 | json_str1 = main.ONOS1cli.links() |
| 843 | json_str2 = main.ONOS2cli.links() |
| 844 | json_str3 = main.ONOS3cli.links() |
| 845 | |
| 846 | if not (json_str1 and json_str2 and json_str3): |
| 847 | main.log.error("CLI command returned error ") |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 848 | break |
| 849 | else: |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 850 | json_obj1 = json.loads(json_str1) |
| 851 | json_obj2 = json.loads(json_str2) |
| 852 | json_obj3 = json.loads(json_str3) |
| 853 | for obj1 in json_obj1: |
| 854 | if '01' not in obj1['src']['device']: |
| 855 | link_down1 = True |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 856 | main.log.report("Link down from "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 857 | "s1 -> s2 on ONOS1 detected") |
| 858 | for obj2 in json_obj2: |
| 859 | if '01' not in obj2['src']['device']: |
| 860 | link_down2 = True |
| 861 | main.log.report("Link down from "+ |
| 862 | "s1 -> s2 on ONOS2 detected") |
| 863 | for obj3 in json_obj3: |
| 864 | if '01' not in obj3['src']['device']: |
| 865 | link_down3 = True |
| 866 | main.log.report("Link down from "+ |
| 867 | "s1 -> s2 on ONOS3 detected") |
| 868 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 869 | loop_count += 1 |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 870 | #If CLI doesn't like the continuous requests |
| 871 | #and exits in this loop, increase the sleep here. |
| 872 | #Consequently, while loop timeout will increase |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 873 | time.sleep(1) |
| 874 | |
| 875 | #Give time for metrics measurement to catch up |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 876 | #NOTE: May need to be configured more accurately |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 877 | time.sleep(10) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 878 | #If we exited the while loop and link down 1,2,3 are still |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 879 | #false, then ONOS has failed to discover link down event |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 880 | if not (link_down1 and link_down2 and link_down3): |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 881 | main.log.info("Link down discovery failed") |
| 882 | |
| 883 | link_down_lat_graph1 = 0 |
| 884 | link_down_lat_graph2 = 0 |
| 885 | link_down_lat_graph3 = 0 |
| 886 | link_down_lat_device1 = 0 |
| 887 | link_down_lat_device2 = 0 |
| 888 | link_down_lat_device3 = 0 |
| 889 | |
| 890 | assertion = main.FALSE |
| 891 | else: |
| 892 | json_topo_metrics_1 =\ |
| 893 | main.ONOS1cli.topology_events_metrics() |
| 894 | json_topo_metrics_2 =\ |
| 895 | main.ONOS2cli.topology_events_metrics() |
| 896 | json_topo_metrics_3 =\ |
| 897 | main.ONOS3cli.topology_events_metrics() |
| 898 | json_topo_metrics_1 = json.loads(json_topo_metrics_1) |
| 899 | json_topo_metrics_2 = json.loads(json_topo_metrics_2) |
| 900 | json_topo_metrics_3 = json.loads(json_topo_metrics_3) |
| 901 | |
| 902 | main.log.info("Obtaining graph and device timestamp") |
| 903 | graph_timestamp_1 = \ |
| 904 | json_topo_metrics_1[graphTimestamp]['value'] |
| 905 | graph_timestamp_2 = \ |
| 906 | json_topo_metrics_2[graphTimestamp]['value'] |
| 907 | graph_timestamp_3 = \ |
| 908 | json_topo_metrics_3[graphTimestamp]['value'] |
| 909 | |
| 910 | link_timestamp_1 = \ |
| 911 | json_topo_metrics_1[linkTimestamp]['value'] |
| 912 | link_timestamp_2 = \ |
| 913 | json_topo_metrics_2[linkTimestamp]['value'] |
| 914 | link_timestamp_3 = \ |
| 915 | json_topo_metrics_3[linkTimestamp]['value'] |
| 916 | |
| 917 | if graph_timestamp_1 and graph_timestamp_2 and\ |
| 918 | graph_timestamp_3 and link_timestamp_1 and\ |
| 919 | link_timestamp_2 and link_timestamp_3: |
| 920 | link_down_lat_graph1 = int(graph_timestamp_1) -\ |
| 921 | timestamp_link_down_t0 |
| 922 | link_down_lat_graph2 = int(graph_timestamp_2) -\ |
| 923 | timestamp_link_down_t0 |
| 924 | link_down_lat_graph3 = int(graph_timestamp_3) -\ |
| 925 | timestamp_link_down_t0 |
| 926 | |
| 927 | link_down_lat_link1 = int(link_timestamp_1) -\ |
| 928 | timestamp_link_down_t0 |
| 929 | link_down_lat_link2 = int(link_timestamp_2) -\ |
| 930 | timestamp_link_down_t0 |
| 931 | link_down_lat_link3 = int(link_timestamp_3) -\ |
| 932 | timestamp_link_down_t0 |
| 933 | else: |
| 934 | main.log.error("There was an error calculating"+ |
| 935 | " the delta for link down event") |
| 936 | link_down_lat_graph1 = 0 |
| 937 | link_down_lat_graph2 = 0 |
| 938 | link_down_lat_graph3 = 0 |
| 939 | |
| 940 | link_down_lat_device1 = 0 |
| 941 | link_down_lat_device2 = 0 |
| 942 | link_down_lat_device3 = 0 |
| 943 | |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 944 | main.log.report("Link down latency ONOS1 iteration "+ |
| 945 | str(i)+" (end-to-end): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 946 | str(link_down_lat_graph1)+" ms") |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 947 | main.log.report("Link down latency ONOS2 iteration "+ |
| 948 | str(i)+" (end-to-end): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 949 | str(link_down_lat_graph2)+" ms") |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 950 | main.log.report("Link down latency ONOS3 iteration "+ |
| 951 | str(i)+" (end-to-end): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 952 | str(link_down_lat_graph3)+" ms") |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 953 | |
| 954 | main.log.report("Link down latency ONOS1 iteration "+ |
| 955 | str(i)+" (link-event-to-system-timestamp): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 956 | str(link_down_lat_link1)+" ms") |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 957 | main.log.report("Link down latency ONOS2 iteration "+ |
| 958 | str(i)+" (link-event-to-system-timestamp): "+ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 959 | str(link_down_lat_link2)+" ms") |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 960 | main.log.report("Link down latency ONOS3 iteration "+ |
| 961 | str(i)+" (link-event-to-system-timestamp): "+ |
| 962 | str(link_down_lat_link3)) |
| 963 | |
| 964 | #Calculate avg of node calculations |
| 965 | link_down_lat_graph_avg =\ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 966 | (link_down_lat_graph1 + |
| 967 | link_down_lat_graph2 + |
| 968 | link_down_lat_graph3) / 3.0 |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 969 | link_down_lat_link_avg =\ |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 970 | (link_down_lat_link1 + |
| 971 | link_down_lat_link2 + |
| 972 | link_down_lat_link3) / 3.0 |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 973 | |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 974 | #Set threshold and append latency to list |
| 975 | if link_down_lat_graph_avg > 0.0 and\ |
| 976 | link_down_lat_graph_avg < 30000: |
| 977 | link_down_graph_to_system_list.append( |
| 978 | link_down_lat_graph_avg) |
| 979 | if link_down_lat_link_avg > 0.0 and\ |
| 980 | link_down_lat_link_avg < 30000: |
| 981 | link_down_link_to_system_list.append( |
| 982 | link_down_lat_link_avg) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 983 | |
| 984 | #NOTE: To remove loss rate and measure latency: |
| 985 | # 'sh tc qdisc del dev s1-eth1 root' |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 986 | timestamp_link_up_t0 = time.time() * 1000 |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 987 | main.Mininet1.handle.sendline("sh tc qdisc del dev "+ |
| 988 | "s1-eth1 root") |
| 989 | main.Mininet1.handle.expect("mininet>") |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 990 | |
| 991 | main.log.info("Checking ONOS for link update") |
| 992 | |
| 993 | link_down1 = True |
| 994 | link_down2 = True |
| 995 | link_down3 = True |
| 996 | loop_count = 0 |
| 997 | while( (link_down1 and link_down2 and link_down3)\ |
| 998 | and loop_count < 30 ): |
| 999 | json_str1 = main.ONOS1cli.links() |
| 1000 | json_str2 = main.ONOS2cli.links() |
| 1001 | json_str3 = main.ONOS3cli.links() |
| 1002 | if not (json_str1 and json_str2 and json_str3): |
| 1003 | main.log.error("CLI command returned error ") |
| 1004 | break |
| 1005 | else: |
| 1006 | json_obj1 = json.loads(json_str1) |
| 1007 | json_obj2 = json.loads(json_str2) |
| 1008 | json_obj3 = json.loads(json_str3) |
| 1009 | |
| 1010 | for obj1 in json_obj1: |
| 1011 | if '01' in obj1['src']['device']: |
| 1012 | link_down1 = False |
| 1013 | main.log.report("Link up from "+ |
| 1014 | "s1 -> s2 on ONOS1 detected") |
| 1015 | for obj2 in json_obj2: |
| 1016 | if '01' in obj2['src']['device']: |
| 1017 | link_down2 = False |
| 1018 | main.log.report("Link up from "+ |
| 1019 | "s1 -> s2 on ONOS2 detected") |
| 1020 | for obj3 in json_obj3: |
| 1021 | if '01' in obj3['src']['device']: |
| 1022 | link_down3 = False |
| 1023 | main.log.report("Link up from "+ |
| 1024 | "s1 -> s2 on ONOS3 detected") |
| 1025 | |
| 1026 | loop_count += 1 |
| 1027 | time.sleep(1) |
| 1028 | |
| 1029 | if (link_down1 and link_down2 and link_down3): |
| 1030 | main.log.info("Link up discovery failed") |
| 1031 | |
| 1032 | link_up_lat_graph1 = 0 |
| 1033 | link_up_lat_graph2 = 0 |
| 1034 | link_up_lat_graph3 = 0 |
| 1035 | link_up_lat_device1 = 0 |
| 1036 | link_up_lat_device2 = 0 |
| 1037 | link_up_lat_device3 = 0 |
| 1038 | |
| 1039 | assertion = main.FALSE |
| 1040 | else: |
| 1041 | json_topo_metrics_1 =\ |
| 1042 | main.ONOS1cli.topology_events_metrics() |
| 1043 | json_topo_metrics_2 =\ |
| 1044 | main.ONOS2cli.topology_events_metrics() |
| 1045 | json_topo_metrics_3 =\ |
| 1046 | main.ONOS3cli.topology_events_metrics() |
| 1047 | json_topo_metrics_1 = json.loads(json_topo_metrics_1) |
| 1048 | json_topo_metrics_2 = json.loads(json_topo_metrics_2) |
| 1049 | json_topo_metrics_3 = json.loads(json_topo_metrics_3) |
| 1050 | |
| 1051 | main.log.info("Obtaining graph and device timestamp") |
| 1052 | graph_timestamp_1 = \ |
| 1053 | json_topo_metrics_1[graphTimestamp]['value'] |
| 1054 | graph_timestamp_2 = \ |
| 1055 | json_topo_metrics_2[graphTimestamp]['value'] |
| 1056 | graph_timestamp_3 = \ |
| 1057 | json_topo_metrics_3[graphTimestamp]['value'] |
| 1058 | |
| 1059 | link_timestamp_1 = \ |
| 1060 | json_topo_metrics_1[linkTimestamp]['value'] |
| 1061 | link_timestamp_2 = \ |
| 1062 | json_topo_metrics_2[linkTimestamp]['value'] |
| 1063 | link_timestamp_3 = \ |
| 1064 | json_topo_metrics_3[linkTimestamp]['value'] |
| 1065 | |
| 1066 | if graph_timestamp_1 and graph_timestamp_2 and\ |
| 1067 | graph_timestamp_3 and link_timestamp_1 and\ |
| 1068 | link_timestamp_2 and link_timestamp_3: |
| 1069 | link_up_lat_graph1 = int(graph_timestamp_1) -\ |
| 1070 | timestamp_link_up_t0 |
| 1071 | link_up_lat_graph2 = int(graph_timestamp_2) -\ |
| 1072 | timestamp_link_up_t0 |
| 1073 | link_up_lat_graph3 = int(graph_timestamp_3) -\ |
| 1074 | timestamp_link_up_t0 |
| 1075 | |
| 1076 | link_up_lat_link1 = int(link_timestamp_1) -\ |
| 1077 | timestamp_link_up_t0 |
| 1078 | link_up_lat_link2 = int(link_timestamp_2) -\ |
| 1079 | timestamp_link_up_t0 |
| 1080 | link_up_lat_link3 = int(link_timestamp_3) -\ |
| 1081 | timestamp_link_up_t0 |
| 1082 | else: |
| 1083 | main.log.error("There was an error calculating"+ |
| 1084 | " the delta for link down event") |
| 1085 | link_up_lat_graph1 = 0 |
| 1086 | link_up_lat_graph2 = 0 |
| 1087 | link_up_lat_graph3 = 0 |
| 1088 | |
| 1089 | link_up_lat_device1 = 0 |
| 1090 | link_up_lat_device2 = 0 |
| 1091 | link_up_lat_device3 = 0 |
| 1092 | |
| 1093 | main.log.info("Link up latency ONOS1 iteration "+ |
| 1094 | str(i)+" (end-to-end): "+ |
| 1095 | str(link_up_lat_graph1)+" ms") |
| 1096 | main.log.info("Link up latency ONOS2 iteration "+ |
| 1097 | str(i)+" (end-to-end): "+ |
| 1098 | str(link_up_lat_graph2)+" ms") |
| 1099 | main.log.info("Link up latency ONOS3 iteration "+ |
| 1100 | str(i)+" (end-to-end): "+ |
| 1101 | str(link_up_lat_graph3)+" ms") |
| 1102 | |
| 1103 | main.log.info("Link up latency ONOS1 iteration "+ |
| 1104 | str(i)+" (link-event-to-system-timestamp): "+ |
| 1105 | str(link_up_lat_link1)+" ms") |
| 1106 | main.log.info("Link up latency ONOS2 iteration "+ |
| 1107 | str(i)+" (link-event-to-system-timestamp): "+ |
| 1108 | str(link_up_lat_link2)+" ms") |
| 1109 | main.log.info("Link up latency ONOS3 iteration "+ |
| 1110 | str(i)+" (link-event-to-system-timestamp): "+ |
| 1111 | str(link_up_lat_link3)) |
| 1112 | |
| 1113 | #Calculate avg of node calculations |
| 1114 | link_up_lat_graph_avg =\ |
| 1115 | (link_up_lat_graph1 + |
| 1116 | link_up_lat_graph2 + |
| 1117 | link_up_lat_graph3) / 3.0 |
| 1118 | link_up_lat_link_avg =\ |
| 1119 | (link_up_lat_link1 + |
| 1120 | link_up_lat_link2 + |
| 1121 | link_up_lat_link3) / 3.0 |
| 1122 | |
| 1123 | #Set threshold and append latency to list |
| 1124 | if link_up_lat_graph_avg > 0.0 and\ |
| 1125 | link_up_lat_graph_avg < 30000: |
| 1126 | link_up_graph_to_system_list.append( |
| 1127 | link_up_lat_graph_avg) |
| 1128 | if link_up_lat_link_avg > 0.0 and\ |
| 1129 | link_up_lat_link_avg < 30000: |
| 1130 | link_up_link_to_system_list.append( |
| 1131 | link_up_lat_link_avg) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1132 | |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1133 | #Calculate min, max, avg of list and report |
| 1134 | link_down_min = min(link_down_graph_to_system_list) |
| 1135 | link_down_max = max(link_down_graph_to_system_list) |
| 1136 | link_down_avg = sum(link_down_graph_to_system_list) / \ |
| 1137 | len(link_down_graph_to_system_list) |
andrewonlab | abb11c3 | 2014-11-04 15:03:24 -0500 | [diff] [blame] | 1138 | link_up_min = min(link_up_graph_to_system_list) |
| 1139 | link_up_max = max(link_up_graph_to_system_list) |
| 1140 | link_up_avg = sum(link_up_graph_to_system_list) / \ |
| 1141 | len(link_up_graph_to_system_list) |
| 1142 | |
| 1143 | main.log.report("Link down latency - Min: "+ |
| 1144 | str(link_down_min)+"ms Max: "+ |
| 1145 | str(link_down_max)+"ms Avg: "+ |
| 1146 | str(link_down_avg)+"ms") |
| 1147 | main.log.report("Link up latency - Min: "+ |
| 1148 | str(link_up_min)+"ms Max: "+ |
| 1149 | str(link_up_max)+"ms Avg: "+ |
| 1150 | str(link_up_avg)+"ms") |
andrewonlab | 4e12448 | 2014-11-04 13:37:25 -0500 | [diff] [blame] | 1151 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1152 | def CASE5(self, main): |
| 1153 | ''' |
| 1154 | 100 Switch discovery latency |
| 1155 | |
| 1156 | Important: |
| 1157 | If a simple topology was used in previous cases, |
| 1158 | you will need to change the topology file in the |
| 1159 | params for this case to proceed |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1160 | |
| 1161 | This test case can be potentially dangerous if |
| 1162 | your machine has previously set iptables rules. |
| 1163 | One of the steps of the test case will flush |
| 1164 | all existing iptables rules. |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1165 | ''' |
| 1166 | import time |
| 1167 | import subprocess |
| 1168 | import os |
| 1169 | import requests |
| 1170 | import json |
| 1171 | |
| 1172 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 1173 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 1174 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 1175 | MN1_ip = main.params['MN']['ip1'] |
| 1176 | ONOS_user = main.params['CTRL']['user'] |
| 1177 | |
| 1178 | default_sw_port = main.params['CTRL']['port1'] |
| 1179 | |
| 1180 | #Number of iterations of case |
| 1181 | num_iter = main.params['TEST']['numIter'] |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1182 | num_sw = main.params['TEST']['numSwitch'] |
| 1183 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1184 | #Timestamp 'keys' for json metrics output. |
| 1185 | #These are subject to change, hence moved into params |
| 1186 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1187 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
| 1188 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1189 | tshark_ofp_output = "/tmp/tshark_ofp_"+num_sw+"sw.txt" |
| 1190 | tshark_tcp_output = "/tmp/tshark_tcp_"+num_sw+"sw.txt" |
| 1191 | |
| 1192 | tshark_ofp_result_list = [] |
| 1193 | tshark_tcp_result_list = [] |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1194 | |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1195 | main.case(num_sw+" Switch discovery latency") |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1196 | main.step("Assigning all switches to ONOS1") |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1197 | for i in range(1, int(num_sw)+1): |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1198 | main.Mininet1.assign_sw_controller( |
| 1199 | sw=str(i), |
| 1200 | ip1=ONOS1_ip, |
| 1201 | port1=default_sw_port) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1202 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1203 | #Ensure that nodes are configured with ptpd |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1204 | #Just a warning message |
| 1205 | main.log.info("Please check ptpd configuration to ensure"+\ |
| 1206 | " All nodes' system times are in sync") |
| 1207 | time.sleep(5) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1208 | |
| 1209 | for i in range(0, int(num_iter)): |
andrewonlab | 8d29f12 | 2014-10-22 17:15:04 -0400 | [diff] [blame] | 1210 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1211 | main.step("Set iptables rule to block incoming sw connections") |
| 1212 | #Set iptables rule to block incoming switch connections |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1213 | #The rule description is as follows: |
| 1214 | # Append to INPUT rule, |
| 1215 | # behavior DROP that matches following: |
| 1216 | # * packet type: tcp |
| 1217 | # * source IP: MN1_ip |
| 1218 | # * destination PORT: 6633 |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1219 | main.ONOS1.handle.sendline( |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1220 | "sudo iptables -A INPUT -p tcp -s "+MN1_ip+ |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1221 | " --dport "+default_sw_port+" -j DROP") |
| 1222 | main.ONOS1.handle.expect("\$") |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1223 | # Append to OUTPUT rule, |
| 1224 | # behavior DROP that matches following: |
| 1225 | # * packet type: tcp |
| 1226 | # * source IP: MN1_ip |
| 1227 | # * destination PORT: 6633 |
| 1228 | main.ONOS1.handle.sendline( |
| 1229 | "sudo iptables -A OUTPUT -p tcp -s "+MN1_ip+ |
| 1230 | " --dport "+default_sw_port+" -j DROP") |
| 1231 | main.ONOS1.handle.expect("\$") |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1232 | #Give time to allow rule to take effect |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1233 | main.log.info("Please wait for switch connection to "+ |
| 1234 | "time out") |
| 1235 | time.sleep(60) |
| 1236 | |
| 1237 | #Gather vendor OFP with tshark |
| 1238 | main.ONOS1.tshark_grep("OFP 86 Vendor", |
| 1239 | tshark_ofp_output) |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1240 | main.ONOS1.tshark_grep("TCP 74 ", |
| 1241 | tshark_tcp_output) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1242 | |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1243 | #NOTE: Remove all iptables rule quickly (flush) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1244 | # Before removal, obtain TestON timestamp at which |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1245 | # removal took place |
| 1246 | # (ensuring nodes are configured via ptp) |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1247 | # sudo iptables -F |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1248 | |
| 1249 | t0_system = time.time() * 1000 |
| 1250 | main.ONOS1.handle.sendline( |
| 1251 | "sudo iptables -F") |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1252 | |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1253 | #Counter to track loop count |
| 1254 | counter_loop = 0 |
| 1255 | counter_avail1 = 0 |
| 1256 | counter_avail2 = 0 |
| 1257 | counter_avail3 = 0 |
| 1258 | onos1_dev = False |
| 1259 | onos2_dev = False |
| 1260 | onos3_dev = False |
| 1261 | while counter_loop < 60: |
| 1262 | #Continue to check devices for all device |
| 1263 | #availability. When all devices in all 3 |
| 1264 | #ONOS instances indicate that devices are available |
| 1265 | #obtain graph event timestamp for t1. |
| 1266 | device_str_obj1 = main.ONOS1cli.devices() |
| 1267 | device_str_obj2 = main.ONOS2cli.devices() |
| 1268 | device_str_obj3 = main.ONOS3cli.devices() |
| 1269 | |
| 1270 | device_json1 = json.loads(device_str_obj1) |
| 1271 | device_json2 = json.loads(device_str_obj2) |
| 1272 | device_json3 = json.loads(device_str_obj3) |
| 1273 | |
| 1274 | for device1 in device_json1: |
| 1275 | if device1['available'] == True: |
| 1276 | counter_avail1 += 1 |
| 1277 | if counter_avail1 == int(num_sw): |
| 1278 | onos1_dev = True |
| 1279 | main.log.info("All devices have been "+ |
| 1280 | "discovered on ONOS1") |
| 1281 | else: |
| 1282 | counter_avail1 = 0 |
| 1283 | for device2 in device_json2: |
| 1284 | if device2['available'] == True: |
| 1285 | counter_avail2 += 1 |
| 1286 | if counter_avail2 == int(num_sw): |
| 1287 | onos2_dev = True |
| 1288 | main.log.info("All devices have been "+ |
| 1289 | "discovered on ONOS2") |
| 1290 | else: |
| 1291 | counter_avail2 = 0 |
| 1292 | for device3 in device_json3: |
| 1293 | if device3['available'] == True: |
| 1294 | counter_avail3 += 1 |
| 1295 | if counter_avail3 == int(num_sw): |
| 1296 | onos3_dev = True |
| 1297 | main.log.info("All devices have been "+ |
| 1298 | "discovered on ONOS3") |
| 1299 | else: |
| 1300 | counter_avail3 = 0 |
| 1301 | |
| 1302 | if onos1_dev and onos2_dev and onos3_dev: |
| 1303 | main.log.info("All devices have been discovered "+ |
| 1304 | "on all ONOS instances") |
| 1305 | json_str_topology_metrics_1 =\ |
| 1306 | main.ONOS1cli.topology_events_metrics() |
| 1307 | json_str_topology_metrics_2 =\ |
| 1308 | main.ONOS2cli.topology_events_metrics() |
| 1309 | json_str_topology_metrics_3 =\ |
| 1310 | main.ONOS3cli.topology_events_metrics() |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1311 | |
| 1312 | #Exit while loop if all devices discovered |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1313 | break |
| 1314 | |
| 1315 | counter_loop += 1 |
| 1316 | #Give some time in between CLI calls |
| 1317 | #(will not affect measurement) |
| 1318 | time.sleep(3) |
| 1319 | |
| 1320 | main.ONOS1.tshark_stop() |
| 1321 | |
| 1322 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 1323 | tshark_ofp_output+" /tmp/") |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1324 | os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+ |
| 1325 | tshark_tcp_output+" /tmp/") |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1326 | ofp_file = open(tshark_ofp_output, 'r') |
| 1327 | |
| 1328 | #The following is for information purpose only. |
| 1329 | #TODO: Automate OFP output analysis |
| 1330 | main.log.info("Tshark OFP Vendor output: ") |
| 1331 | for line in ofp_file: |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1332 | tshark_ofp_result_list.append(line) |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1333 | main.log.info(line) |
| 1334 | |
andrewonlab | 53b641c | 2014-10-31 19:44:44 -0400 | [diff] [blame] | 1335 | ofp_file.close() |
| 1336 | |
| 1337 | tcp_file = open(tshark_tcp_output, 'r') |
| 1338 | main.log.info("Tshark TCP 74 output: ") |
| 1339 | for line in tcp_file: |
| 1340 | tshark_tcp_result_list.append(line) |
| 1341 | main.log.info(line) |
| 1342 | |
| 1343 | tcp_file.close() |
| 1344 | |
andrewonlab | 16ce485 | 2014-10-30 13:41:09 -0400 | [diff] [blame] | 1345 | json_obj_1 = json.loads(json_str_topology_metrics_1) |
| 1346 | json_obj_2 = json.loads(json_str_topology_metrics_2) |
| 1347 | json_obj_3 = json.loads(json_str_topology_metrics_3) |
| 1348 | |
| 1349 | graph_timestamp_1 = \ |
| 1350 | json_obj_1[graphTimestamp]['value'] |
| 1351 | graph_timestamp_2 = \ |
| 1352 | json_obj_2[graphTimestamp]['value'] |
| 1353 | graph_timestamp_3 = \ |
| 1354 | json_obj_3[graphTimestamp]['value'] |
| 1355 | |
| 1356 | main.log.info( |
| 1357 | int(graph_timestamp_1) - int(t0_system)) |
| 1358 | main.log.info( |
| 1359 | int(graph_timestamp_2) - int(t0_system)) |
| 1360 | main.log.info( |
| 1361 | int(graph_timestamp_3) - int(t0_system)) |
| 1362 | |
| 1363 | |
| 1364 | |
| 1365 | |
| 1366 | |
| 1367 | |
andrewonlab | b54b85b | 2014-10-28 18:43:57 -0400 | [diff] [blame] | 1368 | |