Skip to content

Commit 96acb76

Browse files
committed
Improve CrossClusterAsyncEnrichStopIT test
Wait until reduce is finished Fixes #121994
1 parent a644202 commit 96acb76

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
import org.elasticsearch.common.Strings;
1515
import org.elasticsearch.common.settings.Setting;
1616
import org.elasticsearch.common.settings.Settings;
17+
import org.elasticsearch.compute.operator.DriverTaskRunner;
1718
import org.elasticsearch.compute.operator.exchange.ExchangeService;
1819
import org.elasticsearch.core.TimeValue;
1920
import org.elasticsearch.plugins.Plugin;
21+
import org.elasticsearch.tasks.TaskInfo;
2022
import org.elasticsearch.test.AbstractMultiClustersTestCase;
2123
import org.elasticsearch.test.FailingFieldPlugin;
2224
import org.elasticsearch.test.XContentTestUtils;
@@ -273,4 +275,8 @@ protected EsqlQueryResponse runQuery(String query, Boolean ccsMetadataInResponse
273275
}
274276
return runQuery(request);
275277
}
278+
279+
static List<TaskInfo> getDriverTasks(Client client) {
280+
return client.admin().cluster().prepareListTasks().setActions(DriverTaskRunner.ACTION_NAME).setDetailed(true).get().getTasks();
281+
}
276282
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.common.bytes.BytesReference;
1212
import org.elasticsearch.common.xcontent.XContentHelper;
1313
import org.elasticsearch.plugins.Plugin;
14+
import org.elasticsearch.tasks.TaskInfo;
1415
import org.elasticsearch.xcontent.json.JsonXContent;
1516
import org.elasticsearch.xpack.core.async.AsyncStopRequest;
1617
import org.elasticsearch.xpack.esql.plan.logical.Enrich;
@@ -28,9 +29,11 @@
2829

2930
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
3031
import static org.elasticsearch.xpack.esql.EsqlTestUtils.getValuesList;
32+
import static org.elasticsearch.xpack.esql.action.AbstractCrossClusterTestCase.getDriverTasks;
3133
import static org.elasticsearch.xpack.esql.action.EsqlAsyncTestUtils.deleteAsyncId;
3234
import static org.elasticsearch.xpack.esql.action.EsqlAsyncTestUtils.startAsyncQuery;
3335
import static org.elasticsearch.xpack.esql.action.EsqlAsyncTestUtils.waitForCluster;
36+
import static org.hamcrest.Matchers.empty;
3437
import static org.hamcrest.Matchers.equalTo;
3538

3639
// This tests if enrich after stop works correctly
@@ -91,6 +94,13 @@ public void testEnrichAfterStop() throws Exception {
9194
// Run the stop request
9295
var stopRequest = new AsyncStopRequest(asyncExecutionId);
9396
var stopAction = client().execute(EsqlAsyncStopAction.INSTANCE, stopRequest);
97+
// wait until reduce tasks are gone
98+
assertBusy(() -> {
99+
List<TaskInfo> tasks = getDriverTasks(client(REMOTE_CLUSTER_2));
100+
List<TaskInfo> reduceTasks = tasks.stream().filter(t -> t.description().contains("_LuceneSourceOperator") == false).toList();
101+
assertThat(reduceTasks, empty());
102+
});
103+
94104
// Allow the processing to proceed
95105
SimplePauseFieldPlugin.allowEmitting.countDown();
96106

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,4 @@ public void testStopQueryLocalNoRemotes() throws Exception {
244244
assertAcked(deleteAsyncId(client(), asyncExecutionId));
245245
}
246246
}
247-
248-
private static List<TaskInfo> getDriverTasks(Client client) {
249-
return client.admin().cluster().prepareListTasks().setActions(DriverTaskRunner.ACTION_NAME).setDetailed(true).get().getTasks();
250-
}
251247
}

0 commit comments

Comments
 (0)