use of io.druid.indexing.common.TaskStatus in project druid by druid-io.
the class KafkaIndexTaskTest method testRunWithMinimumMessageTime.
@Test(timeout = 60_000L)
public void testRunWithMinimumMessageTime() throws Exception {
final KafkaIndexTask task = createTask(null, new KafkaIOConfig("sequence0", new KafkaPartitions("topic0", ImmutableMap.of(0, 0L)), new KafkaPartitions("topic0", ImmutableMap.of(0, 5L)), kafkaServer.consumerProperties(), true, false, new DateTime("2010")), null, null);
final ListenableFuture<TaskStatus> future = runTask(task);
// Wait for the task to start reading
while (task.getStatus() != KafkaIndexTask.Status.READING) {
Thread.sleep(10);
}
// Insert data
try (final KafkaProducer<byte[], byte[]> kafkaProducer = kafkaServer.newProducer()) {
for (ProducerRecord<byte[], byte[]> record : RECORDS) {
kafkaProducer.send(record).get();
}
}
// Wait for task to exit
Assert.assertEquals(TaskStatus.Status.SUCCESS, future.get().getStatusCode());
// Check metrics
Assert.assertEquals(3, task.getFireDepartmentMetrics().processed());
Assert.assertEquals(0, task.getFireDepartmentMetrics().unparseable());
Assert.assertEquals(2, task.getFireDepartmentMetrics().thrownAway());
// Check published metadata
SegmentDescriptor desc1 = SD(task, "2010/P1D", 0);
SegmentDescriptor desc2 = SD(task, "2011/P1D", 0);
Assert.assertEquals(ImmutableSet.of(desc1, desc2), publishedDescriptors());
Assert.assertEquals(new KafkaDataSourceMetadata(new KafkaPartitions("topic0", ImmutableMap.of(0, 5L))), metadataStorageCoordinator.getDataSourceMetadata(DATA_SCHEMA.getDataSource()));
// Check segments in deep storage
Assert.assertEquals(ImmutableList.of("c"), readSegmentDim1(desc1));
Assert.assertEquals(ImmutableList.of("d", "e"), readSegmentDim1(desc2));
}
use of io.druid.indexing.common.TaskStatus in project druid by druid-io.
the class RemoteTaskRunnerTest method testStatusRemoved.
@Test
public void testStatusRemoved() throws Exception {
doSetup();
ListenableFuture<TaskStatus> future = remoteTaskRunner.run(task);
Assert.assertTrue(taskAnnounced(task.getId()));
mockWorkerRunningTask(task);
Assert.assertTrue(workerRunningTask(task.getId()));
Assert.assertTrue(remoteTaskRunner.getRunningTasks().iterator().next().getTaskId().equals("task"));
cf.delete().forPath(joiner.join(statusPath, task.getId()));
TaskStatus status = future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
Assert.assertEquals(status.getStatusCode(), TaskStatus.Status.FAILED);
}
use of io.druid.indexing.common.TaskStatus in project druid by druid-io.
the class RemoteTaskRunnerTest method testWorkerZKReconnect.
@Test
public void testWorkerZKReconnect() throws Exception {
makeWorker();
makeRemoteTaskRunner(new TestRemoteTaskRunnerConfig(new Period("PT5M")));
Future<TaskStatus> future = remoteTaskRunner.run(task);
Assert.assertTrue(taskAnnounced(task.getId()));
mockWorkerRunningTask(task);
Assert.assertTrue(workerRunningTask(task.getId()));
byte[] bytes = cf.getData().forPath(announcementsPath);
cf.delete().forPath(announcementsPath);
// worker task cleanup scheduled
Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {
@Override
public boolean isValid() {
return remoteTaskRunner.getRemovedWorkerCleanups().containsKey(worker.getHost());
}
}));
// Worker got reconnected
cf.create().forPath(announcementsPath, bytes);
// worker task cleanup should get cancelled and removed
Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {
@Override
public boolean isValid() {
return !remoteTaskRunner.getRemovedWorkerCleanups().containsKey(worker.getHost());
}
}));
mockWorkerCompleteSuccessfulTask(task);
TaskStatus status = future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
Assert.assertEquals(status.getStatusCode(), TaskStatus.Status.SUCCESS);
Assert.assertEquals(TaskStatus.Status.SUCCESS, status.getStatusCode());
}
use of io.druid.indexing.common.TaskStatus in project druid by druid-io.
the class TaskLifecycleTest method testSimple.
@Test
public void testSimple() throws Exception {
final Task task = new AbstractFixedIntervalTask("id1", "id1", new TaskResource("id1", 1), "ds", new Interval("2012-01-01/P1D"), null) {
@Override
public String getType() {
return "test";
}
@Override
public TaskStatus run(TaskToolbox toolbox) throws Exception {
final TaskLock myLock = Iterables.getOnlyElement(toolbox.getTaskActionClient().submit(new LockListAction()));
final DataSegment segment = DataSegment.builder().dataSource("ds").interval(new Interval("2012-01-01/P1D")).version(myLock.getVersion()).build();
toolbox.getTaskActionClient().submit(new SegmentInsertAction(ImmutableSet.of(segment)));
return TaskStatus.success(getId());
}
};
final TaskStatus status = runTask(task);
Assert.assertEquals("statusCode", TaskStatus.Status.SUCCESS, status.getStatusCode());
Assert.assertEquals("segments published", 1, mdc.getPublished().size());
Assert.assertEquals("segments nuked", 0, mdc.getNuked().size());
}
use of io.druid.indexing.common.TaskStatus in project druid by druid-io.
the class TaskLifecycleTest method testRealtimeishTask.
@Test
public void testRealtimeishTask() throws Exception {
final Task rtishTask = new RealtimeishTask();
final TaskStatus status = runTask(rtishTask);
Assert.assertEquals("statusCode", TaskStatus.Status.SUCCESS, status.getStatusCode());
Assert.assertEquals("num segments published", 2, mdc.getPublished().size());
Assert.assertEquals("num segments nuked", 0, mdc.getNuked().size());
}
Aggregations