Updated from OpenStack Ansible Tests

Change-Id: Ie4e5326b5c667e35325c695d7781a3e0c886f243
This commit is contained in:
OpenStack Proposal Bot 2017-10-12 20:45:03 +00:00
parent 8b492e0f67
commit fad0c2fd43
3 changed files with 100 additions and 35 deletions

6
.gitignore vendored
View File

@ -61,13 +61,11 @@ ChangeLog
releasenotes/build
# Test temp files
tests/plugins
tests/playbooks
tests/common
tests/*.retry
# Vagrant artifacts
.vagrant
# IDE created files
.idea/
# Git clones
openstack-ansible-ops

54
Vagrantfile vendored
View File

@ -1,9 +1,47 @@
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provision "shell", inline: <<-SHELL
sudo su -
cd /vagrant
apt-get update
./run_tests.sh
SHELL
# Note:
# This file is maintained in the openstack-ansible-tests repository.
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/Vagrantfile
#
# If you need to perform any change on it, you should modify the central file,
# then, an OpenStack CI job will propagate your changes to every OSA repository
# since every repo uses the same Vagrantfile
# Verify whether required plugins are installed.
required_plugins = [ "vagrant-disksize" ]
required_plugins.each do |plugin|
if not Vagrant.has_plugin?(plugin)
raise "The vagrant plugin #{plugin} is required. Please run `vagrant plugin install #{plugin}`"
end
end
Vagrant.configure(2) do |config|
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
config.vm.provision "shell",
privileged: false,
inline: <<-SHELL
cd /vagrant
./run_tests.sh
SHELL
config.vm.define "ubuntu1604" do |xenial|
xenial.disksize.size = "40GB"
xenial.vm.box = "ubuntu/xenial64"
end
config.vm.define "opensuse422" do |leap422|
leap422.vm.box = "opensuse/openSUSE-42.2-x86_64"
end
config.vm.define "opensuse423" do |leap423|
leap423.vm.box = "opensuse/openSUSE-42.3-x86_64"
end
config.vm.define "centos7" do |centos7|
centos7.vm.box = "centos/7"
end
end

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Copyright 2016, Rackspace US, Inc.
# 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.
@ -12,32 +12,61 @@
# 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.
#
# Note:
# This file is maintained in the openstack-ansible-tests repository.
# 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
# repository and then update this file as well. The purpose of this file is to
# prepare the host and then execute all the tox tests.
#
set -euov
## Shell Opts ----------------------------------------------------------------
set -xeu
FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true}
## Vars ----------------------------------------------------------------------
# prep the host
if [ "$(which apt-get)" ]; then
apt-get install -y build-essential python2.7 python-dev git-core libssl-dev libffi-dev
fi
export WORKING_DIR=${WORKING_DIR:-$(pwd)}
# get pip, if necessary
if [ ! "$(which pip)" ]; then
curl --silent --show-error --retry 5 \
https://bootstrap.pypa.io/get-pip.py | sudo python2.7
fi
## Main ----------------------------------------------------------------------
# install tox
pip install tox
source /etc/os-release || source /usr/lib/os-release
# 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}" != "functional" ]; then
tox -e ${tox_env}
elif [ "${tox_env}" == "functional" ]; then
if ${FUNCTIONAL_TEST}; then
tox -e ${tox_env}
install_pkg_deps() {
pkg_deps="git"
# Prefer dnf over yum for CentOS.
which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
case ${ID,,} in
*suse*) pkg_mgr_cmd="zypper -n in" ;;
centos|rhel) pkg_mgr_cmd="${RHT_PKG_MGR} 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
eval sudo $pkg_mgr_cmd $pkg_deps
}
git_clone_repo() {
if [[ ! -d tests/common ]]; 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} ${WORKING_DIR}/tests/common
else
git clone \
https://git.openstack.org/openstack/openstack-ansible-tests \
tests/common
fi
fi
fi
done
}
install_pkg_deps
git_clone_repo
# start executing the main test script
source tests/common/run_tests_common.sh