diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index 9b101322493..942c3f7bfd7 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -202,6 +202,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase * Maximum number of async operations that indexRandom will kick off at one time. */ private static final int MAX_IN_FLIGHT_ASYNC_INDEXES = 150; + /** * Maximum number of documents in a single bulk index request. */ @@ -1219,8 +1220,10 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase } } } else { - logger.info("Index [{}] docs async: [{}] bulk: [{}]", builders.size(), false, true); - for (List segmented : Lists.partition(builders, between(MAX_BULK_INDEX_REQUEST_SIZE / 2, MAX_BULK_INDEX_REQUEST_SIZE))) { + List> partition = Lists.partition(builders, Math.min(MAX_BULK_INDEX_REQUEST_SIZE, + Math.max(1, (int) (builders.size() * randomDouble())))); + logger.info("Index [{}] docs async: [{}] bulk: [{}] partitions [{}]", builders.size(), false, true, partition.size()); + for (List segmented : partition) { BulkRequestBuilder bulkBuilder = client().prepareBulk(); for (IndexRequestBuilder indexRequestBuilder : segmented) { bulkBuilder.add(indexRequestBuilder);