Skip to content

Simplify testSearchWhileRelocating #128095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
});
}
Expand Down Expand Up @@ -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() {
Expand Down