-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Test: Only sniff host metadata for node_selectors #32750
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6fc5e13
Test: Only sniff host metadata for node_selectors
nik9000 0e5b135
Merge branch '6.x' into no_sniff
nik9000 c43f800
Checkstyle
nik9000 b794e0c
Merge branch '6.x' into no_sniff
nik9000 475a74c
Renames
nik9000 d4a80db
Merge branch '6.x' into no_sniff
nik9000 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
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| import org.elasticsearch.client.Response; | ||
| import org.elasticsearch.client.ResponseException; | ||
| import org.elasticsearch.client.RestClient; | ||
| import org.elasticsearch.client.RestClientBuilder; | ||
| import org.elasticsearch.client.sniff.ElasticsearchNodesSniffer; | ||
| import org.elasticsearch.common.Strings; | ||
| import org.elasticsearch.common.collect.Tuple; | ||
|
|
@@ -58,13 +59,6 @@ | |
| /** | ||
| * Runs a suite of yaml tests shared with all the official Elasticsearch | ||
| * clients against against an elasticsearch cluster. | ||
| * <p> | ||
| * <strong>IMPORTANT</strong>: These tests sniff the cluster for metadata | ||
| * and hosts on startup and replace the list of hosts that they are | ||
| * configured to use with the list sniffed from the cluster. So you can't | ||
| * control which nodes receive the request by providing the right list of | ||
| * nodes in the <code>tests.rest.cluster</code> system property. Instead | ||
| * the tests must explictly use `node_selector`s. | ||
| */ | ||
| public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase { | ||
|
|
||
|
|
@@ -116,11 +110,6 @@ protected ESClientYamlSuiteTestCase(ClientYamlTestCandidate testCandidate) { | |
| @Before | ||
| public void initAndResetContext() throws Exception { | ||
| if (restTestExecutionContext == null) { | ||
| // Sniff host metadata in case we need it in the yaml tests | ||
| List<Node> nodesWithMetadata = sniffHostMetadata(); | ||
| client().setNodes(nodesWithMetadata); | ||
| adminClient().setNodes(nodesWithMetadata); | ||
|
|
||
| assert adminExecutionContext == null; | ||
| assert blacklistPathMatchers == null; | ||
| ClientYamlSuiteRestSpec restSpec = ClientYamlSuiteRestSpec.load(SPEC_PATH); | ||
|
|
@@ -172,8 +161,7 @@ protected ClientYamlTestClient initClientYamlTestClient( | |
| final RestClient restClient, | ||
| final List<HttpHost> hosts, | ||
| final Version esVersion) { | ||
| return new ClientYamlTestClient(restSpec, restClient, hosts, esVersion, | ||
| restClientBuilder -> configureClient(restClientBuilder, restClientSettings())); | ||
| return new ClientYamlTestClient(restSpec, restClient, hosts, esVersion, this::sniffHostMetadata); | ||
| } | ||
|
|
||
| @AfterClass | ||
|
|
@@ -407,13 +395,16 @@ protected boolean randomizeContentType() { | |
| } | ||
|
|
||
| /** | ||
| * Sniff the cluster for host metadata. | ||
| * Sniff the cluster for host metadata and return a | ||
| * {@link RestClientBuilder} for a client with that metadata. | ||
| */ | ||
| private List<Node> sniffHostMetadata() throws IOException { | ||
| protected final RestClientBuilder sniffHostMetadata() throws IOException { | ||
|
||
| ElasticsearchNodesSniffer.Scheme scheme = | ||
| ElasticsearchNodesSniffer.Scheme.valueOf(getProtocol().toUpperCase(Locale.ROOT)); | ||
| ElasticsearchNodesSniffer sniffer = new ElasticsearchNodesSniffer( | ||
| adminClient(), ElasticsearchNodesSniffer.DEFAULT_SNIFF_REQUEST_TIMEOUT, scheme); | ||
| return sniffer.sniff(); | ||
| RestClientBuilder builder = RestClient.builder(sniffer.sniff().toArray(new Node[0])); | ||
| configureClient(builder, restClientSettings()); | ||
| return builder; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
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.
can we rename the instance member and corresponding arguments to something like clientBuilderSupplier or clientBuilderWithSniffedNodes?
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.
Sounds good to me!