diff --git a/tests/test_ntp.py b/tests/test_ntp.py index fa65ea8fcc7d619c16f887a2812cd6bd27c5d02e..339aeef3cd5247ab740efe969f38caa950feb27c 100644 --- a/tests/test_ntp.py +++ b/tests/test_ntp.py @@ -3,7 +3,7 @@ from testinfra.utils.ansible_runner import AnsibleRunner testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') -def test_ntp(Service, SystemInfo): +def test_ntp_service(Service, SystemInfo): if SystemInfo.type == 'openbsd': service = Service('ntpd') elif SystemInfo.type == 'linux': @@ -16,3 +16,24 @@ def test_ntp(Service, SystemInfo): assert service.is_enabled except NotImplementedError: pass + + +def test_ntp_config(SystemInfo, Command): + if SystemInfo.type == 'openbsd' or ( + SystemInfo.type == 'linux' and + SystemInfo.codename not in ['jessie', 'stretch', 'xenial']): + command = Command('ntpd -n') + assert command.rc == 0 + assert 'configuration OK' in command.stderr + + +def test_ntp_status(SystemInfo, Command): + if SystemInfo.type == 'openbsd': + assert Command('ntpctl -s status').rc == 0 + assert 'peers valid' in Command('ntpctl -s status').stdout + elif SystemInfo.type == 'linux' and SystemInfo.codename in [ + 'jessie', 'stretch', 'xenial' + ]: + command = Command('timedatectl status') + assert command.rc == 0 + assert 'Network time on: yes' in command.stdout