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