Skip to content

Commit

Permalink
[tests] Add retries for build_test_image.
Browse files Browse the repository at this point in the history
Sometimes we get a failure to read file.
  • Loading branch information
shizunge committed Dec 3, 2024
1 parent 13f3b64 commit 054107b
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions tests/spec_gantry_test_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,26 @@ build_test_image() {
if [ -n "${EXIT_SECONDS}" ] && [ "${EXIT_SECONDS}" -gt "0" ]; then
EXIT_CMD="sleep ${EXIT_SECONDS};"
fi
local FILE=
FILE=$(make_test_temp_file)
echo "FROM $(_get_test_service_image)" > "${FILE}"
echo "ENTRYPOINT [\"sh\", \"-c\", \"echo $(unique_id); trap \\\"${EXIT_CMD}\\\" HUP INT TERM; ${TASK_CMD}\"]" >> "${FILE}"
pull_image_if_not_exist "$(_get_test_service_image)"
echo "Building image ${IMAGE_WITH_TAG} from ${FILE}"
docker build --quiet --tag "${IMAGE_WITH_TAG}" --file "${FILE}" .
rm "${FILE}"
local RETURN_VALUE=1
local TRIES=0
local MAX_RETRIES=60
while [ "${RETURN_VALUE}" != "0" ]; do
if [ "${TRIES}" -ge "${MAX_RETRIES}" ]; then
echo "build_test_image Reach MAX_RETRIES ${MAX_RETRIES}" >&2
return 1
fi
TRIES=$((TRIES+1))
local FILE=
FILE=$(make_test_temp_file)
echo "FROM $(_get_test_service_image)" > "${FILE}"
echo "ENTRYPOINT [\"sh\", \"-c\", \"echo $(unique_id); trap \\\"${EXIT_CMD}\\\" HUP INT TERM; ${TASK_CMD}\"]" >> "${FILE}"
pull_image_if_not_exist "$(_get_test_service_image)"
echo "Building image ${IMAGE_WITH_TAG} from ${FILE}"
docker build --quiet --tag "${IMAGE_WITH_TAG}" --file "${FILE}" . 2>&1
RETURN_VALUE=$?
rm "${FILE}"
[ "${RETURN_VALUE}" != "0" ] && sleep 1
done
}

build_and_push_test_image() {
Expand Down

0 comments on commit 054107b

Please sign in to comment.