Skip to content

Commit 00d305f

Browse files
[ptf] 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).
1 parent 346ff01 commit 00d305f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/ptf/testutils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,14 +3635,19 @@ def count_matched_packets(test, exp_packet, port, device_number=0, timeout=None)
36353635
"%s() requires positive timeout value." % sys._getframe().f_code.co_name
36363636
)
36373637

3638+
last_matched_packet_time = time.time()
36383639
total_rcv_pkt_cnt = 0
36393640
while True:
3641+
if (time.time() - last_matched_packet_time) > timeout:
3642+
break
3643+
36403644
result = dp_poll(
36413645
test, device_number=device_number, port_number=port, timeout=timeout
36423646
)
36433647
if isinstance(result, test.dataplane.PollSuccess):
36443648
if ptf.dataplane.match_exp_pkt(exp_packet, result.packet):
36453649
total_rcv_pkt_cnt += 1
3650+
last_matched_packet_time = time.time()
36463651
else:
36473652
break
36483653

0 commit comments

Comments
 (0)