openstack-ansible-tests/run_tests_common.sh
Jesse Pretorius 3e807d9186 Clean up unused upgrade test tooling
It has been discussed and decided at the last two PTG's
that upgrade testing in roles is broken in the current
state and that we need to make use of the integrated
repo for upgrade tests. As such these old tools are no
longer required.

Change-Id: I46756bc0db6baa9487dffccce3e64cd5d035fd3c
2018-10-25 14:53:02 +01:00

122 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2015, 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.
## Shell Opts ----------------------------------------------------------------
set -o pipefail
set -xeuo
## Prerequisite check --------------------------------------------------------
# Check whether the require environment variables are set.
if [[ -z ${WORKING_DIR+x} ]] ||\
[[ -z ${COMMON_TESTS_PATH+x} ]] ||\
[[ -z ${TESTING_HOME+x} ]] ||\
[[ -z ${TESTING_BRANCH+x} ]] ||\
[[ -z ${pkg_mgr_cmd+x} ]] ||\
[[ -z ${ID+x} ]] ||\
[[ -z ${VERSION+x} ]]; then
echo "Required environment variables are not set."
echo "Please ensure that run_tests.sh is used to execute tests."
exit 1
fi
## Vars ----------------------------------------------------------------------
# The bindep file contains the basic distribution packages
# required in order to install pip, and ansible via pip.
BINDEP_FILE=${BINDEP_FILE:-bindep.txt}
## Main ----------------------------------------------------------------------
# Perform the initial distribution package install
# to allow pip and bindep to work.
case "${ID,,}" in
*suse*)
# Need to pull libffi and python-pyOpenSSL early
# because we install ndg-httpsclient from pip on Leap 42.1
[[ "${VERSION}" == "42.1" ]] && extra_suse_deps="libffi-devel python-pyOpenSSL"
pkg_list="ca-certificates-mozilla python-devel python-xml lsb-release ${extra_suse_deps:-}"
;;
amzn|centos|rhel)
pkg_list="python-devel redhat-lsb-core yum-utils"
;;
fedora)
pkg_list="python-devel redhat-lsb-core redhat-rpm-config yum-utils"
;;
ubuntu|debian)
pkg_list="python-dev lsb-release"
sudo apt-get update
;;
gentoo)
sudo emaint-sync -A
;;
*)
echo "Unsupported distribution: ${ID,,}"
exit 1
;;
esac
eval sudo ${pkg_mgr_cmd} ${pkg_list}
# Install pip
if ! which pip &>/dev/null; then
curl --silent --show-error --retry 5 \
https://bootstrap.pypa.io/3.3/get-pip.py | sudo python2.7
fi
# Install bindep and tox
sudo pip install 'bindep>=2.4.0' tox
if [[ "${ID,,}" == "fedora" ]]; then
sudo dnf -y install redhat-lsb-core yum-utils
# openSUSE 42.1 does not have python-ndg-httpsclient
elif [[ "${ID,,}" == *suse* ]] && [[ ${VERSION} == "42.1" ]]; then
sudo 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_FILE}" test || true)
echo "Packages to install: ${BINDEP_PKGS}"
# Install OS packages using bindep
if [[ ${#BINDEP_PKGS} > 0 ]]; then
case "${ID,,}" in
*suse*)
sudo zypper -n in ${BINDEP_PKGS}
;;
centos|fedora)
sudo "${RHT_PKG_MGR}" install -y ${BINDEP_PKGS}
;;
ubuntu|debian)
sudo apt-get update
DEBIAN_FRONTEND=noninteractive \
sudo apt-get -q --option "Dpkg::Options::=--force-confold" \
--assume-yes install ${BINDEP_PKGS}
;;
gentoo)
sudo emerge -q --jobs="$(nrpoc)" ${BINDEP_PKGS}
;;
esac
fi
# Get envlist in a $env1,$env2,...,$envn format
toxenvs="$(tox -l | tr '\n' ',' | sed 's/,$//')"
# Execute all $toxenvs or only a specific one
tox -e "${1:-$toxenvs}"
# vim: set ts=4 sw=4 expandtab: