|
8 | 8 | package org.elasticsearch.xpack.esql.action; |
9 | 9 |
|
10 | 10 | import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; |
| 11 | +import org.elasticsearch.client.internal.Client; |
11 | 12 | import org.elasticsearch.common.bytes.BytesReference; |
12 | 13 | import org.elasticsearch.common.xcontent.XContentHelper; |
| 14 | +import org.elasticsearch.compute.operator.DriverTaskRunner; |
13 | 15 | import org.elasticsearch.plugins.Plugin; |
| 16 | +import org.elasticsearch.tasks.TaskInfo; |
14 | 17 | import org.elasticsearch.xcontent.json.JsonXContent; |
15 | 18 | import org.elasticsearch.xpack.core.async.AsyncStopRequest; |
16 | 19 | import org.elasticsearch.xpack.esql.plan.logical.Enrich; |
|
31 | 34 | import static org.elasticsearch.xpack.esql.action.EsqlAsyncTestUtils.deleteAsyncId; |
32 | 35 | import static org.elasticsearch.xpack.esql.action.EsqlAsyncTestUtils.startAsyncQuery; |
33 | 36 | import static org.elasticsearch.xpack.esql.action.EsqlAsyncTestUtils.waitForCluster; |
| 37 | +import static org.hamcrest.Matchers.empty; |
34 | 38 | import static org.hamcrest.Matchers.equalTo; |
| 39 | +import static org.hamcrest.Matchers.not; |
35 | 40 |
|
36 | 41 | // This tests if enrich after stop works correctly |
37 | 42 | public class CrossClusterAsyncEnrichStopIT extends AbstractEnrichBasedCrossClusterTestCase { |
@@ -87,10 +92,23 @@ public void testEnrichAfterStop() throws Exception { |
87 | 92 | // wait until c1 is done |
88 | 93 | waitForCluster(client(), "c1", asyncExecutionId); |
89 | 94 | waitForCluster(client(), LOCAL_CLUSTER, asyncExecutionId); |
| 95 | + // wait until remote reduce task starts on c2 |
| 96 | + assertBusy(() -> { |
| 97 | + List<TaskInfo> tasks = getDriverTasks(client(REMOTE_CLUSTER_2)); |
| 98 | + List<TaskInfo> reduceTasks = tasks.stream().filter(t -> t.description().contains("_LuceneSourceOperator") == false).toList(); |
| 99 | + assertThat(reduceTasks, not(empty())); |
| 100 | + }); |
90 | 101 |
|
91 | 102 | // Run the stop request |
92 | 103 | var stopRequest = new AsyncStopRequest(asyncExecutionId); |
93 | 104 | var stopAction = client().execute(EsqlAsyncStopAction.INSTANCE, stopRequest); |
| 105 | + // wait until remote reduce tasks are gone |
| 106 | + assertBusy(() -> { |
| 107 | + List<TaskInfo> tasks = getDriverTasks(client(REMOTE_CLUSTER_2)); |
| 108 | + List<TaskInfo> reduceTasks = tasks.stream().filter(t -> t.description().contains("_LuceneSourceOperator") == false).toList(); |
| 109 | + assertThat(reduceTasks, empty()); |
| 110 | + }); |
| 111 | + |
94 | 112 | // Allow the processing to proceed |
95 | 113 | SimplePauseFieldPlugin.allowEmitting.countDown(); |
96 | 114 |
|
@@ -153,4 +171,9 @@ record Event(long timestamp, String user, String host) {} |
153 | 171 | } |
154 | 172 | client.admin().indices().prepareRefresh("events").get(); |
155 | 173 | } |
| 174 | + |
| 175 | + static List<TaskInfo> getDriverTasks(Client client) { |
| 176 | + return client.admin().cluster().prepareListTasks().setActions(DriverTaskRunner.ACTION_NAME).setDetailed(true).get().getTasks(); |
| 177 | + } |
| 178 | + |
156 | 179 | } |
0 commit comments