Compare commits
5 Commits
d0627af8e7
...
4d20916a96
Author | SHA1 | Date | |
---|---|---|---|
4d20916a96 | |||
43db99bfaa | |||
2cb6d95ec3 | |||
01162e78a3 | |||
22bdcada4a |
@ -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
|
||||||
|
21
scullery.py
21
scullery.py
@ -106,6 +106,8 @@ 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()
|
||||||
|
|
||||||
@ -161,8 +163,7 @@ 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):
|
||||||
if not os.path.isfile(sshfile):
|
vagrant_sshconfig(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:
|
||||||
@ -172,6 +173,13 @@ 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']
|
||||||
@ -208,10 +216,6 @@ 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:
|
||||||
@ -220,7 +224,9 @@ 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')
|
||||||
@ -240,6 +246,9 @@ 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:
|
||||||
|
@ -12,7 +12,7 @@ Testing functions for Scullery - a SaltStack testing tool.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
#import os
|
import os
|
||||||
import dotenv
|
import dotenv
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,21 +13,6 @@ 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),
|
||||||
@ -38,8 +23,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 [
|
||||||
'Comment: File /srv/hello_world.txt updated',
|
'File /srv/hello_world.txt',
|
||||||
'Succeeded: 1 (changed=1)',
|
'Succeeded: 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',
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
[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
|
name=Tumbleweed.x86_64
|
||||||
|
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]
|
||||||
|
@ -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/Tumbleweed.x86_64-libvirt.box
|
image=https://download.opensuse.org/repositories/home:/crameleon:/appliances/openSUSE_Tumbleweed/boxes/Tumbleweed.x86_64.json
|
||||||
|
|
||||||
[suite.one_minion]
|
[suite.one_minion]
|
||||||
minions=1
|
minions=1
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
bootstrap=scripts/bootstrap.sh
|
bootstrap=scripts/bootstrap.sh
|
||||||
|
|
||||||
[box.tumbleweed]
|
[box.tumbleweed]
|
||||||
name=tumblweed
|
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
|
||||||
|
|
||||||
[suite.one_minion]
|
[suite.one_minion]
|
||||||
minions=1
|
minions=1
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
[box]
|
[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]
|
[box.tumbleweed]
|
||||||
name=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
|
||||||
|
|
||||||
[suite.one_minion]
|
[suite.one_minion]
|
||||||
minions=1
|
minions=1
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
bootstrap=scripts/bootstrap.sh
|
bootstrap=scripts/bootstrap.sh
|
||||||
|
|
||||||
[box.tumbleweed]
|
[box.tumbleweed]
|
||||||
name=tumblweed
|
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
|
||||||
|
|
||||||
[suite.one_minion]
|
[suite.one_minion]
|
||||||
minions=1
|
minions=1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user