Search code examples
javatestingapache-kafkaintegration-testingkafka-cluster

Create Kafka cluster for testing Java-based Kafka clients


I have a Kafka client and I need to test the functionalities of it. For this I need to create a Kafka Cluster locally, and connect to it. As per the limitations, I can't use a Docker image or K8s for this.

I did a search, and found This class used in testing, but I can't change the broker ports.

I tried using Debezium KafkaCluster but it fails to create the cluster intermittently, hence causes intermittent test failures.

Is there a way to create a Kafka Cluster locally, to run integration tests for java-based Kafka clients?


Solution

  • Well, the posted answers helped, but I wanted something different. Ended up creating my own implementation. If anyone wants, they can use it.

    I used kafka.server.KafkaServer and org.apache.zookeeper.server.ZooKeeperServerMain for this.