From bb9d690eb09360fe03bf16bcfa0ffa2e2e8f5826 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Tue, 12 Feb 2019 19:21:00 +0000 Subject: [PATCH] Clone the correct plugins repo for role tests Currently the role tests always clone the plugins repo without specifying a branch. The tests also always use a git clone, even though in zuul the repo is already cloned. This patch ensures that the branch is specified when doing the clone, and also will just symlink to the existing zuul clone if it is present. Change-Id: Iaf5ee20e534a8279b5b563c820518bb176f0f4bb --- test-ansible-env-prep.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test-ansible-env-prep.sh b/test-ansible-env-prep.sh index 378f132a..a628d1b1 100755 --- a/test-ansible-env-prep.sh +++ b/test-ansible-env-prep.sh @@ -45,6 +45,16 @@ export ANSIBLE_ROLE_DEP_DIR="${TESTING_HOME}/.ansible/roles" export ANSIBLE_ROLE_DIR="${TESTING_HOME}/.ansible/testing-role" export COMMON_TESTS_PATH="${WORKING_DIR}/tests/common" +# The place where zuul clones dependent repositories to +ZUUL_PLUGINS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-plugins" + +# Use .gitreview as the key to determine the appropriate +# branch to clone for tests. +TESTING_BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' "${WORKING_DIR}/.gitreview") +if [[ "${TESTING_BRANCH}" == "" ]]; then + TESTING_BRANCH="master" +fi + # Use pip opts to add options to the pip install command. # This can be used to tell it which index to use, etc. export PIP_OPTS=${PIP_OPTS:-""} @@ -103,8 +113,18 @@ if [[ ! -d "${ANSIBLE_PLUGIN_DIR}" ]]; then # symlink it. if [[ "${OSA_PROJECT_NAME}" == "openstack-ansible-plugins" ]]; then ln -s ${WORKING_DIR} "${ANSIBLE_PLUGIN_DIR}" + + # In zuul v3 any dependent repository is placed into + # /home/zuul/src/git.openstack.org, so we check to see + # if there is a tests checkout there already. If so, we + # symlink that and use it. + elif [[ -d "${ZUUL_PLUGINS_CLONE_LOCATION}" ]]; then + ln -s "${ZUUL_PLUGINS_CLONE_LOCATION}" "${ANSIBLE_PLUGIN_DIR}" + + # Otherwise we're clearly not in zuul or using a previously setup + # repo in some way, so just clone it from upstream. else - git clone \ + git clone -b "${TESTING_BRANCH}" \ https://git.openstack.org/openstack/openstack-ansible-plugins \ "${ANSIBLE_PLUGIN_DIR}" fi