Allow specifying cloud name to ansible tests

It would be *really* cool and useful and stuff to be able to run
the Ansible playbooks against more than just devstack. This change
allows that. Now you can send the -c option to the tox command line:

    tox -e ansible -- -c coolcloud

Or, specific tests:

    tox -e ansible -- -c coolcloud auth network

Going against devstack is still:

    tox -e ansible
    tox -e ansible auth network

Change-Id: I666a09aee3d283865c3813d67edfb75123057c22
This commit is contained in:
David Shrewsbury 2015-11-20 10:10:43 -05:00 committed by Monty Taylor
parent 27154a9c14
commit 9d7229f65b
2 changed files with 38 additions and 14 deletions

View File

@ -5,27 +5,50 @@
# Script used to setup a tox environment for running Ansible. This is meant
# to be called by tox (via tox.ini). To run the Ansible tests, use:
#
# tox -e ansible [TAG]
# tox -e ansible [TAG ...]
# or
# tox -e ansible -- -c cloudX [TAG ...]
#
# USAGE:
# run-ansible-tests.sh <envdir> [TAG]
# run-ansible-tests.sh -e ENVDIR [-c CLOUD] [TAG ...]
#
# PARAMETERS:
# <envdir> Directory of the tox environment to use for testing.
# [TAG] Optional list of space-separated tags to control which
# modules are tested.
# -e ENVDIR Directory of the tox environment to use for testing.
# -c CLOUD Name of the cloud to use for testing.
# Defaults to "devstack-admin".
# [TAG ...] Optional list of space-separated tags to control which
# modules are tested.
#
# EXAMPLES:
# # Run all Ansible tests
# run-ansible-tests.sh ansible
# run-ansible-tests.sh -e ansible
#
# # Run auth, keypair, and network tests
# run-ansible-tests.sh ansible auth keypair network
# # Run auth, keypair, and network tests against cloudX
# run-ansible-tests.sh -e ansible -c cloudX auth keypair network
#############################################################################
ENVDIR=$1
shift
TAGS=$( echo "$@" | tr ' ' , )
CLOUD="devstack-admin"
ENVDIR=
while getopts "c:e:" opt
do
case $opt in
c) CLOUD=${OPTARG} ;;
e) ENVDIR=${OPTARG} ;;
?) echo "Invalid option: -${OPTARG}"
exit 1;;
esac
done
if [ -z ${ENVDIR} ]
then
echo "Option -e is required"
exit 1
fi
shift $((OPTIND-1))
TAGS=$( echo "$*" | tr ' ' , )
if [ -d ${ENVDIR}/ansible ]
then
@ -44,8 +67,9 @@ source $ENVDIR/ansible/hacking/env-setup
# Run the shade Ansible tests
tag_opt=""
if [ "${TAGS}" != "" ]
if [ ! -z ${TAGS} ]
then
tag_opt="--tags ${TAGS}"
fi
ansible-playbook -vvv ./shade/tests/ansible/run.yml -e "cloud=devstack-admin" ${tag_opt}
ansible-playbook -vvv ./shade/tests/ansible/run.yml -e "cloud=${CLOUD}" ${tag_opt}

View File

@ -33,7 +33,7 @@ commands = python setup.py testr --coverage --testr-args='{posargs}'
[testenv:ansible]
# Need to pass some env vars for the Ansible playbooks
passenv = HOME USER
commands = {toxinidir}/extras/run-ansible-tests.sh {envdir} {posargs}
commands = {toxinidir}/extras/run-ansible-tests.sh -e {envdir} {posargs}
[flake8]
# Infra does not follow hacking, nor the broken E12* things