diff --git a/tests/test_ntp.py b/tests/test_ntp.py index b703bb433966dd9c0421e880e2a6efcb323516d8..c3b46c264396e76f4560c771a309f27b09c005fb 100755 --- a/tests/test_ntp.py +++ b/tests/test_ntp.py @@ -14,9 +14,13 @@ import imp if os.path.isfile('/usr/bin/ntpq'): cmd = "LANG=C ntpq -pd" expected = "remote" + ntpconf = '/etc/ntp.conf' + ntpconf_expected = 'server ' else: cmd = "LANG=C timedatectl" expected = 'NTP synchronized' + ntpconf = '/etc/systemd/timesyncd.conf' + ntpconf_expected = 'NTP=' print("Running %s" % cmd) status = subprocess.getoutput(cmd) @@ -34,14 +38,14 @@ if os.path.isfile('../utils.py'): conf = es_utils.load_conf() NTP_SERVER = conf.get('NTP_SERVER') or 'ntp.ubuntu.com' - with open('/etc/ntp.conf', 'r') as f: + with open(ntpconf, 'r') as f: d = f.read() servers = list() for l in d.split('\n'): - if l.startswith('server '): - servers.append(l.split('server ')[1]) + if l.startswith(ntpconf_expected): + servers.append(l.split(ntpconf_expected)[1]) if not 'server %s' % NTP_SERVER in d: - print('Expected NTP server %s not found in /etc/ntp.conf, found %s instead' % (NTP_SERVER, servers)) + print('Expected NTP server %s not found in %s, found %s instead' % (NTP_SERVER,ntpconf, servers)) sys.exit(1) else: print('Expected NTP server %s found in configuration (total servers: %s)' % (NTP_SERVER, len(servers)))