Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Roman Bubyr | d4b8741 | 2019-08-05 12:52:40 +0300 | [diff] [blame^] | 16 | |
| 17 | """ |
| 18 | Check README file |
| 19 | """ |
| 20 | |
| 21 | from oftest import config |
| 22 | import logging |
| 23 | import oftest.base_tests as base_tests |
| 24 | import ofp |
| 25 | import os |
| 26 | import time |
| 27 | import json |
| 28 | from oftest.testutils import * |
| 29 | from accton_util import * |
| 30 | from oftest.utils import * |
| 31 | from oftest.ofdpa_utils import * |
| 32 | from accton_util import * |
| 33 | |
| 34 | # Number of xconnections created per port |
| 35 | xcon_num = 64 |
| 36 | |
| 37 | # Number of seconds to wait after switch restart |
| 38 | rest_num = 300 |
| 39 | |
| 40 | #### Global variable # defined globally to check whether base_config was executed or not |
| 41 | BASE_RUN = False |
| 42 | |
| 43 | |
| 44 | ##### |
| 45 | ##Test cases assumes the ONOS controller is Running and Fabric SWitch is configured to use ONOS as the SDN Controller |
| 46 | ## Test cases assumes ONOS controller is in a clean state |
| 47 | ## Test cases assumes Fabric switch is in clean state without any flows or group entries from a previous configuration. Its a good idea to reload the Fabric switch before starting the test cases. |
| 48 | ## Refer to the test plan for more details |
| 49 | |
| 50 | class FabricSW_Scale_Base_TC_0005(base_tests.SimpleDataPlane): |
| 51 | """ |
| 52 | This Test case defines the base configuration which will serve as a pre-requisite on top of which other test cases are executed. |
| 53 | """ |
| 54 | ### Read config parameters from JSON file 'global_vars.json' |
| 55 | ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 56 | with open(ROOT_DIR + '/' + 'global_vars.json') as f: |
| 57 | data = json.load(f) |
| 58 | |
| 59 | onos_server_ip = data['onos_server_ip'] |
| 60 | onos_user = data['onos_user'] |
| 61 | onos_passwd = data['onos_passwd'] |
| 62 | switch_ip = data['switch_ip'] |
| 63 | switch_user = data['switch_user'] |
| 64 | switch_passwd = data['switch_passwd'] |
| 65 | |
| 66 | def runTest(self): |
| 67 | global BASE_RUN |
| 68 | try: |
| 69 | if len(config[ "port_map" ]) < 4: |
| 70 | logging.info("Port count less than 4, can't run this case") |
| 71 | assert False, "Port count less than 4, can't run this case" |
| 72 | return |
| 73 | |
| 74 | base_config(self) |
| 75 | onos_flow_group_dump(self) |
| 76 | switch_flow_group_dump(self) |
| 77 | time.sleep(2) |
| 78 | verify_traffic(self) |
| 79 | |
| 80 | finally: |
| 81 | BASE_RUN = True |
| 82 | logging.info("End of Test") |
| 83 | |
| 84 | |
| 85 | class FabricSW_Scale_Base_TC_0010(base_tests.SimpleDataPlane): |
| 86 | """ |
| 87 | Verify that with scaled up flow configurations, rebooting the switch restores all flows and handles traffic as expected. |
| 88 | """ |
| 89 | ### Read config parameters from JSON file 'global_vars.json' |
| 90 | ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 91 | with open(ROOT_DIR + '/' + 'global_vars.json') as f: |
| 92 | data = json.load(f) |
| 93 | |
| 94 | switch_ip = data['switch_ip'] |
| 95 | switch_user = data['switch_user'] |
| 96 | switch_passwd = data['switch_passwd'] |
| 97 | |
| 98 | def runTest(self): |
| 99 | global BASE_RUN |
| 100 | try: |
| 101 | if len( config[ "port_map" ] ) < 4: |
| 102 | logging.info( "Port count less than 4, can't run this case") |
| 103 | assert False, "Port count less than 4, can't run this case" |
| 104 | return |
| 105 | |
| 106 | if BASE_RUN == False: |
| 107 | logging.info("Test FabricSW_Scale_Base_TC_0010 cannot be executed. FabricSW_Scale_Base_TC_0005 is a pre-requisite to this test case," |
| 108 | " Please execute FabricSW_Scale_Base_TC_0005 before FabricSW_Scale_Base_TC_0010") |
| 109 | assert False, "Test FabricSW_Scale_Base_TC_0010 cannot be executed. FabricSW_Scale_Base_TC_0005 is a pre-requisite to this test case," \ |
| 110 | " Please execute FabricSW_Scale_Base_TC_0005 before FabricSW_Scale_Base_TC_0010" |
| 111 | return |
| 112 | |
| 113 | # Reboot switch |
| 114 | logging.info("Restarting switch") |
| 115 | print("Restarting switch") |
| 116 | switch_restart(self) |
| 117 | logging.info("Switch is restarting, wait for 300 secs") |
| 118 | time.sleep(rest_num) |
| 119 | logging.info("Switch is restarted") |
| 120 | |
| 121 | #Verify traffic after switch reboot |
| 122 | logging.info("Verify traffic") |
| 123 | verify_traffic(self) |
| 124 | time.sleep(2) |
| 125 | |
| 126 | finally: |
| 127 | logging.info("End of Test") |
| 128 | |
| 129 | |
| 130 | class FabricSW_Scale_Base_TC_0015(base_tests.SimpleDataPlane): |
| 131 | """ |
| 132 | Verify that with scaled up flow configurations, after flapping the data port multiple times the switch restores all flows and handles traffic as expected. |
| 133 | """ |
| 134 | ### Read config parameters from JSON file 'global_vars.json' |
| 135 | ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 136 | with open(ROOT_DIR + '/' + 'global_vars.json') as f: |
| 137 | data = json.load(f) |
| 138 | |
| 139 | switch_ip = data['switch_ip'] |
| 140 | switch_user = data['switch_user'] |
| 141 | switch_passwd = data['switch_passwd'] |
| 142 | |
| 143 | def runTest(self): |
| 144 | global BASE_RUN |
| 145 | try: |
| 146 | if len( config[ "port_map" ] ) < 4: |
| 147 | logging.info( "Port count less than 4, can't run this case" ) |
| 148 | assert False, "Port count less than 4, can't run this case" |
| 149 | return |
| 150 | |
| 151 | if BASE_RUN == False: |
| 152 | logging.info("Test FabricSW_Scale_Base_TC_0015 cannot be executed. FabricSW_Scale_Base_TC_0005 is a pre-requisite to this test case," |
| 153 | " Please execute FabricSW_Scale_Base_TC_0005 before FabricSW_Scale_Base_TC_0015") |
| 154 | assert False, "Test FabricSW_Scale_Base_TC_0015 cannot be executed. FabricSW_Scale_Base_TC_0005 is a pre-requisite to this test case," \ |
| 155 | " Please execute FabricSW_Scale_Base_TC_0005 before FabricSW_Scale_Base_TC_0015" |
| 156 | return |
| 157 | |
| 158 | ports = sorted(config["port_map"].keys()) |
| 159 | # Flap port1 for 100 iterations |
| 160 | logging.info("Flap port1 for 100 iterations with an interval of '2' seconds") |
| 161 | for i in range(1, 100): |
| 162 | switch_port_enable(self, ports[0], False) |
| 163 | time.sleep(2) |
| 164 | switch_port_enable(self, ports[0], True) |
| 165 | time.sleep(2) |
| 166 | |
| 167 | #Verify traffic after port flapping |
| 168 | logging.info("Verify traffic after port flapping") |
| 169 | time.sleep(20) |
| 170 | verify_traffic(self) |
| 171 | |
| 172 | finally: |
| 173 | logging.info("End of Test") |
| 174 | |
| 175 | |
| 176 | class FabricSW_Scale_Base_TC_0020(base_tests.SimpleDataPlane): |
| 177 | """ |
| 178 | Verify that with scaled up flow configurations, after configuring and unconfiguring flows multiple times the switch is stable and handles traffic as expected. |
| 179 | """ |
| 180 | |
| 181 | ### Read config parameters from JSON file 'global_vars.json' |
| 182 | ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 183 | with open(ROOT_DIR + '/' + 'global_vars.json') as f: |
| 184 | data = json.load(f) |
| 185 | |
| 186 | onos_server_ip = data['onos_server_ip'] |
| 187 | onos_user = data['onos_user'] |
| 188 | onos_passwd = data['onos_passwd'] |
| 189 | onos_port = data['onos_port'] |
| 190 | switch_ip = data['switch_ip'] |
| 191 | switch_user = data['switch_user'] |
| 192 | switch_passwd = data['switch_passwd'] |
| 193 | |
| 194 | def runTest(self): |
| 195 | global BASE_RUN |
| 196 | try: |
| 197 | if len( config[ "port_map" ] ) < 4: |
| 198 | logging.info( "Port count less than 4, can't run this case") |
| 199 | assert False, "Port count less than 4, can't run this case" |
| 200 | return |
| 201 | |
| 202 | if BASE_RUN == False: |
| 203 | logging.info("Test FabricSW_Scale_Base_TC_0020 cannot be executed. FabricSW_Scale_Base_TC_0005 is a pre-requisite to this test case," |
| 204 | " Please execute FabricSW_Scale_Base_TC_0005 before FabricSW_Scale_Base_TC_0020") |
| 205 | assert False, "Test FabricSW_Scale_Base_TC_0020 cannot be executed. FabricSW_Scale_Base_TC_0005 is a pre-requisite to this test case," \ |
| 206 | " Please execute FabricSW_Scale_Base_TC_0005 before FabricSW_Scale_Base_TC_0020" |
| 207 | return |
| 208 | |
| 209 | # Un-configure and re-configure of all 'vlan-cross-connect' pairs for 100 iterations with an interval of 5 seconds. |
| 210 | logging.info("Un-configure and re-configure of all 'vlan-cross-connect' pairs for 100 iterations with an interval of 5 seconds") |
| 211 | for i in range(1, 100): |
| 212 | print("Re-create config iteration: ", i) |
| 213 | logging.info("Re-create config iteration: {}".format(i)) |
| 214 | remove_base_config(self) |
| 215 | time.sleep(5) |
| 216 | base_config(self) |
| 217 | |
| 218 | #Verify traffic after config re-creation |
| 219 | logging.info("Verify traffic after config re-creation") |
| 220 | time.sleep(2) |
| 221 | verify_traffic(self) |
| 222 | |
| 223 | finally: |
| 224 | logging.info("End of Test") |
| 225 | |
| 226 | |
| 227 | class FabricSW_Scale_Base_TC_0025(base_tests.SimpleDataPlane): |
| 228 | """ |
| 229 | Verify that with scaled up flow configurations, sending bursts of control traffic (resulting in "Packet_In" messages from switch to controller) the switch is stable and handles traffic as expected. |
| 230 | """ |
| 231 | ### Read config parameters from JSON file 'global_vars.json' |
| 232 | ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 233 | with open(ROOT_DIR + '/' + 'global_vars.json') as f: |
| 234 | data = json.load(f) |
| 235 | |
| 236 | switch_ip = data['switch_ip'] |
| 237 | switch_user = data['switch_user'] |
| 238 | switch_passwd = data['switch_passwd'] |
| 239 | controller_ip = data['controller_ip'] |
| 240 | controller_port = data['controller_port'] |
| 241 | onos_server_ip = data['onos_server_ip'] |
| 242 | onos_user = data['onos_user'] |
| 243 | onos_passwd = data['onos_passwd'] |
| 244 | onos_port = data['onos_port'] |
| 245 | |
| 246 | def runTest(self): |
| 247 | global BASE_RUN |
| 248 | try: |
| 249 | if len( config[ "port_map" ] ) < 4: |
| 250 | logging.info( "Port count less than 4, can't run this case" ) |
| 251 | assert False, "Port count less than 4, can't run this case" |
| 252 | return |
| 253 | |
| 254 | if BASE_RUN == False: |
| 255 | logging.info("Test FabricSW_Scale_Base_TC_0025 cannot be executed. FabricSW_Scale_Base_TC_0005 is a pre-requisite to this test case," |
| 256 | " Please execute FabricSW_Scale_Base_TC_0005 before FabricSW_Scale_Base_TC_0025") |
| 257 | assert False, "Test FabricSW_Scale_Base_TC_0025 cannot be executed. FabricSW_Scale_Base_TC_0005 is a pre-requisite to this test case," \ |
| 258 | " Please execute FabricSW_Scale_Base_TC_0005 before FabricSW_Scale_Base_TC_0025" |
| 259 | return |
| 260 | |
| 261 | # create match |
| 262 | match = ofp.match() |
| 263 | match.oxm_list.append(ofp.oxm.eth_type(0x0800)) |
| 264 | match.oxm_list.append(ofp.oxm.ip_proto(1)) |
| 265 | request = ofp.message.flow_add(table_id=60, cookie=42, match=match, instructions=[ |
| 266 | ofp.instruction.apply_actions(actions=[ |
| 267 | ofp.action.output(port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER)]), ], |
| 268 | buffer_id=ofp.OFP_NO_BUFFER, priority=1) |
| 269 | logging.info("Add an ACL table entry to match ICMP packets and send to controller") |
| 270 | self.controller.message_send(request) |
| 271 | |
| 272 | # Sent a burst of 64 ICMP packets to data ports 2, 3, and 4. |
| 273 | logging.info("Sent a burst of 64 ICMP packets to data ports 2, 3, and 4.") |
| 274 | ports = sorted(config["port_map"].keys()) |
| 275 | # Send ICMP packets to port2 |
| 276 | pair = [ports[0], ports[1]] |
| 277 | tmp_ports = list(pair) |
| 278 | tmp_ports.remove(pair[0]) |
| 279 | logging.info("Creating ICMP packets for port2") |
| 280 | # change dest based on port number |
| 281 | mac_src = '00:12:34:56:78:%02X' % pair[1] |
| 282 | parsed_pkt = simple_icmp_packet(eth_src=mac_src) |
| 283 | pkt = str(parsed_pkt) |
| 284 | |
| 285 | for i in range(64): |
| 286 | self.dataplane.send(pair[1], pkt) |
| 287 | print('ICMP to port1 iteration:', i) |
| 288 | verify_packet_in(self, pkt, ports[1], ofp.OFPR_ACTION) |
| 289 | |
| 290 | # Send ICMP packets to port3 |
| 291 | pair = [ports[0], ports[2]] |
| 292 | tmp_ports = list(pair) |
| 293 | tmp_ports.remove(pair[0]) |
| 294 | logging.info("Creating ICMP packets for port3") |
| 295 | # change dest based on port number |
| 296 | mac_src = '00:12:34:56:78:%02X' % pair[1] |
| 297 | parsed_pkt = simple_icmp_packet(eth_src=mac_src) |
| 298 | pkt = str(parsed_pkt) |
| 299 | |
| 300 | for i in range(64): |
| 301 | self.dataplane.send(pair[1], pkt) |
| 302 | print('ICMP to port2 iteration:', i) |
| 303 | verify_packet_in(self, pkt, ports[2], ofp.OFPR_ACTION) |
| 304 | # time.sleep(2) |
| 305 | |
| 306 | # Send ICMP packets to port4 |
| 307 | pair = [ports[0], ports[3]] |
| 308 | tmp_ports = list(pair) |
| 309 | tmp_ports.remove(pair[0]) |
| 310 | logging.info("Creating ICMP packets for port4") |
| 311 | # change dest based on port number |
| 312 | mac_src = '00:12:34:56:78:%02X' % pair[1] |
| 313 | parsed_pkt = simple_icmp_packet(eth_src=mac_src) |
| 314 | pkt = str(parsed_pkt) |
| 315 | |
| 316 | for i in range(64): |
| 317 | self.dataplane.send(pair[1], pkt) |
| 318 | print('ICMP to port3 iteration: ', i) |
| 319 | verify_packet_in(self, pkt, ports[3], ofp.OFPR_ACTION) |
| 320 | |
| 321 | finally: |
| 322 | remove_base_config(self) |
| 323 | logging.info("End of Test") |
| 324 | |
| 325 | def base_config(self): |
| 326 | ports = (config["port_map"].keys()) |
| 327 | datapathid = get_datapathid(self) |
| 328 | l = [] |
| 329 | start, end = 101, (101 + xcon_num) |
| 330 | l.extend(range(start, end)) |
| 331 | # Create flows between port1 and port2 |
| 332 | logging.info("Configure 64 vlan-cross-connect pair between data ports 1 and 2 for vlan101 to vlan164") |
| 333 | for i in l: |
| 334 | print('adding xconn port1-2', i) |
| 335 | add_onos_xconnect(self, datapathid, i, ports[0], ports[1]) |
| 336 | |
| 337 | # Create flows between port1 and port3 |
| 338 | logging.info("Configure 64 vlan-cross-connect pair between data ports 1 and 3 for vlan201 to vlan264") |
| 339 | l = [] |
| 340 | start, end = 201, (201 + xcon_num) |
| 341 | l.extend(range(start, end)) |
| 342 | for i in l: |
| 343 | print('adding xconn port1-3', i) |
| 344 | add_onos_xconnect(self, datapathid, i, ports[0], ports[2]) |
| 345 | |
| 346 | # Create flows between port1 and port3 |
| 347 | logging.info("Configure 64 vlan-cross-connect pair between data ports 1 and 4 for vlan301 to vlan364") |
| 348 | l = [] |
| 349 | start, end = 301, (301 + xcon_num) |
| 350 | l.extend(range(start, end)) |
| 351 | for i in l: |
| 352 | print('adding xconn port1-4', i) |
| 353 | add_onos_xconnect(self, datapathid, i, ports[0], ports[3]) |
| 354 | |
| 355 | |
| 356 | def remove_base_config(self): |
| 357 | datapathid = get_datapathid(self) |
| 358 | l = [] |
| 359 | start, end = 101, (101 + xcon_num) |
| 360 | l.extend(range(start, end)) |
| 361 | # Remove flows vlan101 - vlan164 between ports 1 and 2 |
| 362 | logging.info("Remove flows vlan101 - vlan164 between ports 1 and 2") |
| 363 | for i in l: |
| 364 | remove_onos_xconnect(self, datapathid, i) |
| 365 | |
| 366 | #Removeflows vlan201 - vlan264 between ports 1 and 3 |
| 367 | logging.info("Remove flows vlan201 - vlan264 between ports 1 and 3") |
| 368 | l = [] |
| 369 | start, end = 201, (201 + xcon_num) |
| 370 | l.extend(range(start, end)) |
| 371 | for i in l: |
| 372 | remove_onos_xconnect(self, datapathid, i) |
| 373 | |
| 374 | # Remove flows vlan301 - vlan364 between ports 1 and 4 |
| 375 | logging.info("Remove flows vlan301 - vlan364 between ports 1 and 4") |
| 376 | l = [] |
| 377 | start, end = 301, (301 + xcon_num) |
| 378 | l.extend(range(start, end)) |
| 379 | for i in l: |
| 380 | remove_onos_xconnect(self, datapathid, i) |
| 381 | |
| 382 | |
| 383 | def verify_traffic(self): |
| 384 | ports = sorted(config["port_map"].keys()) |
| 385 | |
| 386 | ##### Reverse traffic verification. From BNG to OLT" ######## |
| 387 | # # Create and send packets between port1 and port2 |
| 388 | # pair = [ports[0], ports[1]] |
| 389 | # packets1 = [] |
| 390 | # logging.info("Create double tagged vlan packets with outer vlan IDs 101 - 164 between port1 and port2") |
| 391 | # # change dest based on port number |
| 392 | # mac_src = '00:12:34:56:78:%02X' % ports[0] |
| 393 | # l = [] |
| 394 | # start, end = 101, (101 + xcon_num) |
| 395 | # l.extend(range(start, end)) |
| 396 | # for i in l: |
| 397 | # parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 398 | # out_vlan_vid=i, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 399 | # eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 400 | # |
| 401 | # pkt = str(parsed_pkt) |
| 402 | # packets1.append(pkt) |
| 403 | # |
| 404 | # logging.info("Transmit double tagged vlan packets with outer vlan101 - vlan164 to data port1") |
| 405 | # logging.info("Verify packets are flooded out of data port 2") |
| 406 | # for i in packets1: |
| 407 | # self.dataplane.send(pair[0], i) |
| 408 | # print('verify port1-2, xcon: ', (packets1.index(i)+101)) |
| 409 | # verify_packet(self, i, pair[1]) |
| 410 | # verify_no_packet(self, i, pair[0]) |
| 411 | |
| 412 | |
| 413 | # time.sleep(1) |
| 414 | |
| 415 | ##### Reverse traffic verification. From BNG to OLT" ######## |
| 416 | # # Create and send packets between port1 and port3 |
| 417 | # pair = [ports[0], ports[2]] |
| 418 | # packets2 = [] |
| 419 | # logging.info("Create double tagged vlan packets with outer vlan IDs 201 - 264 between port1 and port3") |
| 420 | # # change dest based on port number |
| 421 | # mac_src = '00:12:34:56:78:%02X' % ports[0] |
| 422 | # l = [] |
| 423 | # start, end = 201, (201 + xcon_num) |
| 424 | # l.extend(range(start, end)) |
| 425 | # for i in l: |
| 426 | # parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 427 | # out_vlan_vid=i, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 428 | # eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 429 | # |
| 430 | # pkt = str(parsed_pkt) |
| 431 | # packets2.append(pkt) |
| 432 | # |
| 433 | # logging.info("Transmit double tagged vlan packets with outer vlan201 - vlan264 to data port1") |
| 434 | # logging.info("Verify packets are flooded out of data port 3") |
| 435 | # for i in packets2: |
| 436 | # self.dataplane.send(pair[0], i) |
| 437 | # # verify traffic |
| 438 | # print('verify port1-3, xcon: ', packets2.index(i)+201) |
| 439 | # verify_packet(self, i, pair[1]) |
| 440 | # verify_no_packet(self, i, pair[0]) |
| 441 | # |
| 442 | # time.sleep(1) |
| 443 | |
| 444 | ##### Reverse traffic verification. From BNG to OLT" ######## |
| 445 | # Create and send packets between port1 and port4 |
| 446 | # pair = [ports[0], ports[3]] |
| 447 | # packets3 = [] |
| 448 | # logging.info( |
| 449 | # "Create double tagged vlan packets with outer vlan IDs 301 - 364 between port1 and port4") |
| 450 | # # change dest based on port number |
| 451 | # mac_src = '00:12:34:56:78:%02X' % pair[0] |
| 452 | # l = [] |
| 453 | # start, end = 301, (301 + xcon_num) |
| 454 | # l.extend(range(start, end)) |
| 455 | # for i in l: |
| 456 | # parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 457 | # out_vlan_vid=i, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 458 | # eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 459 | # |
| 460 | # pkt = str(parsed_pkt) |
| 461 | # packets3.append(pkt) |
| 462 | # |
| 463 | # logging.info("Transmit double tagged vlan packets with outer vlan301 - vlan364 to data port1") |
| 464 | # logging.info("Verify packets are flooded out of data port 4") |
| 465 | # for i in packets3: |
| 466 | # self.dataplane.send(pair[0], i) |
| 467 | # # verify traffic |
| 468 | # print('verify port1-4, xcon: ', packets3.index(i)+301) |
| 469 | # verify_packet(self, i, pair[1]) |
| 470 | # verify_no_packet(self, i, pair[0]) |
| 471 | # |
| 472 | # time.sleep(1) |
| 473 | |
| 474 | # Create and send packets between port2 and port1 |
| 475 | pair = [ports[0], ports[1]] |
| 476 | packets1 = [] |
| 477 | logging.info("Create double tagged vlan packets with outer vlan IDs 101 - 164 between port2 and port1") |
| 478 | # change dest based on port number |
| 479 | mac_src = '00:12:34:56:78:%02X' % ports[1] |
| 480 | l = [] |
| 481 | start, end = 101, (101 + xcon_num) |
| 482 | l.extend(range(start, end)) |
| 483 | for i in l: |
| 484 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 485 | out_vlan_vid=i, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 486 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 487 | |
| 488 | pkt = str(parsed_pkt) |
| 489 | packets1.append(pkt) |
| 490 | |
| 491 | logging.info("Transmit double tagged vlan packets with outer vlan101 - vlan164 to data port2") |
| 492 | logging.info("Verify packets are flooded out of data port 1") |
| 493 | for i in packets1: |
| 494 | logging.info("Transmitting packet {}".format(packets1.index(i) + 1)) |
| 495 | self.dataplane.send(pair[1], i) |
| 496 | # verify traffic |
| 497 | print('verify port2-1, xcon: ', packets1.index(i)+101) |
| 498 | verify_packet(self, i, pair[0]) |
| 499 | verify_no_packet(self, i, pair[1]) |
| 500 | |
| 501 | time.sleep(1) |
| 502 | |
| 503 | # # Create and send packets between port3 and port1 |
| 504 | pair = [ports[0], ports[2]] |
| 505 | packets2 = [] |
| 506 | logging.info("Create double tagged vlan packets with outer vlan IDs 201 - 264 between port3 and port1") |
| 507 | # change dest based on port number |
| 508 | mac_src = '00:12:34:56:78:%02X' % ports[2] |
| 509 | l = [] |
| 510 | start, end = 201, (201 + xcon_num) |
| 511 | l.extend(range(start, end)) |
| 512 | for i in l: |
| 513 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 514 | out_vlan_vid=i, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 515 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 516 | |
| 517 | pkt = str(parsed_pkt) |
| 518 | packets2.append(pkt) |
| 519 | |
| 520 | logging.info("Transmit double tagged vlan packets with outer vlan101 - vlan164 to data port3") |
| 521 | logging.info("Verify packets are flooded out of data port 1") |
| 522 | for i in packets2: |
| 523 | logging.info("Transmitting packet {}".format(packets2.index(i) + 1)) |
| 524 | self.dataplane.send(pair[1], i) |
| 525 | # verify traffic |
| 526 | print('verify port3-1, xcon: ', packets2.index(i)+201) |
| 527 | verify_packet(self, i, pair[0]) |
| 528 | verify_no_packet(self, i, pair[1]) |
| 529 | |
| 530 | time.sleep(1) |
| 531 | |
| 532 | # Create and send packets between port4 and port1 |
| 533 | pair = [ports[0], ports[3]] |
| 534 | packets3 = [] |
| 535 | logging.info( |
| 536 | "Create double tagged vlan packets with outer vlan IDs 301 - 364 between port4 and port1") |
| 537 | # change dest based on port number |
| 538 | mac_src = '00:12:34:56:78:%02X' % ports[3] |
| 539 | l = [] |
| 540 | start, end = 301, (301 + xcon_num) |
| 541 | l.extend(range(start, end)) |
| 542 | for i in l: |
| 543 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 544 | out_vlan_vid=i, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 545 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 546 | |
| 547 | pkt = str(parsed_pkt) |
| 548 | packets3.append(pkt) |
| 549 | |
| 550 | logging.info("Transmit double tagged vlan packets with outer vlan101 - vlan164 to data port4") |
| 551 | logging.info("Verify packets are flooded out of data port 1") |
| 552 | for i in packets3: |
| 553 | logging.info("Transmitting packet {}".format(packets3.index(i) + 1)) |
| 554 | self.dataplane.send(pair[1], i) |
| 555 | # verify traffic |
| 556 | print('verify port4-1, xcon: ', packets3.index(i)+301) |
| 557 | verify_packet(self, i, pair[0]) |
| 558 | verify_no_packet(self, i, pair[1]) |
| 559 | |
| 560 | |
| 561 | def get_datapathid(self): |
| 562 | feature_reply = get_featureReplay(self) |
| 563 | str_datapath_id_f = "{:016x}".format(feature_reply.datapath_id) |
| 564 | return str_datapath_id_f |
| 565 | |
| 566 | def onos_flow_group_dump(self, logfile_name="ONOS_flow_and_groups_dump.log"): |
| 567 | # Dump the created flows and groups from ONOS in a separate file |
| 568 | datapathid = get_datapathid(self) |
| 569 | log_path = (config["log_dir"]) |
| 570 | log_file = logfile_name |
| 571 | logging.info( |
| 572 | "The configured flow and group entries from onos are dumped to " + log_path + '/' + log_file) |
| 573 | send_command_to_onos_cli(log_file, "flows -s any " + datapathid, self.onos_server_ip, self.onos_user, |
| 574 | self.onos_passwd, regexp='onos>') |
| 575 | send_command_to_onos_cli(log_file, "groups", self.onos_server_ip, self.onos_user, self.onos_passwd, regexp='onos>') |
| 576 | |
| 577 | |
| 578 | def switch_flow_group_dump(self, logfile_name="Switch_flow_and_groups_dump.log"): |
| 579 | # Dump the created flows and groups from Openflow Switch in a separate file |
| 580 | datapathid = get_datapathid(self) |
| 581 | log_path = (config["log_dir"]) |
| 582 | log_file = logfile_name |
| 583 | logging.info( |
| 584 | "The configured flow and group entries from switch are dumped to " + log_path + '/' + log_file) |
| 585 | send_command_to_switch_cli(log_file, "client_flowtable_dump", self.switch_ip, |
| 586 | self.switch_user, self.switch_passwd, regexp='root@localhost:~#') |
| 587 | send_command_to_switch_cli(log_file, "client_grouptable_dump", self.switch_ip, |
| 588 | self.switch_user, self.switch_passwd, regexp='root@localhost:~#') |