Update run_tests.sh and remove tests-repo-clone.sh
The lint tests make use of the common linters test used by the roles, so we need to ensure that the run_tests.sh script is updated and the configuration adjusted accordingly. Change-Id: Id1d112c30978cf2e0a0ec32c899ef56290ef806d
This commit is contained in:
parent
72efb59ad5
commit
07483d1859
73
run_tests.sh
73
run_tests.sh
@ -12,8 +12,14 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
|
||||||
# Note:
|
# 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. This is intended to be the thinnest possible
|
||||||
|
# shim for test execution outside of OpenStack CI.
|
||||||
|
|
||||||
|
# WARNING:
|
||||||
# This file is maintained in the openstack-ansible-tests repository.
|
# This file is maintained in the openstack-ansible-tests repository.
|
||||||
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/run_tests.sh
|
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/run_tests.sh
|
||||||
# If you need to modify this file, update the one in the openstack-ansible-tests
|
# If you need to modify this file, update the one in the openstack-ansible-tests
|
||||||
@ -26,33 +32,60 @@ set -xeu
|
|||||||
|
|
||||||
## Vars ----------------------------------------------------------------------
|
## Vars ----------------------------------------------------------------------
|
||||||
|
|
||||||
export WORKING_DIR=${WORKING_DIR:-$(pwd)}
|
WORKING_DIR="$(readlink -f $(dirname $0))"
|
||||||
|
|
||||||
|
COMMON_TESTS_PATH="${WORKING_DIR}/tests/common"
|
||||||
|
TESTING_HOME=${TESTING_HOME:-$HOME}
|
||||||
|
ZUUL_TESTS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-tests"
|
||||||
|
|
||||||
|
# Use .gitreview as the key to determine the appropriate
|
||||||
|
# branch to clone for tests.
|
||||||
|
TESTING_BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' "${WORKING_DIR}/.gitreview")
|
||||||
|
if [[ "${TESTING_BRANCH}" == "" ]]; then
|
||||||
|
TESTING_BRANCH="master"
|
||||||
|
fi
|
||||||
|
|
||||||
## Main ----------------------------------------------------------------------
|
## Main ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Source distribution information
|
||||||
source /etc/os-release || source /usr/lib/os-release
|
source /etc/os-release || source /usr/lib/os-release
|
||||||
|
|
||||||
install_pkg_deps() {
|
# Prefer dnf over yum for CentOS.
|
||||||
pkg_deps="git"
|
which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
|
||||||
|
|
||||||
# Prefer dnf over yum for CentOS.
|
# Figure out the appropriate package install command
|
||||||
which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
|
case ${ID,,} in
|
||||||
|
*suse*) pkg_mgr_cmd="zypper -n in" ;;
|
||||||
|
centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;;
|
||||||
|
ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
|
||||||
|
*) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
case ${ID,,} in
|
# Install git so that we can clone the tests repo
|
||||||
*suse*) pkg_mgr_cmd="zypper -n in" ;;
|
eval sudo $pkg_mgr_cmd git
|
||||||
centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;;
|
|
||||||
ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
|
|
||||||
*) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
eval sudo $pkg_mgr_cmd $pkg_deps
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install the host distro package dependencies
|
|
||||||
install_pkg_deps
|
|
||||||
|
|
||||||
# Clone the tests repo for access to the common test script
|
# Clone the tests repo for access to the common test script
|
||||||
source tests/tests-repo-clone.sh
|
if [[ ! -d ${COMMON_TESTS_PATH} ]]; then
|
||||||
|
# The tests repo doesn't need a clone, we can just
|
||||||
|
# symlink it.
|
||||||
|
if [[ "$(basename ${WORKING_DIR})" == "openstack-ansible-tests" ]]; then
|
||||||
|
ln -s ${WORKING_DIR} ${COMMON_TESTS_PATH}
|
||||||
|
|
||||||
|
# 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}" ${COMMON_TESTS_PATH}
|
||||||
|
|
||||||
|
# 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 ${TESTING_BRANCH} \
|
||||||
|
https://git.openstack.org/openstack/openstack-ansible-tests \
|
||||||
|
${COMMON_TESTS_PATH}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Execute the common test script
|
# Execute the common test script
|
||||||
source tests/common/run_tests_common.sh
|
source tests/common/run_tests_common.sh
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
#!/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 \
|
|
||||||
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/queens \
|
|
||||||
https://git.openstack.org/openstack/openstack-ansible-tests \
|
|
||||||
${WORKING_DIR}/tests/common/previous
|
|
||||||
fi
|
|
||||||
fi
|
|
5
tox.ini
5
tox.ini
@ -55,7 +55,6 @@ commands =
|
|||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands =
|
commands =
|
||||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
|
||||||
bash -c "{toxinidir}/tests/common/test-pep8.sh"
|
bash -c "{toxinidir}/tests/common/test-pep8.sh"
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +67,6 @@ ignore=F403
|
|||||||
|
|
||||||
[testenv:bashate]
|
[testenv:bashate]
|
||||||
commands =
|
commands =
|
||||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
|
||||||
bash -c "{toxinidir}/tests/common/test-bashate.sh"
|
bash -c "{toxinidir}/tests/common/test-bashate.sh"
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +80,6 @@ deps =
|
|||||||
deps =
|
deps =
|
||||||
{[testenv:ansible]deps}
|
{[testenv:ansible]deps}
|
||||||
commands =
|
commands =
|
||||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
|
||||||
bash -c "{toxinidir}/tests/common/test-ansible-syntax.sh"
|
bash -c "{toxinidir}/tests/common/test-ansible-syntax.sh"
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +87,6 @@ commands =
|
|||||||
deps =
|
deps =
|
||||||
{[testenv:ansible]deps}
|
{[testenv:ansible]deps}
|
||||||
commands =
|
commands =
|
||||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
|
||||||
bash -c "{toxinidir}/tests/common/test-ansible-lint.sh"
|
bash -c "{toxinidir}/tests/common/test-ansible-lint.sh"
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +94,6 @@ commands =
|
|||||||
deps =
|
deps =
|
||||||
{[testenv:ansible]deps}
|
{[testenv:ansible]deps}
|
||||||
commands =
|
commands =
|
||||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
|
||||||
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
|
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user