From f584b139e794f21001a980412ba9dc620d7c88bc Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sun, 18 Dec 2016 21:50:24 +0200 Subject: [PATCH] - Testinfra's Service module can't handle a missing service, so for now I'm guessing the correct service by OS and release. --- tests/test_ntp.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_ntp.py b/tests/test_ntp.py index 9156d53..fa65ea8 100644 --- a/tests/test_ntp.py +++ b/tests/test_ntp.py @@ -3,11 +3,16 @@ from testinfra.utils.ansible_runner import AnsibleRunner testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') -def test_ntp(Service): - assert Service('systemd-timesyncd').is_running or Service( - 'ntpd').is_running or Service('openntpd').is_running +def test_ntp(Service, SystemInfo): + if SystemInfo.type == 'openbsd': + service = Service('ntpd') + elif SystemInfo.type == 'linux': + if SystemInfo.codename in ['jessie', 'stretch', 'xenial']: + service = Service('systemd-timesyncd') + else: + service = Service('openntpd') + assert service.is_running try: - Service('systemd-timesyncd').is_enabled or Service( - 'ntpd').is_enabled or Service('openntpd').is_enabled + assert service.is_enabled except NotImplementedError: pass -- GitLab