#!/bin/bash # Runs in the disposable storage tools container; never uses public storage. set -euo pipefail work=$(mktemp -d) trap 'rm -rf "$work"' EXIT cli=${ARCHIPELAGO_BINARY:-/build/target/release/archipelago} "$cli" registry init "$work/registry/layers" "$cli" registry init "$work/registry/images" "$cli" registry init "$work/registry/layers" "$cli" registry verify "$work/registry/layers" mkdir "$work/unrelated" echo keep > "$work/unrelated/file" if "$cli" registry init "$work/unrelated"; then exit 1; fi test "$(cat "$work/unrelated/file")" = keep ostree --repo="$work/bare" init --mode=bare-user if "$cli" registry init "$work/bare"; then exit 1; fi ln -s "$work/registry/layers" "$work/link" if "$cli" registry init "$work/link"; then exit 1; fi flock "$work/registry/.layers.archipelago.lock" bash -c 'if "$1" registry init "$2"; then exit 1; fi' _ "$cli" "$work/registry/layers" # Native HTTP round-trip in an isolated network namespace. Test objects stay here. mkdir "$work/tree" echo 'native OSTree transport fixture' > "$work/tree/marker" commit=$(ostree --repo="$work/registry/layers" commit -b fixture --tree="dir=$work/tree") ostree --repo="$work/registry/layers" summary --update "$cli" registry verify "$work/registry/layers" python3 /src/infrastructure/tests/storage-http.py "$work/registry/layers" "$work/consumer" "$commit" # Corrupting an object must fail verification without deleting it or changing refs. object="$work/registry/layers/objects/${commit:0:2}/${commit:2}.commit" printf corrupt > "$object" if "$cli" registry verify "$work/registry/layers"; then exit 1; fi test "$(ostree --repo="$work/registry/layers" rev-parse fixture)" = "$commit" test -f "$object" echo 'PASS: init, retry, mode/path/lock rejection, HTTP pull, corrupt-object rejection'