Files
rustfs/crates/rio-v2/tests/minio_fixture_lab/capture_via_docker.sh
T
overtrue 5571d4830b test(interop): let the MinIO fixture lab build from registry mirrors
The fixture lab's throwaway image hardcoded two Docker Hub base images, so on a network that cannot reach registry-1.docker.io the capture script fails at build time and no MinIO fixtures can be generated at all. That matters more than it looks: the interop reader tests are #[ignore]d precisely because the fixtures are gitignored and must be generated locally, so an unreachable registry silently keeps the whole MinIO SSE interop lane unverifiable.

Both base images become build args with the current Docker Hub values as defaults, and the capture script forwards MINIO_LAB_MINIO_IMAGE / MINIO_LAB_PYTHON_IMAGE when set. CI keeps the defaults; a restricted network can point at quay.io (which publishes the MinIO releases) and public.ecr.aws (which mirrors the official Python images), both verified to produce a working lab image and real fixtures.

The README documents the override and warns against an unpinned :latest MinIO tag, since the captured on-disk format is exactly what the interop tests assert against.

Refs rustfs/backlog#1638.
2026-08-16 21:23:17 +08:00

60 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Generate real MinIO on-disk fixtures via Docker — no host `minio`/`mc` install.
#
# Builds a throwaway image carrying the official MinIO server binary plus the
# fixture lab, runs `lab.py capture-matrix` inside it, and writes the captured
# backend fixtures under crates/rio-v2/tests/fixtures/minio-generated (which is
# gitignored — regenerate as needed). The same script is used locally and by the
# nightly `minio-interop` CI workflow so both paths stay in sync.
#
# Usage:
# ./capture_via_docker.sh # the two multipart cases the
# # ignored interop tests consume
# ./capture_via_docker.sh sse-s3-singlepart-64k # specific case id(s)
# ./capture_via_docker.sh all # full SSE/size matrix
set -euo pipefail
IMAGE="${MINIO_LAB_IMAGE:-rustfs-minio-lab:latest}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# repo root is four levels up: crates/rio-v2/tests/minio_fixture_lab -> repo
REPO_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
LAB_REL="crates/rio-v2/tests/minio_fixture_lab"
FIXTURE_REL="crates/rio-v2/tests/fixtures/minio-generated"
# Default to the two multipart cases the ignored round-trip tests consume; pass
# case ids to override, or "all" for the full default matrix.
cases=("$@")
if [ "${#cases[@]}" -eq 0 ]; then
cases=(sse-s3-multipart-8m sse-kms-multipart-8m)
fi
case_args=()
if [ "${cases[0]}" != "all" ]; then
for c in "${cases[@]}"; do
case_args+=(--case-id "$c")
done
fi
# Base images are overridable so a network without Docker Hub access can point
# them at a mirror (see the Dockerfile header). Unset by default, which keeps the
# Dockerfile's Docker Hub defaults for CI.
build_args=()
if [ -n "${MINIO_LAB_MINIO_IMAGE:-}" ]; then
build_args+=(--build-arg "MINIO_IMAGE=${MINIO_LAB_MINIO_IMAGE}")
fi
if [ -n "${MINIO_LAB_PYTHON_IMAGE:-}" ]; then
build_args+=(--build-arg "PYTHON_IMAGE=${MINIO_LAB_PYTHON_IMAGE}")
fi
echo ">> building ${IMAGE}"
docker build -f "${SCRIPT_DIR}/Dockerfile" -t "${IMAGE}" "${build_args[@]}" "${SCRIPT_DIR}"
echo ">> capturing fixtures into ${FIXTURE_REL}"
docker run --rm -v "${REPO_ROOT}:/repo" "${IMAGE}" \
python3 "/repo/${LAB_REL}/lab.py" capture-matrix \
--root "/repo/${FIXTURE_REL}" \
--work-root /tmp/minio-lab-work \
--minio-binary /usr/local/bin/minio \
"${case_args[@]}"
echo ">> done — fixtures under ${REPO_ROOT}/${FIXTURE_REL}/cases/"