diff --git a/vezha/SOURCE.tmpl b/vezha/SOURCE.tmpl new file mode 100644 index 00000000..7b73aa4f --- /dev/null +++ b/vezha/SOURCE.tmpl @@ -0,0 +1,24 @@ +This image ships mc (the MinIO Client), licensed under the GNU Affero General Public License v3 (AGPL-3.0), unmodified. + +Upstream project: https://github.com/minio/mc +Upstream release: @UPSTREAM_RELEASE@ +Upstream commit: @UPSTREAM_COMMIT@ + +Corresponding source at that commit, tagged in this repository: +https://git.vezha.io/para/mc/src/tag/@UPSTREAM_RELEASE@ +Source archive of that tag: +https://git.vezha.io/para/mc/archive/@UPSTREAM_RELEASE@.tar.gz + +Build recipe repository: https://git.vezha.io/para/mc +Build recipe commit: @RECIPE_COMMIT@ +Build recipe at that commit: +https://git.vezha.io/para/mc/src/commit/@RECIPE_COMMIT@ + +Go builder image: @GO_BUILDER@ +Go module: @MODULE@ @MODULE_VERSION@ +Go module sum: @MODULE_SUM@ +Binary sha256 of /usr/bin/mc: @BINARY_SHA256@ + +Base image: @BASE_IMAGE@ +The base image is BusyBox (GPL-2.0-only), unmodified. Its source is published at https://busybox.net/downloads/ and https://github.com/docker-library/busybox. +The CA bundle /etc/ssl/certs/ca-certificates.crt is copied unmodified from the Go builder image (Debian ca-certificates; source: https://tracker.debian.org/pkg/ca-certificates). diff --git a/vezha/smoke.sh b/vezha/smoke.sh new file mode 100644 index 00000000..ac21057d --- /dev/null +++ b/vezha/smoke.sh @@ -0,0 +1,175 @@ +#!/bin/sh +set -eu + +mode=${1:?usage: smoke.sh smoke | smoke.sh continuity } +shift + +run=${GITHUB_RUN_ID:-local} +suffix=$$ +LABEL="io.vezha.smoke=$run" +NET="vezha-smoke-$run-$suffix" +VOL="vezha-smoke-$run-$suffix-data" +SRV="vezha-smoke-$run-$suffix-srv" +GATES=$(dirname "$0")/gates.sh +T=$(mktemp -d) + +fail() { + printf 'REFUSED smoke: %s\n' "$1" >&2 + exit 1 +} + +cleanup() { + docker rm -f "$SRV" > /dev/null 2>&1 || true + docker network rm "$NET" > /dev/null 2>&1 || true + docker volume rm "$VOL" > /dev/null 2>&1 || true + rm -rf "$T" +} +trap cleanup EXIT + +rand() { + head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n' +} + +U=$(rand) +P=$(rand) +RO_SECRET=$(rand) +echo "::add-mask::$U" +echo "::add-mask::$P" +echo "::add-mask::$RO_SECRET" + +docker network create --label "$LABEL" "$NET" > /dev/null +docker volume create --label "$LABEL" "$VOL" > /dev/null + +start_server() { + docker run -d --name "$SRV" --label "$LABEL" --network "$NET" --network-alias minio \ + -e "MINIO_ROOT_USER=$U" -e "MINIO_ROOT_PASSWORD=$P" -v "$VOL:/data" \ + "$1" server /data --console-address :9001 > /dev/null + i=0 + until docker exec "$SRV" mc ready local > /dev/null 2>&1; do + i=$((i + 1)) + if [ "$i" -gt 60 ]; then + docker logs "$SRV" >&2 || true + fail "mc ready local did not succeed within 60 seconds for $1" + fi + sleep 1 + done + echo "smoke: $1 is ready after $i seconds" +} + +stop_server() { + docker stop "$SRV" > /dev/null + docker logs "$SRV" > "$T/$1.log" 2>&1 + docker rm "$SRV" > /dev/null +} + +mcr() { + docker run --rm --label "$LABEL" --network "$NET" -e "MC_HOST_s=http://$U:$P@minio:9000" "$CLIENT" "$@" +} + +mcr_in() { + docker run --rm -i --label "$LABEL" --network "$NET" -e "MC_HOST_s=http://$U:$P@minio:9000" "$CLIENT" "$@" +} + +mcr_ro() { + docker run --rm --label "$LABEL" --network "$NET" -e "MC_HOST_r=http://ro:$RO_SECRET@minio:9000" "$CLIENT" "$@" +} + +mcr_ro_in() { + docker run --rm -i --label "$LABEL" --network "$NET" -e "MC_HOST_r=http://ro:$RO_SECRET@minio:9000" "$CLIENT" "$@" +} + +sha_of() { + sha256sum "$1" | cut -d' ' -f1 +} + +make_objects() { + head -c 1048576 /dev/urandom > "$T/o1" + head -c 1048576 /dev/urandom > "$T/o2" + S1=$(sha_of "$T/o1") + S2=$(sha_of "$T/o2") + [ "$S1" != "$S2" ] || fail "the two random objects are equal" +} + +write_two_versions() { + mcr mb s/b1 + mcr version enable s/b1 + mcr_in pipe s/b1/key < "$T/o1" + mcr_in pipe s/b1/key < "$T/o2" +} + +read_back_versions() { + got=$(mcr cat s/b1/key | sha256sum | cut -d' ' -f1) + [ "$got" = "$S2" ] || fail "cat of the key is $got, expected the second object $S2" + mcr ls --versions --json s/b1/key > "$T/ls.json" + count=$(jq -s '[.[] | select(.versionId != null)] | length' "$T/ls.json") + [ "$count" = 2 ] || fail "ls --versions shows $count versions, expected 2" + distinct=$(jq -s '[.[] | select(.versionId != null) | .versionId] | unique | length' "$T/ls.json") + [ "$distinct" = 2 ] || fail "the two versions share a versionId" + old=$(jq -rs '[.[] | select(.versionId != null and .isLatest != true) | .versionId] | .[0] // ""' "$T/ls.json") + [ -n "$old" ] || fail "no non-latest version in ls --versions" + got=$(mcr cat --version-id "$old" s/b1/key | sha256sum | cut -d' ' -f1) + [ "$got" = "$S1" ] || fail "cat --version-id of the first version is $got, expected the first object $S1" + echo "smoke: two versions read back by versionId with matching sha256" +} + +case $mode in + smoke) + SERVER=${1:?server image} + CLIENT=${2:?client image} + make_objects + start_server "$SERVER" + if [ "${HEALTH:-no}" = yes ]; then + i=0 + until [ "$(docker inspect -f '{{.State.Health.Status}}' "$SRV")" = healthy ]; do + i=$((i + 1)) + [ "$i" -le 60 ] || fail "the image HEALTHCHECK did not reach healthy within 60 seconds" + sleep 1 + done + echo "smoke: the image HEALTHCHECK is healthy" + fi + write_two_versions + read_back_versions + mcr admin user add s ro "$RO_SECRET" > /dev/null + mcr admin policy attach s readonly --user ro > /dev/null + got=$(mcr_ro cat r/b1/key | sha256sum | cut -d' ' -f1) + [ "$got" = "$S2" ] || fail "the read-only user cannot read the key" + code=0 + mcr_ro_in pipe r/b1/denied < "$T/o1" > "$T/put.out" 2>&1 || code=$? + sh "$GATES" put-denied "$code" "$T/put.out" + echo "smoke: the read-only user's PUT is denied" + for n in 1 2; do + docker run --rm --label "$LABEL" --network "$NET" --entrypoint /bin/sh "$CLIENT" -c " + mc alias set local http://minio:9000 $U $P && + mc mb --ignore-existing local/leasevibe-attachments && + echo 'bucket ready'; + " > /dev/null || fail "the minio-init script failed on run $n" + echo "smoke: minio-init run $n exited 0" + done + ;; + continuity) + OLD=${1:?old server image} + NEW=${2:?new server image} + CLIENT=${3:?client image} + make_objects + start_server "$OLD" + write_two_versions + read_back_versions + stop_server old + start_server "$NEW" + read_back_versions + stop_server new + echo "--- first-start log of the old server" + cat "$T/old.log" + echo "--- start log of the new server on the same volume" + cat "$T/new.log" + grep -q 'Formatting' "$T/old.log" || fail "the old server's first-start log has no Formatting line, the re-format assertion would be vacuous" + if grep -q 'Formatting' "$T/new.log"; then + fail "the new server re-formatted the volume" + fi + echo "smoke: the new server started on the old volume without formatting it" + ;; + *) + fail "unknown mode $mode" + ;; +esac +echo "smoke: all assertions passed"