diff --git a/Vagrantfile b/Vagrantfile index 81f3afe..4bca85d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 diff --git a/bindep.txt b/bindep.txt index cfbadec..02339d5 100644 --- a/bindep.txt +++ b/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 diff --git a/run_tests.sh b/run_tests.sh index 20b7527..5e775e5 100755 --- a/run_tests.sh +++ b/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: