Skip to content

Commit

Permalink
Log test list tasks wait for completion (#101388) (#101863)
Browse files Browse the repository at this point in the history
Enable additional logging for testListTasksWaitForCompletion

(cherry picked from commit 64a91bc)
  • Loading branch information
idegtiarenko committed Nov 7, 2023
1 parent 5ceaed0 commit d559372
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Expand Up @@ -50,6 +50,7 @@
import org.elasticsearch.tasks.TaskResult;
import org.elasticsearch.tasks.TaskResultsService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.tasks.MockTaskManager;
import org.elasticsearch.test.tasks.MockTaskManagerListener;
import org.elasticsearch.test.transport.MockTransportService;
Expand Down Expand Up @@ -543,6 +544,10 @@ public void testTasksUnblocking() throws Exception {
);
}

@TestLogging(
reason = "https://github.com/elastic/elasticsearch/issues/97923",
value = "org.elasticsearch.action.admin.cluster.node.tasks.list.TransportListTasksAction:TRACE"
)
public void testListTasksWaitForCompletion() throws Exception {
waitForCompletionTestCase(
randomBoolean(),
Expand Down
Expand Up @@ -8,6 +8,8 @@

package org.elasticsearch.action.admin.cluster.node.tasks.list;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.TaskOperationFailure;
Expand Down Expand Up @@ -39,6 +41,9 @@
import static org.elasticsearch.core.TimeValue.timeValueSeconds;

public class TransportListTasksAction extends TransportTasksAction<Task, ListTasksRequest, ListTasksResponse, TaskInfo> {

private static final Logger logger = LogManager.getLogger(TransportListTasksAction.class);

public static long waitForCompletionTimeout(TimeValue timeout) {
if (timeout == null) {
timeout = DEFAULT_WAIT_FOR_COMPLETION_TIMEOUT;
Expand Down Expand Up @@ -124,6 +129,7 @@ protected void processTasks(CancellableTask nodeTask, ListTasksRequest request,
}
processedTasks.add(task);
}
logger.trace("Matched {} tasks of all running {}", processedTasks, taskManager.getTasks().values());
} catch (Exception e) {
allMatchedTasksRemovedListener.onFailure(e);
return;
Expand Down

0 comments on commit d559372

Please sign in to comment.