I want to specify a custom port from the config for the TestContainers Kafka image To be able to reuse bootstrapservers param later for the black box application testing using https://github.com/testcontainers/testcontainers-scala Kafka module Did not find an API for fixing the port while running the container, all I found is the port is dynamically assigned to the container
class KafkaSetUpSpec extends AnyFlatSpec with TestContainerForAll with Matchers {
override val containerDef: KafkaContainer.Def = KafkaContainer.Def()
import org.testcontainers.Testcontainers
//Testcontainers.exposeHostPorts(9092)
it should "return Kafka connection options for kafka container" in withContainers { kafkaContainer =>
kafkaContainer.bootstrapServers.nonEmpty shouldBe true
kafkaContainer.bootstrapServers.split(":")(2).toInt shouldBe kafkaContainer.container.getMappedPort(9093)
}
All I need is to take the connection URL from the config and fix it in the Kafka container like a port, do you have any idea how to do it? How do assign the same port from the outside world? Addition info that client not in the same network and located localy