From 190b0bd276ec8395d2c40c0494dae38012dc17b9 Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Sat, 21 Jun 2025 18:46:14 -0300 Subject: [PATCH 1/2] Fix index stats field data YAML test Occasional shard allocation issues were causing the YAML tests to fail because the shard that had the document in it would be unavailable. --- .../test/indices.stats/13_fields.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats/13_fields.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats/13_fields.yml index fc751fddfb814..be126f160c128 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats/13_fields.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats/13_fields.yml @@ -9,7 +9,9 @@ setup: # Limit the number of shards so that shards are unlikely # to be relocated or being initialized between the test # set up and the test execution - index.number_of_shards: 2 + # The tests in `IndexStatsIT` provide sufficient coverage for multi-shard scenarios. + index.number_of_shards: 1 + index.number_of_replicas: 0 mappings: properties: bar: @@ -25,11 +27,6 @@ setup: completion: type: completion - - do: - cluster.health: - index: test1 - wait_for_no_relocating_shards: true - - do: index: index: test1 @@ -73,6 +70,12 @@ setup: body: sort: [ "bar", "baz" ] + - do: + cluster.health: + index: test1 + wait_for_status: green + wait_for_no_relocating_shards: true + --- "Fields - blank": - do: From 965ad65de319a14e94b55fc0a6ffcbcb889540a9 Mon Sep 17 00:00:00 2001 From: Niels Bauman Date: Mon, 23 Jun 2025 11:01:49 -0300 Subject: [PATCH 2/2] Add comment --- .../resources/rest-api-spec/test/indices.stats/13_fields.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats/13_fields.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats/13_fields.yml index be126f160c128..1225e216eb2a0 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats/13_fields.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats/13_fields.yml @@ -70,6 +70,8 @@ setup: body: sort: [ "bar", "baz" ] + # Wait for the shards to be allocated to avoid missing results in the stats request + # See https://github.com/elastic/elasticsearch/issues/96711#issuecomment-2996311920 for more context - do: cluster.health: index: test1