Tests: fix testBulkProcessorConcurrentRequestsReadOnlyIndex (#64633) (#64657)

Executing a MultiGetRequest with no items will fail. This makes sure there
is always at least one item in the request.

(cherry picked from commit bd4703250fe331296b8613b277ea25c8bef1dcd9)
Signed-off-by: Andrei Dan <andrei.dan@elastic.co>
This commit is contained in:
Andrei Dan 2020-11-06 09:10:51 +00:00 committed by GitHub
parent dbdaab5a07
commit 460c1364c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -248,7 +248,8 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase {
.setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)).build()) {
for (int i = 1; i <= numDocs; i++) {
if (randomBoolean()) {
// let's make sure we get at least 1 item in the MultiGetRequest regardless of the randomising roulette
if (randomBoolean() || multiGetRequest.getItems().size() == 0) {
testDocs++;
processor.add(new IndexRequest("test").id(Integer.toString(testDocs))
.source(XContentType.JSON, "field", "value"));