blob: 546ff751d0acd24c4132b976bd053c1dbc078a74 [file] [log] [blame]
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -06001import json
2
3
Oleksii Zhurbac3422212018-01-16 20:22:30 +00004def test_uncommited_changes(local_salt_client):
5 git_status = local_salt_client.cmd(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -05006 tgt='salt:master',
7 param='cd /srv/salt/reclass/classes/cluster/; git status',
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -06008 expr_form='pillar', check_status=True)
Oleksii Zhurbac3422212018-01-16 20:22:30 +00009 assert 'nothing to commit' in git_status.values()[0], 'Git status showed' \
10 ' some unmerged changes {}'''.format(git_status.values()[0])
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050011
12
13def test_reclass_smoke(local_salt_client):
14 reclass = local_salt_client.cmd(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050015 tgt='salt:master',
16 param='reclass-salt --top; echo $?',
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -060017 expr_form='pillar', check_status=True)
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050018 result = reclass[reclass.keys()[0]][-1]
19
20 assert result == '0', 'Reclass is broken' \
21 '\n {}'.format(reclass)
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -060022
23
24def 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)'