Class OpenSearchContainer<SELF extends OpenSearchContainer<SELF>>

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

public class OpenSearchContainer<SELF extends OpenSearchContainer<SELF>> extends org.testcontainers.containers.GenericContainer<SELF>
The OpenSearch Docker container (single node cluster) which exposes by default ports 9200 (http/https) and 9300 (tcp, deprecated).
  • 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
    OpenSearchContainer(String dockerImageName)
    Create an OpenSearch Container by passing the full docker image name.
    OpenSearchContainer(org.testcontainers.utility.DockerImageName dockerImageName)
    Create an OpenSearch Container (with security plugin enabled) by passing the full docker image name.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    Return HTTP(s) host and port to connect to OpenSearch container.
    Return password to connect to OpenSearch container (if security plugin is enabled)
    Deprecated.
    Return user name to connect to OpenSearch container (if security plugin is enabled)
    boolean
    Check if security plugin was enabled or not for this container
    Should the security plugin be enabled or stay disabled (default value).

    Methods inherited from class org.testcontainers.containers.GenericContainer

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

    • OpenSearchContainer

      public OpenSearchContainer(String dockerImageName)
      Create an OpenSearch Container by passing the full docker image name.
      Parameters:
      dockerImageName - Full docker image name as a String, like: opensearchproject/opensearch:1.2.4 opensearchproject/opensearch:1.3.1 opensearchproject/opensearch:2.0.0
    • OpenSearchContainer

      public OpenSearchContainer(org.testcontainers.utility.DockerImageName dockerImageName)
      Create an OpenSearch Container (with security plugin enabled) by passing the full docker image name.
      Parameters:
      dockerImageName - Full docker image name as a DockerImageName, like: DockerImageName.parse("opensearchproject/opensearch:1.2.4") DockerImageName.parse("opensearchproject/opensearch:1.3.1") DockerImageName.parse("opensearchproject/opensearch:2.0.0")
  • Method Details

    • withSecurityEnabled

      public SELF withSecurityEnabled()
      Should the security plugin be enabled or stay disabled (default value). If the security plugin is enabled, HTTPS protocol is going to be used along with the default username / password.
      Returns:
      this container instance
    • configure

      protected void configure()
      Overrides:
      configure in class org.testcontainers.containers.GenericContainer<SELF extends OpenSearchContainer<SELF>>
    • getHttpHostAddress

      public String getHttpHostAddress()
      Return HTTP(s) host and port to connect to OpenSearch container.
      Returns:
      HTTP(s) host and port (in a form of "host:port")
    • isSecurityEnabled

      public boolean isSecurityEnabled()
      Check if security plugin was enabled or not for this container
      Returns:
      "true" if if security plugin was enabled for this container, "false" otherwise
    • getTcpHost

      @Deprecated public InetSocketAddress getTcpHost()
      Deprecated.
      Return socket address to connect to OpenSearch over TCP. The TransportClient will is deprecated and may be removed in future versions.
      Returns:
      TCP socket address
    • getUsername

      public String getUsername()
      Return user name to connect to OpenSearch container (if security plugin is enabled)
      Returns:
      user name to connect to OpenSearch container
    • getPassword

      public String getPassword()
      Return password to connect to OpenSearch container (if security plugin is enabled)
      Returns:
      password to connect to OpenSearch container