|
10 | 10 | from tests.common.fixtures.ptfhost_utils import run_garp_service # lgtm[py/unused-import] |
11 | 11 | from tests.common.fixtures.ptfhost_utils import set_ptf_port_mapping_mode # lgtm[py/unused-import] |
12 | 12 | from tests.common.fixtures.ptfhost_utils import ptf_portmap_file_module # lgtm[py/unused-import] |
| 13 | +from tests.common.fixtures.duthost_utils import dut_qos_maps # lgtm[py/unused-import] |
| 14 | +from tests.common.fixtures.duthost_utils import separated_dscp_to_tc_map_on_uplink |
13 | 15 | from tests.common.helpers.assertions import pytest_require, pytest_assert |
14 | 16 | from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_lower_tor, toggle_all_simulator_ports_to_rand_selected_tor, toggle_all_simulator_ports_to_rand_unselected_tor # lgtm[py/unused-import] |
15 | 17 | from tests.common.dualtor.dual_tor_utils import upper_tor_host, lower_tor_host, dualtor_info, get_t1_active_ptf_ports, mux_cable_server_ip, is_tunnel_qos_remap_enabled |
16 | 18 | from tunnel_qos_remap_base import build_testing_packet, check_queue_counter, dut_config, qos_config, load_tunnel_qos_map, run_ptf_test, toggle_mux_to_host, setup_module, update_docker_services, swap_syncd, counter_poll_config # lgtm[py/unused-import] |
17 | 19 | from tunnel_qos_remap_base import leaf_fanout_peer_info, start_pfc_storm, stop_pfc_storm, get_queue_counter |
18 | 20 | from ptf import testutils |
| 21 | +from ptf.testutils import simple_tcp_packet |
19 | 22 | from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts |
20 | 23 | from tests.common.helpers.pfc_storm import PFCStorm |
21 | 24 |
|
|
29 | 32 | SERVER_IP = "192.168.0.2" |
30 | 33 | DUMMY_IP = "1.1.1.1" |
31 | 34 | DUMMY_MAC = "aa:aa:aa:aa:aa:aa" |
| 35 | +VLAN_MAC = "00:aa:bb:cc:dd:ee" |
32 | 36 |
|
33 | 37 | PFC_PKT_COUNT = 10000000 # Cost 32 seconds |
34 | 38 |
|
@@ -198,6 +202,89 @@ def test_tunnel_decap_dscp_to_queue_mapping(ptfhost, rand_selected_dut, rand_uns |
198 | 202 | counter_poll_config(rand_selected_dut, 'queue', 10000) |
199 | 203 |
|
200 | 204 |
|
| 205 | +def test_separated_qos_map_on_tor(ptfhost, rand_selected_dut, rand_unselected_dut, toggle_all_simulator_ports_to_rand_selected_tor, tbinfo, ptfadapter, dut_qos_maps): |
| 206 | + """ |
| 207 | + The test case is to verify separated DSCP_TO_TC_MAP/TC_TO_QUEUE_MAP on uplink and downlink ports of dualtor |
| 208 | + Test steps |
| 209 | + 1. Build IPinIP encapsulated packet with dummy src ip and dst ip (must not be the loopback address of dualtor) |
| 210 | + 2. Ingress the packet from uplink port, verify the packets egressed from expected queue |
| 211 | + 3. Build regular packet with dst_ip = dummy IP (routed by default route) |
| 212 | + 4. Ingress the packet from downlink port, verify the packets egressed from expected queue |
| 213 | + """ |
| 214 | + pytest_require(separated_dscp_to_tc_map_on_uplink(rand_selected_dut, dut_qos_maps), |
| 215 | + "Skip test because separated QoS map is not applied") |
| 216 | + dualtor_meta = dualtor_info(ptfhost, rand_unselected_dut, rand_selected_dut, tbinfo) |
| 217 | + t1_ports = get_t1_active_ptf_ports(rand_selected_dut, tbinfo) |
| 218 | + mg_facts = rand_selected_dut.get_extended_minigraph_facts(tbinfo) |
| 219 | + portchannel_info = mg_facts['minigraph_portchannels'] |
| 220 | + tor_pc_intfs = list() |
| 221 | + for pc in portchannel_info.values(): |
| 222 | + for member in pc['members']: |
| 223 | + tor_pc_intfs.append(member) |
| 224 | + active_tor_mac = rand_selected_dut.facts['router_mac'] |
| 225 | + # Set queue counter polling interval to 1 second to speed up the test |
| 226 | + counter_poll_config(rand_selected_dut, 'queue', 1000) |
| 227 | + PKT_NUM = 100 |
| 228 | + # DSCP 2/6 are mapped to lossless queue 2/6 on uplink ports |
| 229 | + UP_LINK_TEST_DATA = { |
| 230 | + # Inner DSCP, Outer DSCP, Expected queue |
| 231 | + (3, 2, 2), |
| 232 | + (4, 6, 6) |
| 233 | + } |
| 234 | + # DSCP 2/6 are mapped to lossy queue 1 on downlink ports |
| 235 | + DOWN_LINK_TEST_DATA = { |
| 236 | + # DSCP, Expected queue |
| 237 | + (2, 1), |
| 238 | + (6, 1) |
| 239 | + } |
| 240 | + try: |
| 241 | + # uplink port test |
| 242 | + # Always select the last port in the last LAG as src_port |
| 243 | + src_port = _last_port_in_last_lag(t1_ports) |
| 244 | + for inner_dscp, outer_dscp, queue in UP_LINK_TEST_DATA: |
| 245 | + # We use the IPinIP packet only |
| 246 | + _, exp_packet = build_testing_packet(src_ip=DUMMY_IP, |
| 247 | + dst_ip=dualtor_meta['target_server_ip'], |
| 248 | + active_tor_mac=active_tor_mac, |
| 249 | + standby_tor_mac=dualtor_meta['standby_tor_mac'], |
| 250 | + active_tor_ip='20.2.0.22', # The active/standby tor ip must be fake value so that the pack is not decaped |
| 251 | + standby_tor_ip='20.2.0.21', |
| 252 | + inner_dscp=inner_dscp, |
| 253 | + outer_dscp=outer_dscp) |
| 254 | + ipinip_packet = exp_packet.exp_pkt |
| 255 | + # Clear queuecounters before sending traffic |
| 256 | + rand_selected_dut.shell('sonic-clear queuecounters') |
| 257 | + time.sleep(1) |
| 258 | + # Send tunnel packets |
| 259 | + testutils.send(ptfadapter, src_port, ipinip_packet, PKT_NUM) |
| 260 | + # Wait 2 seconds for queue counter to be refreshed |
| 261 | + time.sleep(2) |
| 262 | + # Since the packet will not be decaped by active ToR, we expected to see the packet egress from any uplink ports |
| 263 | + pytest_assert(check_queue_counter(rand_selected_dut, tor_pc_intfs, queue, PKT_NUM), |
| 264 | + "Uplink test: the queue counter for DSCP {} Queue {} is not as expected".format(outer_dscp, queue)) |
| 265 | + |
| 266 | + # downlink port test |
| 267 | + src_port = dualtor_meta['target_server_port'] |
| 268 | + for dscp, queue in DOWN_LINK_TEST_DATA: |
| 269 | + pkt = simple_tcp_packet(eth_dst=VLAN_MAC, |
| 270 | + ip_src=dualtor_meta['target_server_ip'], |
| 271 | + ip_dst=DUMMY_IP, # A dummy IP that will hit default route, |
| 272 | + ip_dscp=dscp) |
| 273 | + |
| 274 | + # Clear queuecounters before sending traffic |
| 275 | + rand_selected_dut.shell('sonic-clear queuecounters') |
| 276 | + time.sleep(1) |
| 277 | + # Send tunnel packets |
| 278 | + testutils.send(ptfadapter, src_port, pkt, PKT_NUM) |
| 279 | + # Wait 2 seconds for queue counter to be refreshed |
| 280 | + time.sleep(2) |
| 281 | + # We expected to see the packet egress from any uplink ports since the dst IP will hit the default route |
| 282 | + pytest_assert(check_queue_counter(rand_selected_dut, tor_pc_intfs, queue, PKT_NUM), |
| 283 | + "Downlink test: the queue counter for DSCP {} Queue {} is not as expected".format(dscp, queue)) |
| 284 | + finally: |
| 285 | + counter_poll_config(rand_selected_dut, 'queue', 10000) |
| 286 | + |
| 287 | + |
201 | 288 | def test_pfc_pause_extra_lossless_standby(ptfhost, fanouthosts, rand_selected_dut, rand_unselected_dut, toggle_all_simulator_ports_to_rand_unselected_tor, tbinfo, ptfadapter, conn_graph_facts, fanout_graph_facts): |
202 | 289 | """ |
203 | 290 | The test case is to verify PFC pause frame can pause extra lossless queues in dualtor deployment. |
|
0 commit comments