#Integration tests with shared container lifecycle

3 messages · Page 1 of 1 (latest)

true prism
#

I've been working on this for 4 days and my headache is pounding.

I'm trying to find a good way to handle the lifecycle of a single shared PostgreSQL container within my test suite.

I use nextest as a test runner, this spawns 29 test processes (one per file). Currently I use a "lock file" on the filesystem, which the first test (leader) creates, following tests check for the file and re-uses the container.

The problem is cleanup, the container is lingering after the tests are finished. I'm using testcontainers to start the containers, but since I have to keep the container reference static the Drop implementation is not called, or called too late.

Anyone here that has experience with problems like this that is up to having a chat about this?

Note: I know the obvious solution is to manually manage the container lifecycle or using a wrapper script to start containers -> run tests -> stop containers. But what's the fun in that?

rapid flame
#

I know the obvious solution is to manually manage the container lifecycle or using a wrapper script to start containers -> run tests -> stop containers. But what's the fun in that?
Actually, the canonical solution is to not share stuff between tests

#

Each test gets its own instance, which it's responsible for cleaning up too