From e262d560e0f5dca96de423598848672734b1c146 Mon Sep 17 00:00:00 2001 From: wumiao_nokia Date: Wed, 17 Jul 2024 14:38:33 -0400 Subject: [PATCH] Fix: Fix NTP config long jump test failure issue (#13671) The restart command needs to be run using root privilege. --- .../plugins/conditional_mark/tests_mark_conditions.yaml | 7 ------- tests/ntp/test_ntp.py | 8 ++++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml b/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml index ceb24cacccc..f9cbe383b66 100644 --- a/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml +++ b/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml @@ -889,13 +889,6 @@ ntp/test_ntp.py::test_ntp: conditions: - https://github.com/sonic-net/sonic-buildimage/issues/19425 -ntp/test_ntp.py::test_ntp_long_jump_disabled: - # Due to NTP code bug, long jump will still happen after disable it. - # Set xfail flag for this test case - xfail: - strict: True - reason: "Known NTP bug" - ####################################### ##### pc ##### ####################################### diff --git a/tests/ntp/test_ntp.py b/tests/ntp/test_ntp.py index f40fe5e4d0c..ecbcf68b209 100644 --- a/tests/ntp/test_ntp.py +++ b/tests/ntp/test_ntp.py @@ -39,9 +39,9 @@ def config_long_jump(duthost, enable=False): regex = "s/NTPD_OPTS='-g'/NTPD_OPTS='-x'/" if using_ntpsec: - duthost.command("sed -i '%s' /etc/default/ntpsec" % regex) + duthost.command("sudo sed -i '%s' /etc/default/ntpsec" % regex) else: - duthost.command("sed -i %s /etc/default/ntp" % regex) + duthost.command("sudo sed -i %s /etc/default/ntp" % regex) duthost.service(name='ntp', state='restarted') @@ -148,8 +148,8 @@ def test_ntp_long_jump_disabled(duthosts, rand_one_dut_hostname, setup_ntp, setu config_long_jump(duthost, enable=False) - if wait_until(720, 10, 0, check_ntp_status, duthost): - pytest.fail("NTP long jump disable failed") + pytest_assert(wait_until(720, 10, 0, check_ntp_status, duthost), + "NTP long jump disable failed") def run_ntp(duthosts, rand_one_dut_hostname, setup_ntp):