use of org.apache.druid.indexing.common.task.NoopTask in project druid by druid-io.
the class FillCapacityWithAffinityWorkerSelectStrategyTest method testIsolation.
@Test
public void testIsolation() {
FillCapacityWorkerSelectStrategy strategy = new FillCapacityWithAffinityWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost")), false));
ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("localhost", new ImmutableWorkerInfo(new Worker("http", "localhost", "localhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null));
Assert.assertNull(worker);
}
use of org.apache.druid.indexing.common.task.NoopTask in project druid by druid-io.
the class OverlordResourceTest method testGetTaskPayload.
@Test
public void testGetTaskPayload() throws Exception {
// This is disabled since OverlordResource.getTaskStatus() is annotated with TaskResourceFilter which is supposed to
// set authorization token properly, but isn't called in this test.
// This should be fixed in https://github.com/apache/druid/issues/6685.
// expectAuthorizationTokenCheck();
final NoopTask task = NoopTask.create("mydatasource");
EasyMock.expect(taskStorageQueryAdapter.getTask("mytask")).andReturn(Optional.of(task));
EasyMock.expect(taskStorageQueryAdapter.getTask("othertask")).andReturn(Optional.absent());
EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req, workerTaskRunnerQueryAdapter);
final Response response1 = overlordResource.getTaskPayload("mytask");
final TaskPayloadResponse taskPayloadResponse1 = TestHelper.makeJsonMapper().readValue(TestHelper.makeJsonMapper().writeValueAsString(response1.getEntity()), TaskPayloadResponse.class);
Assert.assertEquals(new TaskPayloadResponse("mytask", task), taskPayloadResponse1);
final Response response2 = overlordResource.getTaskPayload("othertask");
final TaskPayloadResponse taskPayloadResponse2 = TestHelper.makeJsonMapper().readValue(TestHelper.makeJsonMapper().writeValueAsString(response2.getEntity()), TaskPayloadResponse.class);
Assert.assertEquals(new TaskPayloadResponse("othertask", null), taskPayloadResponse2);
}
use of org.apache.druid.indexing.common.task.NoopTask 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());
}
use of org.apache.druid.indexing.common.task.NoopTask in project druid by druid-io.
the class EqualDistributionWithAffinityWorkerSelectStrategyTest method testFindWorkerForTaskWithNulls.
@Test
public void testFindWorkerForTaskWithNulls() {
EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWithAffinityWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost")), false));
ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("lhost", new ImmutableWorkerInfo(new Worker("http", "lhost", "lhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc()), "localhost", new ImmutableWorkerInfo(new Worker("http", "localhost", "localhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null));
Assert.assertEquals("lhost", worker.getWorker().getHost());
}
use of org.apache.druid.indexing.common.task.NoopTask in project druid by druid-io.
the class FillCapacityWithCategorySpecWorkerSelectStrategyTest method selectWorker.
private ImmutableWorkerInfo selectWorker(WorkerCategorySpec workerCategorySpec) {
final FillCapacityWithCategorySpecWorkerSelectStrategy strategy = new FillCapacityWithCategorySpecWorkerSelectStrategy(workerCategorySpec);
ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_TIER_TESTS, new NoopTask(null, null, "ds1", 1, 0, null, null, null));
return worker;
}
Aggregations