Ash FrameworkAF
Ash Framework2mo ago
4 replies
Arvind S.

Recommended Testing Setup for Postgres Schema-Based Multitenancy?

I’m curious what testing setups people have had success with when using Postgres schema-based multitenancy.

I’ve noticed my test suite getting slower as it grows, mostly because each test module creates one or more tenants in a setup block, that adds overhead pretty quickly.

Digging into this, I found some interesting discussions (Triplex Discussion and Elixir Forum Setup All Discussion) from various third-party libraries about how they’ve worked around similar performance issues.

These seem like good starting points, but I’d love to hear what has actually worked well for others:

- Do you create tenants once per test run?
- Reuse a shared tenant across multiple tests? (I'm currently going this route)
- Use connection sandboxing or transaction rollback to keep things isolated?
- Something else entirely?

Any concrete patterns, examples, or pitfalls you’ve run into would be super helpful.
GitHub
I'm trying to figure out how to incorporate Triplex into my unit tests. Right now, I have Triplex.create :test in my setup function, but this has exponentially increased the length of time it t...
Triplex.create is too slow for tests · Issue #47 · ateliware/triplex
Was this page helpful?