From c928b5774ada6185e5ed18872da2c3701586a0ca Mon Sep 17 00:00:00 2001 From: David Moreau-Simard Date: Fri, 17 Feb 2017 10:19:44 -0500 Subject: [PATCH] Install ARA with zuul-cloner if we're running inside the ARA gate This commit mutually benefits both OSA and ARA: it allows ARA to leverage the func jobs of OSA as a mean to test itself in it's own gate and make sure one of it's patches does not break OSA. It also moves the ARA callback setup from env-prep to functional which is the only place where it makes sense to set up ARA in the first place. Change-Id: Ia7b46424740da94b82c57b828b53c7993fdaa76b --- test-ansible-deps.txt | 3 --- test-ansible-env-prep.sh | 9 --------- test-ansible-functional.sh | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/test-ansible-deps.txt b/test-ansible-deps.txt index 280cd07b..fbd1f66b 100644 --- a/test-ansible-deps.txt +++ b/test-ansible-deps.txt @@ -13,6 +13,3 @@ git+git://github.com/ansible/ansible.git@e85f3f44610fa454c80da6b0f5ae84e3887a695 # The Ansible lint version used for lint tests ansible-lint==3.4.1 - -# ARA for reporting -ara diff --git a/test-ansible-env-prep.sh b/test-ansible-env-prep.sh index 598041b1..d583bb9e 100755 --- a/test-ansible-env-prep.sh +++ b/test-ansible-env-prep.sh @@ -95,15 +95,6 @@ else echo "Skipping the role link because no role name was provided." fi -# Link the ARA Callback directory to the the ansible callback directory -if [ -d "${WORKING_DIR}/.tox/functional/lib/python2.7/site-packages/ara/plugins/callbacks" ]; then - if [ ! -L "${ANSIBLE_PLUGIN_DIR}/callback/ara" ]; then - echo "Linking ${ANSIBLE_PLUGIN_DIR}/callback/ara to ${WORKING_DIR}/.tox/functional/lib/python2.7/site-packages/ara/plugins/callbacks/" - mkdir -p "${ANSIBLE_PLUGIN_DIR}/callback/ara" - ln -sf "${WORKING_DIR}/.tox/functional/lib/python2.7/site-packages/ara/plugins/callbacks" "${ANSIBLE_PLUGIN_DIR}/callback/ara/" - fi -fi - # Ensure that the Ansible configuration file is in the right place if [ ! -f "${ANSIBLE_CFG_PATH}" ]; then if [ -f "${COMMON_TESTS_PATH}/test-ansible.cfg" ]; then diff --git a/test-ansible-functional.sh b/test-ansible-functional.sh index 3291684a..cd06c6f6 100755 --- a/test-ansible-functional.sh +++ b/test-ansible-functional.sh @@ -60,6 +60,29 @@ function set_ansible_parameters { } +function setup_ara { + + # Don't do anything if ARA has already been set up + [[ -L "${ANSIBLE_PLUGIN_DIR}/callback/ara" ]] && return 0 + + # Install ARA from source if running in ARA gate, otherwise install from PyPi + if [[ -e /usr/zuul-env/bin/zuul-cloner && "${ZUUL_PROJECT}" == "openstack/ara" ]]; then + /usr/zuul-env/bin/zuul-cloner --workspace /tmp --cache-dir /opt/git \ + git://git.openstack.org openstack/ara + ${WORKING_DIR}/.tox/functional/bin/pip install /tmp/openstack/ara + else + ${WORKING_DIR}/.tox/functional/bin/pip install ara + fi + + # Dynamically figure out the location of ARA (ex: py2 vs py3) + ara_location=$(${WORKING_DIR}/.tox/functional/bin/python -c "import os,ara; print(os.path.dirname(ara.__file__))") + + echo "Linking ${ANSIBLE_PLUGIN_DIR}/callback/ara to ${ara_location}/plugins/callbacks/" + mkdir -p "${ANSIBLE_PLUGIN_DIR}/callback/ara" + ln -sf "${ara_location}/plugins/callbacks" "${ANSIBLE_PLUGIN_DIR}/callback/ara/" + +} + function execute_ansible_playbook { CMD_TO_EXECUTE="ansible-playbook ${TEST_PLAYBOOK} $@ ${ANSIBLE_CLI_PARAMETERS}" @@ -90,6 +113,7 @@ fi # Ensure that the Ansible environment is properly prepared source "${COMMON_TESTS_PATH}/test-ansible-env-prep.sh" +setup_ara # Set gate job exit traps, this is run regardless of exit state when the job finishes. trap gate_job_exit_tasks EXIT