Add Open Index API to the high level REST client#27574
Add Open Index API to the high level REST client#27574javanna merged 5 commits intoelastic:masterfrom
Conversation
|
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
|
@elasticmachine please test this |
| */ | ||
| public final void openIndexAsync(OpenIndexRequest openIndexRequest, ActionListener<OpenIndexResponse> listener, Header... headers) { | ||
| performRequestAsyncAndParseEntity(openIndexRequest, Request::openIndex, OpenIndexResponse::fromXContent, listener, | ||
| Collections.singleton(404), headers); |
There was a problem hiding this comment.
we need these only in IndicesClient, so that users can do client.indices().openIndex() . No need to add them here too.
| OpenIndexRequest openIndexRequest = new OpenIndexRequest(indexName); | ||
| OpenIndexResponse openIndexResponse = execute(openIndexRequest, highLevelClient().indices()::openIndex, | ||
| highLevelClient().indices()::openIndexAsync); | ||
| assertTrue(openIndexResponse.isAcknowledged()); |
There was a problem hiding this comment.
maybe it would be good to close the index first using the low-level REST client, then verify that opening it actually does something?
|
|
||
| ElasticsearchException exception = expectThrows(ElasticsearchException.class, | ||
| () -> execute(openIndexRequest, highLevelClient().indices()::openIndex, highLevelClient().indices()::openIndexAsync)); | ||
| assertEquals(RestStatus.NOT_FOUND, exception.status()); |
There was a problem hiding this comment.
maybe also test the API against multiple indices?
| Map<String, String> expectedParams = new HashMap<>(); | ||
| setRandomTimeout(openIndexRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); | ||
| setRandomMasterTimeout(openIndexRequest, expectedParams); | ||
| setRandomIndicesOptions(openIndexRequest::indicesOptions, openIndexRequest::indicesOptions, expectedParams); |
There was a problem hiding this comment.
can we also add the set wait for active shards ?
| boolean humanReadable = randomBoolean(); | ||
| final XContentType xContentType = randomFrom(XContentType.values()); | ||
| BytesReference originalBytes = toShuffledXContent(openIndexResponse, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); | ||
|
|
There was a problem hiding this comment.
can you also add here an insertRandomFields step to verify forward compatibility (as we ignore any unknown fields rather than throwing errors)
| final XContentType xContentType = randomFrom(XContentType.values()); | ||
| BytesReference originalBytes = toShuffledXContent(openIndexResponse, xContentType, ToXContent.EMPTY_PARAMS, humanReadable); | ||
|
|
||
| OpenIndexResponse parsedCreateIndexResponse; |
|
@javanna thanks for the review. Ready for a second round ;) |
|
test this please |
| * See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a> | ||
| */ | ||
| public void getAsync(GetRequest getRequest, ActionListener<GetResponse> listener, Header... headers) { | ||
| public final void getAsync(GetRequest getRequest, ActionListener<GetResponse> listener, Header... headers) { |
There was a problem hiding this comment.
thank you, seems like I left this out :)
| public final void openIndexAsync(OpenIndexRequest openIndexRequest, ActionListener<OpenIndexResponse> listener, Header... headers) { | ||
| performRequestAsyncAndParseEntity(openIndexRequest, Request::openIndex, OpenIndexResponse::fromXContent, listener, emptySet(), | ||
| headers); | ||
| } |
There was a problem hiding this comment.
we don't need these two methods, they are already in IndicesClient. Can you remove them?
| return randomIndices(0, 5); | ||
| } | ||
|
|
||
| private String[] randomIndices(int minIndicesNum, int maxIndicesNum) { |
| assertEquals(RestStatus.NOT_FOUND, exception.status()); | ||
| } | ||
|
|
||
| private String[] randomIndices() { |
There was a problem hiding this comment.
maybe we can remove this method and always call the other one?
| assertTrue(openIndexResponse.isAcknowledged()); | ||
|
|
||
| for (String index : indices) { | ||
| client().performRequest("GET", index + "/_search"); |
There was a problem hiding this comment.
check that 200 was returned?
| OpenIndexRequest openIndexRequest = new OpenIndexRequest(nonExistentIndices); | ||
| ElasticsearchException exception = expectThrows(ElasticsearchException.class, | ||
| () -> execute(openIndexRequest, highLevelClient().indices()::openIndex, highLevelClient().indices()::openIndexAsync)); | ||
| assertEquals(RestStatus.NOT_FOUND, exception.status()); |
There was a problem hiding this comment.
would you mind checking also that with IndicesOptions.lenientExpandOpen we don't get back an error?
|
@javanna my bad! Ready for another round ;) |
|
test this please |
|
retest this please |
|
heya @olcbean I took the liberty to merge master in as there were conflicts and push to your remote. Running tests one last time and then merging. Thanks a lot! |
|
retest this please |
|
Thanks @javanna! |
|
sounds great @olcbean thank you! |
* master: (414 commits) Set ACK timeout on indices service test Implement byte array reusage in `NioTransport` (elastic#27696) [TEST] Remove leftover ES temp directories before Vagrant tests (elastic#27722) Cleanup split strings by comma method Remove unused import from AliasResolveRoutingIT Add read timeouts to http module (elastic#27713) Fix routing with leading or trailing whitespace remove await fix from FullClusterRestartIT.testRecovery Add missing 's' to tmpdir name (elastic#27721) [Issue-27716]: CONTRIBUTING.md IntelliJ configurations settings are confusing. (elastic#27717) [TEST] Now actually wait for merges Test out of order delivery of append only index and retry with an intermediate delete [TEST] remove code duplications in RequestTests [Tests] Add test for GeoShapeFieldType#setStrategyName (elastic#27703) Remove unused *Commit* classes (elastic#27714) Add test for writer operation buffer accounting (elastic#27707) [TEST] Wait for merging to complete before testing breaker Add Open Index API to the high level REST client (elastic#27574) Correcting some minor typos in comments Add unreleased v5.6.6 version ...
Add _open to the high level REST client Relates to #27205
Add
_opento the high level REST clientRelates to #27205