Update run_tests to be more complete

This patch updates the run_tests convenience script to make it
execute all test environments using tox, but also ensures that
all the correct pre-requisites are in place before doing so.

Change-Id: If188d528944470cf99d2551c284e2c5cba4a4aac
This commit is contained in:
Jesse Pretorius 2015-12-09 13:41:03 +00:00
parent c3405ef941
commit 37a1f4cd16
2 changed files with 21 additions and 16 deletions

View File

@ -15,24 +15,29 @@
set -euov
ROLE_NAME=$(basename $(pwd))
FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true}
pushd tests
ansible-galaxy install \
--role-file=ansible-role-requirements.yml \
--ignore-errors \
--force
# prep the host
if [ "$(which apt-get)" ]; then
apt-get install -y build-essential python2.7 python-dev git-core
fi
ansible-playbook -i inventory \
--syntax-check \
--list-tasks \
-e "rolename=${ROLE_NAME}" \
test.yml
# 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
ansible-lint test.yml
# install tox
pip install tox
if ${FUNCTIONAL_TEST}; then
ansible-playbook -i inventory -e "rolename=${ROLE_NAME}" test.yml
# 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
popd
done

View File

@ -1,7 +1,7 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = docs,pep8,bashate,ansible-syntax,ansible-lint
envlist = docs,pep8,bashate,ansible-syntax,ansible-lint,ansible-functional
[testenv]
usedevelop = True