@@ -34,8 +34,14 @@ if [[ -z "${ADMIN_PASSWORD}" ]]; then
3434fi
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
4046function 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
125131pushd ${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"
147181pushd horizon
148- git " ${GIT_CMD_ARGS[@]} " pull --rebase
149- git checkout ${HORIZON_REPO_BRANCH}
150182
151183clean_leftover_images
152184create_custom_resources
0 commit comments