From 8d040dc1dff7051874f71f09dfc6f6c680f99fab Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 10 Apr 2017 22:55:16 +0100 Subject: [PATCH] Add openSUSE and CentOS as supported distributions There is no distro specific code in this role so add openSUSE and CentOS as supported distributions similarly to the rest of the OpenStack Ansible roles. This also updates the run_tests.sh, bindep.txt and Vagrantfile from the opentack-ansible-tests repository. Change-Id: Ib540a8fc3474075393cc5ae351aee5d59bfa4853 --- Vagrantfile | 34 +++++++++++++++++++---- bindep.txt | 33 ++++++++++++++++------ meta/main.yml | 6 ++++ run_tests.sh | 77 +++++++++++++++++---------------------------------- 4 files changed, 84 insertions(+), 66 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 6b92f5b..4bca85d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,12 +1,34 @@ Vagrant.configure(2) do |config| - config.vm.box = "ubuntu/xenial64" config.vm.provider "virtualbox" do |v| v.memory = 2048 v.cpus = 2 end - config.vm.provision "shell", inline: <<-SHELL - sudo su - - cd /vagrant - ./run_tests.sh - SHELL + + config.vm.define "ubuntu1604" do |xenial| + xenial.vm.box = "ubuntu/xenial64" + xenial.vm.provision "shell", inline: <<-SHELL + sudo su - + cd /vagrant + ./run_tests.sh + SHELL + end + + config.vm.define "opensuse421" do |leap421| + leap421.vm.box = "opensuse/openSUSE-42.1-x86_64" + leap421.vm.provision "shell", inline: <<-SHELL + sudo su - + cd /vagrant + ./run_tests.sh + 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 1f095d1..02339d5 100644 --- a/bindep.txt +++ b/bindep.txt @@ -9,6 +9,18 @@ # 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] @@ -18,21 +30,26 @@ libffi-dev [platform:dpkg] python2.7 [platform:dpkg] python-dev [platform:dpkg] -# Base requirements for CentOS +# Base requirements for RPM distros gcc [platform:rpm] gcc-c++ [platform:rpm] git [platform:rpm] -python-devel [platform:rpm] libffi-devel [platform:rpm] openssl-devel [platform:rpm] +python-devel [platform:rpm] # For SELinux -libselinux-python [platform:rpm] +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] -python2-pyOpenSSL [platform:rpm] -python-ndg_httpsclient [platform:rpm] +python2-pyasn1 [platform:centos] +python2-pyOpenSSL [platform:centos] +python-pyOpenSSL [platform:suselinux] +python-ndg_httpsclient [platform:centos] + +# Required for compressing collected log files in CI +gzip diff --git a/meta/main.yml b/meta/main.yml index e99e385..d6095b7 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -23,6 +23,12 @@ galaxy_info: - name: Ubuntu versions: - xenial + - name: EL + versions: + - 7 + - name: opensuse + versions: + - all categories: - cloud - rabbitmq diff --git a/run_tests.sh b/run_tests.sh index 94ccf8b..dca488c 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -13,62 +13,35 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -xeuo pipefail +set -xeu -FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true} +source /etc/os-release || source /usr/lib/os-release -# Install python2 for Ubuntu 16.04 and CentOS 7 -if which apt-get; then - sudo apt-get update && sudo apt-get install -y python -fi +install_pkg_deps() { + pkg_deps="git" -if which yum; then - sudo yum install -y python -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; 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 with pip. -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; then - sudo yum -y install redhat-lsb-core epel-release -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 a list of OS packages provided by bindep. -if which apt-get; then - sudo apt-get update - DEBIAN_FRONTEND=noninteractive \ - sudo apt-get -q --option "Dpkg::Options::=--force-confold" \ - --assume-yes install $BINDEP_PKGS -elif which yum; then - # Don't run yum with an empty list of packages. - # It will fail and cause the script to exit with an error. - if [[ ${#BINDEP_PKGS} > 0 ]]; then - sudo yum install -y $BINDEP_PKGS +git_clone_repo() { + if [[ ! -d tests/common ]]; then + git clone https://git.openstack.org/openstack/openstack-ansible-tests tests/common fi -fi +} -# Loop through each tox environment and run tests. -for tox_env in $(awk -F= '/envlist/ { gsub(",", " "); print $2 }' tox.ini); do - echo "Executing tox environment: ${tox_env}" - if [[ ${tox_env} == ansible-functional ]]; then - if ${FUNCTIONAL_TEST}; then - tox -e ${tox_env} - fi - else - tox -e ${tox_env} - 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: