From 8f5ad1f4961d77b4594bfc7af0829c399815ef9e Mon Sep 17 00:00:00 2001 From: mramezani95 Date: Thu, 14 May 2026 13:42:33 -0700 Subject: [PATCH] Fixing a packet trimming counter test failure seen on TH5 (#24605) ### Description of PR This PR fixes a test failure in `test_trimming_counters` seen on TH5 devices. Summary: Microsoft ADO ID: 37947965 Fixed a packet trimming counter test failure seen on TH5. ### Type of change - [ ] Bug fix - [ ] Testbed and Framework(new/improvement) - [ ] New Test case - [ ] Skipped for non-supported platforms - [x] Test case improvement ### Back port request - [ ] 202205 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 - [x] 202511 ### Approach #### What is the motivation for this PR? The last step of `test_trimming_counters` is to block the trim queue and verify trim drop counters. The test does not expect to receive any trimmed packets since the trim queue is blocked. However, TH5 switches cannot completely block egress queues. So the test fails because trimmed packets leak out from the trim queue at a very low rate. #### How did you do it? For TH5 switches, we skip checking that no trimmed packet is captured on the egress port. #### How did you verify/test it? Ran the test on a TH5 device after changes: ``` packet_trimming/test_packet_trimming_symmetric.py::TestPacketTrimmingSymmetric::test_trimming_counters PASSED [100%] ``` #### Any platform specific information? The behavior of the test is only changed for TH5. #### Supported testbed topology if it's a new test case? N/A ### Documentation N/A Signed-off-by: Mahdi Ramezani Signed-off-by: mssonicbld --- tests/packet_trimming/base_packet_trimming.py | 6 +++++- tests/packet_trimming/packet_trimming_helper.py | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/packet_trimming/base_packet_trimming.py b/tests/packet_trimming/base_packet_trimming.py index b07f7330121..c73e3476d59 100644 --- a/tests/packet_trimming/base_packet_trimming.py +++ b/tests/packet_trimming/base_packet_trimming.py @@ -402,7 +402,11 @@ def test_trimming_counters(self, duthost, ptfadapter, test_params, trim_counter_ # Trigger trimmed packets on queue6 counter_kwargs = self.get_verify_trimmed_counter_packet_kwargs(duthost, ptfadapter, {**trim_counter_params}) - counter_kwargs.update({'expect_packets': False}) + # TH5 cannot completely block egress queues, so trimmed packets will leak out of the trim queues. + if duthost.get_asic_name() == "th5": + counter_kwargs.update({'expect_packets': "skip"}) + else: + counter_kwargs.update({'expect_packets': False}) verify_trimmed_packet(**counter_kwargs) # Get the TrimDrop counters on port level diff --git a/tests/packet_trimming/packet_trimming_helper.py b/tests/packet_trimming/packet_trimming_helper.py index f799805da9d..0e4c4cc0795 100644 --- a/tests/packet_trimming/packet_trimming_helper.py +++ b/tests/packet_trimming/packet_trimming_helper.py @@ -916,7 +916,7 @@ def verify_packet_trimming(duthost, ptfadapter, ingress_port, egress_port, block verify_ports = [egress_port['ptf_id']] # Verify packet based on expectation - if expect_packets: + if expect_packets is True: logger.info( f"Expecting packets on ports {verify_ports} with size {recv_pkt_size} and DSCP {recv_pkt_dscp}") _, matched = testutils.verify_packet_any_port( @@ -929,7 +929,7 @@ def verify_packet_trimming(duthost, ptfadapter, ingress_port, egress_port, block logger.info( f"Successfully verified {packet_type} packet trimming with size {recv_pkt_size} " f"and DSCP {recv_pkt_dscp}") - else: + elif expect_packets is False: logger.info(f"Expecting NO packets on any of ports {verify_ports}") testutils.verify_no_packet_any( ptfadapter, @@ -938,6 +938,8 @@ def verify_packet_trimming(duthost, ptfadapter, ingress_port, egress_port, block timeout=timeout ) logger.info(f"Successfully verified NO {packet_type} packets were received as expected") + else: + logger.info(f"Skip capturing packets on ports {verify_ports}.") return True