From 0824f4cc32f4be0859202b0b79f3c85353f24f57 Mon Sep 17 00:00:00 2001 From: Ievgen Degtiarenko Date: Tue, 20 May 2025 08:36:18 +0200 Subject: [PATCH] Simplify testSearchWhileRelocating (#128095) This change logs the query failure as well as stops the test immediately after it. This makes it easier to read the logs and troubleshot the flaky failures once they happen. --- .../elasticsearch/xpack/esql/action/ManyShardsIT.java | 2 +- .../xpack/esql/plugin/DataNodeRequestSenderIT.java | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java index 2cd93fdade508..c04c14169a71b 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java @@ -123,7 +123,7 @@ public void testConcurrentQueries() throws Exception { logger.warn("Query failed with exception", e); throw e; } - }, "testConcurrentQueries"); + }, "testConcurrentQueries-" + q); } for (Thread thread : threads) { thread.start(); diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSenderIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSenderIT.java index 1e22d2c69c881..9b3c2278c1bb8 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSenderIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSenderIT.java @@ -21,12 +21,10 @@ import java.util.Collection; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.LongAdder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.xpack.esql.EsqlTestUtils.as; import static org.elasticsearch.xpack.esql.EsqlTestUtils.getValuesList; -import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; public class DataNodeRequestSenderIT extends AbstractEsqlIntegTestCase { @@ -52,17 +50,19 @@ public void testSearchWhileRelocating() throws InterruptedException { // start background searches var stopped = new AtomicBoolean(false); - var queries = new LongAdder(); var threads = new Thread[randomIntBetween(1, 5)]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(() -> { while (stopped.get() == false) { try (EsqlQueryResponse resp = run("FROM index-1")) { assertThat(getValuesList(resp), hasSize(docs)); + } catch (Exception | AssertionError e) { + logger.warn("Query failed with exception", e); + stopped.set(true); + throw e; } - queries.increment(); } - }); + }, "testSearchWhileRelocating-" + i); } for (Thread thread : threads) { thread.start(); @@ -93,7 +93,6 @@ public void testSearchWhileRelocating() throws InterruptedException { .prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT) .setPersistentSettings(Settings.builder().putNull("cluster.routing.allocation.exclude._name")) .get(); - assertThat(queries.sum(), greaterThan((long) threads.length)); } public void testRetryOnShardMovement() {