Kev
06/21/2025, 8:45 AM2025-06-21T10:42:16.910+02:00 WARN 74817 --- [app] [ Test worker] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Failed to validate connection org.postgresql.jdbc.PgConnection@5a0c0680 (This connection has been closed.). Possibly consider using a shorter maxLifetime value.
My base test class looks like this:
@Testcontainers
abstract class SpringBootTestBase {
companion object {
@Container
@JvmStatic
val postgres = PostgreSQLContainer<Nothing>("postgres:15").apply {
withDatabaseName("testdb")
withUsername("test")
withPassword("test")
}
@JvmStatic
@DynamicPropertySource
fun registerPgProperties(registry: DynamicPropertyRegistry) {
registry.add("spring.datasource.url", postgres::getJdbcUrl)
registry.add("spring.datasource.username", postgres::getUsername)
registry.add("spring.datasource.password", postgres::getPassword)
}
}
}
I have overridden properties for hikari. I have no special test properties either.
Any idea?Marian Schubert
06/23/2025, 12:24 PMjdbc:tc:postgresql:15:///testdb
- see https://java.testcontainers.org/modules/databases/jdbc/ it will handle setup of Postgres for youKev
06/23/2025, 12:25 PMMarian Schubert
06/23/2025, 12:25 PMKev
06/23/2025, 3:09 PM