neiam
/waxx
waxx
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
test: cap DB pool + ExUnit max_cases via POOL_SIZE for CI
df94c7b · gmorell · 2026-06-27 15:19
Files changed
modified
config/test.exs
+4
−1
@@ -12,7 +12,10 @@ config :waxx, Waxx.Repo,
| 12 | 12 | port: 54328, |
| 13 | 13 | database: "waxx_test#{System.get_env("MIX_TEST_PARTITION")}", |
| 14 | 14 | pool: Ecto.Adapters.SQL.Sandbox, |
| 15 | − pool_size: System.schedulers_online() * 2 | |
| 15 | + # One sandbox connection per concurrent async test. On a many-core CI runner | |
| 16 | + # this can exceed Postgres' max_connections (default 100) — cap it there with | |
| 17 | + # POOL_SIZE. test_helper.exs keeps ExUnit's max_cases in lockstep. | |
| 18 | + pool_size: String.to_integer(System.get_env("POOL_SIZE") || "#{System.schedulers_online() * 2}") | |
| 16 | 19 | |
| 17 | 20 | # We don't run a server during test. If one is required, |
| 18 | 21 | # you can enable the server option below. |
modified
test/test_helper.exs
+6
−1
@@ -1,2 +1,7 @@
| 1 | −ExUnit.start() | |
| 1 | +# Cap ExUnit's concurrency at the Repo pool size so async tests never wait on a | |
| 2 | +# sandbox connection (each owns one for its duration). Without this, the default | |
| 3 | +# `max_cases` (= cores × 2) on a many-core runner outruns a capped `POOL_SIZE`. | |
| 4 | +max_cases = Application.get_env(:waxx, Waxx.Repo)[:pool_size] | |
| 5 | + | |
| 6 | +ExUnit.start(max_cases: max_cases) | |
| 2 | 7 | Ecto.Adapters.SQL.Sandbox.mode(Waxx.Repo, :manual) |
Parents: 9532882