Package org.testcontainers.elasticsearch
Class ElasticsearchContainer
java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<ElasticsearchContainer>
org.testcontainers.elasticsearch.ElasticsearchContainer
- All Implemented Interfaces:
AutoCloseable,org.junit.rules.TestRule,org.testcontainers.containers.Container<ElasticsearchContainer>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
public class ElasticsearchContainer
extends org.testcontainers.containers.GenericContainer<ElasticsearchContainer>
Testcontainers implementation for Elasticsearch.
Supported image: docker.elastic.co/elasticsearch/elasticsearch, elasticsearch
Exposed ports:
- HTTP: 9200
- TCP Transport: 9300
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.testcontainers.containers.Container
org.testcontainers.containers.Container.ExecResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringDeprecated.static final StringElasticsearch Default Password for Elasticsearch >= 8Fields inherited from class org.testcontainers.containers.GenericContainer
CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategyFields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.ElasticsearchContainer(String dockerImageName) Create an Elasticsearch Container by passing the full docker image nameElasticsearchContainer(org.testcontainers.utility.DockerImageName dockerImageName) Create an Elasticsearch Container by passing the full docker image name -
Method Summary
Modifier and TypeMethodDescriptionOptional<byte[]>If this is running above Elasticsearch 8, this will return the probably self-signed CA cert that has been extractedA SSL context based on the self-signed CA, so that using this SSL Context allows to connect to the Elasticsearch serviceDeprecated.withCertPath(String certPath) Configure a CA cert path that is not the defaultwithPassword(String password) Define the Elasticsearch password to set.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, withWorkingDirectoryMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.testcontainers.containers.Container
addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindMethods 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, isRunningMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Field Details
-
ELASTICSEARCH_DEFAULT_PASSWORD
Elasticsearch Default Password for Elasticsearch >= 8- See Also:
-
DEFAULT_TAG
Deprecated.Elasticsearch Default version- See Also:
-
-
Constructor Details
-
ElasticsearchContainer
Deprecated.useElasticsearchContainer(DockerImageName)instead -
ElasticsearchContainer
Create an Elasticsearch Container by passing the full docker image name- Parameters:
dockerImageName- Full docker image name as aString, like: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
-
ElasticsearchContainer
public ElasticsearchContainer(org.testcontainers.utility.DockerImageName dockerImageName) Create an Elasticsearch Container by passing the full docker image name- Parameters:
dockerImageName- Full docker image name as aDockerImageName, like: DockerImageName.parse("docker.elastic.co/elasticsearch/elasticsearch:7.9.2")
-
-
Method Details
-
caCertAsBytes
If this is running above Elasticsearch 8, this will return the probably self-signed CA cert that has been extracted- Returns:
- byte array optional containing the CA cert extracted from the docker container
-
createSslContextFromCa
A SSL context based on the self-signed CA, so that using this SSL Context allows to connect to the Elasticsearch service- Returns:
- a customized SSL Context
-
withPassword
Define the Elasticsearch password to set. It enables security behind the scene for major version below 8.0.0. It's not possible to use security with the oss image.- Parameters:
password- Password to set- Returns:
- this
-
withCertPath
Configure a CA cert path that is not the default- Parameters:
certPath- Path to the CA certificate within the Docker container to extract it from after start up- Returns:
- this
-
getHttpHostAddress
-
getTcpHost
Deprecated.
-
ElasticsearchContainer(DockerImageName)instead