Skip to content

Commit 8f5a686

Browse files
committed
Reduce work in testBulkIndexingRequestSplitting (#145188)
No need to try and index 300 documents if we're splitting each one into its own bulk, and indeed it can take more than the allowed 10s to do so many separate bulks. With this change we sometimes try larger watermarks, and only ever try and index up to roughly twice as many docs as needed to trigger a split. Closes #144579
1 parent 57c510f commit 8f5a686

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/http/netty4/Netty4IncrementalRequestHandlingIT.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ private void assertHttpBodyLogging(Consumer<ClientContext> test) throws Exceptio
530530
}
531531

532532
public void testBulkIndexingRequestSplitting() throws Exception {
533-
final var watermarkBytes = between(100, 200);
533+
final var watermarkBytes = between(100, 2000);
534534
final var tinyNode = internalCluster().startCoordinatingOnlyNode(
535535
Settings.builder()
536536
.put(IndexingPressure.SPLIT_BULK_LOW_WATERMARK.getKey(), ByteSizeValue.ofBytes(watermarkBytes))
@@ -546,7 +546,7 @@ public void testBulkIndexingRequestSplitting() throws Exception {
546546
final var channel = clientContext.channel();
547547
channel.writeAndFlush(request);
548548

549-
final var indexName = randomIdentifier();
549+
final var indexName = randomIndexName();
550550
final var indexCreatedListener = ClusterServiceUtils.addTemporaryStateListener(
551551
cs -> Iterators.filter(
552552
cs.metadata().indicesAllProjects().iterator(),
@@ -558,13 +558,21 @@ public void testBulkIndexingRequestSplitting() throws Exception {
558558

559559
final var valueLength = between(10, 30);
560560
final var docSizeBytes = "{'field':''}".length() + valueLength;
561-
final var itemCount = between(watermarkBytes / docSizeBytes + 1, 300); // enough to split at least once
561+
final var minItemCount = watermarkBytes / docSizeBytes + 1;
562+
final var itemCount = between(minItemCount, minItemCount * 2); // enough to split at least once
562563
assertThat(itemCount * docSizeBytes, greaterThan(watermarkBytes));
563564
for (int i = 0; i < itemCount; i++) {
564565
channel.write(new DefaultHttpContent(Unpooled.wrappedBuffer(Strings.format("""
565566
{"index":{"_index":"%s"}}
566567
{"field":"%s"}
567568
""", indexName, randomAlphaOfLength(valueLength)).getBytes(StandardCharsets.UTF_8))));
569+
570+
if (i == minItemCount && randomBoolean()) {
571+
channel.flush();
572+
if (randomBoolean()) {
573+
safeAwait(indexCreatedListener);
574+
}
575+
}
568576
}
569577

570578
channel.flush();

0 commit comments

Comments
 (0)