|
11 | 11 | import org.elasticsearch.common.bytes.BytesReference; |
12 | 12 | import org.elasticsearch.common.xcontent.XContentHelper; |
13 | 13 | import org.elasticsearch.plugins.Plugin; |
| 14 | +import org.elasticsearch.tasks.TaskInfo; |
14 | 15 | import org.elasticsearch.xcontent.json.JsonXContent; |
15 | 16 | import org.elasticsearch.xpack.core.async.AsyncStopRequest; |
16 | 17 | import org.elasticsearch.xpack.esql.plan.logical.Enrich; |
|
28 | 29 |
|
29 | 30 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
30 | 31 | import static org.elasticsearch.xpack.esql.EsqlTestUtils.getValuesList; |
| 32 | +import static org.elasticsearch.xpack.esql.action.AbstractCrossClusterTestCase.getDriverTasks; |
31 | 33 | import static org.elasticsearch.xpack.esql.action.EsqlAsyncTestUtils.deleteAsyncId; |
32 | 34 | import static org.elasticsearch.xpack.esql.action.EsqlAsyncTestUtils.startAsyncQuery; |
33 | 35 | import static org.elasticsearch.xpack.esql.action.EsqlAsyncTestUtils.waitForCluster; |
| 36 | +import static org.hamcrest.Matchers.empty; |
34 | 37 | import static org.hamcrest.Matchers.equalTo; |
| 38 | +import static org.hamcrest.Matchers.not; |
35 | 39 |
|
36 | 40 | // This tests if enrich after stop works correctly |
37 | 41 | public class CrossClusterAsyncEnrichStopIT extends AbstractEnrichBasedCrossClusterTestCase { |
@@ -87,10 +91,23 @@ public void testEnrichAfterStop() throws Exception { |
87 | 91 | // wait until c1 is done |
88 | 92 | waitForCluster(client(), "c1", asyncExecutionId); |
89 | 93 | waitForCluster(client(), LOCAL_CLUSTER, asyncExecutionId); |
| 94 | + // wait until remote reduce task starts on c2 |
| 95 | + assertBusy(() -> { |
| 96 | + List<TaskInfo> tasks = getDriverTasks(client(REMOTE_CLUSTER_2)); |
| 97 | + List<TaskInfo> reduceTasks = tasks.stream().filter(t -> t.description().contains("_LuceneSourceOperator") == false).toList(); |
| 98 | + assertThat(reduceTasks, not(empty())); |
| 99 | + }); |
90 | 100 |
|
91 | 101 | // Run the stop request |
92 | 102 | var stopRequest = new AsyncStopRequest(asyncExecutionId); |
93 | 103 | var stopAction = client().execute(EsqlAsyncStopAction.INSTANCE, stopRequest); |
| 104 | + // wait until remote reduce tasks are gone |
| 105 | + assertBusy(() -> { |
| 106 | + List<TaskInfo> tasks = getDriverTasks(client(REMOTE_CLUSTER_2)); |
| 107 | + List<TaskInfo> reduceTasks = tasks.stream().filter(t -> t.description().contains("_LuceneSourceOperator") == false).toList(); |
| 108 | + assertThat(reduceTasks, empty()); |
| 109 | + }); |
| 110 | + |
94 | 111 | // Allow the processing to proceed |
95 | 112 | SimplePauseFieldPlugin.allowEmitting.countDown(); |
96 | 113 |
|
|
0 commit comments