Skip to content

Commit 8304915

Browse files
illia-kotvitskyigshemesh2
authored andcommitted
added a retry of sending traffic in ptf test_fib in case packet wasn't correctly sent to the DUT (sonic-net#18012)
In case of a weak nic, when a packet is not received, resend the packet Related PR: sonic-net#14139 Signed-off-by: Guy Shemesh <gshemesh@nvidia.com>
1 parent ba40374 commit 8304915

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

ansible/roles/test/files/ptftests/fib_test.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,20 @@ def check_ipv4_route(self, src_port, dst_ip_addr, dst_port_lists):
393393

394394
dst_ports = list(itertools.chain(*dst_port_lists))
395395
if self.pkt_action == self.ACTION_FWD:
396-
rcvd_port_index, rcvd_pkt = verify_packet_any_port(
397-
self, masked_exp_pkt, dst_ports, timeout=1)
396+
try:
397+
rcvd_port_index, rcvd_pkt = verify_packet_any_port(
398+
self, masked_exp_pkt, dst_ports, timeout=1)
399+
except AssertionError:
400+
logging.warning("Traffic wasn't sent successfully, trying again")
401+
send_packet(self, src_port, pkt, count=5)
402+
403+
logging.info('Sent Ether(src={}, dst={})/IP(src={}, dst={})/TCP(sport={}, dport={}) on port {}'
404+
.format(pkt.src, pkt.dst, pkt['IP'].src, pkt['IP'].dst, sport, dport, src_port))
405+
logging.info('Expect Ether(src={}, dst={})/IP(src={}, dst={})/TCP(sport={}, dport={})'
406+
.format('any', 'any', ip_src, ip_dst, sport, dport))
407+
408+
rcvd_port_index, rcvd_pkt = verify_packet_any_port(
409+
self, masked_exp_pkt, dst_ports, timeout=1)
398410
rcvd_port = dst_ports[rcvd_port_index]
399411
len_rcvd_pkt = len(rcvd_pkt)
400412
logging.info('Recieved packet at port {} and packet is {} bytes'.format(
@@ -488,8 +500,21 @@ def check_ipv6_route(self, src_port, dst_ip_addr, dst_port_lists):
488500

489501
dst_ports = list(itertools.chain(*dst_port_lists))
490502
if self.pkt_action == self.ACTION_FWD:
491-
rcvd_port_index, rcvd_pkt = verify_packet_any_port(
492-
self, masked_exp_pkt, dst_ports, timeout=1)
503+
try:
504+
rcvd_port_index, rcvd_pkt = verify_packet_any_port(
505+
self, masked_exp_pkt, dst_ports, timeout=1)
506+
except AssertionError:
507+
logging.warning("Traffic wasn't sent successfully, trying again")
508+
send_packet(self, src_port, pkt, count=5)
509+
510+
logging.info('Sent Ether(src={}, dst={})/IPv6(src={}, dst={})/TCP(sport={}, dport={}) on port {}'
511+
.format(pkt.src, pkt.dst, pkt['IPv6'].src, pkt['IPv6'].dst, sport, dport, src_port))
512+
logging.info('Expect Ether(src={}, dst={})/IPv6(src={}, dst={})/TCP(sport={}, dport={})'
513+
.format('any', 'any', ip_src, ip_dst, sport, dport))
514+
515+
rcvd_port_index, rcvd_pkt = verify_packet_any_port(
516+
self, masked_exp_pkt, dst_ports, timeout=1)
517+
493518
rcvd_port = dst_ports[rcvd_port_index]
494519
len_rcvd_pkt = len(rcvd_pkt)
495520
logging.info('Recieved packet at port {} and packet is {} bytes'.format(

0 commit comments

Comments
 (0)