parallel tests

This commit is contained in:
counterweight 2025-12-25 00:48:22 +01:00
parent 73a45b81cc
commit 139a5fbef3
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
5 changed files with 61 additions and 228 deletions

View file

@ -38,13 +38,18 @@ db-ready:
@until docker compose exec -T db pg_isready -U postgres > /dev/null 2>&1; do \
sleep 1; \
done
@docker compose exec -T db psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'arbret'" | grep -q 1 || \
docker compose exec -T db psql -U postgres -c "CREATE DATABASE arbret"
@docker compose exec -T db psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'arbret_test'" | grep -q 1 || \
docker compose exec -T db psql -U postgres -c "CREATE DATABASE arbret_test"
@# Create worker-specific databases for parallel test execution (pytest-xdist)
@# Create worker-specific databases for parallel backend test execution (pytest-xdist)
@for i in 0 1 2 3 4 5 6 7; do \
docker compose exec -T db psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'arbret_test_gw$$i'" | grep -q 1 || \
docker compose exec -T db psql -U postgres -c "CREATE DATABASE arbret_test_gw$$i"; \
done
@# Create separate database for e2e tests
@docker compose exec -T db psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'arbret_e2e'" | grep -q 1 || \
docker compose exec -T db psql -U postgres -c "CREATE DATABASE arbret_e2e"
@echo "PostgreSQL is ready"
db-seed: db-ready
@ -63,15 +68,27 @@ dev:
# E2E: TEST="auth" (file pattern matching e2e/*.spec.ts)
TEST ?=
test-backend: db-clean db-ready
test-backend: db-ready test-backend-clean-dbs
cd backend && uv run pytest -v -n 8 $(TEST)
# Clean only backend test databases (not e2e or main db)
test-backend-clean-dbs:
@for db in arbret_test arbret_test_gw0 arbret_test_gw1 arbret_test_gw2 arbret_test_gw3 arbret_test_gw4 arbret_test_gw5 arbret_test_gw6 arbret_test_gw7; do \
docker compose exec -T db psql -U postgres -c "DROP DATABASE IF EXISTS $$db" 2>/dev/null || true; \
docker compose exec -T db psql -U postgres -c "CREATE DATABASE $$db"; \
done
test-frontend:
cd frontend && npm run test $(if $(TEST),-- $(TEST),)
test-e2e: db-clean db-ready
test-e2e: db-ready test-e2e-clean-db
./scripts/e2e.sh $(TEST)
# Clean only e2e database (not backend test dbs or main db)
test-e2e-clean-db:
@docker compose exec -T db psql -U postgres -c "DROP DATABASE IF EXISTS arbret_e2e" 2>/dev/null || true
@docker compose exec -T db psql -U postgres -c "CREATE DATABASE arbret_e2e"
test: check-constants check-types-fresh test-backend test-frontend test-e2e
typecheck: generate-types-standalone