Just ran into a very confusing situation where I would have saved a good amount of time if the database container classes produced better diagnostic messages. Only about a third of the following concerns the library, but I'll briefly give all the context:
- I added a runtime dependency to the PostgreSQL JDBC drivers to my project's
build.gradle;
- I forgot to click on the IntelliJ button to refresh the configuration, so IntelliJ did not place the driver into my classpath;
- My unit test using the
PostgreSQLContainer class failed with an error saying that it timed out waiting for the database port to become available.
The problem, as I understood it, is in this line of code (though maybe elsewhere as well):
|
return Unreliables.retryUntilSuccess(60, TimeUnit.SECONDS, () -> getJdbcDriverInstance().connect(url, info)); |
If this fails with a ClassNotFoundException it will continue retrying the connection and when the timer runs out falsely report that we timed out attempting to connect. The problem is that only some exceptions in connection attempts (e.g., IOException or perhaps SQLException) should lead to a retry—others (like ClassNotFoundException) should lead to an immediate abort and report of the exception that caused the failure.
It might be rather tricky to figure out which exceptions fall into which category, however, given how so much of this might vary between different vendors' JDBC drivers.
(Version of testcontainers: 1.1.6.)
Just ran into a very confusing situation where I would have saved a good amount of time if the database container classes produced better diagnostic messages. Only about a third of the following concerns the library, but I'll briefly give all the context:
build.gradle;PostgreSQLContainerclass failed with an error saying that it timed out waiting for the database port to become available.The problem, as I understood it, is in this line of code (though maybe elsewhere as well):
testcontainers-java/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java
Line 120 in f436842
If this fails with a
ClassNotFoundExceptionit will continue retrying the connection and when the timer runs out falsely report that we timed out attempting to connect. The problem is that only some exceptions in connection attempts (e.g.,IOExceptionor perhapsSQLException) should lead to a retry—others (likeClassNotFoundException) should lead to an immediate abort and report of the exception that caused the failure.It might be rather tricky to figure out which exceptions fall into which category, however, given how so much of this might vary between different vendors' JDBC drivers.
(Version of testcontainers: 1.1.6.)