Kev
05/29/2024, 8:42 AMclass PostgreSQL : PostgreSQLContainer<PostgreSQL>("postgres:latest") {
init {
println("waiting for postgres")
waitingFor(Wait.forListeningPorts())
println("finished waiting for postgres: running=${this.isRunning}")
}
}
It passes the waitingFor but the container returns false for isRunning. Am I missing something?mudasar187
05/29/2024, 10:45 AMobject PostgresListener : TestListener {
private val container =
GenericContainer("postgres:16-alpine")
.withExposedPorts(5432)
.withEnv("POSTGRES_DB", PropertiesConfig.PostgresProperties().databaseName)
.withEnv("POSTGRES_USER", PropertiesConfig.PostgresProperties().adminUser)
.withEnv("POSTGRES_PASSWORD", "postgres")
.withCreateContainerCmdModifier { cmd ->
cmd.hostConfig!!.withPortBindings(PortBinding(Ports.Binding.bindPort(5432), ExposedPort(5432)))
}
.waitingFor(Wait.forLogMessage(".*ready to accept connections*\\n", 1))
val dataSource: HikariDataSource by lazy {
DatabaseConfig.postgresDataSource(DatabaseTestConfig.hikariPostgresConfig(container.host))
}
override suspend fun beforeTest(testCase: TestCase) {
container.start()
DatabaseConfig.postgresMigrate(dataSource)
}
override suspend fun afterTest(
testCase: TestCase,
result: TestResult,
) {
container.stop()
}
}
mudasar187
05/29/2024, 10:45 AM.waitingFor(Wait.forLogMessage(".*ready to accept connections*\\n", 1))
because otherwise it wont know when the container is up and runningKev
05/29/2024, 10:49 AMmudasar187
05/29/2024, 10:51 AMMervyn McCreight
05/29/2024, 9:38 PM