Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* Testcontainers implementation for Elasticsearch.
* <p>
* Supported image: {@code docker.elastic.co/elasticsearch/elasticsearch}
* Supported image: {@code docker.elastic.co/elasticsearch/elasticsearch}, {@code elasticsearch}
* <p>
* Exposed ports:
* <ul>
Expand Down Expand Up @@ -64,6 +64,8 @@ public class ElasticsearchContainer extends GenericContainer<ElasticsearchContai
"docker.elastic.co/elasticsearch/elasticsearch-oss"
);

private static final DockerImageName ELASTICSEARCH_IMAGE_NAME = DockerImageName.parse("elasticsearch");

/**
* Elasticsearch Default version
*/
Expand Down Expand Up @@ -100,7 +102,7 @@ public ElasticsearchContainer(String dockerImageName) {
*/
public ElasticsearchContainer(final DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, DEFAULT_OSS_IMAGE_NAME);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, DEFAULT_OSS_IMAGE_NAME, ELASTICSEARCH_IMAGE_NAME);
this.isOss = dockerImageName.isCompatibleWith(DEFAULT_OSS_IMAGE_NAME);

withNetworkAliases("elasticsearch-" + Base58.randomString(6));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,16 @@ public void testElasticsearch8SecureByDefault() throws Exception {
// Start the container. This step might take some time...
container.start();

Response response = getClusterHealth(container);
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
assertThat(EntityUtils.toString(response.getEntity())).contains("cluster_name");
assertClusterHealthResponse(container);
}
}

@Test
public void testDockerHubElasticsearch8ImageSecureByDefault() throws Exception {
try (ElasticsearchContainer container = new ElasticsearchContainer("elasticsearch:8.1.2")) {
container.start();

assertClusterHealthResponse(container);
}
}

Expand Down Expand Up @@ -351,9 +358,7 @@ public void testElasticsearch8SecureByDefaultHttpWaitStrategy() throws Exception
// Start the container. This step might take some time...
container.start();

Response response = getClusterHealth(container);
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
assertThat(EntityUtils.toString(response.getEntity())).contains("cluster_name");
assertClusterHealthResponse(container);
}
}

Expand Down Expand Up @@ -488,4 +493,10 @@ private void assertElasticsearchContainerHasHeapSize(ElasticsearchContainer cont
assertThat(responseBody).contains("\"heap_init_in_bytes\":" + heapSizeInBytes);
assertThat(responseBody).contains("\"heap_max_in_bytes\":" + heapSizeInBytes);
}

private void assertClusterHealthResponse(ElasticsearchContainer container) throws IOException {
Response response = getClusterHealth(container);
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
assertThat(EntityUtils.toString(response.getEntity())).contains("cluster_name");
}
}