Files
seaweedfs/seaweed-block/.github/scripts/chunkstore-scope-test.sh
T
pingqiuandClaude Opus 5.5 166bba1252 ci: run the integration tests for provider-only changes; harden the ledger check
The scope gate selected the real-filer suites only for chunk-store and
storage changes, but its second suite tests the durable provider: a PR
that changed only core/frontend/durable/ skipped it. The ledger anchor
check is the hardened script: a git failure or a ledger with no rows is
an error (exit 2), not a pass, and a path matches whole components only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 18:45:26 -08:00

54 lines
2.0 KiB
Bash

#!/usr/bin/env bash
# Tests chunkstore-scope.sh against real commits. Any failure exits nonzero.
set -euo pipefail
here=$(cd "$(dirname "$0")" && pwd)
scope="$here/chunkstore-scope.sh"
fail=0
check() { # name want got
if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: want [$2], got [$3]"; fail=1; fi
}
repo=$(mktemp -d)
trap 'rm -rf "$repo"' EXIT
cd "$repo"
git init -q
git config user.email t@example.invalid
git config user.name t
git config core.autocrlf false
mkdir -p core/frontend/chunkstore core/frontend/durable core/storage core/other docs
echo c >core/frontend/chunkstore/c.go
echo p >core/frontend/durable/p.go
echo s >core/storage/s.go
echo o >core/other/o.go
echo d >docs/d.md
git add -A
git commit -qm base
base=$(git rev-parse HEAD)
case_of() { # name want: commit the current tree, classify against base, reset
git add -A
git commit -qm "$1" --allow-empty
check "$1" "$2" "$(bash "$scope" "$base" HEAD)"
git reset -q --hard "$base"
}
echo c2 >core/frontend/chunkstore/c.go
case_of "a chunkstore file" "run 1 core/frontend/chunkstore/c.go"
echo p2 >core/frontend/durable/p.go
case_of "a durable provider file only" "run 1 core/frontend/durable/p.go"
echo s2 >core/storage/s.go; echo o2 >core/other/o.go
case_of "storage and another package" "run 2 core/storage/s.go"
echo o2 >core/other/o.go; echo d2 >docs/d.md
case_of "neither path" "skip 2"
case_of "no file changed" "skip 0"
mkdir -p core/storage-old; echo x >core/storage-old/x.go
case_of "a storage-like prefix" "skip 1"
git rm -q core/storage/s.go
case_of "a storage deletion" "run 1 core/storage/s.go"
for i in $(seq 1 20000); do printf 'x\n' >"docs/f$i.md"; done
echo late >core/storage/zz_late.go
case_of "20000 other files and one storage file, listed last" "run 20001 core/storage/zz_late.go"
if out=$(bash "$scope" "$base" no-such-revision 2>/dev/null); then
check "an unknown revision is an error" "nonzero exit" "exit 0: $out"
else
check "an unknown revision is an error" "nonzero exit" "nonzero exit"
fi
exit "$fail"