diff --git a/scripts/run_external_state_tests.sh b/scripts/run_external_state_tests.sh index f08dc87..2ab13e1 100644 --- a/scripts/run_external_state_tests.sh +++ b/scripts/run_external_state_tests.sh @@ -79,19 +79,37 @@ case "$arch" in *) echo "Unsupported MinIO architecture: ${arch}" >&2; exit 1 ;; esac -MINIO_BIN="${MINIO_BIN:-${WORK_DIR}/minio}" -MC_BIN="${MC_BIN:-${WORK_DIR}/mc}" +default_minio_bin="${WORK_DIR}/minio" +default_mc_bin="${WORK_DIR}/mc" +if command -v minio >/dev/null 2>&1; then + default_minio_bin="$(command -v minio)" +fi +if command -v mc >/dev/null 2>&1; then + default_mc_bin="$(command -v mc)" +fi +MINIO_BIN="${MINIO_BIN:-${default_minio_bin}}" +MC_BIN="${MC_BIN:-${default_mc_bin}}" + +download_tool() { + local url=$1 + local output=$2 + local partial="${output}.part" + curl --fail --silent --show-error --location \ + --retry 10 --retry-all-errors --retry-delay 2 --connect-timeout 20 \ + --continue-at - --output "$partial" "$url" + mv "$partial" "$output" + chmod +x "$output" +} + if [[ ! -x "$MINIO_BIN" ]]; then - curl --fail --silent --show-error --location --retry 3 \ + download_tool \ "https://dl.min.io/server/minio/release/linux-${minio_arch}/minio" \ - --output "$MINIO_BIN" - chmod +x "$MINIO_BIN" + "$MINIO_BIN" fi if [[ ! -x "$MC_BIN" ]]; then - curl --fail --silent --show-error --location --retry 3 \ + download_tool \ "https://dl.min.io/client/mc/release/linux-${minio_arch}/mc" \ - --output "$MC_BIN" - chmod +x "$MC_BIN" + "$MC_BIN" fi export IMAGEFORGE_TEST_S3_ENDPOINT="${IMAGEFORGE_TEST_S3_ENDPOINT:-http://127.0.0.1:19000}"