:wave: Hi there. I'm trying to use kotest-extensio...
# kotest
b
👋 Hi there. I'm trying to use kotest-extensions-testcontainers in AnnotationSpec driven test in order to test against Kafka container. I have more or less something like this in my code:
Copy code
class 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:
Copy code
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.
@sam can you shed some light on it in a spare moment?