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
This commit is contained in:
Jesse Pretorius 2019-02-12 19:21:00 +00:00
parent d90acf00b6
commit bb9d690eb0

View File

@ -45,6 +45,16 @@ export ANSIBLE_ROLE_DEP_DIR="${TESTING_HOME}/.ansible/roles"
export ANSIBLE_ROLE_DIR="${TESTING_HOME}/.ansible/testing-role" export ANSIBLE_ROLE_DIR="${TESTING_HOME}/.ansible/testing-role"
export COMMON_TESTS_PATH="${WORKING_DIR}/tests/common" 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. # Use pip opts to add options to the pip install command.
# This can be used to tell it which index to use, etc. # This can be used to tell it which index to use, etc.
export PIP_OPTS=${PIP_OPTS:-""} export PIP_OPTS=${PIP_OPTS:-""}
@ -103,8 +113,18 @@ if [[ ! -d "${ANSIBLE_PLUGIN_DIR}" ]]; then
# symlink it. # symlink it.
if [[ "${OSA_PROJECT_NAME}" == "openstack-ansible-plugins" ]]; then if [[ "${OSA_PROJECT_NAME}" == "openstack-ansible-plugins" ]]; then
ln -s ${WORKING_DIR} "${ANSIBLE_PLUGIN_DIR}" 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 else
git clone \ git clone -b "${TESTING_BRANCH}" \
https://git.openstack.org/openstack/openstack-ansible-plugins \ https://git.openstack.org/openstack/openstack-ansible-plugins \
"${ANSIBLE_PLUGIN_DIR}" "${ANSIBLE_PLUGIN_DIR}"
fi fi