use of io.druid.indexing.common.IndexingServiceCondition in project druid by druid-io.
the class RemoteTaskRunnerTest method testRunSameAvailabilityGroup.
@Test
public void testRunSameAvailabilityGroup() throws Exception {
doSetup();
TestRealtimeTask task1 = new TestRealtimeTask("rt1", new TaskResource("rt1", 1), "foo", TaskStatus.running("rt1"), jsonMapper);
remoteTaskRunner.run(task1);
Assert.assertTrue(taskAnnounced(task1.getId()));
mockWorkerRunningTask(task1);
TestRealtimeTask task2 = new TestRealtimeTask("rt2", new TaskResource("rt1", 1), "foo", TaskStatus.running("rt2"), jsonMapper);
remoteTaskRunner.run(task2);
TestRealtimeTask task3 = new TestRealtimeTask("rt3", new TaskResource("rt2", 1), "foo", TaskStatus.running("rt3"), jsonMapper);
remoteTaskRunner.run(task3);
Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {
@Override
public boolean isValid() {
return remoteTaskRunner.getRunningTasks().size() == 2;
}
}));
Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {
@Override
public boolean isValid() {
return remoteTaskRunner.getPendingTasks().size() == 1;
}
}));
Assert.assertTrue(remoteTaskRunner.getPendingTasks().iterator().next().getTaskId().equals("rt2"));
}
use of io.druid.indexing.common.IndexingServiceCondition in project druid by druid-io.
the class RemoteTaskRunnerTest method testWorkerRemoved.
@Test
public void testWorkerRemoved() throws Exception {
doSetup();
Future<TaskStatus> future = remoteTaskRunner.run(task);
Assert.assertTrue(taskAnnounced(task.getId()));
mockWorkerRunningTask(task);
Assert.assertTrue(workerRunningTask(task.getId()));
cf.delete().forPath(announcementsPath);
TaskStatus status = future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
Assert.assertEquals(TaskStatus.Status.FAILED, status.getStatusCode());
RemoteTaskRunnerConfig config = remoteTaskRunner.getRemoteTaskRunnerConfig();
Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {
@Override
public boolean isValid() {
return remoteTaskRunner.getRemovedWorkerCleanups().isEmpty();
}
}, // cleanup task is independently scheduled by event listener. we need to wait some more time.
config.getTaskCleanupTimeout().toStandardDuration().getMillis() * 2));
Assert.assertNull(cf.checkExists().forPath(statusPath));
}
use of io.druid.indexing.common.IndexingServiceCondition 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.IndexingServiceCondition in project druid by druid-io.
the class RemoteTaskRunnerTest method testRunWithCapacity.
@Test
public void testRunWithCapacity() throws Exception {
doSetup();
TestRealtimeTask task1 = new TestRealtimeTask("rt1", new TaskResource("rt1", 1), "foo", TaskStatus.running("rt1"), jsonMapper);
remoteTaskRunner.run(task1);
Assert.assertTrue(taskAnnounced(task1.getId()));
mockWorkerRunningTask(task1);
TestRealtimeTask task2 = new TestRealtimeTask("rt2", new TaskResource("rt2", 3), "foo", TaskStatus.running("rt2"), jsonMapper);
remoteTaskRunner.run(task2);
TestRealtimeTask task3 = new TestRealtimeTask("rt3", new TaskResource("rt3", 2), "foo", TaskStatus.running("rt3"), jsonMapper);
remoteTaskRunner.run(task3);
Assert.assertTrue(taskAnnounced(task3.getId()));
mockWorkerRunningTask(task3);
Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {
@Override
public boolean isValid() {
return remoteTaskRunner.getRunningTasks().size() == 2;
}
}));
Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {
@Override
public boolean isValid() {
return remoteTaskRunner.getPendingTasks().size() == 1;
}
}));
Assert.assertTrue(remoteTaskRunner.getPendingTasks().iterator().next().getTaskId().equals("rt2"));
}
Aggregations