Implement bootstrap tests
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
1788a9cdf3
commit
43193ad292
@ -1,14 +1,27 @@
|
|||||||
[box]
|
[box]
|
||||||
bootstrap=tests/scripts/bootstrap.sh
|
bootstrap=tests/scripts/bootstrap.sh
|
||||||
|
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/Tumbleweed.x86_64-libvirt.box
|
||||||
|
|
||||||
[box.tumbleweed]
|
[box.tumbleweed]
|
||||||
name=tumbleweed
|
name=tumbleweed
|
||||||
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/Tumbleweed.x86_64-libvirt.box
|
|
||||||
|
[box.tumbleweed_bootstrap]
|
||||||
|
name=tumbleweed_bootstrap
|
||||||
|
bootstrap=tests/scripts/bootstrap_hello_world.sh
|
||||||
|
|
||||||
[suite.one_minion]
|
[suite.one_minion]
|
||||||
minions=1
|
minions=1
|
||||||
box=tumbleweed
|
box=tumbleweed
|
||||||
|
|
||||||
|
[suite.one_minion_bootstrap]
|
||||||
|
minions=1
|
||||||
|
box=tumbleweed_bootstrap
|
||||||
|
|
||||||
|
[suite.one_minion_one_master_bootstrap]
|
||||||
|
minions=1
|
||||||
|
masters=1
|
||||||
|
box=tumbleweed_bootstrap
|
||||||
|
|
||||||
[suite.two_minions]
|
[suite.two_minions]
|
||||||
minions=2
|
minions=2
|
||||||
box=tumbleweed
|
box=tumbleweed
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import os
|
import os
|
||||||
import libvirt
|
import libvirt
|
||||||
|
import vagrant
|
||||||
|
import dotenv
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def script():
|
def script():
|
||||||
@ -25,3 +27,16 @@ def config(testbase, request):
|
|||||||
def virt():
|
def virt():
|
||||||
return libvirt.openReadOnly('qemu:///system')
|
return libvirt.openReadOnly('qemu:///system')
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def vag():
|
||||||
|
return vagrant.Vagrant(quiet_stderr=False, quiet_stdout=False)
|
||||||
|
|
||||||
|
def loadenv():
|
||||||
|
env = os.environ.copy()
|
||||||
|
envmap = dotenv.dotenv_values('.scullery_env')
|
||||||
|
for variable, value in envmap.items():
|
||||||
|
if value is not None:
|
||||||
|
if isinstance(value, list):
|
||||||
|
value = ','.join(value)
|
||||||
|
env[variable] = value
|
||||||
|
return env
|
||||||
|
1
tests/scripts/bootstrap_hello_world.sh
Normal file
1
tests/scripts/bootstrap_hello_world.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
echo 'Hello world!' > /srv/hello_world.txt
|
@ -49,7 +49,7 @@ def test_config_undefined(script_runner, script, testbase, section, message):
|
|||||||
('two_minions_one_master', "[Status(name='scullery-master0', state='not_created', provider='libvirt'), Status(name='scullery-minion0', state='not_created', provider='libvirt'), Status(name='scullery-minion1', state='not_created', provider='libvirt')]")
|
('two_minions_one_master', "[Status(name='scullery-master0', state='not_created', provider='libvirt'), Status(name='scullery-minion0', state='not_created', provider='libvirt'), Status(name='scullery-minion1', state='not_created', provider='libvirt')]")
|
||||||
])
|
])
|
||||||
def test_status_report_not_running(script_runner, script, config, suite, report):
|
def test_status_report_not_running(script_runner, script, config, suite, report):
|
||||||
result = script_runner.run(script, '--config', config, '--suite', suite, '--status')
|
result = script_runner.run(script, '--config', config, '--suite', suite, '--status', '--debug', '--env')
|
||||||
assert result.success
|
assert result.success
|
||||||
assert result.stderr.endswith("INFO - main_interactive: Status report: {}\n".format(report))
|
assert result.stderr.endswith("INFO - main_interactive: Status report: {}\n".format(report))
|
||||||
|
|
||||||
@ -114,10 +114,12 @@ def test_envfile(script_runner, script, config, suite, masters, minions):
|
|||||||
'two_minions',
|
'two_minions',
|
||||||
'one_master',
|
'one_master',
|
||||||
'one_minion_one_master',
|
'one_minion_one_master',
|
||||||
'two_minions_one_master'
|
'two_minions_one_master',
|
||||||
|
'one_minion_bootstrap',
|
||||||
|
'one_minion_one_master_bootstrap'
|
||||||
])
|
])
|
||||||
def test_stop(script_runner, script, virt, config, suite):
|
def test_stop(script_runner, script, virt, config, suite):
|
||||||
cmd = (script, '--config', config, '--suite', suite, '--stop')
|
cmd = (script, '--config', config, '--suite', suite, '--stop', '--force')
|
||||||
result = script_runner.run(*cmd)
|
result = script_runner.run(*cmd)
|
||||||
assert result.success
|
assert result.success
|
||||||
domains = []
|
domains = []
|
||||||
|
30
tests/test_vagrant.py
Normal file
30
tests/test_vagrant.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import pytest
|
||||||
|
import os
|
||||||
|
from conftest import loadenv
|
||||||
|
import sys
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('config', ['complete'], indirect=True)
|
||||||
|
@pytest.mark.parametrize('suite', [
|
||||||
|
'one_minion_bootstrap',
|
||||||
|
'one_minion_one_master_bootstrap',
|
||||||
|
])
|
||||||
|
def test_bootstrap(script_runner, script, config, suite, vag, testbase):
|
||||||
|
bootstrap_script = '{}/scripts/bootstrap_hello_world.txt'.format(testbase)
|
||||||
|
do_digest = False
|
||||||
|
if sys.version_info[1] > 10:
|
||||||
|
do_digest = True
|
||||||
|
import hashlib
|
||||||
|
with open(bootstrap_script, 'rb') as fh:
|
||||||
|
digest_local = hashlib.file_digest(fh, 'md5')
|
||||||
|
cmd = (script, '--config', config, '--suite', suite)
|
||||||
|
result = script_runner.run(*cmd, '--env')
|
||||||
|
assert result.success
|
||||||
|
assert result.stderr.endswith('main_interactive: Launching {} ...\n'.format(suite))
|
||||||
|
v = vag
|
||||||
|
v.env = loadenv()
|
||||||
|
assert v.ssh(command='cat /srv/hello_world.txt') == 'Hello world!\n'
|
||||||
|
if do_digest:
|
||||||
|
digest_remote = v.ssh(command='md5sum /srv/hello_world.txt | awk "{ print $1 }"')
|
||||||
|
assert digest_local == digest_remote
|
||||||
|
assert script_runner.run(*cmd, '--stop')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user