Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 2.27 KB

File metadata and controls

55 lines (38 loc) · 2.27 KB

Elasticsearch container

This module helps running elasticsearch using Testcontainers.

Note that it's based on the official Docker image provided by elastic.

Usage example

You can start an elasticsearch container instance from any Java application by using:

HttpClient inside_block:httpClientContainer TransportClient inside_block:transportClientContainer

Note that if you are still using the TransportClient (not recommended as it is deprecated), the default cluster name is set to docker-cluster so you need to change cluster.name setting or set client.transport.ignore_cluster_name to true.

Secure your Elasticsearch cluster

The default distribution of Elasticsearch comes with the basic license which contains security feature. You can turn on security by providing a password:

HttpClient inside_block:httpClientSecuredContainer

Choose your Elasticsearch license

If you prefer to start a Docker image with the pure OSS version (which means with no security in older versions or other new and advanced features), you can use this instead:

Elasticsearch OSS inside_block:ossContainer

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

testImplementation "org.testcontainers:elasticsearch:{{latest_version}}"
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>{{latest_version}}</version>
    <scope>test</scope>
</dependency>