Class S3MockContainer
-
- All Implemented Interfaces:
-
java.lang.AutoCloseable,org.testcontainers.containers.Container,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
public final class S3MockContainer extends GenericContainer<S3MockContainer>
Testcontainer for S3Mock.
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description S3MockContainer(DockerImageName dockerImageName)S3MockContainer(String tag)Create a S3MockContainer.
-
Method Summary
Modifier and Type Method Description final StringgetHttpEndpoint()final StringgetHttpsEndpoint()final IntegergetHttpServerPort()final IntegergetHttpsServerPort()final StringgetVectorsHttpEndpoint()final StringgetVectorsHttpsEndpoint()final IntegergetVectorsHttpServerPort()final IntegergetVectorsHttpsServerPort()final S3MockContainerwithRegion(String region)final S3MockContainerwithSpringProfiles(String profiles)Add one or more Spring profiles to the container's SPRING_PROFILES_ACTIVEenv var.final S3MockContainerwithVectors()Activate the vectorsSpring profile so the container serves the S3 Vectors API on vectorsHttpEndpoint / vectorsHttpsEndpoint.final S3MockContainerwithDebug()Activate the server's debugSpring profile, which raises logging to debug level and (via the server'sspring.profiles.group.debug=actuatorgrouping) also activates theactuatorprofile.final S3MockContainerwithRetainFilesOnExit(Boolean retainFilesOnExit)final S3MockContainerwithValidKmsKeys(String kmsKeys)final S3MockContainerwithInitialBuckets(String initialBuckets)final S3MockContainerwithNamedVolume(String volumeName)Mount a Docker named volume as the S3Mock store root (STORE_ROOT_MOUNT_PATH) so data persists across container restarts without running the container as root. final S3MockContainerwithVolumeAsRoot(String root)Mount a volume from the host system for the S3Mock to use as the "root". final S3MockContainerwithVolumeAsRoot(Path root)Mount a volume from the host system for the S3Mock to use as the "root". -
Methods inherited from class com.adobe.testing.s3mock.testcontainers.S3MockContainer
getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPortNumbers, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWorkingDirectory, isHostAccessible, isPrivilegedMode, isShouldBeReused, setBinds, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory -
Methods inherited from class org.testcontainers.containers.ContainerState
copyFileFromContainer, copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getMappedPort, isCreated, isHealthy, isRunning -
Methods inherited from class org.testcontainers.containers.GenericContainer
dependsOn, dependsOn, dependsOn, withAccessToHost, withCreateContainerCmdModifier, withReuse, withSharedMemorySize, withStartupAttempts, withTmpFs -
Methods inherited from class org.testcontainers.lifecycle.Startable
start, stop -
Methods inherited from class org.testcontainers.containers.Container
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFileSystemBind, addLink, followOutput, followOutput, self, setCommand, setCommand, waitingFor, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withEnv, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withStartupCheckStrategy, withStartupTimeout, withVolumesFrom, withWorkingDirectory -
Methods inherited from class java.lang.AutoCloseable
close -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
S3MockContainer
S3MockContainer(DockerImageName dockerImageName)
-
S3MockContainer
S3MockContainer(String tag)
Create a S3MockContainer.
- Parameters:
tag- in the format of "2.1.
-
-
Method Detail
-
getHttpEndpoint
final String getHttpEndpoint()
-
getHttpsEndpoint
final String getHttpsEndpoint()
-
getHttpServerPort
final Integer getHttpServerPort()
-
getHttpsServerPort
final Integer getHttpsServerPort()
-
getVectorsHttpEndpoint
final String getVectorsHttpEndpoint()
-
getVectorsHttpsEndpoint
final String getVectorsHttpsEndpoint()
-
getVectorsHttpServerPort
final Integer getVectorsHttpServerPort()
-
getVectorsHttpsServerPort
final Integer getVectorsHttpsServerPort()
-
withRegion
final S3MockContainer withRegion(String region)
-
withSpringProfiles
final S3MockContainer withSpringProfiles(String profiles)
Add one or more Spring profiles to the container's
SPRING_PROFILES_ACTIVEenv var.Profiles compose: repeated calls (and helpers such as withVectors) accumulate into a single comma-separated value rather than overwriting each other, and duplicates are ignored.
-
withVectors
final S3MockContainer withVectors()
Activate the
vectorsSpring profile so the container serves the S3 Vectors API on vectorsHttpEndpoint / vectorsHttpsEndpoint. Without this, the vectors ports are exposed but nothing listens on them.Composes with other profiles — see withSpringProfiles.
-
withDebug
final S3MockContainer withDebug()
Activate the server's
debugSpring profile, which raises logging to debug level and (via the server'sspring.profiles.group.debug=actuatorgrouping) also activates theactuatorprofile.Composes with other profiles — see withSpringProfiles.
-
withRetainFilesOnExit
final S3MockContainer withRetainFilesOnExit(Boolean retainFilesOnExit)
-
withValidKmsKeys
final S3MockContainer withValidKmsKeys(String kmsKeys)
-
withInitialBuckets
final S3MockContainer withInitialBuckets(String initialBuckets)
-
withNamedVolume
final S3MockContainer withNamedVolume(String volumeName)
Mount a Docker named volume as the S3Mock store root (STORE_ROOT_MOUNT_PATH) so data persists across container restarts without running the container as root.
The S3Mock OCI image pre-creates STORE_ROOT_MOUNT_PATH owned by the non-root
cnbuser it runs as. Docker initialises a fresh named volume with that directory's ownership, so the non-root process can write into the mounted volume — unlike a bind mount, which keeps its host ownership and therefore requires withVolumeAsRoot. Combine with withRetainFilesOnExit to keep the data after the container shuts down.Docker creates the named volume on demand if it does not exist yet. The caller owns its lifecycle (e.g. removing it afterwards).
- Parameters:
volumeName- name of the Docker named volume to mount
-
withVolumeAsRoot
final S3MockContainer withVolumeAsRoot(String root)
Mount a volume from the host system for the S3Mock to use as the "root". Docker must be able to read / write into this directory (!)
The container is forced to run as
rootfor this mount because the S3Mock OCI image is built by Cloud Native Buildpacks and runs as the non-rootcnbuser by default. On Linux, a bind-mounted host directory keeps its host ownership, so the non-root user cannot write into it and every write fails with an HTTP 500. Running asrootsidesteps the host/container UID mismatch and restores the writable behaviour of the previous root-based image.For a Docker named volume prefer withNamedVolume, which stays non-root.
- Parameters:
root- absolute path in host system
-
withVolumeAsRoot
final S3MockContainer withVolumeAsRoot(Path root)
Mount a volume from the host system for the S3Mock to use as the "root". Docker must be able to read / write into this directory (!)
- Parameters:
root- absolute path in host system
-
-
-
-