Use centralised test scripts
This patch consumes the test scripts implemented by https://review.openstack.org/375061 to ensure that the tests and test preparation is consistent and more maintainable. Change-Id: I2c26eb12711128082a7136ab962f8239b59124b4
This commit is contained in:
parent
f460a97651
commit
ec1b42a2f9
@ -30,4 +30,4 @@ export ANSIBLE_SSH_ARGS="-o ControlMaster=no \
|
||||
-o ForwardAgent=yes"
|
||||
|
||||
echo "Run manual functional tests by executing the following:"
|
||||
echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml -e \"rolename=$(pwd)\""
|
||||
echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml"
|
||||
|
@ -52,7 +52,7 @@
|
||||
- "'\nUnattended-Upgrade::Mail \"root\";\n' in unattended_upgrades_file"
|
||||
when: ansible_pkg_mgr == 'apt'
|
||||
roles:
|
||||
- role: "{{ rolename }}"
|
||||
- role: "openstack-ansible-security"
|
||||
vars:
|
||||
security_unattended_upgrades_enabled: true
|
||||
security_unattended_upgrades_notifications: true
|
||||
|
@ -16,4 +16,4 @@
|
||||
- name: Playbook for role testing (check mode)
|
||||
hosts: localhost
|
||||
roles:
|
||||
- role: "{{ rolename }}"
|
||||
- role: "openstack-ansible-security"
|
||||
|
92
tox.ini
92
tox.ini
@ -22,17 +22,14 @@ passenv =
|
||||
NO_PROXY
|
||||
whitelist_externals =
|
||||
bash
|
||||
git
|
||||
rm
|
||||
wget
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
PYTHONUNBUFFERED=1
|
||||
ROLE_NAME=openstack-ansible-security
|
||||
VIRTUAL_ENV={envdir}
|
||||
WORKING_DIR={toxinidir}
|
||||
|
||||
|
||||
[testenv:docs]
|
||||
deps=
|
||||
{[testenv]deps}
|
||||
commands=
|
||||
bash -c "rm -rf doc/build"
|
||||
doc8 doc
|
||||
@ -44,6 +41,7 @@ commands=
|
||||
extensions = .rst
|
||||
allow-long-titles=1
|
||||
|
||||
|
||||
[testenv:releasenotes]
|
||||
commands =
|
||||
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||
@ -55,17 +53,17 @@ commands =
|
||||
{posargs}
|
||||
|
||||
|
||||
[testenv:tests_clone]
|
||||
commands =
|
||||
bash -c "if [ ! -d "{toxinidir}/tests/common" ]; then \
|
||||
git clone https://git.openstack.org/openstack/openstack-ansible-tests {toxinidir}/tests/common; \
|
||||
fi"
|
||||
|
||||
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
# Run hacking/flake8 check for all python files
|
||||
bash -c "grep --recursive --binary-files=without-match \
|
||||
--files-with-match '^.!.*python$' \
|
||||
--exclude-dir .eggs \
|
||||
--exclude-dir .git \
|
||||
--exclude-dir .tox \
|
||||
--exclude-dir *.egg-info \
|
||||
--exclude-dir doc \
|
||||
{toxinidir} | xargs flake8 --verbose"
|
||||
{[testenv:tests_clone]commands}
|
||||
bash -c "{toxinidir}/tests/common/test-pep8.sh"
|
||||
|
||||
|
||||
[flake8]
|
||||
@ -78,69 +76,27 @@ ignore=F403,H303
|
||||
|
||||
[testenv:bashate]
|
||||
commands =
|
||||
# Run bashate check for all bash scripts
|
||||
# Ignores the following rules:
|
||||
# E003: Indent not multiple of 4 (we prefer to use multiples of 2)
|
||||
# E006: Line longer than 79 columns (as many scripts use jinja
|
||||
# templating, this is very difficult)
|
||||
# E040: Syntax error determined using `bash -n` (as many scripts
|
||||
# use jinja templating, this will often fail and the syntax
|
||||
# error will be discovered in execution anyway)
|
||||
bash -c "grep --recursive --binary-files=without-match \
|
||||
--files-with-match '^.!.*\(ba\)\?sh$' \
|
||||
--exclude-dir .tox \
|
||||
--exclude-dir .git \
|
||||
{toxinidir} | xargs bashate --error . --verbose --ignore=E003,E006,E040"
|
||||
{[testenv:tests_clone]commands}
|
||||
bash -c "{toxinidir}/tests/common/test-bashate.sh"
|
||||
|
||||
|
||||
[testenv:ansible]
|
||||
deps =
|
||||
{[testenv]deps}
|
||||
ansible==2.1.1
|
||||
ansible-lint>=2.7.0,<3.0.0
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
ANSIBLE_HOST_KEY_CHECKING = False
|
||||
ANSIBLE_SSH_CONTROL_PATH = /tmp/%%h-%%r
|
||||
# TODO (odyssey4me) These are only here as they are non-standard folder
|
||||
# names for Ansible 1.9.x. We are using the standard folder names for
|
||||
# Ansible v2.x. We can remove this when we move to Ansible 2.x.
|
||||
ANSIBLE_ACTION_PLUGINS = {homedir}/.ansible/plugins/action
|
||||
ANSIBLE_CALLBACK_PLUGINS = {homedir}/.ansible/plugins/callback
|
||||
ANSIBLE_FILTER_PLUGINS = {homedir}/.ansible/plugins/filter
|
||||
ANSIBLE_LOOKUP_PLUGINS = {homedir}/.ansible/plugins/lookup
|
||||
# This is required as the default is the current path or a path specified
|
||||
# in ansible.cfg
|
||||
ANSIBLE_LIBRARY = {homedir}/.ansible/plugins/library
|
||||
# This is required as the default is '/etc/ansible/roles' or a path
|
||||
# specified in ansible.cfg
|
||||
ANSIBLE_ROLES_PATH = {homedir}/.ansible/roles:{toxinidir}/..
|
||||
ANSIBLE_TRANSPORT = "ssh"
|
||||
-rhttp://git.openstack.org/cgit/openstack/openstack-ansible-tests/plain/test-ansible-deps.txt
|
||||
commands =
|
||||
# NOTE(cloudnull): Galaxy INIT it running here because there are no role deps to create the skel
|
||||
ansible-galaxy init {homedir}/.ansible/roles/security --force --offline
|
||||
rm -rf {homedir}/.ansible/plugins
|
||||
git clone https://git.openstack.org/openstack/openstack-ansible-plugins \
|
||||
{homedir}/.ansible/plugins
|
||||
rm -rf {homedir}/.ansible/roles/security
|
||||
bash -c "ln -s {toxinidir} {homedir}/.ansible/roles/security"
|
||||
rm -rf {toxinidir}/tests/playbooks
|
||||
git clone https://git.openstack.org/openstack/openstack-ansible-tests \
|
||||
{toxinidir}/tests/playbooks
|
||||
{[testenv:tests_clone]commands}
|
||||
bash -c "{toxinidir}/tests/common/test-ansible-env-prep.sh"
|
||||
|
||||
|
||||
[testenv:ansible-syntax]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv:ansible]setenv}
|
||||
commands =
|
||||
{[testenv:ansible]commands}
|
||||
ansible-playbook -i {toxinidir}/tests/inventory \
|
||||
--syntax-check \
|
||||
--list-tasks \
|
||||
-e "rolename={toxinidir}" \
|
||||
-t ssh \
|
||||
{toxinidir}/tests/test.yml
|
||||
|
||||
|
||||
@ -162,10 +118,7 @@ install_command =
|
||||
|
||||
[testenv:func_logs]
|
||||
commands =
|
||||
bash -c 'mkdir -p {toxinidir}/logs'
|
||||
bash -c 'rsync --archive --verbose --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true'
|
||||
bash -c 'find "{toxinidir}/logs/" -type f | sed "p;s|$|.txt|" | xargs -n2 mv'
|
||||
bash -c 'command gzip --best --recursive "{toxinidir}/logs/"'
|
||||
bash -c "{toxinidir}/tests/common/test-log-collect.sh"
|
||||
|
||||
|
||||
[testenv:functional]
|
||||
@ -181,8 +134,6 @@ install_command =
|
||||
{[testenv:func_base]install_command}
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv:ansible]setenv}
|
||||
commands =
|
||||
{[testenv:ansible]commands}
|
||||
# NOTE(odyssey4me): We have to skip V-38462 as openstack-infra are now
|
||||
@ -193,17 +144,14 @@ commands =
|
||||
# https://review.openstack.org/#/c/354819/ merges.
|
||||
ansible-playbook --check \
|
||||
-i {toxinidir}/tests/inventory \
|
||||
-e "rolename={toxinidir}" \
|
||||
-e "install_test_packages=True" \
|
||||
--skip-tag V-38462,V-38660 \
|
||||
{toxinidir}/tests/test_check.yml
|
||||
ansible-playbook -i {toxinidir}/tests/inventory \
|
||||
-e "rolename={toxinidir}" \
|
||||
-e "install_test_packages=True" \
|
||||
--skip-tag V-38462,V-38660 \
|
||||
{toxinidir}/tests/test.yml
|
||||
bash -c 'ansible-playbook -i {toxinidir}/tests/inventory \
|
||||
-e "rolename={toxinidir}" \
|
||||
-e "install_test_packages=True" \
|
||||
--skip-tag V-38462,V-38660 \
|
||||
{toxinidir}/tests/test.yml \
|
||||
@ -217,8 +165,6 @@ commands =
|
||||
[testenv:linters]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv:ansible]setenv}
|
||||
commands =
|
||||
{[testenv:pep8]commands}
|
||||
{[testenv:bashate]commands}
|
||||
|
Loading…
Reference in New Issue
Block a user