testcontainers-java: Quarkus BOM breaks Testcontainers starting with 1.16.0
Hi, I tried to update testcontainer from version 1.15.3 to 1.16.0 and my tests crashed with the following error:
java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
This is my test:
@Testcontainers
public class testContainer {
@Test
public void containerWithInitScriptShouldWork() {
Jdbi jdbi = Jdbi.create("jdbc:tc:postgis:13-3.1:///testWIthData?TC_INITSCRIPT=sql/init_sql.sql")
.installPlugin(new PostgresPlugin())
.installPlugin(new Jackson2Plugin());
List<Map<String, Object>> values = jdbi.withHandle(handle ->
handle.createQuery("select ID, LAST_NAME, FIRST_NAME from users")
.mapToMap().list());
assertEquals(1, values.size());
Map<String, Object> data = values.get(0);
assertEquals(1, data.get("id"));
assertEquals("Doe", data.get("last_name"));
assertEquals("John", data.get("first_name"));
}
}
I tried on macOS and Linux but neither worked (same for Github actions).
Application:
- Java 11
- Quarkus
- maven
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (9 by maintainers)
@bsideup Testcontainers 1.16.0 depends on docker-java 3.2.11. Testcontainers 1.15.3 depends on docker-java 3.2.8.
In the Quarkus BOM, they are in sync. In this issue, they are out of sync, because @swerky overrode the Testcontainers version (to 1.16.0), but didn’t override the docker-java version (to 3.2.11).
This is a general problem of aligning transitive dependencies. I spent countless hours on aligning dependencies (on some other product), so I totally feel your pain, but I’m not aware of a better solution – not with Maven at least. Either you stick with what Quarkus gives you, or you’re on your own. (Granted, the Quarkus BOM might be seen by some as way too large, but that’s because Quarkus is not a library, it’s a platform. That’s off-topic here, though.)
I have no idea why, but Quarkus’ BOM forces
docker-java-api
version to3.2.8
: https://repo1.maven.org/maven2/io/quarkus/quarkus-bom/2.0.3.Final/quarkus-bom-2.0.3.Final.pomThis will break your project. Consider reporting to the Quarkus team and temporary forcing
docker-java-api
anddocker-java-transport-zerodep
to the version that Testcontainers defines (3.2.11
as per https://mvnrepository.com/artifact/org.testcontainers/testcontainers/1.16.0)./cc @Ladicek who added the enforcement in https://github.com/quarkusio/quarkus/commit/11f2e68f8c0ac6627b1b0c87e5b675a6dee857f2
Ah one general recommendation for Maven, though. If you add the Maven Enforcer plugin and enable dependency convergence check, that helps a lot. Something like this:
I was hoping that people updating Testcontainers in Quarkus would notice the comment and update docker-java too. Oh well 😕
This is only the stacktrace, not the logs. Please configure your logging as per documentation.