Skip to content

Commit

Permalink
[ptf] Consider only expected packets for timeout (#21150)
Browse files Browse the repository at this point in the history
Why I did it
dhcp_relay/test_dhcp_relay_stress.py::test_dhcp_relay_stress[offer|ack] tests are failing on dualtor topologies with signature Failed: /tmp/dhcp_stress_test_offer.json is missing, see issue aristanetworks/sonic-qual.msft#325 for more details.

Work item tracking
Microsoft ADO (number only):
How I did it
count_matched_packets method is getting stuck in a while loop as long as ptf server port receives any packet (Ex: in dualtor case, we do see continuous ICMP packets on ptf port). Fix is to consider only expected packets w.r.t timeout (similar to count_matched_packets_all_ports logic).

How to verify it
With this PR changes we should not see dhcp_relay/test_dhcp_relay_stress.py failures on dualtor topologies with symptom Failed: /tmp/dhcp_stress_test_offer.json is missing.
  • Loading branch information
vkjammala-arista authored and mssonicbld committed Dec 24, 2024
1 parent ea4ccc0 commit 4feafb4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From f961a46cd8b3736a7ac8534fad774433b2a8ce6b Mon Sep 17 00:00:00 2001
From: Vinod Kumar <vkjammala@arista.com>
Date: Thu, 12 Dec 2024 11:04:21 +0000
Subject: [PATCH] Consider only expected packets for timeout

"count_matched_packets" method is getting stuck in a while loop as long
as ptf server port receives any packet (Ex: in dualtor case, we do see
continuous ICMP packets on ptf port). Fix is to consider only expected
packets w.r.t timeout (similar to "count_matched_packets_all_ports" logic).
---
src/ptf/testutils.py | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/src/ptf/testutils.py b/src/ptf/testutils.py
index 46b926c..2402e8f 100755
--- a/src/ptf/testutils.py
+++ b/src/ptf/testutils.py
@@ -3636,14 +3636,19 @@ def count_matched_packets(test, exp_packet, port, device_number=0, timeout=None)
"%s() requires positive timeout value." % sys._getframe().f_code.co_name
)

+ last_matched_packet_time = time.time()
total_rcv_pkt_cnt = 0
while True:
+ if (time.time() - last_matched_packet_time) > timeout:
+ break
+
result = dp_poll(
test, device_number=device_number, port_number=port, timeout=timeout
)
if isinstance(result, test.dataplane.PollSuccess):
if ptf.dataplane.match_exp_pkt(exp_packet, result.packet):
total_rcv_pkt_cnt += 1
+ last_matched_packet_time = time.time()
else:
break

--
2.43.5

1 change: 1 addition & 0 deletions src/ptf-py3.patch/series
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0001-Remove-ord-in-get_mac-to-avoid-TypeError.patch
0002-Fill-byte-formatted-client-mac-address-in-DHCP-Disco.patch
0003-Avoid-local-version-scheme-by-setuptools-scm.patch
0004-Consider-only-expected-packets-for-timeout.patch

0 comments on commit 4feafb4

Please sign in to comment.