Implement Salt test tests

Test the tests.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2023-05-21 13:32:04 +02:00
parent 8506b12e36
commit cc15766671
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57
4 changed files with 35 additions and 2 deletions

View File

@ -150,7 +150,9 @@ def test_test_incomplete(script_runner, script, config):
'one_minion_one_master', 'one_minion_one_master',
'two_minions_one_master', 'two_minions_one_master',
'one_minion_bootstrap', 'one_minion_bootstrap',
'one_minion_one_master_bootstrap' 'one_minion_one_master_bootstrap',
'one_minion_salt',
'two_minions_one_master_salt'
]) ])
def test_stop(script_runner, script, config, suite): def test_stop(script_runner, script, config, suite):
cmd = (script, '--config', config, '--suite', suite, '--stop', '--force') cmd = (script, '--config', config, '--suite', suite, '--stop', '--force')

View File

@ -28,3 +28,32 @@ def test_salt(script_runner, script, config, suite):
assert 'DEBUG - main_interactive: state.apply requested' in result.stderr assert 'DEBUG - main_interactive: state.apply requested' in result.stderr
assert script_runner.run(*cmd, '--stop') assert script_runner.run(*cmd, '--stop')
@pytest.mark.parametrize('config', ['complete'], indirect=True)
@pytest.mark.parametrize('suite,count', [
('one_minion_salt', 0),
('two_minions_one_master_salt', 1)
])
def test_salt_test(script_runner, script, config, suite, count):
cmd = (script, '--config', config, '--suite', suite)
result = script_runner.run(*cmd, '--debug', '--env', '--test')
assert result.success
for message in [
'Comment: File /srv/hello_world.txt updated',
'Succeeded: 1 (changed=1)',
'DEBUG - main_interactive: state.apply requested',
'INFO - main_interactive: Initiating tests ...',
'DEBUG - runtests: Test result is 0',
'DEBUG - runtests: Test succeeded'
]:
assert message in result.stderr
assert not any(term in result.stderr for term in [
'FAILED', 'WARNING - runtests: Tests failed',
'DEBUG - runtests: Test result is 1', 'AssertionError'
])
if count > 0:
minions = [0, 1]
else:
minions = [0]
for m in minions:
assert 'test_hello_world_content[paramiko://scullery-minion%i] PASSED' % m in result.stdout
assert script_runner.run(*cmd, '--stop')

View File

@ -56,7 +56,7 @@ test=bogus
[test.hello] [test.hello]
apply=hello_world apply=hello_world
test=salt/hello_world/tests/test_hello.py test=tests/salt/hello_world/tests/test_hello.py
[test.bogus] [test.bogus]
apply=cashew apply=cashew

View File

@ -0,0 +1,2 @@
def test_hello_world_content(host):
assert host.file('/srv/hello_world.txt').content.decode('UTF-8') == 'Hello salted world!\n'