Search in sources :

Example 51 with TaskToolbox

use of org.apache.druid.indexing.common.TaskToolbox in project druid by druid-io.

the class WorkerTaskManagerTest method testTaskStatusWhenTaskRunnerFutureThrowsException.

@Test(timeout = 30_000L)
public void testTaskStatusWhenTaskRunnerFutureThrowsException() throws Exception {
    Task task = new NoopTask("id", null, null, 100, 0, null, null, ImmutableMap.of(Tasks.PRIORITY_KEY, 0)) {

        @Override
        public TaskStatus run(TaskToolbox toolbox) {
            throw new Error("task failure test");
        }
    };
    workerTaskManager.start();
    workerTaskManager.assignTask(task);
    Map<String, TaskAnnouncement> completeTasks;
    do {
        completeTasks = workerTaskManager.getCompletedTasks();
    } while (completeTasks.isEmpty());
    Assert.assertEquals(1, completeTasks.size());
    TaskAnnouncement announcement = completeTasks.get(task.getId());
    Assert.assertNotNull(announcement);
    Assert.assertEquals(TaskState.FAILED, announcement.getStatus());
    Assert.assertEquals("Failed to run task with an exception. See middleManager or indexer logs for more details.", announcement.getTaskStatus().getErrorMsg());
}
Also used : TaskToolbox(org.apache.druid.indexing.common.TaskToolbox) Task(org.apache.druid.indexing.common.task.Task) NoopTask(org.apache.druid.indexing.common.task.NoopTask) NoopTask(org.apache.druid.indexing.common.task.NoopTask) Test(org.junit.Test)

Aggregations

TaskToolbox (org.apache.druid.indexing.common.TaskToolbox)51 TaskStatus (org.apache.druid.indexer.TaskStatus)34 Test (org.junit.Test)31 DataSegment (org.apache.druid.timeline.DataSegment)23 TaskActionClient (org.apache.druid.indexing.common.actions.TaskActionClient)20 ISE (org.apache.druid.java.util.common.ISE)18 File (java.io.File)16 ArrayList (java.util.ArrayList)14 Map (java.util.Map)14 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)13 List (java.util.List)12 IOException (java.io.IOException)11 Preconditions (com.google.common.base.Preconditions)10 Collections (java.util.Collections)10 Pair (org.apache.druid.java.util.common.Pair)10 Interval (org.joda.time.Interval)10 ImmutableMap (com.google.common.collect.ImmutableMap)9 HashMap (java.util.HashMap)9 Set (java.util.Set)9 Nullable (javax.annotation.Nullable)9