Skip to content

Commit efa6864

Browse files
echuawumssonicbld
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 03991c7 commit efa6864

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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
@@ -57,7 +57,7 @@
5757
l2_ports = set()
5858
vlans_to_remove = []
5959
interfaces_to_startup = []
60-
balancing_test_times = 240
60+
balancing_test_times = 480
6161
balancing_range = 0.25
6262
balancing_range_in_port = 0.8
6363
vxlan_ecmp_utils = VxLAN_Ecmp_Utils()

0 commit comments

Comments
 (0)