Skip to content

Commit

Permalink
[dhcp_relay] Use restart_dhcp_service instead of simple restart dhcp_… (
Browse files Browse the repository at this point in the history
sonic-net#14727)

Description of PR
[dhcp_relay] Use restart_dhcp_service instead of simple restart dhcp_relay
Summary:
Fixes # (issue)
Fix the flaky of dhcpmon not ready failure in testing.

Approach
What is the motivation for this PR?
Fix the flaky of dhcpmon not ready failure in testing.

How did you do it?
Use restart_dhcp_service instead of simple restart dhcp_relay

How did you verify/test it?
Multiple run with Elasictest test plan

authorized by: [email protected]
  • Loading branch information
yejianquan authored Sep 25, 2024
1 parent e098100 commit 29ea29a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/dhcp_relay/test_dhcp_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,28 @@ def enable_source_port_ip_in_relay(duthosts, rand_one_dut_hostname, tbinfo):
create_checkpoint(duthost, check_point)
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
expect_op_success(duthost, output)
duthost.restart_service("dhcp_relay")
restart_dhcp_service(duthost)

def dhcp_ready(enable_source_port_ip_in_relay):
dhcp_relay_running = duthost.is_service_fully_started("dhcp_relay")
dhcp_relay_process = duthost.shell("ps -ef |grep dhcrelay|grep -v grep",
module_ignore_errors=True)["stdout"]
dhcp_mon_process = duthost.shell("ps -ef |grep dhcpmon|grep -v grep",
module_ignore_errors=True)["stdout"]
dhcp_mon_process_running = "dhcpmon" in dhcp_mon_process
if enable_source_port_ip_in_relay:
dhcp_relay_process_ready = "-si" in dhcp_relay_process and "dhcrelay" in dhcp_relay_process
else:
dhcp_relay_process_ready = "-si" not in dhcp_relay_process and "dhcrelay" in dhcp_relay_process
return dhcp_relay_running and dhcp_relay_process_ready
return dhcp_relay_running and dhcp_relay_process_ready and dhcp_mon_process_running
pytest_assert(wait_until(60, 2, 0, dhcp_ready, True), "Source port ip in relay is not enabled!")
yield
finally:
delete_tmpfile(duthost, tmpfile)
logger.info("Rolled back to original checkpoint")
rollback_or_reload(duthost, check_point)
delete_checkpoint(duthost, check_point)
duthost.restart_service("dhcp_relay")
restart_dhcp_service(duthost)
pytest_assert(wait_until(60, 2, 0, dhcp_ready, False), "Source port ip in relay is not disabled!")


Expand Down

0 comments on commit 29ea29a

Please sign in to comment.