Class StrimziKafkaCluster

java.lang.Object
io.strimzi.test.container.StrimziKafkaCluster
All Implemented Interfaces:
KafkaContainer, AutoCloseable, org.testcontainers.lifecycle.Startable

public class StrimziKafkaCluster extends Object implements KafkaContainer
A multi-node instance of Kafka using the latest image from quay.io/strimzi/kafka with the given version. It perfectly fits for integration/system testing.
  • Method Details

    • getNodes

      public Collection<org.testcontainers.containers.GenericContainer<?>> getNodes()
      Returns the underlying GenericContainer instances for all Kafka nodes in the cluster. In the current setup, all nodes are combined-role (i.e., each acts as both broker and controller) in KRaft mode.
      Returns:
      Collection of GenericContainer representing the cluster nodes
    • getNetworkBootstrapServers

      public String getNetworkBootstrapServers()
      Get the bootstrap servers that containers on the same network should use to connect
      Returns:
      a comma separated list of Kafka bootstrap servers
    • getBootstrapServers

      public String getBootstrapServers()
      Description copied from interface: KafkaContainer
      Get the Kafka cluster bootstrap servers.
      Specified by:
      getBootstrapServers in interface KafkaContainer
      Returns:
      bootstrap servers
    • getBootstrapControllers

      public String getBootstrapControllers()
      Get the bootstrap controllers that can be used for controller operations
      Specified by:
      getBootstrapControllers in interface KafkaContainer
      Returns:
      a comma separated list of Kafka controller endpoints
    • getNetworkBootstrapControllers

      public String getNetworkBootstrapControllers()
      Get the bootstrap controllers that containers on the same network should use to connect to controllers
      Returns:
      a comma separated list of Kafka controller endpoints
    • start

      public void start()
      Specified by:
      start in interface org.testcontainers.lifecycle.Startable
    • stop

      public void stop()
      Specified by:
      stop in interface org.testcontainers.lifecycle.Startable
    • getControllers

      public Collection<KafkaContainer> getControllers()
      Returns the controller nodes. For combined-role clusters, this returns all nodes. For dedicated-role clusters, this returns only the controller-only nodes.
      Returns:
      Collection of controller nodes
    • getBrokers

      public Collection<KafkaContainer> getBrokers()
      Returns the broker nodes. For combined-role clusters, this returns all nodes. For dedicated-role clusters, this returns only the broker-only nodes. Keep the method name getBrokers() to preserve backwards compatibility.
      Returns:
      Collection of broker nodes
    • isUsingDedicatedRoles

      public boolean isUsingDedicatedRoles()
      Checks if the cluster is using dedicated controller/broker roles.
      Returns:
      true if using dedicated roles, false if using combined roles