From 09021aff50a39ad8e1e4056a714c0e4982301cf3 Mon Sep 17 00:00:00 2001 From: "ievgen.degtiarenko" Date: Fri, 16 May 2025 11:28:11 +0200 Subject: [PATCH] Simplify testSearchWhileRelocating 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. --- .../xpack/esql/plugin/DataNodeRequestSenderIT.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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..9f6081b3667b9 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,15 +50,17 @@ 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(); } }); } @@ -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() {