Oleksii Zhurba | d6c250e | 2019-01-30 20:55:38 -0600 | [diff] [blame] | 1 | import json |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame^] | 2 | import pytest |
Oleksii Zhurba | d6c250e | 2019-01-30 20:55:38 -0600 | [diff] [blame] | 3 | |
| 4 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame^] | 5 | @pytest.mark.full |
Oleksii Zhurba | c342221 | 2018-01-16 20:22:30 +0000 | [diff] [blame] | 6 | def test_uncommited_changes(local_salt_client): |
| 7 | git_status = local_salt_client.cmd( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 8 | tgt='salt:master', |
| 9 | param='cd /srv/salt/reclass/classes/cluster/; git status', |
Oleksii Zhurba | d6c250e | 2019-01-30 20:55:38 -0600 | [diff] [blame] | 10 | expr_form='pillar', check_status=True) |
Oleksii Zhurba | c342221 | 2018-01-16 20:22:30 +0000 | [diff] [blame] | 11 | assert 'nothing to commit' in git_status.values()[0], 'Git status showed' \ |
| 12 | ' some unmerged changes {}'''.format(git_status.values()[0]) |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 13 | |
| 14 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame^] | 15 | @pytest.mark.smoke |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 16 | def test_reclass_smoke(local_salt_client): |
| 17 | reclass = local_salt_client.cmd( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 18 | tgt='salt:master', |
| 19 | param='reclass-salt --top; echo $?', |
Oleksii Zhurba | d6c250e | 2019-01-30 20:55:38 -0600 | [diff] [blame] | 20 | expr_form='pillar', check_status=True) |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 21 | result = reclass[reclass.keys()[0]][-1] |
| 22 | |
| 23 | assert result == '0', 'Reclass is broken' \ |
| 24 | '\n {}'.format(reclass) |
Oleksii Zhurba | d6c250e | 2019-01-30 20:55:38 -0600 | [diff] [blame] | 25 | |
| 26 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame^] | 27 | @pytest.mark.smoke |
Oleksii Zhurba | d6c250e | 2019-01-30 20:55:38 -0600 | [diff] [blame] | 28 | def test_reclass_nodes(local_salt_client): |
| 29 | reclass = local_salt_client.cmd( |
| 30 | tgt='salt:master', |
| 31 | param='reclass-salt -o json --top', |
| 32 | expr_form='pillar', check_status=True) |
| 33 | salt = local_salt_client.cmd( |
| 34 | tgt='salt:master', |
| 35 | param='salt-run manage.status timeout=10 --out=json', |
| 36 | expr_form='pillar', check_status=True).values()[0] |
| 37 | reclass_warnings = reclass[reclass.keys()[0]].split('{\n "base":')[0] |
| 38 | if reclass_warnings: |
| 39 | print "\nReclass-salt output has warnings" |
| 40 | reclass_nodes = reclass[reclass.keys()[0]].split('{\n "base":')[1] |
| 41 | assert reclass_nodes != '', 'No nodes were found in' \ |
| 42 | ' reclass-salt --top output' |
| 43 | reclass_nodes = sorted(json.loads(reclass_nodes.strip("}")).keys()) |
| 44 | salt_nodes = sorted([x for xs in json.loads(salt).values() for x in xs]) |
| 45 | assert salt_nodes == reclass_nodes, 'Mismatch between registered salt nodes (left) ' \ |
| 46 | 'and defined reclass nodes (right)' |