registry icon indicating copy to clipboard operation
registry copied to clipboard

Use `testcontainers` for integration tests

Open blkt opened this issue 3 months ago • 3 comments

Currently, Makefile has targets to run Postgres which is then used in integartion tests.

It might be better to use testcontainers (example here), which has the advantage of allowing entirely isolated tests that can be executed in parallel and reduces dependency on the toolchain, simplifying automation.

blkt avatar Nov 10 '25 10:11 blkt

I'm generally supportive of moving to testcontainers. Here's a pro/con list (largely Claude's work) on migrating from the current Docker Compose approach:

Migration Trade-offs

Pros:

  • Parallel test execution - each test package can have its own isolated Postgres
  • Self-contained tests - just run go test, no external Postgres needed
  • Simpler CI/CD - no setup orchestration
  • No port conflicts or leftover databases

Cons:

  • ~2-5s startup overhead per container
  • Higher resource usage with parallel execution
  • More complex test setup code
  • Slightly harder debugging (ephemeral container logs)

Given we already have Docker everywhere, the real trade-off is startup overhead + RAM vs parallelization + simpler automation. With ~30 test files, parallel execution likely wins despite per-container overhead.

Worth prototyping to measure actual performance impact.

domdomegg avatar Nov 17 '25 14:11 domdomegg

Basically happy to approve a PR from you if:

  • it results in a major simplification in the codebase; OR
  • it's demonstrably faster / better devex, e.g. if you can show a benchmark running over the code

domdomegg avatar Nov 17 '25 14:11 domdomegg

Hey @domdomegg, thank you for your reply. I won't be able to pick this up this week, I'll try the next.

blkt avatar Nov 19 '25 13:11 blkt