From 08748cb468b1c66eaf8b76208d94d045f098e28a Mon Sep 17 00:00:00 2001 From: Myron Sosyak <49795530+msosyak@users.noreply.github.com> Date: Tue, 12 May 2020 21:27:00 +0300 Subject: [PATCH] [pytest/ntp] Use local time when behind proxy (#1640) When testbed is behind a proxy then NTP inside the ptf container cant synchronize with public NTP servers and test hung on ntpd -gq command --- tests/ntp/test_ntp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/ntp/test_ntp.py b/tests/ntp/test_ntp.py index 1298ffae89..80d094f687 100644 --- a/tests/ntp/test_ntp.py +++ b/tests/ntp/test_ntp.py @@ -10,8 +10,11 @@ ] @pytest.fixture(scope="module") -def setup_ntp(ptfhost, duthost): +def setup_ntp(ptfhost, duthost, creds): """setup ntp client and server""" + if creds.get('proxy_env'): + # If testbed is behaind proxy then force ntpd inside ptf use local time + ptfhost.lineinfile(path="/etc/ntp.conf", line="server 127.127.1.0 prefer") # enable ntp server ptfhost.service(name="ntp", state="started") @@ -31,7 +34,6 @@ def setup_ntp(ptfhost, duthost): # stop ntp server ptfhost.service(name="ntp", state="stopped") - # reset ntp client configuration duthost.command("config ntp del %s" % ptfip) for ntp_server in ntp_servers: