diff --git a/extras/run-ansible-tests.sh b/extras/run-ansible-tests.sh index bfd1ada36..7797cc349 100755 --- a/extras/run-ansible-tests.sh +++ b/extras/run-ansible-tests.sh @@ -5,16 +5,27 @@ # 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 +# tox -e ansible [TAG] # # USAGE: -# run-ansible-tests.sh +# run-ansible-tests.sh [TAG] # # PARAMETERS: # Directory of the tox environment to use for testing. +# [TAG] Optional list of space-separated tags to control which +# modules are tested. +# +# EXAMPLES: +# # Run all Ansible tests +# run-ansible-tests.sh ansible +# +# # Run auth, keypair, and network tests +# run-ansible-tests.sh ansible auth keypair network ############################################################################# ENVDIR=$1 +shift +TAGS=$( echo "$@" | tr ' ' , ) if [ -d ${ENVDIR}/ansible ] then @@ -32,4 +43,9 @@ source $ENVDIR/bin/activate source $ENVDIR/ansible/hacking/env-setup # Run the shade Ansible tests -ansible-playbook -vvv ./shade/tests/ansible/run.yml -e "cloud=devstack-admin" +tag_opt="" +if [ "${TAGS}" != "" ] +then + tag_opt="--tags ${TAGS}" +fi +ansible-playbook -vvv ./shade/tests/ansible/run.yml -e "cloud=devstack-admin" ${tag_opt} diff --git a/shade/tests/ansible/README.txt b/shade/tests/ansible/README.txt index fd255d5bf..3931b4af9 100644 --- a/shade/tests/ansible/README.txt +++ b/shade/tests/ansible/README.txt @@ -3,18 +3,24 @@ OpenStack modules. You will need a clouds.yaml file in order to run the tests. You must provide a value for the `cloud` variable for each run (using the -e option) as a default is not currently provided. +If you want to run these tests against devstack, it is easiest to use +the tox target. This assumes you have a devstack-admin cloud defined +in your clouds.yaml file that points to devstack. Some examples of +using tox: -Examples --------- + tox -e ansible -* Run all module tests against a provider: + tox -e ansible keypair security_group +If you want to run these tests directly, or against different clouds, +then you'll need to use the ansible-playbook command that comes with +the Ansible distribution and feed it the run.yml playbook. Some examples: + + # Run all module tests against a provider ansible-playbook run.yml -e "cloud=hp" -* Run only the keypair and security_group tests: - + # Run only the keypair and security_group tests ansible-playbook run.yml -e "cloud=hp" --tags "keypair,security_group" -* Run all tests except security_group: - + # Run all tests except security_group ansible-playbook run.yml -e "cloud=hp" --skip-tags "security_group" diff --git a/tox.ini b/tox.ini index fb2415f7e..586ede98a 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} +commands = {toxinidir}/extras/run-ansible-tests.sh {envdir} {posargs} [flake8] # Infra does not follow hacking, nor the broken E12* things