use of com.netflix.titus.master.jobmanager.service.common.action.task.TaskTimeoutChangeActions.TimeoutStatus in project titus-control-plane by Netflix.
the class TaskTimeoutChangeActionsTest method testTimeout.
@Test
public void testTimeout() throws Exception {
BatchJobTask launchedTask = createTaskInState(TaskState.Launched);
EntityHolder initialRoot = rootFrom(job, launchedTask);
EntityHolder initialChild = first(initialRoot.getChildren());
// Initially there is no timeout associated
TimeoutStatus timeoutStatus = TaskTimeoutChangeActions.getTimeoutStatus(initialChild, testClock);
assertThat(timeoutStatus).isEqualTo(TimeoutStatus.NotSet);
// Apply timeout
List<ModelActionHolder> modelActionHolders = TaskTimeoutChangeActions.setTimeout(launchedTask.getId(), launchedTask.getStatus().getState(), DEADLINE_INTERVAL_MS, testClock).apply().toBlocking().first();
EntityHolder rootWithTimeout = modelActionHolders.get(0).getAction().apply(initialRoot).get().getLeft();
assertThat(TaskTimeoutChangeActions.getTimeoutStatus(first(rootWithTimeout.getChildren()), testClock)).isEqualTo(TimeoutStatus.Pending);
// Advance time to trigger timeout
testClock.advanceTime(DEADLINE_INTERVAL_MS, TimeUnit.MILLISECONDS);
assertThat(TaskTimeoutChangeActions.getTimeoutStatus(first(rootWithTimeout.getChildren()), testClock)).isEqualTo(TimeoutStatus.TimedOut);
}
Aggregations