Use tests repo for all lint tests
The lint tests are inconsistent and often timing out due to
the implementation not using the cached repositories in the
same way as the tests repo's lint tests.
It'll be simpler to maintain if all lint tests worked the
same way.
Depends-On: I8bea90082dbde7de49c5e2e86d298c017b16591d
Change-Id: I4a5f6fe69e2d421846999c7cbd949504be77f23d
(cherry picked from commit f3dccff4ea
)
This commit is contained in:
parent
f8e8fbde32
commit
527cbf72cd
117
tests/tests-repo-clone.sh
Executable file
117
tests/tests-repo-clone.sh
Executable file
@ -0,0 +1,117 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2017, Rackspace US, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# PURPOSE:
|
||||
# This script clones the openstack-ansible-tests repository to the
|
||||
# tests/common folder in order to be able to re-use test components
|
||||
# for role testing.
|
||||
|
||||
# WARNING:
|
||||
# This file is maintained in the openstack-ansible-tests repository:
|
||||
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests
|
||||
# If you need to change this script, then propose the change there.
|
||||
# Once it merges, the change will be replicated to the other repositories.
|
||||
|
||||
## Shell Opts ----------------------------------------------------------------
|
||||
|
||||
set -e
|
||||
|
||||
## Vars ----------------------------------------------------------------------
|
||||
|
||||
export TESTING_HOME=${TESTING_HOME:-$HOME}
|
||||
export WORKING_DIR=${WORKING_DIR:-$(pwd)}
|
||||
export CLONE_UPGRADE_TESTS=${CLONE_UPGRADE_TESTS:-no}
|
||||
export ZUUL_TESTS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-tests"
|
||||
|
||||
## Functions -----------------------------------------------------------------
|
||||
|
||||
function create_tests_clonemap {
|
||||
|
||||
# Prepare the clonemap for zuul-cloner to use
|
||||
cat > ${TESTING_HOME}/tests-clonemap.yaml << EOF
|
||||
clonemap:
|
||||
- name: openstack/openstack-ansible-tests
|
||||
dest: ${WORKING_DIR}/tests/common
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
## Main ----------------------------------------------------------------------
|
||||
|
||||
# If zuul-cloner is present, use it so that we
|
||||
# also include any dependent patches from the
|
||||
# tests repo noted in the commit message.
|
||||
# We only want to use zuul-cloner if we detect
|
||||
# zuul v2 running, so we check for the presence
|
||||
# of the ZUUL_REF environment variable.
|
||||
# ref: http://git.openstack.org/cgit/openstack-infra/zuul/tree/zuul/ansible/filter/zuul_filters.py?h=feature/zuulv3#n17
|
||||
if [[ -x /usr/zuul-env/bin/zuul-cloner ]] && [[ "${ZUUL_REF:-none}" != "none" ]]; then
|
||||
|
||||
# Prepare the clonemap for zuul-cloner to use
|
||||
create_tests_clonemap
|
||||
|
||||
# Execute the clone
|
||||
/usr/zuul-env/bin/zuul-cloner \
|
||||
--cache-dir /opt/git \
|
||||
--map ${TESTING_HOME}/tests-clonemap.yaml \
|
||||
git://git.openstack.org \
|
||||
openstack/openstack-ansible-tests
|
||||
|
||||
# Clean up the clonemap.
|
||||
rm -f ${TESTING_HOME}/tests-clonemap.yaml
|
||||
|
||||
# Alternatively, use a simple git-clone. We do
|
||||
# not re-clone if the directory exists already
|
||||
# to prevent overwriting any local changes which
|
||||
# may have been made.
|
||||
elif [[ ! -d tests/common ]]; then
|
||||
|
||||
# The tests repo doesn't need a clone, we can just
|
||||
# symlink it. As zuul v3 clones into a folder called
|
||||
# 'workspace' we have to use one of its environment
|
||||
# variables to determine the project name.
|
||||
if [[ "${ZUUL_SHORT_PROJECT_NAME:-none}" == "openstack-ansible-tests" ]] ||\
|
||||
[[ "$(basename ${WORKING_DIR})" == "openstack-ansible-tests" ]]; then
|
||||
ln -s ${WORKING_DIR} ${WORKING_DIR}/tests/common
|
||||
|
||||
# In zuul v3 any dependent repository is placed into
|
||||
# /home/zuul/src/git.openstack.org, so we check to see
|
||||
# if there is a tests checkout there already. If so, we
|
||||
# symlink that and use it.
|
||||
elif [[ -d "${ZUUL_TESTS_CLONE_LOCATION}" ]]; then
|
||||
ln -s "${ZUUL_TESTS_CLONE_LOCATION}" ${WORKING_DIR}/tests/common
|
||||
|
||||
# Otherwise we're clearly not in zuul or using a previously setup
|
||||
# repo in some way, so just clone it from upstream.
|
||||
else
|
||||
git clone -b stable/pike \
|
||||
https://git.openstack.org/openstack/openstack-ansible-tests \
|
||||
${WORKING_DIR}/tests/common
|
||||
fi
|
||||
fi
|
||||
|
||||
# If this test set includes an upgrade test, the
|
||||
# previous stable release tests repo must also be
|
||||
# cloned.
|
||||
# Note:
|
||||
# Dependent patches to the previous stable release
|
||||
# tests repo are not supported.
|
||||
if [[ "${CLONE_UPGRADE_TESTS}" == "yes" ]]; then
|
||||
if [[ ! -d "${WORKING_DIR}/tests/common/previous" ]]; then
|
||||
git clone -b stable/ocata \
|
||||
https://git.openstack.org/openstack/openstack-ansible-tests \
|
||||
${WORKING_DIR}/tests/common/previous
|
||||
fi
|
||||
fi
|
116
tox.ini
116
tox.ini
@ -22,11 +22,16 @@ passenv =
|
||||
NO_PROXY
|
||||
whitelist_externals =
|
||||
bash
|
||||
rm
|
||||
sudo
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
PYTHONUNBUFFERED=1
|
||||
PYTHONWARNINGS=default::DeprecationWarning
|
||||
VIRTUAL_ENV={envdir}
|
||||
WORKING_DIR={toxinidir}
|
||||
ANSIBLE_EXTRA_ROLE_DIRS={toxinidir}/playbooks/roles
|
||||
ANSIBLE_ROLE_REQUIREMENTS_PATH={toxinidir}/ansible-role-requirements.yml
|
||||
TEST_PLAYBOOK={toxinidir}/tests/bootstrap-aio.yml {toxinidir}/playbooks/setup-everything.yml
|
||||
|
||||
|
||||
|
||||
[testenv:docs]
|
||||
commands=
|
||||
@ -34,35 +39,37 @@ commands=
|
||||
doc8 doc
|
||||
python setup.py build_sphinx
|
||||
|
||||
|
||||
|
||||
[testenv:deploy-guide]
|
||||
commands = sphinx-build -a -E -W -d deploy-guide/build/doctrees -b html deploy-guide/source deploy-guide/build/html
|
||||
|
||||
|
||||
|
||||
[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]
|
||||
commands =
|
||||
{posargs}
|
||||
|
||||
|
||||
|
||||
[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"
|
||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
||||
bash -c "{toxinidir}/tests/common/test-pep8.sh"
|
||||
|
||||
|
||||
|
||||
[flake8]
|
||||
@ -72,76 +79,48 @@ commands =
|
||||
ignore=F403
|
||||
|
||||
|
||||
|
||||
[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"
|
||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
||||
bash -c "{toxinidir}/tests/common/test-bashate.sh"
|
||||
|
||||
|
||||
|
||||
# The deps URL should be set to the appropriate git URL.
|
||||
# In the tests repo itself, the variable is uniquely set to
|
||||
# the toxinidir so that the role is able to test itself, but
|
||||
# the tox config is exactly the same as other repositories.
|
||||
#
|
||||
# The value for other repositories must be:
|
||||
# http://git.openstack.org/cgit/openstack/openstack-ansible-tests/plain/test-ansible-deps.txt
|
||||
# or for a stable branch:
|
||||
# http://git.openstack.org/cgit/openstack/openstack-ansible-tests/plain/test-ansible-deps.txt?h=stable/newton
|
||||
[testenv:ansible]
|
||||
deps =
|
||||
{[testenv]deps}
|
||||
-r{toxinidir}/global-requirement-pins.txt
|
||||
-rhttps://git.openstack.org/cgit/openstack/openstack-ansible-tests/plain/test-ansible-deps.txt?h=stable/pike
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
ANSIBLE_HOST_KEY_CHECKING = False
|
||||
ANSIBLE_SSH_CONTROL_PATH = /tmp/%%h-%%r
|
||||
ANSIBLE_ACTION_PLUGINS = {homedir}/.ansible/roles/plugins/action
|
||||
ANSIBLE_CALLBACK_PLUGINS = {homedir}/.ansible/roles/plugins/callback
|
||||
ANSIBLE_FILTER_PLUGINS = {homedir}/.ansible/roles/plugins/filter
|
||||
ANSIBLE_LOOKUP_PLUGINS = {homedir}/.ansible/roles/plugins/lookup
|
||||
ANSIBLE_LIBRARY = {homedir}/.ansible/roles/plugins/library
|
||||
ANSIBLE_ROLES_PATH = {homedir}/.ansible/roles:{toxinidir}/playbooks/roles
|
||||
commands =
|
||||
rm -rf {homedir}/.ansible/roles
|
||||
ansible-playbook -i 'localhost,' \
|
||||
-e role_file={toxinidir}/ansible-role-requirements.yml \
|
||||
-e role_path_default={homedir}/.ansible/roles \
|
||||
{toxinidir}/tests/get-ansible-role-requirements.yml
|
||||
|
||||
|
||||
[testenv:ansible-lint]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv:ansible]setenv}
|
||||
commands =
|
||||
{[testenv:ansible]commands}
|
||||
# Perform an Ansible lint check
|
||||
ansible-lint --exclude {homedir}/.ansible/roles/sshd \
|
||||
{toxinidir}/tests/bootstrap-aio.yml
|
||||
ansible-lint {toxinidir}/playbooks/setup-everything.yml
|
||||
|
||||
|
||||
[testenv:ansible-syntax]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv:ansible]setenv}
|
||||
commands =
|
||||
{[testenv:ansible]commands}
|
||||
# Perform an Ansible syntax check
|
||||
ansible-playbook -i 'localhost ansible-connection=local,' \
|
||||
--syntax-check \
|
||||
--list-tasks \
|
||||
{toxinidir}/tests/bootstrap-aio.yml
|
||||
ansible-playbook -i 'localhost ansible-connection=local,' \
|
||||
--syntax-check \
|
||||
--list-tasks \
|
||||
-e 'force_containers_destroy=yes' \
|
||||
{toxinidir}/playbooks/setup-everything.yml
|
||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
||||
bash -c "{toxinidir}/tests/common/test-ansible-syntax.sh"
|
||||
|
||||
|
||||
|
||||
[testenv:ansible-lint]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
commands =
|
||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
||||
bash -c "{toxinidir}/tests/common/test-ansible-lint.sh"
|
||||
|
||||
|
||||
|
||||
[testenv:inventory]
|
||||
# Use a fixed seed since some inventory tests rely on specific ordering
|
||||
@ -157,6 +136,8 @@ commands =
|
||||
coverage run -a {toxinidir}/tests/test_filesystem.py
|
||||
coverage report --show-missing --include={toxinidir}/playbooks/inventory/*,{toxinidir}/osa_toolkit/*
|
||||
|
||||
|
||||
|
||||
[testenv:py3-inventory]
|
||||
basepython = python3.5
|
||||
setenv =
|
||||
@ -165,11 +146,10 @@ commands =
|
||||
{[testenv:inventory]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