Skip to content

Log more details in TaskAssertions #88864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import org.apache.http.client.methods.HttpGet;
import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsAction;
import org.elasticsearch.client.Request;
import org.elasticsearch.test.junit.annotations.TestLogging;

@TestLogging(value = "org.elasticsearch.tasks.TaskManager:TRACE,org.elasticsearch.test.TaskAssertions:TRACE", reason = "debugging")
public class IndicesSegmentsRestCancellationIT extends BlockedSearcherRestCancellationTestCase {
public void testIndicesSegmentsRestCancellation() throws Exception {
runTest(new Request(HttpGet.METHOD_NAME, "/_segments"), IndicesSegmentsAction.NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.tasks.CancellableTask;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskInfo;
import org.elasticsearch.tasks.TaskManager;
import org.elasticsearch.transport.TransportService;

import java.util.List;
import java.util.stream.Collectors;

import static junit.framework.TestCase.assertTrue;
import static junit.framework.TestCase.fail;
Expand All @@ -33,7 +35,14 @@ public static void awaitTaskWithPrefix(String actionPrefix) throws Exception {

assertBusy(() -> {
for (TransportService transportService : internalCluster().getInstances(TransportService.class)) {
if (transportService.getTaskManager().getTasks().values().stream().anyMatch(t -> t.getAction().startsWith(actionPrefix))) {
List<Task> matchingTasks = transportService.getTaskManager()
.getTasks()
.values()
.stream()
.filter(t -> t.getAction().startsWith(actionPrefix))
.collect(Collectors.toList());
if (matchingTasks.isEmpty() == false) {
logger.trace("--> found {} tasks with prefix [{}]: {}", matchingTasks.size(), actionPrefix, matchingTasks);
return;
}
}
Expand All @@ -51,6 +60,7 @@ public static void assertAllCancellableTasksAreCancelled(String actionPrefix) th
assertTrue(taskManager.assertCancellableTaskConsistency());
for (CancellableTask cancellableTask : taskManager.getCancellableTasks().values()) {
if (cancellableTask.getAction().startsWith(actionPrefix)) {
logger.trace("--> found task with prefix [{}] marked as cancelled: [{}]", actionPrefix, cancellableTask);
foundTask = true;
assertTrue(
"task " + cancellableTask.getId() + "/" + cancellableTask.getAction() + " not cancelled",
Expand Down