-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Incremental bulk integration with rest layer #112154
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
Tim-Brooks
merged 27 commits into
elastic:partial-rest-requests
from
Tim-Brooks:incremental_bulk_rest
Aug 30, 2024
Merged
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b5a4054
Incremental bulk integration with rest layer
Tim-Brooks a75b31d
Change
Tim-Brooks 4063a91
Merge remote-tracking branch 'origin/partial-rest-requests' into incr…
Tim-Brooks e26df4a
Header
Tim-Brooks fbfcbb5
Change
Tim-Brooks 3c8d8c0
Try_no_split
Tim-Brooks 2b3bcd5
Change
Tim-Brooks 1011086
Changes
Tim-Brooks 247efaf
Change
Tim-Brooks 861c27f
Changes
Tim-Brooks d3bbac1
Changes
Tim-Brooks 1bdb92d
Change
Tim-Brooks 6fa8109
More changes
Tim-Brooks c007b5a
Change
Tim-Brooks 74d69cf
More
Tim-Brooks 13ef3f5
Fix
Tim-Brooks b303cc7
Change
Tim-Brooks 0b9362e
Merge remote-tracking branch 'origin/partial-rest-requests' into incr…
Tim-Brooks 4b3aab5
Fix
Tim-Brooks aba3eb3
Fixes
Tim-Brooks 16cfc81
Merge remote-tracking branch 'origin/partial-rest-requests' into incr…
Tim-Brooks 89c76d8
Merge branch 'partial-rest-requests' into incremental_bulk_rest
Tim-Brooks 3dc16ce
Awaits fix
Tim-Brooks 9236611
Merge branch 'partial-rest-requests' into incremental_bulk_rest
Tim-Brooks 4c1b20c
Fix
Tim-Brooks 321377a
Fixes
Tim-Brooks b5308c3
Fix
Tim-Brooks 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
96 changes: 96 additions & 0 deletions
96
qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/IncrementalBulkRestIT.java
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 |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| package org.elasticsearch.http; | ||
|
|
||
| import org.elasticsearch.client.Request; | ||
| import org.elasticsearch.client.Response; | ||
| import org.elasticsearch.client.ResponseException; | ||
| import org.elasticsearch.common.xcontent.XContentHelper; | ||
| import org.elasticsearch.test.ESIntegTestCase; | ||
| import org.elasticsearch.xcontent.json.JsonXContent; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import static org.elasticsearch.rest.RestStatus.OK; | ||
| import static org.hamcrest.Matchers.equalTo; | ||
|
|
||
| @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, supportsDedicatedMasters = false, numDataNodes = 2, numClientNodes = 0) | ||
| public class IncrementalBulkRestIT extends HttpSmokeTestCase { | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| public void testIncrementalBulk() throws IOException { | ||
| Request createRequest = new Request("PUT", "/index_name"); | ||
| createRequest.setJsonEntity(""" | ||
| { | ||
| "settings": { | ||
| "index": { | ||
| "number_of_shards": 1, | ||
| "number_of_replicas": 1, | ||
| "write.wait_for_active_shards": 2 | ||
| } | ||
| } | ||
| }"""); | ||
| final Response indexCreatedResponse = getRestClient().performRequest(createRequest); | ||
| assertThat(indexCreatedResponse.getStatusLine().getStatusCode(), equalTo(OK.getStatus())); | ||
|
|
||
| Request successfulIndexingRequest = new Request("POST", "/index_name/_bulk"); | ||
|
|
||
| // index documents for the rollup job | ||
| final StringBuilder bulk = new StringBuilder(); | ||
| for (int i = 0; i < 1000; i++) { | ||
| bulk.append("{\"index\":{\"_index\":\"index_name\"}}\n"); | ||
| bulk.append("{\"field\":").append(i).append("}\n"); | ||
| } | ||
| bulk.append("\r\n"); | ||
|
|
||
| successfulIndexingRequest.setJsonEntity(bulk.toString()); | ||
|
|
||
| final Response indexSuccessFul = getRestClient().performRequest(successfulIndexingRequest); | ||
| assertThat(indexSuccessFul.getStatusLine().getStatusCode(), equalTo(OK.getStatus())); | ||
| Map<String, Object> responseMap = XContentHelper.convertToMap( | ||
| JsonXContent.jsonXContent, | ||
| indexSuccessFul.getEntity().getContent(), | ||
| true | ||
| ); | ||
|
|
||
| assertFalse((Boolean) responseMap.get("errors")); | ||
| assertThat(((List<Object>) responseMap.get("items")).size(), equalTo(1000)); | ||
| } | ||
|
|
||
| public void testIncrementalMalformed() throws IOException { | ||
| Request createRequest = new Request("PUT", "/index_name"); | ||
| createRequest.setJsonEntity(""" | ||
| { | ||
| "settings": { | ||
| "index": { | ||
| "number_of_shards": 1, | ||
| "number_of_replicas": 1, | ||
| "write.wait_for_active_shards": 2 | ||
| } | ||
| } | ||
| }"""); | ||
| final Response indexCreatedResponse = getRestClient().performRequest(createRequest); | ||
| assertThat(indexCreatedResponse.getStatusLine().getStatusCode(), equalTo(OK.getStatus())); | ||
|
|
||
| Request bulkRequest = new Request("POST", "/index_name/_bulk"); | ||
|
|
||
| // index documents for the rollup job | ||
| final StringBuilder bulk = new StringBuilder(); | ||
| bulk.append("{\"index\":{\"_index\":\"index_name\"}}\n"); | ||
| bulk.append("{\"field\":1}\n"); | ||
| bulk.append("{}\n"); | ||
| bulk.append("\r\n"); | ||
|
|
||
| bulkRequest.setJsonEntity(bulk.toString()); | ||
|
|
||
| expectThrows(ResponseException.class, () -> getRestClient().performRequest(bulkRequest)); | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.