Compare commits

..

No commits in common. "4d20916a961cb2bc90c147b496111054c073e71c" and "d0627af8e725be3ebcbd569c696208fa3dddfc61" have entirely different histories.

9 changed files with 40 additions and 31 deletions

View File

@ -23,14 +23,14 @@ Vagrant.configure("2") do |config|
master_config.vm.provider :libvirt do |libvirt|
libvirt.memory = 768
end
if salt_bootstrap
master_config.vm.provision "shell", path: salt_bootstrap
end
master_config.vm.provision "shell", env: {'SALT_FILE_ROOTS': salt_file_roots}, inline: <<-SHELL
printf 'auto_accept: True\n' > /etc/salt/master.d/notsecure.conf
printf "$SALT_FILE_ROOTS" > /etc/salt/master.d/roots.conf
systemctl enable --now salt-master
SHELL
if salt_bootstrap
master_config.vm.provision "shell", path: salt_bootstrap
end
end
end
end

View File

@ -106,8 +106,6 @@ def _setenv(envmap, dump=False):
env[variable] = value
if dump:
fh.write(f'{variable}={value}\n')
elif variable in env:
del env[variable]
if dump:
fh.close()
@ -163,7 +161,8 @@ def runapply(state, target):
log.info('\n{}\n'.format(str(sshout)))
def runtests(payload, hosts):
vagrant_sshconfig(sshfile)
if not os.path.isfile(sshfile):
vagrant_sshconfig(sshfile)
testresult = pytest.main(['--verbose', '--hosts={}'.format(','.join(hosts)), '--ssh-config={}'.format(sshfile), payload])
log.debug('Test result is {}'.format(str(testresult.value)))
if testresult == ExitCode.OK:
@ -173,13 +172,6 @@ def runtests(payload, hosts):
return False
return True
def _cleanup():
for file in [envfile, sshfile]:
if os.path.isfile(file):
log.debug('Removing {}'.format(file))
os.remove(file)
def main_interactive():
configmap = _config()
boxes = configmap['boxes']
@ -216,6 +208,10 @@ def main_interactive():
if True in [args.stop, args.force_stop]:
log.info('Destroying machines ...')
v.destroy()
for file in [envfile, sshfile]:
if os.path.isfile(file):
log.debug('Removing {}'.format(file))
os.remove(file)
if vagrant_isup(suite)[0] is False:
log.debug('OK')
else:
@ -224,9 +220,7 @@ def main_interactive():
log.info('Deployment is already running')
elif args.refresh:
log.info('Deployment is running, initiating refresh ...')
_cleanup()
v.provision()
vagrant_sshconfig(sshfile)
elif status[0] is False:
if status[1] is True:
log.debug('Deployment is not running')
@ -246,9 +240,6 @@ def main_interactive():
else:
_abort('Start failed')
if args.stop:
_cleanup()
if args.test:
test = suiteconf.get('test', None)
if test is None:

View File

@ -12,7 +12,7 @@ Testing functions for Scullery - a SaltStack testing tool.
"""
import pytest
import os
#import os
import dotenv

View File

@ -13,6 +13,21 @@ 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')
@pytest.mark.parametrize('config', ['complete'], indirect=True)
@pytest.mark.parametrize('suite,count', [
('one_minion_salt', 0),
@ -23,8 +38,8 @@ def test_salt_test(script_runner, script, config, suite, count):
result = script_runner.run(*cmd, '--debug', '--env', '--test')
assert result.success
for message in [
'File /srv/hello_world.txt',
'Succeeded: 1',
'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',

View File

@ -1,14 +1,16 @@
[box]
bootstrap=tests/scripts/bootstrap.sh
name=Tumbleweed.x86_64
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/boxes/Tumbleweed.x86_64.json
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/Tumbleweed.x86_64-libvirt.box
[box.tumbleweed]
name=tumbleweed
[box.tumbleweed_bootstrap]
name=tumbleweed_bootstrap
bootstrap=tests/scripts/bootstrap_hello_world.sh
[box.tumbleweed_salt]
name=tumbleweed_salt
bootstrap=tests/scripts/bootstrap_salt.sh
[suite.one_minion]

View File

@ -2,7 +2,7 @@
bootstrap=scripts/bootstrap.sh
[box.tumbleweed]
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/boxes/Tumbleweed.x86_64.json
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/Tumbleweed.x86_64-libvirt.box
[suite.one_minion]
minions=1

View File

@ -2,8 +2,8 @@
bootstrap=scripts/bootstrap.sh
[box.tumbleweed]
name=Tumbleweed.x86_64
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/boxes/Tumbleweed.x86_64.json
name=tumblweed
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/Tumbleweed.x86_64-libvirt.box
[suite.one_minion]
minions=1

View File

@ -1,8 +1,9 @@
[box]
[box.tumbleweed]
bootstrap=tests/scripts/bootstrap_salt.sh
name=Tumbleweed.x86_64
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/boxes/Tumbleweed.x86_64.json
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

View File

@ -2,8 +2,8 @@
bootstrap=scripts/bootstrap.sh
[box.tumbleweed]
name=Tumbleweed.x86_64
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/boxes/Tumbleweed.x86_64.json
name=tumblweed
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/Tumbleweed.x86_64-libvirt.box
[suite.one_minion]
minions=1