Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 1 | import pytest |
| 2 | import os |
| 3 | from cvp_checks import utils |
| 4 | |
| 5 | |
| 6 | @pytest.mark.parametrize( |
| 7 | "node", |
| 8 | utils.get_active_nodes(utils.get_configuration(__file__)) |
| 9 | ) |
| 10 | def test_ntp_sync(local_salt_client, node): |
| 11 | config = utils.get_configuration(__file__) |
| 12 | fail = {} |
| 13 | |
| 14 | saltmaster_time = int(local_salt_client.cmd( |
| 15 | os.uname()[1] + '*', 'cmd.run', ['date +%s']).values()[0]) |
| 16 | |
| 17 | nodes_time = local_salt_client.cmd( |
| 18 | node, 'cmd.run', ['date +%s'], expr_form='pcre') |
| 19 | |
| 20 | for node, time in nodes_time.iteritems(): |
| 21 | if (int(time) - saltmaster_time) > config["time_deviation"] or \ |
| 22 | (int(time) - saltmaster_time) < -config["time_deviation"]: |
| 23 | fail[node] = time |
| 24 | |
| 25 | assert not fail, 'SaltMaster time: {}\n' \ |
| 26 | 'Nodes with time mismatch:\n {}'.format(saltmaster_time, |
| 27 | fail) |