Compare commits
No commits in common. "00c9634579d0cdb765d48999a053f3e2748bd469" and "d37bd67b2ed5f12ffc3d5435d0782b37d776caf5" have entirely different histories.
00c9634579
...
d37bd67b2e
19
scullery.py
19
scullery.py
@ -141,21 +141,11 @@ def vagrant_sshconfig(outfile):
|
|||||||
with open(outfile, 'w') as fh:
|
with open(outfile, 'w') as fh:
|
||||||
fh.write(ssh_config)
|
fh.write(ssh_config)
|
||||||
|
|
||||||
def _saltcmd(target):
|
def runapply(state, target):
|
||||||
if target == 'local':
|
if target == 'local':
|
||||||
saltcmd = 'salt-call --local'
|
saltcmd = 'salt-call --local'
|
||||||
else:
|
else:
|
||||||
saltcmd = 'salt -t10 {}'.format(target)
|
saltcmd = 'salt {}'.format(target)
|
||||||
return saltcmd
|
|
||||||
|
|
||||||
def runping(target):
|
|
||||||
saltcmd = _saltcmd(target)
|
|
||||||
sshout = v.ssh(command='sudo {} test.ping'.format(saltcmd))
|
|
||||||
log.info('\n{}\n'.format(str(sshout)))
|
|
||||||
return sshout
|
|
||||||
|
|
||||||
def runapply(state, target):
|
|
||||||
saltcmd = _saltcmd(target)
|
|
||||||
sshout = v.ssh(command='sudo {} state.apply {}'.format(saltcmd, state))
|
sshout = v.ssh(command='sudo {} state.apply {}'.format(saltcmd, state))
|
||||||
log.info('\n{}\n'.format(str(sshout)))
|
log.info('\n{}\n'.format(str(sshout)))
|
||||||
|
|
||||||
@ -251,11 +241,6 @@ def main_interactive():
|
|||||||
log.debug('state.apply requested')
|
log.debug('state.apply requested')
|
||||||
if masters is not None:
|
if masters is not None:
|
||||||
target = 'scullery-*'
|
target = 'scullery-*'
|
||||||
count = 0
|
|
||||||
while not runping(target):
|
|
||||||
if count == 5:
|
|
||||||
_abort('Unable to reach minions')
|
|
||||||
count += 1
|
|
||||||
else:
|
else:
|
||||||
target = 'local'
|
target = 'local'
|
||||||
runapply(testconf['apply'], target)
|
runapply(testconf['apply'], target)
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
"""
|
|
||||||
Copyright 2023, Georg Pfuetzenreuter
|
|
||||||
|
|
||||||
Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence").
|
|
||||||
You may not use this work except in compliance with the Licence.
|
|
||||||
An English copy of the Licence is shipped in a file called LICENSE along with this applications source code.
|
|
||||||
You may obtain copies of the Licence in any of the official languages at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Testing functions for Scullery - a SaltStack testing tool.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('config', ['complete'], indirect=True)
|
|
||||||
@pytest.mark.parametrize('suite', [
|
|
||||||
'one_minion_salt',
|
|
||||||
'two_minions_one_master_salt',
|
|
||||||
])
|
|
||||||
def test_salt(script_runner, script, config, suite):
|
|
||||||
cmd = (script, '--config', config, '--suite', suite)
|
|
||||||
result = script_runner.run(*cmd, '--debug', '--env', '--test')
|
|
||||||
# not possible until we have a way to apply without invoking tests
|
|
||||||
# assert result.success
|
|
||||||
assert 'Comment: File /srv/hello_world.txt updated' in result.stderr
|
|
||||||
assert 'Succeeded: 1 (changed=1)' in result.stderr
|
|
||||||
assert 'DEBUG - main_interactive: state.apply requested' in result.stderr
|
|
||||||
assert script_runner.run(*cmd, '--stop')
|
|
||||||
|
|
@ -9,10 +9,6 @@ name=tumbleweed
|
|||||||
name=tumbleweed_bootstrap
|
name=tumbleweed_bootstrap
|
||||||
bootstrap=tests/scripts/bootstrap_hello_world.sh
|
bootstrap=tests/scripts/bootstrap_hello_world.sh
|
||||||
|
|
||||||
[box.tumbleweed_salt]
|
|
||||||
name=tumbleweed_salt
|
|
||||||
bootstrap=tests/scripts/bootstrap_salt.sh
|
|
||||||
|
|
||||||
[suite.one_minion]
|
[suite.one_minion]
|
||||||
minions=1
|
minions=1
|
||||||
box=tumbleweed
|
box=tumbleweed
|
||||||
@ -44,30 +40,6 @@ minions=2
|
|||||||
masters=1
|
masters=1
|
||||||
box=tumbleweed
|
box=tumbleweed
|
||||||
|
|
||||||
[suite.one_minion_bogus_test]
|
|
||||||
minions=1
|
|
||||||
box=tumbleweed
|
|
||||||
test=cashew
|
|
||||||
|
|
||||||
[suite.one_minion_bogus_test_2]
|
|
||||||
minions=1
|
|
||||||
box=tumbleweed
|
|
||||||
test=bogus
|
|
||||||
|
|
||||||
[test.hello]
|
[test.hello]
|
||||||
apply=hello_world
|
apply=hello_world
|
||||||
test=salt/hello_world/tests/test_hello.py
|
test=salt/hello_world/tests/test_hello.py
|
||||||
|
|
||||||
[test.bogus]
|
|
||||||
apply=cashew
|
|
||||||
|
|
||||||
[suite.one_minion_salt]
|
|
||||||
minions=1
|
|
||||||
box=tumbleweed_salt
|
|
||||||
test=hello
|
|
||||||
|
|
||||||
[suite.two_minions_one_master_salt]
|
|
||||||
masters=1
|
|
||||||
minions=2
|
|
||||||
box=tumbleweed_salt
|
|
||||||
test=hello
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
[box]
|
|
||||||
bootstrap=tests/scripts/bootstrap_salt.sh
|
|
||||||
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/Tumbleweed.x86_64-libvirt.box
|
|
||||||
|
|
||||||
[box.tumbleweed]
|
|
||||||
name=tumbleweed
|
|
||||||
|
|
||||||
[suite.one_minion]
|
|
||||||
minions=1
|
|
||||||
box=tumbleweed
|
|
||||||
|
|
||||||
[suite.two_minions_one_master_bootstrap]
|
|
||||||
minions=2
|
|
||||||
masters=1
|
|
||||||
box=tumbleweed
|
|
@ -1,16 +1,3 @@
|
|||||||
"""
|
|
||||||
Copyright 2023, Georg Pfuetzenreuter
|
|
||||||
|
|
||||||
Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence").
|
|
||||||
You may not use this work except in compliance with the Licence.
|
|
||||||
An English copy of the Licence is shipped in a file called LICENSE along with this applications source code.
|
|
||||||
You may obtain copies of the Licence in any of the official languages at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Testing functions for Scullery - a SaltStack testing tool.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import os
|
import os
|
||||||
import libvirt
|
import libvirt
|
||||||
|
@ -1 +0,0 @@
|
|||||||
greeting: 'Hello salted world!'
|
|
@ -1,3 +0,0 @@
|
|||||||
/srv/hello_world.txt:
|
|
||||||
file.managed:
|
|
||||||
- contents_pillar: greeting
|
|
@ -1,27 +0,0 @@
|
|||||||
testbase='/vagrant/tests/salt/hello_world'
|
|
||||||
sls='hello_world.sls'
|
|
||||||
|
|
||||||
ln -s "$testbase/states/$sls" /srv/salt/
|
|
||||||
ln -s "$testbase/pillar/$sls" /srv/pillar/
|
|
||||||
|
|
||||||
tee /srv/pillar/top.sls >/dev/null <<EOF
|
|
||||||
base:
|
|
||||||
'*':
|
|
||||||
- hello_world
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if systemctl is-enabled salt-master
|
|
||||||
then
|
|
||||||
count=0
|
|
||||||
until salt -t10 scullery-\* test.ping
|
|
||||||
do
|
|
||||||
if [ "$count" = 3 ]
|
|
||||||
then
|
|
||||||
logger -s 'No minions connected'
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo 'Waiting for minions to connect ...'
|
|
||||||
sleep 5
|
|
||||||
count=$((count+1))
|
|
||||||
done
|
|
||||||
fi
|
|
@ -1,16 +1,3 @@
|
|||||||
"""
|
|
||||||
Copyright 2023, Georg Pfuetzenreuter
|
|
||||||
|
|
||||||
Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence").
|
|
||||||
You may not use this work except in compliance with the Licence.
|
|
||||||
An English copy of the Licence is shipped in a file called LICENSE along with this applications source code.
|
|
||||||
You may obtain copies of the Licence in any of the official languages at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Testing functions for Scullery - a SaltStack testing tool.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
#import os
|
#import os
|
||||||
import dotenv
|
import dotenv
|
||||||
@ -121,27 +108,6 @@ def test_envfile(script_runner, script, config, suite, masters, minions):
|
|||||||
assert os.path.isfile(envfile) is False
|
assert os.path.isfile(envfile) is False
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('config', ['complete'], indirect=True)
|
|
||||||
def test_test_undeclared(script_runner, script, config):
|
|
||||||
result = script_runner.run(script, '--config', config, '--suite', 'one_minion', '--test')
|
|
||||||
assert not result.success
|
|
||||||
assert result.stderr.endswith('Tests requested but not declared in suite configuration\n')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('config', ['complete'], indirect=True)
|
|
||||||
def test_test_undefined(script_runner, script, config):
|
|
||||||
result = script_runner.run(script, '--config', config, '--suite', 'one_minion_bogus_test', '--test')
|
|
||||||
assert not result.success
|
|
||||||
assert result.stderr.endswith('Specified test is not defined\n')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('config', ['complete'], indirect=True)
|
|
||||||
def test_test_incomplete(script_runner, script, config):
|
|
||||||
result = script_runner.run(script, '--config', config, '--suite', 'one_minion_bogus_test_2', '--test')
|
|
||||||
assert not result.success
|
|
||||||
assert result.stderr.endswith('Incomplete test configuration\n')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('config', ['complete'], indirect=True)
|
@pytest.mark.parametrize('config', ['complete'], indirect=True)
|
||||||
@pytest.mark.parametrize('suite', [
|
@pytest.mark.parametrize('suite', [
|
||||||
'one_minion',
|
'one_minion',
|
@ -1,16 +1,3 @@
|
|||||||
"""
|
|
||||||
Copyright 2023, Georg Pfuetzenreuter
|
|
||||||
|
|
||||||
Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence").
|
|
||||||
You may not use this work except in compliance with the Licence.
|
|
||||||
An English copy of the Licence is shipped in a file called LICENSE along with this applications source code.
|
|
||||||
You may obtain copies of the Licence in any of the official languages at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Testing functions for Scullery - a SaltStack testing tool.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import os
|
import os
|
||||||
from conftest import loadenv
|
from conftest import loadenv
|
Loading…
x
Reference in New Issue
Block a user