Skip to content

Commit 675bc9d

Browse files
authored
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.
1 parent bc34ae9 commit 675bc9d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void testConcurrentQueries() throws Exception {
122122
logger.warn("Query failed with exception", e);
123123
throw e;
124124
}
125-
}, "testConcurrentQueries");
125+
}, "testConcurrentQueries-" + q);
126126
}
127127
for (Thread thread : threads) {
128128
thread.start();

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSenderIT.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121

2222
import java.util.Collection;
2323
import java.util.concurrent.atomic.AtomicBoolean;
24-
import java.util.concurrent.atomic.LongAdder;
2524

2625
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
2726
import static org.elasticsearch.xpack.esql.EsqlTestUtils.as;
2827
import static org.elasticsearch.xpack.esql.EsqlTestUtils.getValuesList;
29-
import static org.hamcrest.Matchers.greaterThan;
3028
import static org.hamcrest.Matchers.hasSize;
3129

3230
public class DataNodeRequestSenderIT extends AbstractEsqlIntegTestCase {
@@ -52,17 +50,19 @@ public void testSearchWhileRelocating() throws InterruptedException {
5250

5351
// start background searches
5452
var stopped = new AtomicBoolean(false);
55-
var queries = new LongAdder();
5653
var threads = new Thread[randomIntBetween(1, 5)];
5754
for (int i = 0; i < threads.length; i++) {
5855
threads[i] = new Thread(() -> {
5956
while (stopped.get() == false) {
6057
try (EsqlQueryResponse resp = run("FROM index-1")) {
6158
assertThat(getValuesList(resp), hasSize(docs));
59+
} catch (Exception | AssertionError e) {
60+
logger.warn("Query failed with exception", e);
61+
stopped.set(true);
62+
throw e;
6263
}
63-
queries.increment();
6464
}
65-
});
65+
}, "testSearchWhileRelocating-" + i);
6666
}
6767
for (Thread thread : threads) {
6868
thread.start();
@@ -93,7 +93,6 @@ public void testSearchWhileRelocating() throws InterruptedException {
9393
.prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
9494
.setPersistentSettings(Settings.builder().putNull("cluster.routing.allocation.exclude._name"))
9595
.get();
96-
assertThat(queries.sum(), greaterThan((long) threads.length));
9796
}
9897

9998
public void testRetryOnShardMovement() {

0 commit comments

Comments
 (0)