Class RedpandaContainer

java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<RedpandaContainer>
org.testcontainers.redpanda.RedpandaContainer
All Implemented Interfaces:
AutoCloseable, org.junit.rules.TestRule, org.testcontainers.containers.Container<RedpandaContainer>, org.testcontainers.containers.ContainerState, org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.containers.wait.strategy.WaitStrategyTarget, org.testcontainers.lifecycle.Startable

public class RedpandaContainer extends org.testcontainers.containers.GenericContainer<RedpandaContainer>
Testcontainers implementation for Redpanda.

Supported images: redpandadata/redpanda, docker.redpanda.com/redpandadata/redpanda

Exposed ports:

  • Broker: 9092
  • Schema Registry: 8081
  • Proxy: 8082
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.testcontainers.containers.Container

    org.testcontainers.containers.Container.ExecResult
  • Field Summary

    Fields inherited from class org.testcontainers.containers.GenericContainer

    CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategy

    Fields inherited from interface org.testcontainers.containers.ContainerState

    STATE_HEALTHY
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    RedpandaContainer(org.testcontainers.utility.DockerImageName imageName)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
    containerIsStarting(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
     
    Enables authorization.
    Enables SASL.
    Enables Http Basic Auth for Schema Registry.
    Returns the admin address.
    Returns the bootstrap servers address.
    Returns the rest proxy address.
    Returns the schema registry address.
    withListener(String listener)
    Add a listener in the format host:port.
    withListener(String listener, Supplier<String> advertisedListener)
    Add a listener in the format host:port and a Supplier for the advertised listener.
    withListener(Supplier<String> listenerSupplier)
    Deprecated.
    Register username as a superuser.

    Methods inherited from class org.testcontainers.containers.GenericContainer

    addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectory

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.testcontainers.containers.Container

    addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBind

    Methods inherited from interface org.testcontainers.containers.ContainerState

    copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning

    Methods inherited from interface org.testcontainers.lifecycle.Startable

    close
  • Constructor Details

    • RedpandaContainer

      public RedpandaContainer(String image)
    • RedpandaContainer

      public RedpandaContainer(org.testcontainers.utility.DockerImageName imageName)
  • Method Details

    • configure

      protected void configure()
      Overrides:
      configure in class org.testcontainers.containers.GenericContainer<RedpandaContainer>
    • containerIsStarting

      protected void containerIsStarting(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
      Overrides:
      containerIsStarting in class org.testcontainers.containers.GenericContainer<RedpandaContainer>
    • getBootstrapServers

      public String getBootstrapServers()
      Returns the bootstrap servers address.
      Returns:
      the bootstrap servers address
    • getSchemaRegistryAddress

      public String getSchemaRegistryAddress()
      Returns the schema registry address.
      Returns:
      the schema registry address
    • getAdminAddress

      public String getAdminAddress()
      Returns the admin address.
      Returns:
      the admin address
    • getRestProxyAddress

      public String getRestProxyAddress()
      Returns the rest proxy address.
      Returns:
      the rest proxy address
    • enableAuthorization

      public RedpandaContainer enableAuthorization()
      Enables authorization.
      Returns:
      this RedpandaContainer instance
    • enableSasl

      public RedpandaContainer enableSasl()
      Enables SASL.
      Returns:
      this RedpandaContainer instance
    • enableSchemaRegistryHttpBasicAuth

      public RedpandaContainer enableSchemaRegistryHttpBasicAuth()
      Enables Http Basic Auth for Schema Registry.
      Returns:
      this RedpandaContainer instance
    • withSuperuser

      public RedpandaContainer withSuperuser(String username)
      Register username as a superuser.
      Parameters:
      username - username to register as a superuser
      Returns:
      this RedpandaContainer instance
    • withListener

      @Deprecated public RedpandaContainer withListener(Supplier<String> listenerSupplier)
      Deprecated.
      Add a Supplier that will provide a listener with format host:port. Host will be added as a network alias.

      The listener will be added to the default listeners.

      Default listeners:

      • 0.0.0.0:9092
      • 0.0.0.0:9093

      Default advertised listeners:

      • container.getHost():container.getMappedPort(9092)
      • 127.0.0.1:9093
      Parameters:
      listenerSupplier - a supplier that will provide a listener
      Returns:
      this RedpandaContainer instance
    • withListener

      public RedpandaContainer withListener(String listener)
      Add a listener in the format host:port. Host will be included as a network alias.

      Use it to register additional connections to the Kafka broker within the same container network.

      The listener will be added to the list of default listeners.

      Default listeners:

      • 0.0.0.0:9092
      • 0.0.0.0:9093

      The listener will be added to the list of default advertised listeners.

      Default advertised listeners:

      • container.getConfig().getHostName():9092
      • container.getHost():container.getMappedPort(9093)
      Parameters:
      listener - a listener with format host:port
      Returns:
      this RedpandaContainer instance
    • withListener

      public RedpandaContainer withListener(String listener, Supplier<String> advertisedListener)
      Add a listener in the format host:port and a Supplier for the advertised listener. Host from listener will be included as a network alias.

      Use it to register additional connections to the Kafka broker from outside the container network

      The listener will be added to the list of default listeners.

      Default listeners:

      • 0.0.0.0:9092
      • 0.0.0.0:9093

      The Supplier will be added to the list of default advertised listeners.

      Default advertised listeners:

      • container.getConfig().getHostName():9092
      • container.getHost():container.getMappedPort(9093)
      Parameters:
      listener - a supplier that will provide a listener
      advertisedListener - a supplier that will provide a listener
      Returns:
      this RedpandaContainer instance