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