Browse Source

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
changes/26/636426/1
Jesse Pretorius 4 months ago
parent
commit
bb9d690eb0
1 changed files with 21 additions and 1 deletions
  1. 21
    1
      test-ansible-env-prep.sh

+ 21
- 1
test-ansible-env-prep.sh View File

@@ -45,6 +45,16 @@ export ANSIBLE_ROLE_DEP_DIR="${TESTING_HOME}/.ansible/roles"
45 45
 export ANSIBLE_ROLE_DIR="${TESTING_HOME}/.ansible/testing-role"
46 46
 export COMMON_TESTS_PATH="${WORKING_DIR}/tests/common"
47 47
 
48
+# The place where zuul clones dependent repositories to
49
+ZUUL_PLUGINS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-plugins"
50
+
51
+# Use .gitreview as the key to determine the appropriate
52
+# branch to clone for tests.
53
+TESTING_BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' "${WORKING_DIR}/.gitreview")
54
+if [[ "${TESTING_BRANCH}" == "" ]]; then
55
+  TESTING_BRANCH="master"
56
+fi
57
+
48 58
 # Use pip opts to add options to the pip install command.
49 59
 # This can be used to tell it which index to use, etc.
50 60
 export PIP_OPTS=${PIP_OPTS:-""}
@@ -103,8 +113,18 @@ if [[ ! -d "${ANSIBLE_PLUGIN_DIR}" ]]; then
103 113
   # symlink it.
104 114
   if [[ "${OSA_PROJECT_NAME}" == "openstack-ansible-plugins" ]]; then
105 115
     ln -s ${WORKING_DIR} "${ANSIBLE_PLUGIN_DIR}"
116
+
117
+  # In zuul v3 any dependent repository is placed into
118
+  # /home/zuul/src/git.openstack.org, so we check to see
119
+  # if there is a tests checkout there already. If so, we
120
+  # symlink that and use it.
121
+  elif [[ -d "${ZUUL_PLUGINS_CLONE_LOCATION}" ]]; then
122
+    ln -s "${ZUUL_PLUGINS_CLONE_LOCATION}" "${ANSIBLE_PLUGIN_DIR}"
123
+
124
+  # Otherwise we're clearly not in zuul or using a previously setup
125
+  # repo in some way, so just clone it from upstream.
106 126
   else
107
-    git clone \
127
+    git clone -b "${TESTING_BRANCH}" \
108 128
         https://git.openstack.org/openstack/openstack-ansible-plugins \
109 129
         "${ANSIBLE_PLUGIN_DIR}"
110 130
   fi

Loading…
Cancel
Save