Skip to content
Closed
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 @@ -8,7 +8,6 @@
import java.time.Duration;

import static java.net.HttpURLConnection.HTTP_OK;
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;

/**
* Represents an elasticsearch docker instance which exposes by default port 9200 and 9300 (transport.tcp.port)
Expand Down Expand Up @@ -52,7 +51,8 @@ public ElasticsearchContainer(String dockerImageName) {
addExposedPorts(ELASTICSEARCH_DEFAULT_PORT, ELASTICSEARCH_DEFAULT_TCP_PORT);
setWaitStrategy(new HttpWaitStrategy()
.forPort(ELASTICSEARCH_DEFAULT_PORT)
.forStatusCodeMatching(response -> response == HTTP_OK || response == HTTP_UNAUTHORIZED)
.forPath("/_cluster/health")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint is probably not available either when the cluster is secured AFAIK. I don't think this can work as is IMO.
I'd let the default behavior.

But we can add this nice idea in #2321 which adds a simple withPassword() method which makes the cluster secured. There we can add

.withBasicCredentials("elastic", password)

and just check the HTTP_OK status.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct. This is what I have described in the comment as well: #2982 (comment)

(Sorry for causing confusion by keeping most of the conversation on the issue, not the pull request)

.forStatusCode(HTTP_OK)
.withStartupTimeout(Duration.ofMinutes(2)));
}

Expand Down