Parallel Gradle tests have trouble finding valid Docker environment
See original GitHub issueHi,
I know about the limitations that JUnit 5 is not tested with a parallel setup and corresponding ticket https://github.com/testcontainers/testcontainers-java/issues/1495.
I’m opening this because it’s a slightly different issue (but probably the same effects). We’re not using parallel JUnit 5 tests or the testcontainers JUnit 5 extension at all, but specify ./gradlew test --parallel
to parallelize the different Gradle tasks in a multi-module setup.
We’re often getting the following messages in random modules, while the others work fine (so it’s not a general problem where all modules fail). There is even the chance that everything works fine, but the flakyness has increased lately
15:15:41.847 [Test worker] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - UnixSocketClientProviderStrategy: failed with exception TimeoutException (org.rnorth.ducttape.TimeoutException: java.util.concurrent.TimeoutException). Root cause TimeoutException (null)
15:15:41.848 [Test worker] DEBUG org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy - $XDG_RUNTIME_DIR is set but '/run/user/997/docker.sock' does not exist.
15:15:41.850 [Test worker] DEBUG org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy - '/var/lib/jenkins/.docker/run' does not exist.
15:15:41.895 [Test worker] DEBUG org.testcontainers.dockerclient.RootlessDockerClientProviderStrategy - '/run/user/997/docker.sock' does not exist.
15:15:41.961 [Test worker] INFO org.testcontainers.dockerclient.DockerMachineClientProviderStrategy - docker-machine executable was not found on PATH ([/usr/local/bin, /usr/bin, /bin, /usr/games])
15:15:41.994 [Test worker] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy - Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
15:15:41.995 [Test worker] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy - UnixSocketClientProviderStrategy: failed with exception TimeoutException (org.rnorth.ducttape.TimeoutException: java.util.concurrent.TimeoutException). Root cause TimeoutException (null)
15:15:41.996 [Test worker] ERROR org.testcontainers.dockerclient.DockerClientProviderStrategy - As no valid configuration was found, execution cannot continue
Our testcontainers part looks roughly like this in a base integration test class that the tests across modules all extend from:
private static final DockerImageName imageName = DockerImageName.parse("our-artifactory/postgres:latest")
.asCompatibleSubstituteFor("postgres");
private static final PostgreSQLContainer<?> postgresContainer = new PostgreSQLContainer<>(imageName)
.withDatabaseName("db")
.withUsername("user")
.withPassword("pass")
.withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2))
.withLogConsumer(new Slf4jLogConsumer(log));
static {
// Only use init script if resource exists
String initScript = "docker/db/init.sql";
URL resource = ScriptUtils.class.getClassLoader().getResource(initScript);
if (resource == null) {
initScript = null;
}
postgresContainer.withInitScript(initScript).start();
}
Unfortunately, I can’t share more or an example project. But any help is highly appreciated.
Cheers, Christoph
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
That particular build step takes ~12 minutes sequentially vs. roughly 6 minutes when we run it with
--parallel
, @kiview .Raising
client.ping.timeout
to 30 again solved the issue for me. Maybe the default of 30 can be brought back or this ticket can be turned into a documentation ticket.