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: Iffbb70a29d1c5c0a7a9d0956b8df39fa53e0f686
This commit is contained in:
parent
544adfe686
commit
44a1f65272
@ -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"
|
||||
|
@ -3,8 +3,13 @@
|
||||
# process, which may cause wedges in the gate later.
|
||||
bashate>=0.2 # Apache-2.0
|
||||
flake8<2.6.0,>=2.5.4 # MIT
|
||||
pyasn1 # BSD
|
||||
pyOpenSSL>=0.14 # Apache-2.0
|
||||
requests>=2.10.0 # Apache-2.0
|
||||
ndg-httpsclient>=0.4.2;python_version<'3.0' # BSD
|
||||
|
||||
# this is required for the docs build jobs
|
||||
sphinx!=1.3b1,<1.3,>=1.2.1 # BSD
|
||||
oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
|
||||
oslosphinx>=4.7.0 # Apache-2.0
|
||||
doc8 # Apache-2.0
|
||||
reno>=1.8.0 # Apache2
|
||||
|
2
tests/inventory
Normal file
2
tests/inventory
Normal file
@ -0,0 +1,2 @@
|
||||
[all]
|
||||
localhost ansible_connection=local ansible_become=True
|
145
tox.ini
145
tox.ini
@ -1,44 +1,69 @@
|
||||
[tox]
|
||||
minversion = 1.6
|
||||
minversion = 2.0
|
||||
skipsdist = True
|
||||
envlist = docs,linters
|
||||
envlist = docs,linters,functional
|
||||
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
install_command = pip install -U {opts} {packages}
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = /usr/bin/find . -type f -name "*.pyc" -delete
|
||||
install_command =
|
||||
pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||
deps =
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands =
|
||||
/usr/bin/find . -type f -name "*.pyc" -delete
|
||||
passenv =
|
||||
HOME
|
||||
http_proxy
|
||||
HTTP_PROXY
|
||||
https_proxy
|
||||
HTTPS_PROXY
|
||||
no_proxy
|
||||
NO_PROXY
|
||||
whitelist_externals =
|
||||
bash
|
||||
setenv =
|
||||
PYTHONUNBUFFERED=1
|
||||
ROLE_NAME=os_sahara
|
||||
VIRTUAL_ENV={envdir}
|
||||
WORKING_DIR={toxinidir}
|
||||
|
||||
|
||||
[testenv:docs]
|
||||
commands=
|
||||
bash -c "rm -rf doc/build"
|
||||
doc8 doc
|
||||
python setup.py build_sphinx
|
||||
|
||||
|
||||
[doc8]
|
||||
# Settings for doc8:
|
||||
extensions = .rst
|
||||
|
||||
|
||||
[testenv:releasenotes]
|
||||
commands =
|
||||
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||
|
||||
|
||||
# environment used by the -infra templated docs job
|
||||
[testenv:venv]
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = {posargs}
|
||||
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]
|
||||
# Ignores the following rules due to how ansible modules work in general
|
||||
@ -50,62 +75,36 @@ 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/plugins --force --offline
|
||||
rm -rf {homedir}/.ansible/plugins
|
||||
bash -c "ln -s {toxinidir} {homedir}/.ansible/plugins"
|
||||
rm -rf {toxinidir}/tests/playbooks
|
||||
git clone https://git.openstack.org/openstack/openstack-ansible-tests \
|
||||
{toxinidir}/tests/playbooks
|
||||
ansible-playbook {toxinidir}/tests/test.yml -i 'localhost,' -vvvv
|
||||
{[testenv:tests_clone]commands}
|
||||
bash -c "{toxinidir}/tests/common/test-ansible-env-prep.sh"
|
||||
|
||||
[testenv:linters]
|
||||
|
||||
[testenv:ansible-syntax]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv:ansible]setenv}
|
||||
commands =
|
||||
{[testenv:pep8]commands}
|
||||
{[testenv:bashate]commands}
|
||||
{[testenv:ansible]commands}
|
||||
ansible-playbook -i {toxinidir}/tests/inventory \
|
||||
--syntax-check \
|
||||
--list-tasks \
|
||||
{toxinidir}/tests/test.yml
|
||||
|
||||
|
||||
[testenv:ansible-lint]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
commands =
|
||||
{[testenv:ansible]commands}
|
||||
ansible-lint {toxinidir}
|
||||
|
||||
|
||||
[testenv:func_base]
|
||||
@ -118,10 +117,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]
|
||||
@ -137,13 +133,20 @@ install_command =
|
||||
{[testenv:func_base]install_command}
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv:ansible]setenv}
|
||||
commands =
|
||||
{[testenv:ansible]commands}
|
||||
echo '============ No Functional tests to run just yet. ============'
|
||||
ansible-playbook -i {toxinidir}/tests/inventory \
|
||||
-e "install_test_packages=True" \
|
||||
{toxinidir}/tests/test.yml -vvvv
|
||||
{[testenv:func_logs]commands}
|
||||
|
||||
|
||||
[testenv:releasenotes]
|
||||
commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||
[testenv:linters]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
commands =
|
||||
{[testenv:pep8]commands}
|
||||
{[testenv:bashate]commands}
|
||||
{[testenv:ansible-lint]commands}
|
||||
{[testenv:ansible-syntax]commands}
|
||||
{[testenv:docs]commands}
|
||||
|
Loading…
Reference in New Issue
Block a user