From 2a6c00fddbf8f5a1c974b9689f08ba072ecc043e Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Tue, 20 Dec 2016 10:52:05 +0200
Subject: [PATCH] - Added config check and status tests.

---
 tests/test_ntp.py | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/tests/test_ntp.py b/tests/test_ntp.py
index fa65ea8..339aeef 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
-- 
GitLab