Skip to content

Commit cb7f454

Browse files
echuawusreejithsreekumaran
authored andcommitted
Enhance generic hash script packet sending function (sonic-net#14139)
1. In case of a weak nic, when packet is not received, resend the packet 2. Loop more times to make hash result more stable Change-Id: I89bfa1e4de43e281d82d736b102dc33a55a8e089
1 parent ddf649a commit cb7f454

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

ansible/roles/test/files/ptftests/py3/generic_hash_test.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,17 @@ def check_ip_route(self, pkt, masked_expected_pkt, sending_port):
379379
send the packet and check it is received by one of the expected ports
380380
"""
381381
testutils.send_packet(self, sending_port, pkt)
382-
port_index, received = testutils.verify_packet_any_port(
383-
self, masked_expected_pkt, self.expected_port_list, timeout=0.1)
382+
try:
383+
port_index, received = testutils.verify_packet_any_port(
384+
self, masked_expected_pkt, self.expected_port_list, timeout=0.1)
385+
except AssertionError:
386+
logging.error("Traffic wasn't sent successfully, trying again")
387+
logging.info(f"Expected packet: {masked_expected_pkt}")
388+
for _ in range(5):
389+
testutils.send_packet(self, sending_port, pkt, count=1)
390+
time.sleep(0.1)
391+
port_index, received = testutils.verify_packet_any_port(
392+
self, masked_expected_pkt, self.expected_port_list, timeout=1)
384393
# The port_index is the index of expected_port_list, need to convert it to the ptf port index
385394
return self.expected_port_list[port_index], received
386395

tests/hash/generic_hash_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
l2_ports = set()
5959
vlans_to_remove = []
6060
interfaces_to_startup = []
61-
balancing_test_times = 240
61+
balancing_test_times = 480
6262
balancing_range = 0.25
6363
balancing_range_in_port = 0.8
6464
vxlan_ecmp_utils = VxLAN_Ecmp_Utils()

0 commit comments

Comments
 (0)