Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 1 | from cvp_checks import utils |
| 2 | |
| 3 | |
Oleksii Zhurba | 17a8848 | 2017-10-06 14:29:05 -0500 | [diff] [blame^] | 4 | def test_ntp_sync(local_salt_client): |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 5 | config = utils.get_configuration(__file__) |
| 6 | fail = {} |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 7 | saltmaster_time = int(local_salt_client.cmd( |
Oleksii Zhurba | 17a8848 | 2017-10-06 14:29:05 -0500 | [diff] [blame^] | 8 | 'salt:master', |
| 9 | 'cmd.run', |
| 10 | ['date +%s'], |
| 11 | expr_form='pillar').values()[0]) |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 12 | |
| 13 | nodes_time = local_salt_client.cmd( |
Oleksii Zhurba | 17a8848 | 2017-10-06 14:29:05 -0500 | [diff] [blame^] | 14 | '*', 'cmd.run', ['date +%s']) |
Oleksii Zhurba | a10927b | 2017-09-27 22:09:23 +0000 | [diff] [blame] | 15 | |
| 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) |