blob: 75a0116fdc617615b42bd8edcb9ca74c3aeeac69 [file] [log] [blame]
Oleksii Zhurba448c1b82019-01-30 20:55:38 -06001import json
Oleksii Zhurba23c18332019-05-09 18:53:40 -05002import pytest
Hanna Arhipova1eef8312019-05-06 20:14:18 +03003import logging
Oleksii Zhurba448c1b82019-01-30 20:55:38 -06004
5
Oleksii Zhurba23c18332019-05-09 18:53:40 -05006@pytest.mark.full
Oleksii Zhurbac3422212018-01-16 20:22:30 +00007def test_uncommited_changes(local_salt_client):
8 git_status = local_salt_client.cmd(
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +03009 tgt='salt:master',
10 param='cd /srv/salt/reclass/classes/cluster/; git status',
Oleksii Zhurba448c1b82019-01-30 20:55:38 -060011 expr_form='pillar', check_status=True)
Oleksii Zhurbac3422212018-01-16 20:22:30 +000012 assert 'nothing to commit' in git_status.values()[0], 'Git status showed' \
13 ' some unmerged changes {}'''.format(git_status.values()[0])
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050014
15
Oleksii Zhurba23c18332019-05-09 18:53:40 -050016@pytest.mark.smoke
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050017def test_reclass_smoke(local_salt_client):
18 reclass = local_salt_client.cmd(
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +030019 tgt='salt:master',
20 param='reclass-salt --top; echo $?',
Oleksii Zhurba448c1b82019-01-30 20:55:38 -060021 expr_form='pillar', check_status=True)
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050022 result = reclass[reclass.keys()[0]][-1]
23
24 assert result == '0', 'Reclass is broken' \
25 '\n {}'.format(reclass)
Oleksii Zhurba448c1b82019-01-30 20:55:38 -060026
27
Oleksii Zhurba23c18332019-05-09 18:53:40 -050028@pytest.mark.smoke
Oleksii Zhurba448c1b82019-01-30 20:55:38 -060029def 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)'