blob: f0d6499c38be4b8a8addf1f229b04f420d96d467 [file] [log] [blame]
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -06001import json
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -05002import pytest
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -06003
4
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -05005@pytest.mark.full
Oleksii Zhurbac3422212018-01-16 20:22:30 +00006def test_uncommited_changes(local_salt_client):
7 git_status = local_salt_client.cmd(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -05008 tgt='salt:master',
9 param='cd /srv/salt/reclass/classes/cluster/; git status',
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -060010 expr_form='pillar', check_status=True)
Oleksii Zhurbac3422212018-01-16 20:22:30 +000011 assert 'nothing to commit' in git_status.values()[0], 'Git status showed' \
12 ' some unmerged changes {}'''.format(git_status.values()[0])
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050013
14
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -050015@pytest.mark.smoke
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050016def test_reclass_smoke(local_salt_client):
17 reclass = local_salt_client.cmd(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050018 tgt='salt:master',
19 param='reclass-salt --top; echo $?',
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -060020 expr_form='pillar', check_status=True)
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050021 result = reclass[reclass.keys()[0]][-1]
22
23 assert result == '0', 'Reclass is broken' \
24 '\n {}'.format(reclass)
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -060025
26
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -050027@pytest.mark.smoke
Oleksii Zhurbad6c250e2019-01-30 20:55:38 -060028def 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)'