use of org.apache.druid.indexer.TaskInfo in project druid by druid-io.
the class OverlordResourceTest method testShutdownAllTasks.
@Test
public void testShutdownAllTasks() {
// This is disabled since OverlordResource.shutdownTasksForDataSource is annotated with DatasourceResourceFilter
// This should be fixed in https://github.com/apache/druid/issues/6685.
// expectAuthorizationTokenCheck();
TaskQueue mockQueue = EasyMock.createMock(TaskQueue.class);
EasyMock.expect(taskMaster.isLeader()).andReturn(true).anyTimes();
EasyMock.expect(taskMaster.getTaskRunner()).andReturn(Optional.of(taskRunner)).anyTimes();
EasyMock.expect(taskMaster.getTaskQueue()).andReturn(Optional.of(mockQueue)).anyTimes();
EasyMock.expect(taskStorageQueryAdapter.getActiveTaskInfo("datasource")).andStubReturn(ImmutableList.of(new TaskInfo("id_1", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_1"), "datasource", getTaskWithIdAndDatasource("id_1", "datasource")), new TaskInfo("id_2", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_2"), "datasource", getTaskWithIdAndDatasource("id_2", "datasource"))));
mockQueue.shutdown("id_1", "Shutdown request from user");
EasyMock.expectLastCall();
mockQueue.shutdown("id_2", "Shutdown request from user");
EasyMock.expectLastCall();
EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req, mockQueue, workerTaskRunnerQueryAdapter);
final Map<String, Integer> response = (Map<String, Integer>) overlordResource.shutdownTasksForDataSource("datasource").getEntity();
Assert.assertEquals("datasource", response.get("dataSource"));
}
use of org.apache.druid.indexer.TaskInfo in project druid by druid-io.
the class OverlordResourceTest method testGetNullCompleteTask.
@Test
public void testGetNullCompleteTask() {
expectAuthorizationTokenCheck();
EasyMock.expect(taskStorageQueryAdapter.getCompletedTaskInfoByCreatedTimeDuration(null, null, null)).andStubReturn(ImmutableList.of(new TaskInfo("id_1", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_1"), "allow", null), new TaskInfo("id_2", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_2"), "deny", getTaskWithIdAndDatasource("id_2", "deny")), new TaskInfo("id_3", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_3"), "allow", getTaskWithIdAndDatasource("id_3", "allow"))));
EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req, workerTaskRunnerQueryAdapter);
List<TaskStatusPlus> responseObjects = (List<TaskStatusPlus>) overlordResource.getTasks("complete", null, null, null, null, req).getEntity();
Assert.assertEquals(2, responseObjects.size());
Assert.assertEquals("id_1", responseObjects.get(0).getId());
TaskStatusPlus tsp = responseObjects.get(0);
Assert.assertEquals(null, tsp.getType());
Assert.assertTrue("DataSource Check", "allow".equals(responseObjects.get(0).getDataSource()));
}
use of org.apache.druid.indexer.TaskInfo in project druid by druid-io.
the class OverlordResourceTest method testGetTasksFilterCompleteStateWithInterval.
@Test
public void testGetTasksFilterCompleteStateWithInterval() {
expectAuthorizationTokenCheck();
List<String> tasksIds = ImmutableList.of("id_1", "id_2", "id_3");
Duration duration = new Period("PT86400S").toStandardDuration();
EasyMock.expect(taskStorageQueryAdapter.getCompletedTaskInfoByCreatedTimeDuration(null, duration, null)).andStubReturn(ImmutableList.of(new TaskInfo("id_1", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_1"), "deny", getTaskWithIdAndDatasource("id_1", "deny")), new TaskInfo("id_2", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_2"), "allow", getTaskWithIdAndDatasource("id_2", "allow")), new TaskInfo("id_3", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_3"), "allow", getTaskWithIdAndDatasource("id_3", "allow"))));
EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req, workerTaskRunnerQueryAdapter);
String interval = "2010-01-01_P1D";
List<TaskStatusPlus> responseObjects = (List<TaskStatusPlus>) overlordResource.getTasks("complete", null, interval, null, null, req).getEntity();
Assert.assertEquals(2, responseObjects.size());
Assert.assertEquals("id_2", responseObjects.get(0).getId());
Assert.assertTrue("DataSource Check", "allow".equals(responseObjects.get(0).getDataSource()));
}
Aggregations