From 289445c05c22d9c1b3fa71573ac418ac2f3d5772 Mon Sep 17 00:00:00 2001 From: yaqiangz Date: Tue, 24 Dec 2024 14:23:52 +0000 Subject: [PATCH] [dhcp_relay][telemetry] Update events test for dhcp6relay bind issue --- tests/telemetry/events/dhcp-relay_events.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/telemetry/events/dhcp-relay_events.py b/tests/telemetry/events/dhcp-relay_events.py index 17621eb914..fb9aa62de1 100644 --- a/tests/telemetry/events/dhcp-relay_events.py +++ b/tests/telemetry/events/dhcp-relay_events.py @@ -56,21 +56,29 @@ def trigger_dhcp_relay_bind_failure(duthost): vlan = dhcp_test_info["vlan"] dhcp6_relay_process = dhcp_test_info["dhcp6relay_process"] - ipv6_ip = dhcp_test_info["ipv6_address"] + ipv6_global_unique_ip = dhcp_test_info["ipv6_address"] try: # Flush ipv6 address from vlan - duthost.shell("ip -6 address flush dev {}".format(vlan)) + duthost.shell("ip -6 address del {} dev {}".format(ipv6_global_unique_ip, vlan)) # Restart dhcrelay process duthost.shell("docker exec dhcp_relay supervisorctl restart {}".format(dhcp6_relay_process)) + # Wait dhcp6relay to hit bind failure, dhcp6relay would try 6 times with interval 5s, hence wait 35s to hit + # bind failure + time.sleep(35) finally: # Add back ipv6 address to vlan - duthost.shell("ip address add {} dev {}".format(ipv6_ip, vlan)) - - # Restart dhcrelay process - duthost.shell("docker exec dhcp_relay supervisorctl restart {}".format(dhcp6_relay_process)) + duthost.shell("ip address add {} dev {}".format(ipv6_global_unique_ip, vlan)) + + # After bind failure test, dhcp6relay would exit because fail to bind. It's critical process of dhcp_relay, + # hence maybe in that time dhcp_relay container has crashed, we need to restart whole dhcp_relay service to + # recover + duthost.shell("systemctl reset-failed dhcp_relay") + duthost.restart_service("dhcp_relay") + py_assert(wait_until(100, 10, 0, duthost.is_service_fully_started_per_asic_or_host, "dhcp_relay"), + "dhcp_relay not started.") def send_dhcp_discover_packets(duthost, ptfadapter, packets_to_send=5, interval=1):