Merge "Add ntp_skipped_nodes parameter, do not compare time on nodes with salt master"
diff --git a/test_set/cvp-sanity/global_config.yaml b/test_set/cvp-sanity/global_config.yaml
index 4146147..ab593d7 100644
--- a/test_set/cvp-sanity/global_config.yaml
+++ b/test_set/cvp-sanity/global_config.yaml
@@ -90,6 +90,4 @@
 
 # ntp test setting
 # this test may skip specific node (use fqdn)
-test_ntp_sync:
-  { #"skipped_nodes": [""],
-    "time_deviation": 1}
+ntp_skipped_nodes: [""]
diff --git a/test_set/cvp-sanity/tests/test_ntp_sync.py b/test_set/cvp-sanity/tests/test_ntp_sync.py
index 23a98a3..3636f14 100644
--- a/test_set/cvp-sanity/tests/test_ntp_sync.py
+++ b/test_set/cvp-sanity/tests/test_ntp_sync.py
@@ -1,39 +1,34 @@
 import json
-import os
-
 import utils
 
 
 def test_ntp_sync(local_salt_client):
-    testname = os.path.basename(__file__).split('.')[0]
-    active_nodes = utils.get_active_nodes(os.path.basename(__file__))
+    """Test checks that system time is the same across all nodes"""
+
+    active_nodes = utils.get_active_nodes()
     config = utils.get_configuration()
-    fail = {}
-    saltmaster_time = int(local_salt_client.cmd(
-        'salt:master',
-        'cmd.run',
-        ['date +%s'],
-        expr_form='pillar').values()[0])
     nodes_time = local_salt_client.cmd(
         utils.list_to_target_string(active_nodes, 'or'),
         'cmd.run',
         ['date +%s'],
         expr_form='compound')
-    diff = config.get(testname)["time_deviation"] or 30
+    result = {}
     for node, time in nodes_time.iteritems():
-        if (int(time) - saltmaster_time) > diff or \
-                (int(time) - saltmaster_time) < -diff:
-            fail[node] = time
-
-    assert not fail, 'SaltMaster time: {}\n' \
-                     'Nodes with time mismatch:\n {}'.format(saltmaster_time,
-                                                             fail)
+        if node in config.get("ntp_skipped_nodes"):
+            continue
+        if time in result:
+            result[time].append(node)
+            result[time].sort()
+        else:
+            result[time] = [node]
+    assert len(result) <= 1, 'Not all nodes have the same time:\n {}'.format(
+                             json.dumps(result, indent=4))
 
 
 def test_ntp_peers_state(local_salt_client):
-    """Test gets ntpq peers state and check the system peer is declared"""
+    """Test gets ntpq peers state and checks the system peer is declared"""
 
-    active_nodes = utils.get_active_nodes(os.path.basename(__file__))
+    active_nodes = utils.get_active_nodes()
     state = local_salt_client.cmd(
         utils.list_to_target_string(active_nodes, 'or'),
         'cmd.run',