diff --git a/extras/run-ansible-tests.sh b/extras/run-ansible-tests.sh index 7797cc349..816eb53fe 100755 --- a/extras/run-ansible-tests.sh +++ b/extras/run-ansible-tests.sh @@ -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 [TAG] +# run-ansible-tests.sh -e ENVDIR [-c CLOUD] [TAG ...] # # PARAMETERS: -# 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} diff --git a/tox.ini b/tox.ini index 586ede98a..2ca4fefd5 100644 --- a/tox.ini +++ b/tox.ini @@ -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