Hello everyone, I’m trying to run my Ktor integrat...
# ktor
m
Hello everyone, I’m trying to run my Ktor integration tests in parallel. They make use of Postgres running via testcontainers. To increase efficiency, my base test generates a new database (CREATE DATABASE …) with a randomized name, such that I can use a single docker container for all my integration tests. When using gradle parallelism (maxParallelForks > 1), it works (these spawn multiple JVM processes if I understood that correctly). But when using JUnit parallelism (
junit.jupiter.execution.parallel.enabled=true
+ `junit.jupiter.execution.parallel.mode.default=concurrent`; running in multiple threads), the tests affect each other: Even though each test has its own database, somehow they sometimes “see” another tests database. Is it possible that starting multiple
testApplication { … }
in the same JVM, that somehow they affect each other (for example, possibly sharing/overriding config values)? I don’t have any global variables, everything “global” is assigned to application.attributes (using
Attributes(concurrent = true)
).
a
The
testApplication
creates a new test server for each call, so there are no shared parts. Can you share the code where the new databases are created?
m
Sure, this is my base test function and an example how it is used. I’m not 100% sure its Ktors “fault”, I just want to make sure it is not. The important part is in
extendConfig
block
The config values defined above are used by the connectPostgresDB call to connect. The initial connection to create the new DB uses the default DB that is created on postgres container start.
a
I would try to reproduce the problem without Ktor involved to determine the cause.
m
Yes that is a good idea, too many variables this way.. thank you