Bartłomiej Kępa
04/15/2024, 10:20 PMclass KafkaContainerDrivenTest: AnnotationSpec() {
private val testNetwork = Network.newNetwork()
private val kafkaContainer = install(ContainerExtension(beforeStart = { println("before start")}, afterStart = { println("after start")}, container = KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:6.2.1")))) {
println("configuring")
withExposedPorts(9093)
withNetwork(testNetwork)
withNetworkAliases("kafka")
}
...
}
judging from ContainerExtension.mount()
function and std output (where I see that 'before start' and 'after start' hooks are running before 'configuring' block) how can I ensure that my Kafka container is properly configured before it gets started. Looks like container is started before its configuration lambda gets executed. I am expecting following output:
configuring
before start
after start
Please correct me if I'm wrong. I'm struggling with getting this properly configured and running in tests along with toxiproxy. I am on "io.kotest.extensions:kotest-extensions-testcontainers:2.0.2
and io.kotest:kotest-runner-junit5:5.8.1.
Bartłomiej Kępa
04/16/2024, 9:46 AMBartłomiej Kępa
04/16/2024, 9:49 AM