Permit little time diff in test_ntp_sync
Related-prod: PROD-34238
Change-Id: I854ae9a9c0a080dea6d06f4deb6b4dc1edc5e86d
(cherry picked from commit aa4f93968974cc21903971016d532239d1416e06)
diff --git a/test_set/cvp-sanity/global_config.yaml b/test_set/cvp-sanity/global_config.yaml
index b0cba57..c7dd823 100644
--- a/test_set/cvp-sanity/global_config.yaml
+++ b/test_set/cvp-sanity/global_config.yaml
@@ -106,6 +106,10 @@
# this test may skip specific node (use fqdn)
ntp_skipped_nodes: []
+# Maximum time diff for nodes
+# Need for case if test test_ntp_sync is running on the border between seconds
+maximum_time_diff: 1
+
# packages need to skip in
# test_check_package_versions
skipped_packages: []
diff --git a/test_set/cvp-sanity/tests/test_ntp_sync.py b/test_set/cvp-sanity/tests/test_ntp_sync.py
index 2589165..f1c6cea 100644
--- a/test_set/cvp-sanity/tests/test_ntp_sync.py
+++ b/test_set/cvp-sanity/tests/test_ntp_sync.py
@@ -9,7 +9,6 @@
#move to sl?
def test_ntp_sync(local_salt_client):
"""Test checks that system time is the same across all nodes"""
-
config = utils.get_configuration()
nodes_time = local_salt_client.cmd(
tgt='*',
@@ -26,10 +25,12 @@
result[time].sort()
else:
result[time] = [node]
- assert len(result) <= 1, (
- 'Time is out of sync on the following nodes:\n{}'.format(
- json.dumps(result, indent=4))
- )
+ for time in result:
+ time_diff = abs(int(time)-int(list(result)[0]))
+ assert time_diff <= config.get("maximum_time_diff"), (
+ 'Time is out of sync on the following nodes:\n{}'.format(
+ json.dumps(result, indent=4))
+ )
@pytest.mark.flaky(reruns=5, reruns_delay=60)