Class MinioContainer

java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<MinioContainer>
io.camunda.zeebe.qa.util.testcontainers.MinioContainer
All Implemented Interfaces:
AutoCloseable, org.junit.rules.TestRule, org.testcontainers.containers.Container<MinioContainer>, org.testcontainers.containers.ContainerState, org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.containers.wait.strategy.WaitStrategyTarget, org.testcontainers.lifecycle.Startable

public final class MinioContainer extends org.testcontainers.containers.GenericContainer<MinioContainer>
Minio is a S3 compatible high performance object storage. See their official page for more.

We use it primarily to test compatibility with our S3 backup store, as it's lightweight and popular.

When using this, keep in mind that you will need to add a network alias per bucket that you want to create. You should use withDomain(String, String...) for this, and read the method's documentation.

In most cases, it's expected you will configure the domain as above.

  • 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
    Creates a default container with a pinned image version.
    Creates a new container with the specific image version.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the configured Minio access key.
    org.testcontainers.containers.wait.strategy.WaitStrategy
     
    Returns the S3 accessible endpoint for a client running on the host machine.
    Returns the internal endpoint, i.e.
    Returns the configured Minio region.
    Returns the configured Minio secret key.
    withDomain(String domain, String... buckets)
    Configures Minio to use the specific domain as its internal hostname and virtual wild card host, allowing subdomain access for buckets.

    Methods inherited from class org.testcontainers.containers.GenericContainer

    addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, 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

    • MinioContainer

      public MinioContainer()
      Creates a default container with a pinned image version. It's unlikely we ever need to change this.
    • MinioContainer

      public MinioContainer(String version)
      Creates a new container with the specific image version.
      Parameters:
      version - the minio version to use
  • Method Details

    • defaultWaitStrategy

      public org.testcontainers.containers.wait.strategy.WaitStrategy defaultWaitStrategy()
    • externalEndpoint

      public String externalEndpoint()
      Returns the S3 accessible endpoint for a client running on the host machine. Note that this may use a hostname. If you wish to use path-style access (e.g. you don't know your buckets beforehand), then you can format the endpoint yourself using 127.0.0.1 as the IP address instead of the host.

      NOTE: if this is a common use case, we can add a method here that does so.

    • internalEndpoint

      public String internalEndpoint()
      Returns the internal endpoint, i.e. the S3 accessible endpoint used when your client is running in a container in the same network as this one. If you wish to use path-style access (e.g. you don't know your buckets beforehand), then you can format the endpoint yourself using the container's internal IP address. You can fetch that by inspecting the container via GenericContainer.getContainerInfo() and checking the network settings for the IP address.

      NOTE: if this is a common use case, we can add a method here that does so.

    • region

      public String region()
      Returns the configured Minio region. You can pass this to your S3 client builder.
    • accessKey

      public String accessKey()
      Returns the configured Minio access key. You can pass this to your S3 client builder.
    • secretKey

      public String secretKey()
      Returns the configured Minio secret key. You can pass this to your S3 client builder.
    • withDomain

      public MinioContainer withDomain(String domain, String... buckets)
      Configures Minio to use the specific domain as its internal hostname and virtual wild card host, allowing subdomain access for buckets. In order for the bucket subdomain to be resolvable, you must provide them here, so they can be added as routes to the network.

      So if you pass, say, minio.local, and two buckets called bucketA and bucketB, you can access the following domains: http://minio.local, http://bucketA.minio.local, and http://bucketB.minio.local. This is the default operating mode for an S3 client.

      If you do not know your bucket names in advance, then you will need to find to use the container's IP address as the endpoint; this will force your client to use the path-style access to access your buckets.

      Parameters:
      domain - the root domain accessible from the container's network
      buckets - a list of bucket names which will be added as subdomains for the root domain
      Returns:
      this container for chaining