fix(ci): serialize integration test packages (-p 1) to stop TRUNCATE deadlocks
First CI integration run proved the act_runner pattern works (service discovery, migrate, exactly-one guard all functioned) but ~150 tests failed with `dbtest.ResetDB truncate: deadlock detected (40P01)` plus cascading FK/dup-key symptoms. Root cause: `go test ./...` runs package binaries concurrently (default -p = NumCPU); every integration package TRUNCATEs the single shared minstrel_test DB, so concurrent truncates deadlock and half-seeded fixtures violate FKs. The documented local invocation is `go test -p 1 ./...` for exactly this reason. Serialize package execution in both the CI step and `make test-integration`. Genuine (non-concurrency) failures will remain after this — never caught before because integration tests never ran in CI. Triaged next. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,9 @@ jobs:
|
|||||||
for i in $(seq 1 60); do (echo > "/dev/tcp/${PG_IP}/5432") 2>/dev/null && break; sleep 2; done
|
for i in $(seq 1 60); do (echo > "/dev/tcp/${PG_IP}/5432") 2>/dev/null && break; sleep 2; done
|
||||||
|
|
||||||
# Apply embedded migrations to the fresh test DB, then run the
|
# Apply embedded migrations to the fresh test DB, then run the
|
||||||
# full suite (no -short → integration tests execute).
|
# full suite (no -short → integration tests execute). -p 1:
|
||||||
|
# every integration package TRUNCATEs the one shared test DB;
|
||||||
|
# concurrent package binaries → TRUNCATE deadlocks. Serialize
|
||||||
|
# package execution (the documented local invocation too).
|
||||||
MINSTREL_DATABASE_URL="$MINSTREL_TEST_DATABASE_URL" go run ./cmd/minstrel migrate
|
MINSTREL_DATABASE_URL="$MINSTREL_TEST_DATABASE_URL" go run ./cmd/minstrel migrate
|
||||||
go test -race ./...
|
go test -p 1 -race ./...
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ test-short:
|
|||||||
test-integration:
|
test-integration:
|
||||||
docker compose up -d postgres
|
docker compose up -d postgres
|
||||||
-docker compose exec -T postgres createdb -U minstrel minstrel_test
|
-docker compose exec -T postgres createdb -U minstrel minstrel_test
|
||||||
MINSTREL_TEST_DATABASE_URL=postgres://minstrel:minstrel@localhost:5432/minstrel_test?sslmode=disable go test -race ./...
|
# -p 1: integration packages share one test DB and each TRUNCATEs it;
|
||||||
|
# concurrent package binaries deadlock on TRUNCATE. Serialize packages.
|
||||||
|
MINSTREL_TEST_DATABASE_URL=postgres://minstrel:minstrel@localhost:5432/minstrel_test?sslmode=disable go test -p 1 -race ./...
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
golangci-lint run ./...
|
golangci-lint run ./...
|
||||||
|
|||||||
Reference in New Issue
Block a user