88package org .elasticsearch .xpack .esql .action ;
99
1010import org .elasticsearch .Build ;
11+ import org .elasticsearch .ElasticsearchTimeoutException ;
1112import org .elasticsearch .action .ActionFuture ;
1213import org .elasticsearch .client .internal .Client ;
1314import org .elasticsearch .core .Tuple ;
1617import org .elasticsearch .tasks .TaskInfo ;
1718import org .elasticsearch .transport .TransportService ;
1819import org .elasticsearch .xpack .core .async .AsyncStopRequest ;
20+ import org .elasticsearch .xpack .core .async .DeleteAsyncResultRequest ;
21+ import org .elasticsearch .xpack .core .async .TransportDeleteAsyncResultAction ;
1922import org .elasticsearch .xpack .esql .plugin .EsqlPlugin ;
2023import org .elasticsearch .xpack .esql .plugin .QueryPragmas ;
2124
2831
2932import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
3033import static org .elasticsearch .xpack .esql .action .AbstractEsqlIntegTestCase .randomIncludeCCSMetadata ;
31- import static org .elasticsearch .xpack .esql .action .EsqlAsyncTestUtils .deleteAsyncId ;
3234import static org .elasticsearch .xpack .esql .action .EsqlAsyncTestUtils .getAsyncResponse ;
3335import static org .elasticsearch .xpack .esql .action .EsqlAsyncTestUtils .startAsyncQuery ;
3436import static org .elasticsearch .xpack .esql .action .EsqlAsyncTestUtils .startAsyncQueryWithPragmas ;
@@ -43,6 +45,11 @@ public class CrossClusterAsyncQueryStopIT extends AbstractCrossClusterTestCase {
4345
4446 private static final Logger LOGGER = LogManager .getLogger (CrossClusterAsyncQueryStopIT .class );
4547
48+ @ Override
49+ protected boolean reuseClusters () {
50+ return false ;
51+ }
52+
4653 public void testStopQuery () throws Exception {
4754 assumeTrue ("Pragma does not work in release builds" , Build .current ().isSnapshot ());
4855 Map <String , Object > testClusterInfo = setupClusters (3 );
@@ -125,7 +132,7 @@ public void testStopQuery() throws Exception {
125132 } finally {
126133 // Ensure proper cleanup if the test fails
127134 CountingPauseFieldPlugin .allowEmitting .countDown ();
128- assertAcked ( deleteAsyncId (client (), asyncExecutionId ) );
135+ deleteAsyncId (client (), asyncExecutionId );
129136 }
130137 }
131138
@@ -222,7 +229,7 @@ public void testStopQueryLocal() throws Exception {
222229 }
223230 } finally {
224231 SimplePauseFieldPlugin .allowEmitting .countDown ();
225- assertAcked ( deleteAsyncId (client , asyncExecutionId ) );
232+ deleteAsyncId (client , asyncExecutionId );
226233 }
227234 }
228235
@@ -265,7 +272,7 @@ public void testStopQueryLocalNoRemotes() throws Exception {
265272 }
266273 } finally {
267274 SimplePauseFieldPlugin .allowEmitting .countDown ();
268- assertAcked ( deleteAsyncId (client (), asyncExecutionId ) );
275+ deleteAsyncId (client (), asyncExecutionId );
269276 }
270277 }
271278
@@ -351,7 +358,16 @@ public void testStopQueryInlineStats() throws Exception {
351358 } finally {
352359 // Ensure proper cleanup if the test fails
353360 CountingPauseFieldPlugin .allowEmitting .countDown ();
354- assertAcked (deleteAsyncId (client (), asyncExecutionId ));
361+ deleteAsyncId (client (), asyncExecutionId );
362+ }
363+ }
364+
365+ public void deleteAsyncId (Client client , String id ) {
366+ try {
367+ DeleteAsyncResultRequest request = new DeleteAsyncResultRequest (id );
368+ assertAcked (client .execute (TransportDeleteAsyncResultAction .TYPE , request ).actionGet (30 , TimeUnit .SECONDS ));
369+ } catch (ElasticsearchTimeoutException e ) {
370+ LOGGER .warn ("timeout waiting for DELETE response: {}: {}" , id , e );
355371 }
356372 }
357373
0 commit comments