feat(bdd): parallel-safe schema-per-package isolation (T12 stage 2/2) — 2.85x speedup (#35)
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 7s
CI/CD Pipeline / CI Pipeline (push) Failing after 3m58s
CI/CD Pipeline / Trigger Docker Push (push) Has been skipped

Per-package isolated Postgres schema with migrations. Local benchmark: 12.87s sequential → 4.51s parallel = 2.85x. ADR-0025 status to Implemented. CI uses BDD_SCHEMA_ISOLATION=true.

Co-authored-by: Gabriel Radureau <arcodange@gmail.com>
Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
This commit was merged in pull request #35.
This commit is contained in:
2026-05-03 19:42:09 +02:00
committed by arcodange
parent 4452620df8
commit 82feaec51f
6 changed files with 116 additions and 24 deletions

View File

@@ -144,9 +144,21 @@ run_tests_with_tags() {
# Note: -tags flag in go test is for Go build tags, NOT Godog feature tags
# We use GODOG_TAGS env var which is read by the test framework
echo "🚀 Running: GODOG_TAGS=\"${DEFAULT_TAGS}\" go test ./features/..."
# -p 1 forces sequential package execution to avoid DB-state contention between feature packages
# (different packages would otherwise spawn concurrent test servers sharing the same Postgres DB).
GODOG_TAGS="$DEFAULT_TAGS" go test ./features/... -v -p 1 -cover -coverpkg=./... -coverprofile=coverage.out 2>&1 | tee /tmp/bdd_test_output.txt && test_output=$(cat /tmp/bdd_test_output.txt) && rm -f /tmp/bdd_test_output.txt || test_output=$(cat /tmp/bdd_test_output.txt 2>/dev/null || echo "")
# When BDD_SCHEMA_ISOLATION=true (T12 architecture):
# each test PACKAGE gets its own isolated PostgreSQL schema with its own
# connection pool + migrations (cf. pkg/bdd/testserver/server.go Start()).
# Packages then run in parallel safely. ~2.85x speedup observed locally.
# When unset:
# fall back to -p 1 (sequential). Uses public schema with TRUNCATE-style
# cleanup between scenarios.
if [ "${BDD_SCHEMA_ISOLATION:-}" = "true" ]; then
PARALLEL_FLAG=""
echo "🔀 BDD_SCHEMA_ISOLATION=true → feature packages run in parallel"
else
PARALLEL_FLAG="-p 1"
echo "🐌 BDD_SCHEMA_ISOLATION not set → feature packages run sequentially (-p 1)"
fi
GODOG_TAGS="$DEFAULT_TAGS" go test ./features/... -v $PARALLEL_FLAG -cover -coverpkg=./... -coverprofile=coverage.out 2>&1 | tee /tmp/bdd_test_output.txt && test_output=$(cat /tmp/bdd_test_output.txt) && rm -f /tmp/bdd_test_output.txt || test_output=$(cat /tmp/bdd_test_output.txt 2>/dev/null || echo "")
test_exit_code=${PIPESTATUS[0]}
fi