Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ tests:
- class: org.elasticsearch.xpack.ccr.FollowIndexSecurityIT
method: testCleanShardFollowTaskAfterDeleteFollower
issue: https://github.com/elastic/elasticsearch/issues/120339
- class: org.elasticsearch.search.ccs.CrossClusterIT
method: testCancel
issue: https://github.com/elastic/elasticsearch/issues/108061
- class: org.elasticsearch.reservedstate.service.FileSettingsServiceTests
method: testInvalidJSON
issue: https://github.com/elastic/elasticsearch/issues/120482
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,11 @@ public void testCancel() throws Exception {
PlainActionFuture<SearchResponse> queryFuture = new PlainActionFuture<>();
SearchRequest searchRequest = new SearchRequest("demo", "cluster_a:prod");
searchRequest.allowPartialSearchResults(false);
searchRequest.setCcsMinimizeRoundtrips(randomBoolean());
boolean minimizeRoundTrips = randomBoolean();
searchRequest.setCcsMinimizeRoundtrips(minimizeRoundTrips);
searchRequest.source(new SearchSourceBuilder().query(new MatchAllQueryBuilder()).size(1000));
logger.info("Beginning search with mrt=" + minimizeRoundTrips);

client(LOCAL_CLUSTER).search(searchRequest, queryFuture);
SearchListenerPlugin.waitSearchStarted();
// Get the search task and cancelled
Expand Down Expand Up @@ -271,18 +274,23 @@ public void testCancel() throws Exception {
});

for (TaskInfo taskInfo : remoteClusterSearchTasks.get()) {
logger.info("Checking for task's cancellation: " + taskInfo.taskId());
assertFalse("taskInfo is cancelled: " + taskInfo, taskInfo.cancelled());
}

final CancelTasksRequest cancelRequest = new CancelTasksRequest().setTargetTaskId(rootTask.taskId());
cancelRequest.setWaitForCompletion(randomBoolean());
boolean waitForCompletion = randomBoolean();
cancelRequest.setWaitForCompletion(waitForCompletion);
logger.info("Cancelling task with waitForCompletion=" + waitForCompletion);

final ActionFuture<ListTasksResponse> cancelFuture = client().admin().cluster().cancelTasks(cancelRequest);
assertBusy(() -> {
final Iterable<TransportService> transportServices = cluster("cluster_a").getInstances(TransportService.class);
for (TransportService transportService : transportServices) {
Collection<CancellableTask> cancellableTasks = transportService.getTaskManager().getCancellableTasks().values();
for (CancellableTask cancellableTask : cancellableTasks) {
if (cancellableTask.getAction().contains(TransportSearchAction.TYPE.name())) {
logger.info("Cancelled task: " + cancellableTask);
assertTrue(cancellableTask.getDescription(), cancellableTask.isCancelled());
}
}
Expand All @@ -296,12 +304,15 @@ public void testCancel() throws Exception {
.getTasks()
.stream()
.filter(t -> t.action().startsWith("indices:data/read/search"))
.collect(Collectors.toList());
.toList();

logger.info("Remote search tasks after cancellation: " + remoteSearchTasksAfterCancellation.size());
for (TaskInfo taskInfo : remoteSearchTasksAfterCancellation) {
assertTrue(taskInfo.description(), taskInfo.cancelled());
}

SearchListenerPlugin.allowQueryPhase();
logger.info("Query phase resumed: " + queryFuture.state());
try {
queryFuture.get();
fail("query should have failed");
Expand Down