Skip to content

Commit

Permalink
[pytest/ntp] Use local time when behind proxy (#1640)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
msosyak authored May 12, 2020
1 parent cbaef7e commit 08748cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/ntp/test_ntp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand Down

0 comments on commit 08748cb

Please sign in to comment.