From 47414cc6033ac670702bd15c08dc21c075f46889 Mon Sep 17 00:00:00 2001 From: Sonic Build Admin Date: Mon, 18 May 2026 23:19:37 +0000 Subject: [PATCH] Fixing a packet trimming counter test failure seen on TH5 ### 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: Sonic Build Admin --- 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 645b549055..f045d41728 100644 --- a/tests/packet_trimming/base_packet_trimming.py +++ b/tests/packet_trimming/base_packet_trimming.py @@ -391,7 +391,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 switch level diff --git a/tests/packet_trimming/packet_trimming_helper.py b/tests/packet_trimming/packet_trimming_helper.py index a238391fe2..24640138f0 100644 --- a/tests/packet_trimming/packet_trimming_helper.py +++ b/tests/packet_trimming/packet_trimming_helper.py @@ -915,7 +915,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( @@ -928,7 +928,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, @@ -937,6 +937,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