blob: 10eb130b84a6cb0c6b8f10c85e6cbf128638e058 [file] [log] [blame]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00001from cvp_checks import utils
2
3
Oleksii Zhurba17a88482017-10-06 14:29:05 -05004def test_ntp_sync(local_salt_client):
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00005 config = utils.get_configuration(__file__)
6 fail = {}
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00007 saltmaster_time = int(local_salt_client.cmd(
Oleksii Zhurba17a88482017-10-06 14:29:05 -05008 'salt:master',
9 'cmd.run',
10 ['date +%s'],
11 expr_form='pillar').values()[0])
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000012
13 nodes_time = local_salt_client.cmd(
Oleksii Zhurba17a88482017-10-06 14:29:05 -050014 '*', 'cmd.run', ['date +%s'])
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000015
16 for node, time in nodes_time.iteritems():
17 if (int(time) - saltmaster_time) > config["time_deviation"] or \
18 (int(time) - saltmaster_time) < -config["time_deviation"]:
19 fail[node] = time
20
21 assert not fail, 'SaltMaster time: {}\n' \
22 'Nodes with time mismatch:\n {}'.format(saltmaster_time,
23 fail)