Repository navigation
Conversation
MySQLContainer, MariaDBContainer and MSSQLServerContainer use the default JdbcDatabaseContainer startup check, which connects over JDBC. Projects that only use R2DBC therefore still need the JDBC driver on the test classpath, and without it the container fails with a bare "Could not get Driver". - Name the driver class in the NoDriverFoundException message and say why it is needed, also when the application only uses R2DBC - Document the requirement in the R2DBC page and in the MySQL, MariaDB and MS SQL Server module pages - Add a unit test for the message that does not need Docker
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Problem
MySQLContainer,MariaDBContainerandMSSQLServerContainerdo not overridewaitUntilContainerStarted(), so they use the defaultJdbcDatabaseContainerstartup check, which opens a JDBC connection and runs the test query. A project that only uses R2DBC (testcontainers-r2dbc+r2dbc-mssql, for example) therefore still needs the JDBC driver on the test classpath. Without it, the container fails with:The driver class name only shows up in the
ClassNotFoundExceptioncause, and neitherr2dbc.mdnor the module pages mention that R2DBC users need the JDBC driver.modules/mssqlserver/build.gradlealready notes it internally (// MSSQL's wait strategy requires the JDBC driver), but it does not reach users. Related questions: #4610 / #4611, #9465 (ClickHouse, solved there by changing the wait strategy in #9466).PostgreSQL, Oracle Free and ClickHouse override the startup check, so they are not affected.
Changes
JdbcDatabaseContainer.getJdbcDriverInstance(): theNoDriverFoundExceptionmessage now names the driver class and explains why it is required, also for R2DBC-only applications. The message still starts withCould not get Driver.MissingJdbcDriverTest.shouldNameTheMissingDriverClass: asserts the new message; it callsgetJdbcDriverInstance()directly, so it does not need Docker.r2dbc.mdand one sentence in the existing driver hint ofmysql.md,mariadb.mdandmssqlserver.md.No behavior change; the wait strategy is untouched (changing it for MSSQL looked riskier, and #12080 is moving PostgreSQL in the opposite direction).
Verification
./gradlew :testcontainers-jdbc:test --tests org.testcontainers.jdbc.MissingJdbcDriverTest.shouldNameTheMissingDriverClass: green./gradlew :testcontainers-jdbc:spotlessCheck :testcontainers-jdbc:compileTestJava :testcontainers-r2dbc:compileTestJava: greenshouldFailFastIfNoDriverFoundonly asserts the root cause type, which is unchanged.Summary by CodeRabbit