|
| 1 | +#!/usr/bin/env bash |
| 2 | +# OCI Distribution (/v2) black-box smoke for the storage-only compose stack |
| 3 | +# (docs/plan/plan-20261001.md, OCI domain BB-10..BB-23). Runs inside the |
| 4 | +# `interop-smoke` service; clients are oras and curl (never libra, ADR-BB-03). |
| 5 | +# |
| 6 | +# docker compose -p mega2-trunk -f docker/docker-compose-storage-only.yml --profile interop \ |
| 7 | +# exec -T [-e MEGA2_SMOKE_CASE='<case>'] interop-smoke bash /repo/scripts/oci_client_smoke_storage_only.sh |
| 8 | +# |
| 9 | +# Env: MEGA2_BASE_URL (default http://127.0.0.1:9000, the runner's loopback |
| 10 | +# relay to mega2), MEGA2_IT_SEED_TOKEN (push token), MEGA2_SMOKE_CASE |
| 11 | +# (exact case name), MEGA2_SMOKE_AUTH_NONE=1 (opt-in auth-none cases; use |
| 12 | +# scripts/bb_optin_run.sh). Output and exit codes: scripts/lib/smoke-runner.sh. |
| 13 | +set -uo pipefail |
| 14 | + |
| 15 | +# Only bash builtins until require_tools has run, so a missing tool exits 2. |
| 16 | +SCRIPT_DIR="${BASH_SOURCE[0]%/*}" |
| 17 | +[ "$SCRIPT_DIR" = "${BASH_SOURCE[0]}" ] && SCRIPT_DIR=. |
| 18 | +# shellcheck source=scripts/lib/smoke-runner.sh disable=SC1091 |
| 19 | +source "$SCRIPT_DIR/lib/smoke-runner.sh" |
| 20 | + |
| 21 | +smoke_init "oci client" |
| 22 | +require_tools curl jq oras sha256sum mktemp date rm perl |
| 23 | + |
| 24 | +MEGA2_BASE_URL="${MEGA2_BASE_URL:-http://127.0.0.1:9000}" |
| 25 | +MEGA2_BASE_URL="${MEGA2_BASE_URL%/}" |
| 26 | +TOKEN="${MEGA2_IT_SEED_TOKEN:-}" |
| 27 | +[ -n "$TOKEN" ] || smoke_die "MEGA2_IT_SEED_TOKEN is empty" |
| 28 | +REGISTRY="${MEGA2_BASE_URL#http://}" |
| 29 | +RUN_ID="$(date -u +%Y%m%dt%H%M%S)" || smoke_die "cannot build RUN_ID" |
| 30 | +RUN_ID="$RUN_ID$RANDOM" |
| 31 | +WORK="$(mktemp -d)" || smoke_die "cannot create a work directory" |
| 32 | +trap 'rm -rf "$WORK"' EXIT |
| 33 | + |
| 34 | +# Preflight: any HTTP status from GET /v2/ means the registry is reachable. |
| 35 | +code=$(curl -sS --connect-timeout 3 --max-time 5 -o /dev/null -w '%{http_code}' "$MEGA2_BASE_URL/v2/" 2>/dev/null || true) |
| 36 | +[[ "$code" =~ ^[1-5][0-9][0-9]$ ]] || smoke_die "$MEGA2_BASE_URL/v2/ is not reachable" |
| 37 | + |
| 38 | +export REGISTRY RUN_ID WORK TOKEN MEGA2_BASE_URL |
| 39 | + |
| 40 | +finish |
0 commit comments