compose.test.yaml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Test-only shared services for the compose-first integration harness.
  2. #
  3. # Starts ONE Postgres + ONE Redis shared by every test process. Per-test
  4. # isolation comes from the harness itself (fresh `CREATE DATABASE` per test,
  5. # unique Redis key prefixes per test) — never from per-test containers, and
  6. # never via FLUSHALL/FLUSHDB (nextest runs tests in parallel processes).
  7. #
  8. # Credentials and ports match the harness defaults exactly
  9. # (`D_OAUTH_TEST_POSTGRES_URL` / `D_OAUTH_TEST_REDIS_URL` overrides in
  10. # `tests/common/mod.rs`):
  11. #
  12. # docker compose -f compose.test.yaml up -d
  13. # cargo nextest run -E 'test(migration_users_creates_schema_and_second_run_is_noop)'
  14. # docker compose -f compose.test.yaml down -v
  15. #
  16. # Ports 5433/6380 avoid clashing with a developer's local 5432/6379.
  17. # This file is test-only; the local proof deployment stays in `compose.yaml`.
  18. #
  19. # `testcontainers` remains only for suites that need Redis nodes of their own:
  20. # the stop/start lifecycle, Sentinel/Cluster topology, the `--appendfsync always`
  21. # durability suites, and the private-container Redis flush test. Every other
  22. # unit and integration suite uses these shared services.
  23. #
  24. # `test-db` runs with `max_connections=500`: the shared server now backs many
  25. # parallel per-suite databases (one nextest process per CPU, each test holding
  26. # a max-4 pool), so the default 100 is too low. 500 is the floor for high-core
  27. # CI; hosts above ~125 logical CPUs need `max(500, 4*nproc + margin)`.
  28. #
  29. # The same concentration raised aggregate Postgres parallel-worker DSM
  30. # pressure: the Docker `/dev/shm` default is 64 MB and hit 95% full,
  31. # producing `could not resize shared memory segment` (SQLSTATE 53100) flakes.
  32. # So `shm_size` is pinned to 1 GB and parallel gather is disabled
  33. # (`max_parallel_workers_per_gather=0`); a test server does not need parallel
  34. # query, and this removes the DSM/`/dev/shm` allocation entirely.
  35. name: d-oauth-test
  36. services:
  37. test-db:
  38. image: postgres:18-alpine
  39. command: ["postgres", "-c", "max_connections=500", "-c", "max_parallel_workers_per_gather=0"]
  40. shm_size: 1gb
  41. environment:
  42. POSTGRES_PASSWORD: oauth-test-only
  43. ports:
  44. - "5433:5432"
  45. healthcheck:
  46. test: ["CMD-SHELL", "pg_isready -U postgres"]
  47. interval: 5s
  48. timeout: 3s
  49. retries: 20
  50. test-redis:
  51. image: redis:8-alpine
  52. # Mirrors the server's durability contract: AOF on, eviction off.
  53. command: ["redis-server", "--appendonly", "yes", "--maxmemory-policy", "noeviction"]
  54. ports:
  55. - "6380:6379"
  56. healthcheck:
  57. test: ["CMD", "redis-cli", "ping"]
  58. interval: 5s
  59. timeout: 3s
  60. retries: 20