Files
seaweedfs/seaweed-block/.github/workflows/test.yml
T
pingqiuandClaude Opus 5.5 af7ee03fe4 Merge branch 'main' into ci/failure-bundle-ae
Conflict in the test workflow: main added the self-hosted runner NVMe
check after checkout; this branch adds the load-evidence start and its
self-test there. Both kept, the NVMe check first so a misplaced runner
stops before anything else runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 23:40:50 -08:00

351 lines
19 KiB
YAML

name: Test
on:
pull_request:
# ready_for_review: a Draft runs no Go suite (below); marking it ready starts one.
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- main
permissions:
contents: read
# One run per PR (or per branch for pushes). A new push to a PR cancels the
# superseded run; runs on main are never cancelled so every merge gets a result.
concurrency:
group: test-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test:
# One job, two suites, one runner selection. 'unit' is the Go suite below;
# 'process' runs the process-level tests: real blockmaster, blockvolume and
# sw-block against a pinned SeaweedFS release. Those tests are named in
# .github/process-level-tests.txt, and every one must PASS, so a test that
# skips, fails, never starts or is cut off by the timeout fails the suite.
# Tests that need root or systemd are not in the list (see its header).
strategy:
fail-fast: false
matrix:
suite: [unit, process]
name: ${{ matrix.suite == 'unit' && 'go test (linux)' || 'process-level tests (real binaries)' }}
# The suite writes heavily to the runner disk (real files, fsync), so a
# Draft PR skips it; its author tests locally until the PR is ready.
if: github.event_name == 'push' || !github.event.pull_request.draft
# Pull requests run on GitHub-hosted runners (free for this public repo, many
# jobs in parallel); pushes to main keep the team's tp04 runner (seaweed.slice,
# capped at 8 cores / 8 GiB) as the self-hosted signal. A train PR (branch
# train/* of this repository, a few a day) also runs on the team's runners:
# it is the merge gate, and the organization's shared GitHub-hosted queue held
# it 30-55 minutes before it started. A PR from a fork never runs there.
runs-on: ${{ (github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository)) && 'tp04-seaweed-block' || 'ubuntu-latest' }}
# process: 44 tests in 4 parallel shards of about 13 min each (55 min in sequence).
timeout-minutes: ${{ matrix.suite == 'unit' && 40 || 90 }}
env:
# Pure-Go build: no package in the default build needs cgo, and the
# hosted runner should not depend on a C toolchain being present.
CGO_ENABLED: "0"
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
persist-credentials: false
# Two commits: the PR merge commit and its base parent, so the test
# step can see which packages the PR touches.
fetch-depth: 2
- name: Runner disk is NVMe
# A self-hosted runner whose work, temp or Go cache directory sits on a
# SATA system disk times the process-level tests out under disk load;
# this names the runner and stops the job before it starts.
if: runner.environment == 'self-hosted'
run: |
bash .github/scripts/require-nvme-test.sh
bash .github/scripts/require-nvme.sh "$GITHUB_WORKSPACE" "$RUNNER_TEMP" "${TMPDIR:-/tmp}" "${GOCACHE:-$HOME/.cache/go-build}"
- name: Start whole-job load evidence
# Begins after checkout, before toolchain setup/build/tests. No host
# installation or privileged reads. A job-sized lifetime also bounds
# the sampler if cancellation prevents the stop step.
continue-on-error: true
env:
CI_EVIDENCE_DIR: ${{ runner.temp }}/ci-${{ matrix.suite }}-${{ github.run_id }}-${{ github.run_attempt }}
run: |
echo "CI_EVIDENCE_DIR=$CI_EVIDENCE_DIR" >>"$GITHUB_ENV"
mkdir -p "$CI_EVIDENCE_DIR"
: >"$CI_EVIDENCE_DIR/go-test.json"
python3 -I .github/scripts/ci-load.py start "$CI_EVIDENCE_DIR/load.tsv" --duration ${{ matrix.suite == 'unit' && 2400 || 5400 }}
- name: Self-test evidence capture
run: |
python3 -B .github/scripts/ci-load-test.py
bash .github/scripts/record-go-test-test.sh
- name: Docs-only pull request
id: scope
if: matrix.suite == 'process' && github.event_name == 'pull_request'
# A pull request that changes only files under docs/ runs no product
# code the process-level tests could exercise, so they are skipped and
# the job still reports success. HEAD is the merge commit, HEAD^1 its
# base parent (fetch-depth 2 above). Pushes to main always run them, and
# so does any error of the check (.github/scripts/docs-only-scope.sh).
run: |
set -euo pipefail
bash .github/scripts/docs-only-scope-test.sh
if out=$(bash .github/scripts/docs-only-scope.sh HEAD^1 HEAD); then
case $out in
"docs_only "*)
echo "skipped: docs only (${out#docs_only } files under docs/); the process-level tests run on the merge to main"
echo "docs_only=1" >>"$GITHUB_OUTPUT" ;;
*) echo "process-level tests run: $out" ;;
esac
else
echo "process-level tests run: the docs-only check failed"
fi
- name: Set up Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
# The self-hosted runner keeps GOCACHE/GOMODCACHE on its own disk;
# uploading them as an Actions cache (~4 GB) in the post step
# outlasted the job timeout after every test had passed. Only the
# GitHub-hosted (fork PR) runner uses the Actions cache.
cache: ${{ runner.environment == 'github-hosted' }}
cache-dependency-path: go.sum
- name: Go version
if: matrix.suite == 'unit'
run: go version
- name: Build
if: matrix.suite == 'unit'
run: go build ./...
- name: Vet
if: matrix.suite == 'unit'
run: go vet ./...
- name: Lab build tags stay out of images and releases
if: matrix.suite == 'unit'
# swblock_lab_bigvol lifts the 256 GiB create cap and the local
# headroom refusal for scale rehearsals only; swblock_v11_format turns
# on the draft v1.1 store format. The default test run pins the
# release cap (TestReleaseBuildKeepsTheCreateCap) and the release
# format. This step checks the tags' allowlist and that every image
# Dockerfile refuses a lab binary (scripts/refuse-lab-binary.sh) after
# its build, with controls, then tests each tag alone and both.
run: |
set -euo pipefail
bash .github/scripts/lab-tag-check.sh .
bash .github/scripts/lab-tag-check-test.sh
for tags in swblock_lab_bigvol swblock_v11_format swblock_lab_bigvol,swblock_v11_format; do
go vet -tags "$tags" ./core/geometry/ ./core/frontend/durable/ ./internal/buildinfo/ ./core/storage/
bash .github/scripts/record-go-test.sh "$CI_EVIDENCE_DIR/go-test.json" -count=1 -tags "$tags" -run 'Lab|Headroom|Revision' ./core/geometry/ ./core/frontend/durable/ ./internal/buildinfo/
bash .github/scripts/record-go-test.sh "$CI_EVIDENCE_DIR/go-test.json" -count=1 -tags "$tags" -run 'TestV11FormatFollowsItsOwnTagAlone' ./core/storage/
done
- name: Test default configuration
if: matrix.suite == 'unit'
# The runner disk is shared, so the long, disk-heavy, timing-sensitive
# packages do not run here on main or on train PRs: every train runs the
# whole suite (both configurations) on a separate test VM before it
# merges, and main moves only by those trains. A PR runs the light set
# plus every heavy package its own diff touches.
env:
EVENT: ${{ github.event_name }}
HEAD_REF: ${{ github.head_ref }}
run: |
set -euo pipefail
pkgs=$(go list ./... | grep -vE '/core/(storage|frontend/durable|host/master|authority)$')
if [ "$EVENT" != push ] && [[ "$HEAD_REF" != train/* ]]; then
mod=$(go list -m)
changed=$(git diff --name-only HEAD^1 HEAD)
for p in core/storage core/frontend/durable core/host/master core/authority; do
if printf '%s\n' "$changed" | grep -qE "^$p/[^/]+$"; then
pkgs="$pkgs $mod/$p"
fi
done
fi
# 20m per package: core/storage alone took 602 s on tp04 on main
# (2026-11-22), past the old 10m, so any PR touching it failed.
bash .github/scripts/record-go-test.sh "$CI_EVIDENCE_DIR/go-test.json" -p=1 -short -count=1 -timeout 20m $pkgs
- name: Format v3 tagged tests
if: matrix.suite == 'unit'
# The swblock_format_v3_test tests of the four packages that carry them.
# Five durable tests are skipped by name: each installs a BASE on a chunk
# store, which no production path does (its invariant row is DORMANT);
# they are rewritten at the start of the next release, then this skip
# goes.
run: |
set -euo pipefail
skip='^(TestDurableProviderV3_AttachesCompletedChunkBASE|TestDurableProviderV3_CompletedBASEDoesNotRestoreOlderHEAD|TestDurableProviderV3_DefersBASERetirementUntilLocalPresence|TestDurableProviderV3_FreshMarkerCrashKeepsCompletedBASE|TestDurableProviderV3_FreshMarkerCaptureCrashKeepsCompletedBASE)$'
bash .github/scripts/record-go-test.sh "$CI_EVIDENCE_DIR/go-test.json" -p=1 -count=1 -timeout 20m -tags swblock_format_v3_test -skip "$skip" \
./core/frontend/durable/ ./core/recovery/ ./core/replication/ ./core/transport/
- name: Self-test of the required-tests gate
if: matrix.suite == 'process' && steps.scope.outputs.docs_only != '1'
# The gate must fail on a skip, a failure, a test that never ran, one
# cut off mid-run, and one that reports PASS and then exits nonzero or
# hangs; this proves it before it judges the real run.
run: |
python3 -I .github/scripts/required-tests-check-test.py
bash .github/scripts/chunkstore-scope-test.sh
bash .github/scripts/run-named-tests-test.sh
python3 -I .github/scripts/shard-named-tests-test.py
- name: Pinned SeaweedFS
if: matrix.suite == 'process' && steps.scope.outputs.docs_only != '1'
# The release archive is checked against its sha256 before every use,
# also when taken from the runner's cache; a mismatch fails the step.
# Nothing else is fetched.
env:
WEED_VERSION: "4.53"
WEED_SHA256: d1a7dec9f48d8b33895a0ea8951971defc2dc5312906dcc76fa5a5f74a6ee90d
run: |
set -euo pipefail
cache="${RUNNER_TOOL_CACHE:-$RUNNER_TEMP}/seaweedfs-weed/$WEED_VERSION"
tgz="$cache/linux_amd64.tar.gz"
mkdir -p "$cache"
if ! echo "$WEED_SHA256 $tgz" | sha256sum -c --status - 2>/dev/null; then
part="$tgz.$$.part"
curl -fsSL --retry 3 -o "$part" "https://github.com/seaweedfs/seaweedfs/releases/download/$WEED_VERSION/linux_amd64.tar.gz"
echo "$WEED_SHA256 $part" | sha256sum -c - || { rm -f "$part"; exit 1; }
mv -f "$part" "$tgz"
fi
bin="$RUNNER_TEMP/weed-$WEED_VERSION"
mkdir -p "$bin"
tar -xzf "$tgz" -C "$bin" weed
echo "CHUNKSTORE_WEED=$bin/weed" >>"$GITHUB_ENV"
- name: Real-filer integration tests
if: matrix.suite == 'process' && steps.scope.outputs.docs_only != '1'
# The chunkstore_integration tests run against the pinned weed above
# (master, volume and filer as real processes): the conditional HEAD
# writes, cut uploads and object deletes of the chunk store, and the
# layout sync crash cases of the durable provider. They fail, never
# skip, without the binary. Pushes to main and train PRs always run
# them; another PR runs them when it touches core/frontend/chunkstore/,
# core/storage/ or core/frontend/durable/.
env:
EVENT: ${{ github.event_name }}
HEAD_REF: ${{ github.head_ref }}
# .github/scripts/chunkstore-scope.sh decides; an error of that check
# runs the tests. Each filtered run must PASS at least one test, so a
# filter that matches nothing fails instead of passing empty.
run: |
set -euo pipefail
if [ "$EVENT" != push ] && [[ "$HEAD_REF" != train/* ]]; then
if out=$(bash .github/scripts/chunkstore-scope.sh HEAD^1 HEAD); then
case $out in
"skip "*) echo "skipped: the PR touches neither core/frontend/chunkstore/ nor core/storage/ ($out)"; exit 0 ;;
*) echo "real-filer integration tests run: $out" ;;
esac
else
echo "real-filer integration tests run: the scope check failed"
fi
fi
for spec in "./core/frontend/chunkstore/ ^TestIntegration" "./core/frontend/durable/ ^TestQD1LayoutSync"; do
pkg=${spec%% *}; filter=${spec#* }
log="$RUNNER_TEMP/integration-$(basename "$pkg").log"
bash .github/scripts/record-go-test.sh "$CI_EVIDENCE_DIR/go-test.json" -count=1 -v -timeout 20m -tags chunkstore_integration -run "$filter" "$pkg" 2>&1 | tee "$log"
grep -q '^--- PASS: ' "$log" || { echo "no test of $pkg matched $filter"; exit 1; }
done
- name: Build the binaries and the test binary once
if: matrix.suite == 'process' && steps.scope.outputs.docs_only != '1'
run: |
set -euo pipefail
bins="$RUNNER_TEMP/swblock-bins"
mkdir -p "$bins"
for b in blockmaster blockvolume sw-block; do go build -o "$bins/$b" "./cmd/$b"; done
go test -c -tags 'subprocess chunkstore_integration' -o "$bins/blockvolume.test" ./cmd/blockvolume
go test -c -o "$bins/blockcsi.test" ./cmd/blockcsi
# The known-zero acceptance's first-start crash step holds a test-only
# blockvolume (build tag kzhold, never released) at a chosen point.
go build -tags kzhold -o "$RUNNER_TEMP/blockvolume-kzhold" ./cmd/blockvolume
echo "SWBLOCK_TEST_BINS=$bins" >>"$GITHUB_ENV"
echo "KZ_HOLD_BIN=$RUNNER_TEMP/blockvolume-kzhold" >>"$GITHUB_ENV"
- name: Run the named process-level tests
if: matrix.suite == 'process' && steps.scope.outputs.docs_only != '1'
# Each named test in its own process of the one test binary, in
# sequence, so a panic or a hang in one cannot hide the others; each
# is bounded (TEST_TIMEOUT, then killed) and its exit status is kept:
# the gate needs a PASS event AND exit 0 for every named test. The known-zero acceptance
# runs its small shape (1 GiB, user-space client, no device); the
# 1 TiB run is lab only.
env:
KZ_RUN: "1"
KZ_SIZE: 1G
F1_RUN: "1"
TEST_TIMEOUT: 15m
# A failed test copies each daemon's whole log here (keepFullLog);
# the step below keeps them as the run's artifact.
SWBLOCK_TEST_LOG_DIR: ${{ env.CI_EVIDENCE_DIR }}/daemon-logs
run: |
set -euo pipefail
# SHARDS parallel shards, balanced by their last measured times
# (.github/process-level-seconds.txt). Each shard is its own sequence
# of test processes with its own slice of the test port ranges
# (SWBLOCK_TEST_PORT_SHARD) and its own TMPDIR; the gate judges every
# named test from all the shards together.
names=.github/process-level-tests.txt
# The manifest tags CSI entries; every other name uses blockvolume.test.
# The final checker still requires the complete, unsplit manifest.
awk '!/# package=blockcsi/' "$names" > "$RUNNER_TEMP/blockvolume-names.txt"
awk '/# package=blockcsi/ {sub(/#.*/, ""); if ($0 ~ /[^[:space:]]/) print}' "$names" > "$RUNNER_TEMP/blockcsi-names.txt"
test -s "$RUNNER_TEMP/blockcsi-names.txt"
shards=4
python3 -I .github/scripts/shard-named-tests.py "$RUNNER_TEMP/blockvolume-names.txt" .github/process-level-seconds.txt "$shards" "$RUNNER_TEMP/shard"
pids=()
for k in $(seq 1 "$shards"); do
mkdir -p "$RUNNER_TEMP/tmp-$k"
SWBLOCK_TEST_PORT_SHARD=$k SWBLOCK_TEST_PORT_SHARDS=$shards TMPDIR="$RUNNER_TEMP/tmp-$k" \
bash .github/scripts/run-named-tests.sh "$SWBLOCK_TEST_BINS/blockvolume.test" "$RUNNER_TEMP/shard/$k.txt" \
"$RUNNER_TEMP/process-level-$k.json" "$RUNNER_TEMP/process-level-$k.status" "$TEST_TIMEOUT" cmd/blockvolume \
>"$RUNNER_TEMP/process-level-$k.log" 2>&1 &
pids+=($!)
done
for p in "${pids[@]}"; do wait "$p" || true; done
for k in $(seq 1 "$shards"); do sed "s/^/[shard $k] /" "$RUNNER_TEMP/process-level-$k.log"; done
# CSI uses the same per-case isolation, timeout and verdict as the shards.
TEST_PKG=github.com/seaweedfs/seaweed-block/cmd/blockcsi \
bash .github/scripts/run-named-tests.sh "$SWBLOCK_TEST_BINS/blockcsi.test" "$RUNNER_TEMP/blockcsi-names.txt" \
"$RUNNER_TEMP/process-level-csi.json" "$RUNNER_TEMP/process-level-csi.status" "$TEST_TIMEOUT" cmd/blockcsi \
>"$RUNNER_TEMP/process-level-csi.log" 2>&1 || true
cat "$RUNNER_TEMP/process-level-csi.log"
cat "$RUNNER_TEMP"/process-level-*.status >"$RUNNER_TEMP/process-level.status"
python3 -I .github/scripts/required-tests-check.py --status "$RUNNER_TEMP/process-level.status" \
"$names" "$RUNNER_TEMP"/process-level-*.json
- name: Stop load evidence and collect raw process events
if: always()
continue-on-error: true
env:
SUITE: ${{ matrix.suite }}
run: |
if [ -z "${CI_EVIDENCE_DIR:-}" ]; then exit 0; fi
python3 -I .github/scripts/ci-load.py stop "$CI_EVIDENCE_DIR/load.tsv" || true
if [ "$SUITE" = process ]; then
mkdir -p "$CI_EVIDENCE_DIR/shards"
shopt -s nullglob
for file in "$RUNNER_TEMP"/process-level-*.json "$RUNNER_TEMP"/process-level-*.log "$RUNNER_TEMP"/process-level*.status; do
cp "$file" "$CI_EVIDENCE_DIR/shards/"
done
for file in "$CI_EVIDENCE_DIR"/shards/*.json; do cat "$file" >>"$CI_EVIDENCE_DIR/go-test.json"; done
fi
- name: Keep failed-job tests, load, daemon logs and shard results
# Both suites retain timed events and whole-job load. Process evidence
# also retains the original shard receipts and full daemon logs.
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ci-${{ matrix.suite }}-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ env.CI_EVIDENCE_DIR }}
retention-days: 14
if-no-files-found: warn