Skip to content

Commit 286e36a

Browse files
Merge pull request #253 from HanzJas/pin-horizontest-to-dashboard
Pin horizontest to the Horizon dashboard SHA
2 parents 4b27226 + 58d5cf6 commit 286e36a

3 files changed

Lines changed: 60 additions & 22 deletions

File tree

‎containers/horizontest/horizontest/Containerfile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ RUN chmod 440 /etc/sudoers.d/horizontest_sudoers
6161
RUN mkdir -p /var/lib/horizontest/external_files && \
6262
chown -R horizontest:horizontest /var/lib/horizontest
6363

64+
# Bake the Horizon test tree from sources.txt so the default run matches
65+
# the dashboard pin. build.sh clones it to src/horizontest (sources.txt name).
66+
COPY src/horizontest /usr/share/horizontest/horizon
67+
RUN chown -R horizontest:horizontest /usr/share/horizontest
68+
6469
COPY horizontest/scripts/run_horizontest.sh /usr/local/bin/run_horizontest.sh
6570
RUN chmod +x /usr/local/bin/run_horizontest.sh
6671

‎containers/horizontest/horizontest/scripts/run_horizontest.sh‎

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ if [[ -z "${ADMIN_PASSWORD}" ]]; then
3434
fi
3535
[[ -z ${DASHBOARD_URL} ]] && echo "DASHBOARD_URL not set" && exit 1
3636
[[ -z ${AUTH_URL} ]] && echo "AUTH_URL not set" && exit 1
37-
[[ -z ${REPO_URL} ]] && REPO_URL="https://review.opendev.org/openstack/horizon"
38-
[[ -z ${HORIZON_REPO_BRANCH} ]] && HORIZON_REPO_BRANCH="master"
37+
# Default test tree is baked from sources.txt (same Horizon SHA as the
38+
# dashboard image). The test-operator CRD still defaults repoUrl to
39+
# review.opendev.org and horizonRepoBranch to master; treat that pair as
40+
# "use the image pin". Clone at runtime only for a real CR override:
41+
# internal git, or a branch other than master.
42+
DEFAULT_REPO_URL="https://review.opendev.org/openstack/horizon"
43+
BAKED_HORIZON="/usr/share/horizontest/horizon"
44+
[[ -z ${REPO_URL} ]] && REPO_URL="${DEFAULT_REPO_URL}"
3945

4046
function catch_error_if_debug {
4147
echo "File run_horizontest.sh has run into an error!"
@@ -123,30 +129,56 @@ function delete_custom_resources {
123129
}
124130

125131
pushd ${HORIZONTEST_DIR}
126-
GIT_CMD_ARGS=()
127-
if [[ ${REPO_URL} == *redhat.com* ]]; then
128-
GIT_CMD_ARGS+=(-c http.sslVerify=false)
129-
fi
130-
131-
_trial=0
132-
_limit=5
133-
_delay=30
134132

135-
GIT_CLONE_CMD=(git "${GIT_CMD_ARGS[@]}" clone "${REPO_URL}" "${HORIZONTEST_DIR}/horizon")
133+
use_baked_horizon_tests() {
134+
[[ -d "${BAKED_HORIZON}" ]] || return 1
135+
# Clone when the CR points at a different git host (fork, internal
136+
# git, etc.). The historical CRD default matches DEFAULT_REPO_URL.
137+
if [[ "${REPO_URL}" != "${DEFAULT_REPO_URL}" ]]; then
138+
return 1
139+
fi
140+
# Unset or the historical CRD default (master) means "no override".
141+
if [[ -n "${HORIZON_REPO_BRANCH}" && "${HORIZON_REPO_BRANCH}" != "master" ]]; then
142+
return 1
143+
fi
144+
return 0
145+
}
136146

137-
until ("${GIT_CLONE_CMD[@]}"); do
138-
if [ "${_trial}" -lt "${_limit}" ]; then
139-
_trial=$(( _trial + 1 ))
140-
echo "Git clone failed; retrying in ${_delay} seconds..."
141-
sleep "${_delay}"
142-
else
143-
exit 1
147+
if use_baked_horizon_tests; then
148+
echo "Using Horizon tests from image pin (${BAKED_HORIZON})"
149+
rm -rf "${HORIZONTEST_DIR}/horizon"
150+
cp -a "${BAKED_HORIZON}" "${HORIZONTEST_DIR}/horizon"
151+
else
152+
[[ -z ${HORIZON_REPO_BRANCH} ]] && HORIZON_REPO_BRANCH="master"
153+
echo "Cloning Horizon tests from ${REPO_URL} branch ${HORIZON_REPO_BRANCH}"
154+
GIT_CMD_ARGS=()
155+
if [[ ${REPO_URL} == *redhat.com* ]]; then
156+
GIT_CMD_ARGS+=(-c http.sslVerify=false)
144157
fi
145-
done
146-
chown -R horizontest:horizontest horizon
158+
159+
_trial=0
160+
_limit=5
161+
_delay=30
162+
163+
GIT_CLONE_CMD=(git "${GIT_CMD_ARGS[@]}" clone "${REPO_URL}" "${HORIZONTEST_DIR}/horizon")
164+
165+
until ("${GIT_CLONE_CMD[@]}"); do
166+
if [ "${_trial}" -lt "${_limit}" ]; then
167+
_trial=$(( _trial + 1 ))
168+
echo "Git clone failed; retrying in ${_delay} seconds..."
169+
sleep "${_delay}"
170+
else
171+
exit 1
172+
fi
173+
done
174+
chown -R horizontest:horizontest horizon
175+
pushd horizon
176+
git "${GIT_CMD_ARGS[@]}" pull --rebase
177+
git checkout ${HORIZON_REPO_BRANCH}
178+
popd
179+
fi
180+
chown -R horizontest:horizontest "${HORIZONTEST_DIR}/horizon"
147181
pushd horizon
148-
git "${GIT_CMD_ARGS[@]}" pull --rebase
149-
git checkout ${HORIZON_REPO_BRANCH}
150182

151183
clean_leftover_images
152184
create_custom_resources

‎containers/horizontest/sources.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# <stream> <name> <repo-url> <branch-to-follow> <pinned-hash> version
22
master upper-constraints https://opendev.org/openstack/requirements.git stable/2026.2 0f4ec11eed11de1891d7bf30a4cd72f7032e411f -
3+
master horizontest https://opendev.org/openstack/horizon.git stable/2026.2 5bfe59196bbffa8f689924b98241eab630675d1b 27.0.1.dev6

0 commit comments

Comments
 (0)