run_tests.sh: Use common test script to run the tox tests
Update the run_tests.sh script to use the common script file from the openstack-ansible-tests repository in order to keep the testing logic into a central place and avoid duplication. This also updates the bindep.txt to match the one from the openstack-ansible-tests repository. Finally, CentOS7 support has been added to the Vagrantfile file. Change-Id: I2339bcf43384d50109ae8e958f70de9e63adbb76
This commit is contained in:
parent
871e31911d
commit
7b7c5b0d49
9
Vagrantfile
vendored
9
Vagrantfile
vendored
@ -22,4 +22,13 @@ Vagrant.configure(2) do |config|
|
||||
SHELL
|
||||
end
|
||||
|
||||
config.vm.define "centos7" do |centos7|
|
||||
centos7.vm.box = "centos/7"
|
||||
centos7.vm.provision "shell", inline: <<-SHELL
|
||||
sudo su -
|
||||
cd /vagrant
|
||||
./run_tests.sh
|
||||
SHELL
|
||||
end
|
||||
|
||||
end
|
||||
|
38
bindep.txt
38
bindep.txt
@ -3,12 +3,24 @@
|
||||
#
|
||||
# See the following for details:
|
||||
# - http://docs.openstack.org/infra/bindep/
|
||||
# - https://github.com/openstack-infra/bindep
|
||||
# - https://git.openstack.org/cgit/openstack-infra/bindep
|
||||
#
|
||||
# Even if the role does not make use of this facility, it
|
||||
# is better to have this file empty, otherwise OpenStack-CI
|
||||
# will fall back to installing its default packages which
|
||||
# will potentially be detrimental to the tests executed.
|
||||
#
|
||||
# Note:
|
||||
# This file is maintained in the openstack-ansible-tests repository.
|
||||
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/bindep.txt
|
||||
# If you need to remove or add extra dependencies, you should modify
|
||||
# the central file instead and once your change is accepted then update
|
||||
# this file as well. The purpose of this file is to ensure that Python and
|
||||
# Ansible have all their necessary binary requirements on the test host before
|
||||
# tox executes. Any binary requirements needed by services/roles should be
|
||||
# installed by those roles in their applicable package install tasks, not through
|
||||
# using this file.
|
||||
#
|
||||
|
||||
# Base requirements for Ubuntu
|
||||
build-essential [platform:dpkg]
|
||||
@ -21,31 +33,23 @@ python-dev [platform:dpkg]
|
||||
# Base requirements for RPM distros
|
||||
gcc [platform:rpm]
|
||||
gcc-c++ [platform:rpm]
|
||||
git [platform:rpm]
|
||||
libffi-devel [platform:rpm]
|
||||
openssl-devel [platform:rpm]
|
||||
python-devel [platform:rpm]
|
||||
|
||||
# Base requirements for CentOS
|
||||
git [platform:centos]
|
||||
libffi-devel [platform:centos]
|
||||
openssl-devel [platform:centos]
|
||||
|
||||
# Base requirements for openSUSE Leap 42.1
|
||||
git-core [platform:suselinux]
|
||||
libffi-devel-gcc5 [platform:suselinux]
|
||||
libopenssl-devel [platform:suselinux]
|
||||
|
||||
# For SELinux
|
||||
libselinux-python [platform:centos]
|
||||
libsemanage-python [platform:centos]
|
||||
|
||||
# For SSL SNI support
|
||||
python-pyasn1 [platform:dpkg]
|
||||
python-openssl [platform:dpkg]
|
||||
python-pyasn1 [platform:dpkg platform:suselinux]
|
||||
python-openssl [platform:dpkg platform:suselinux]
|
||||
python-ndg-httpsclient [platform:ubuntu]
|
||||
python2-pyasn1 [platform:rpm !platform:suselinux]
|
||||
python-pyasn1 [platform:suselinux]
|
||||
python2-pyOpenSSL [platform:rpm !platform:suselinux]
|
||||
python2-pyasn1 [platform:centos]
|
||||
python2-pyOpenSSL [platform:centos]
|
||||
python-pyOpenSSL [platform:suselinux]
|
||||
python-ndg_httpsclient [platform:rpm !platform:suselinux]
|
||||
python-ndg_httpsclient [platform:centos]
|
||||
|
||||
# Required for compressing collected log files in CI
|
||||
gzip
|
||||
|
83
run_tests.sh
83
run_tests.sh
@ -13,72 +13,35 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o pipefail
|
||||
set -euov
|
||||
set -xeu
|
||||
|
||||
FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true}
|
||||
source /etc/os-release || /usr/lib/os-release
|
||||
|
||||
# Start fresh
|
||||
rm -rf .tox
|
||||
install_pkg_deps() {
|
||||
pkg_deps="git"
|
||||
|
||||
# Install python2 for Ubuntu 16.04,CentOS 7 and openSUSE Leap 42.1
|
||||
if which apt-get &>/dev/null && ! which zypper &>/dev/null; then
|
||||
sudo apt-get update && sudo apt-get install -y python-dev
|
||||
elif which yum &>/dev/null; then
|
||||
sudo yum install -y python-devel
|
||||
elif which zypper &>/dev/null; then
|
||||
# Need to pull libffi and python-pyOpenSSL early
|
||||
# because we install ndg-httpsclient from pip
|
||||
sudo zypper -n in python-devel libffi-devel python-pyOpenSSL
|
||||
fi
|
||||
case ${ID,,} in
|
||||
*suse*) pkg_mgr_cmd="zypper -n in" ;;
|
||||
centos|rhel) pkg_mgr_cmd="yum install -y" ;;
|
||||
fedora) pkg_mgr_cmd="dnf -y install" ;;
|
||||
ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
|
||||
*) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
|
||||
esac
|
||||
|
||||
# Install pip
|
||||
if ! which pip &>/dev/null; then
|
||||
curl --silent --show-error --retry 5 \
|
||||
https://bootstrap.pypa.io/get-pip.py | sudo python2.7
|
||||
fi
|
||||
eval sudo $pkg_mgr_cmd $pkg_deps
|
||||
}
|
||||
|
||||
# Install bindep and tox
|
||||
sudo pip install bindep tox
|
||||
|
||||
# CentOS 7 requires two additional packages:
|
||||
# redhat-lsb-core - for bindep profile support
|
||||
# epel-release - required to install python-ndg_httpsclient/python2-pyasn1
|
||||
if which yum &>/dev/null; then
|
||||
sudo yum -y install redhat-lsb-core epel-release
|
||||
# openSUSE 42.1 does not have python-ndg-httpsclient
|
||||
elif which zypper &>/dev/null; then
|
||||
pip install ndg-httpsclient
|
||||
fi
|
||||
|
||||
# Get a list of packages to install with bindep. If packages need to be
|
||||
# installed, bindep exits with an exit code of 1.
|
||||
BINDEP_PKGS=$(bindep -b -f bindep.txt test || true)
|
||||
echo "Packages to install: ${BINDEP_PKGS}"
|
||||
|
||||
# Install OS packages using bindep
|
||||
if [[ ${#BINDEP_PKGS} > 0 ]]; then
|
||||
if which apt-get &>/dev/null && ! which zypper &>/dev/null ; then
|
||||
sudo apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
sudo apt-get -q --option "Dpkg::Options::=--force-confold" \
|
||||
--assume-yes install `bindep -b -f bindep.txt test`
|
||||
elif which yum &>/dev/null; then
|
||||
sudo yum install -y $BINDEP_PKGS
|
||||
elif which zypper &>/dev/null; then
|
||||
sudo zypper -n in $BINDEP_PKGS
|
||||
git_clone_repo() {
|
||||
if [[ ! -d tests/common ]]; then
|
||||
git clone https://git.openstack.org/openstack/openstack-ansible-tests tests/common
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# run through each tox env and execute the test
|
||||
for tox_env in $(awk -F= '/envlist/ {print $2}' tox.ini | sed 's/,/ /g'); do
|
||||
if [ "${tox_env}" != "ansible-functional" ]; then
|
||||
tox -e ${tox_env}
|
||||
elif [ "${tox_env}" == "ansible-functional" ]; then
|
||||
if ${FUNCTIONAL_TEST}; then
|
||||
tox -e ${tox_env}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
install_pkg_deps
|
||||
|
||||
git_clone_repo
|
||||
|
||||
# start executing the main test script
|
||||
source tests/common/run_tests.sh
|
||||
|
||||
# vim: set ts=4 sw=4 expandtab:
|
||||
|
Loading…
x
Reference in New Issue
Block a user