Skip to content

Commit

Permalink
Enhance generic hash script packet sending function (sonic-net#14139)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
echuawu authored and mssonicbld committed Oct 29, 2024
1 parent 03991c7 commit d73955f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions ansible/roles/test/files/ptftests/py3/generic_hash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,17 @@ def check_ip_route(self, pkt, masked_expected_pkt, sending_port):
send the packet and check it is received by one of the expected ports
"""
testutils.send_packet(self, sending_port, pkt)
port_index, received = testutils.verify_packet_any_port(
self, masked_expected_pkt, self.expected_port_list, timeout=0.1)
try:
port_index, received = testutils.verify_packet_any_port(
self, masked_expected_pkt, self.expected_port_list, timeout=0.1)
except AssertionError:
logging.error("Traffic wasn't sent successfully, trying again")
logging.info(f"Expected packet: {masked_expected_pkt}")
for _ in range(5):
testutils.send_packet(self, sending_port, pkt, count=1)
time.sleep(0.1)
port_index, received = testutils.verify_packet_any_port(
self, masked_expected_pkt, self.expected_port_list, timeout=1)
# The port_index is the index of expected_port_list, need to convert it to the ptf port index
return self.expected_port_list[port_index], received

Expand Down
2 changes: 1 addition & 1 deletion tests/hash/generic_hash_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
l2_ports = set()
vlans_to_remove = []
interfaces_to_startup = []
balancing_test_times = 240
balancing_test_times = 480
balancing_range = 0.25
balancing_range_in_port = 0.8
vxlan_ecmp_utils = VxLAN_Ecmp_Utils()
Expand Down

0 comments on commit d73955f

Please sign in to comment.