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| master_config.vm.provider :libvirt do |libvirt|
libvirt.memory = 768 libvirt.memory = 768
end 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 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 'auto_accept: True\n' > /etc/salt/master.d/notsecure.conf
printf "$SALT_FILE_ROOTS" > /etc/salt/master.d/roots.conf printf "$SALT_FILE_ROOTS" > /etc/salt/master.d/roots.conf
systemctl enable --now salt-master systemctl enable --now salt-master
SHELL SHELL
if salt_bootstrap
master_config.vm.provision "shell", path: salt_bootstrap
end
end end
end end
end end

View File

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

View File

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

View File

@ -13,6 +13,21 @@ Testing functions for Scullery - a SaltStack testing tool.
import pytest 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('config', ['complete'], indirect=True)
@pytest.mark.parametrize('suite,count', [ @pytest.mark.parametrize('suite,count', [
('one_minion_salt', 0), ('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') result = script_runner.run(*cmd, '--debug', '--env', '--test')
assert result.success assert result.success
for message in [ for message in [
'File /srv/hello_world.txt', 'Comment: File /srv/hello_world.txt updated',
'Succeeded: 1', 'Succeeded: 1 (changed=1)',
'DEBUG - main_interactive: state.apply requested', 'DEBUG - main_interactive: state.apply requested',
'INFO - main_interactive: Initiating tests ...', 'INFO - main_interactive: Initiating tests ...',
'DEBUG - runtests: Test result is 0', 'DEBUG - runtests: Test result is 0',

View File

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

View File

@ -2,7 +2,7 @@
bootstrap=scripts/bootstrap.sh bootstrap=scripts/bootstrap.sh
[box.tumbleweed] [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] [suite.one_minion]
minions=1 minions=1

View File

@ -2,8 +2,8 @@
bootstrap=scripts/bootstrap.sh bootstrap=scripts/bootstrap.sh
[box.tumbleweed] [box.tumbleweed]
name=Tumbleweed.x86_64 name=tumblweed
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] [suite.one_minion]
minions=1 minions=1

View File

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

View File

@ -2,8 +2,8 @@
bootstrap=scripts/bootstrap.sh bootstrap=scripts/bootstrap.sh
[box.tumbleweed] [box.tumbleweed]
name=Tumbleweed.x86_64 name=tumblweed
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] [suite.one_minion]
minions=1 minions=1