blob: be0f41146d7113a8385c7eef0ebdb2fa551f7cd8 [file] [log] [blame]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00001from cvp_checks import utils
Oleksii Zhurba1a21b562019-02-26 17:33:43 -06002import json
Hanna Arhipovaa3c6a852019-03-28 09:30:20 +02003import pytest
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00004
Hanna Arhipovaa3c6a852019-03-28 09:30:20 +02005@pytest.mark.xfail
Oleksii Zhurba17a88482017-10-06 14:29:05 -05006def test_ntp_sync(local_salt_client):
Oleksii Zhurba1a21b562019-02-26 17:33:43 -06007 """Test checks that system time is the same across all nodes"""
8
9 active_nodes = utils.get_active_nodes()
Oleksii Zhurbae0668ae2017-10-27 23:58:18 +000010 config = utils.get_configuration()
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000011 nodes_time = local_salt_client.cmd(
Oleksii Zhurbae0668ae2017-10-27 23:58:18 +000012 utils.list_to_target_string(active_nodes, 'or'),
13 'cmd.run',
14 ['date +%s'],
15 expr_form='compound')
Oleksii Zhurba1a21b562019-02-26 17:33:43 -060016 result = {}
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000017 for node, time in nodes_time.iteritems():
Oleksii Zhurba1a21b562019-02-26 17:33:43 -060018 if node in config.get("ntp_skipped_nodes"):
19 continue
20 if time in result:
21 result[time].append(node)
22 result[time].sort()
23 else:
24 result[time] = [node]
25 assert len(result) <= 1, 'Not all nodes have the same time:\n {}'.format(
26 json.dumps(result, indent=4))