-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve docs for Elasticsearch 8 #8870
Merged
eddumelendez
merged 11 commits into
testcontainers:main
from
bakdata:feature/elasticsearch8-docs
Aug 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0a77fa2
Improve docs for Elasticsearch 8
philipp94831 db45ed7
Improve docs for Elasticsearch 8
philipp94831 2e2e133
Fix curly brackets
philipp94831 3b32c4f
Remove redundant test
philipp94831 efbfeea
Fix curly brackets
philipp94831 8a07e41
Fix curly brackets
philipp94831 3fa5777
Fix curly brackets
philipp94831 c02594f
Fix curly brackets
philipp94831 b0a8f2d
Fix curly brackets
philipp94831 cfc4d03
Fix curly brackets
philipp94831 50c19ce
Run spotless
philipp94831 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Improve docs for Elasticsearch 8
- Loading branch information
commit 0a77fa2e59567f7a36449d94b0fbc0c56a354cd8
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -213,6 +213,85 @@ public void restClientClusterHealth() throws IOException { | |||||
// } | ||||||
} | ||||||
|
||||||
@Test | ||||||
public void restClientClusterHealthElasticsearch8() throws IOException { | ||||||
// httpClientContainer8 { | ||||||
// Create the elasticsearch container. | ||||||
try ( | ||||||
ElasticsearchContainer container = new ElasticsearchContainer( | ||||||
"docker.elastic.co/elasticsearch/elasticsearch:8.1.2" | ||||||
) | ||||||
) { | ||||||
// Start the container. This step might take some time... | ||||||
container.start(); | ||||||
|
||||||
// Do whatever you want with the rest client ... | ||||||
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); | ||||||
credentialsProvider.setCredentials( | ||||||
AuthScope.ANY, | ||||||
new UsernamePasswordCredentials(ELASTICSEARCH_USERNAME, ELASTICSEARCH_PASSWORD) | ||||||
); | ||||||
|
||||||
client = | ||||||
RestClient | ||||||
// use HTTPS for Elasticsearch 8 | ||||||
.builder(HttpHost.create("https://" + container.getHttpHostAddress())) | ||||||
.setHttpClientConfigCallback(httpClientBuilder -> { | ||||||
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); | ||||||
// SSL is activated by default in Elasticseach 8 | ||||||
httpClientBuilder.setSSLContext(container.createSslContextFromCa()); | ||||||
return httpClientBuilder; | ||||||
}) | ||||||
.build(); | ||||||
|
||||||
Response response = client.performRequest(new Request("GET", "/_cluster/health")); | ||||||
// }} | ||||||
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); | ||||||
assertThat(EntityUtils.toString(response.getEntity())).contains("cluster_name"); | ||||||
// httpClientContainer8 {{ | ||||||
} | ||||||
// } | ||||||
} | ||||||
|
||||||
@Test | ||||||
public void restClientClusterHealthElasticsearch8WithoutSSL() throws IOException { | ||||||
// httpClientContainer8NoSSL { | ||||||
// Create the elasticsearch container. | ||||||
try ( | ||||||
ElasticsearchContainer container = new ElasticsearchContainer( | ||||||
"docker.elastic.co/elasticsearch/elasticsearch:8.1.2" | ||||||
) | ||||||
// disable SSL | ||||||
.withEnv("xpack.security.transport.ssl.enabled", "false") | ||||||
.withEnv("xpack.security.http.ssl.enabled", "false") | ||||||
) { | ||||||
// Start the container. This step might take some time... | ||||||
container.start(); | ||||||
|
||||||
// Do whatever you want with the rest client ... | ||||||
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); | ||||||
credentialsProvider.setCredentials( | ||||||
AuthScope.ANY, | ||||||
new UsernamePasswordCredentials(ELASTICSEARCH_USERNAME, ELASTICSEARCH_PASSWORD) | ||||||
); | ||||||
|
||||||
client = | ||||||
RestClient | ||||||
.builder(HttpHost.create(container.getHttpHostAddress())) | ||||||
.setHttpClientConfigCallback(httpClientBuilder -> { | ||||||
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); | ||||||
}) | ||||||
.build(); | ||||||
|
||||||
Response response = client.performRequest(new Request("GET", "/_cluster/health")); | ||||||
// }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); | ||||||
assertThat(EntityUtils.toString(response.getEntity())).contains("cluster_name"); | ||||||
// httpClientContainer8NoSSL {{ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
// } | ||||||
} | ||||||
|
||||||
@Test | ||||||
public void restClientSecuredClusterHealth() throws IOException { | ||||||
// httpClientSecuredContainer { | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line 211 it is also
{{
. Which one is correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be a single curly brace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it and it only works with a single curly brace here. Docs preview looks good to me now