diff --git a/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java b/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java index 893acbd22cc23..8ae9db4c904c9 100644 --- a/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java +++ b/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java @@ -884,8 +884,17 @@ private void initManyBigFieldsIndex(int docs, String type) throws IOException { } private void initGiantTextField(int docs) throws IOException { - logger.info("loading many documents with one big text field"); - int docsPerBulk = 3; + int docsPerBulk = 10; + for (Map nodeInfo : getNodesInfo(adminClient()).values()) { + for (Object module : (List) nodeInfo.get("modules")) { + Map moduleInfo = (Map) module; + final String moduleName = moduleInfo.get("name").toString(); + if (moduleName.startsWith("serverless-")) { + docsPerBulk = 3; + } + } + } + logger.info("loading many documents with one big text field - docs per bulk {}", docsPerBulk); int fieldSize = Math.toIntExact(ByteSizeValue.ofMb(5).getBytes()); Request request = new Request("PUT", "/bigtext"); @@ -1052,6 +1061,15 @@ private void bulk(String name, String bulk) throws IOException { ); Response response = client().performRequest(request); assertThat(entityAsMap(response), matchesMap().entry("errors", false).extraOk()); + + /* + * Flush after each bulk to clear the test-time seenSequenceNumbers Map in + * TranslogWriter. Without this the server will OOM from time to time keeping + * stuff around to run assertions on. + */ + request = new Request("POST", "/" + name + "/_flush"); + response = client().performRequest(request); + assertThat(entityAsMap(response), matchesMap().entry("_shards", matchesMap().extraOk().entry("failed", 0)).extraOk()); } private void initIndex(String name, String bulk) throws IOException {