Search in sources :

Example 1 with TimeoutStatus

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);
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) EntityHolder(com.netflix.titus.common.framework.reconciler.EntityHolder) TimeoutStatus(com.netflix.titus.master.jobmanager.service.common.action.task.TaskTimeoutChangeActions.TimeoutStatus) ModelActionHolder(com.netflix.titus.common.framework.reconciler.ModelActionHolder) Test(org.junit.Test)

Aggregations

BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)1 EntityHolder (com.netflix.titus.common.framework.reconciler.EntityHolder)1 ModelActionHolder (com.netflix.titus.common.framework.reconciler.ModelActionHolder)1 TimeoutStatus (com.netflix.titus.master.jobmanager.service.common.action.task.TaskTimeoutChangeActions.TimeoutStatus)1 Test (org.junit.Test)1