use of com.netflix.titus.api.jobmanager.model.job.Task in project titus-control-plane by Netflix.
the class TaskRelocationLimitControllerTest method testJobUpdate.
@Test
public void testJobUpdate() {
Job<BatchJobExt> job = createBatchJob(1);
Task task = jobOperations.getTasks(job.getId()).get(0);
Reference jobReference = Reference.job(job.getId());
// Consume in first instance of the controller
TaskRelocationLimitController firstController = new TaskRelocationLimitController(job, jobOperations, SelfJobDisruptionBudgetResolver.getInstance());
assertThat(firstController.consume(task.getId()).isApproved()).isTrue();
jobComponentStub.moveTaskToState(task, TaskState.Started);
jobComponentStub.killTask(task, false, false, V3JobOperations.Trigger.Eviction);
Task replacement1 = jobComponentStub.getJobOperations().getTasks().stream().filter(t -> t.getOriginalId().equals(task.getId())).findFirst().get();
assertThat(firstController.consume(replacement1.getId()).isApproved()).isFalse();
// Update
Job<BatchJobExt> updatedJob = exceptPolicy(changeBatchJobSize(job, 20), perTaskRelocationLimitPolicy(2));
jobComponentStub.changeJob(updatedJob);
jobComponentStub.createDesiredTasks(updatedJob);
TaskRelocationLimitController updatedController = firstController.update(updatedJob);
assertThat(updatedController.getQuota(jobReference).getQuota()).isEqualTo(20);
// Consume again, after limit increase
assertThat(updatedController.consume(replacement1.getId()).isApproved()).isTrue();
jobComponentStub.moveTaskToState(replacement1, TaskState.Started);
jobComponentStub.killTask(replacement1, false, false, V3JobOperations.Trigger.Eviction);
Task replacement2 = jobComponentStub.getJobOperations().getTasks().stream().filter(t -> t.getOriginalId().equals(task.getId())).findFirst().get();
assertThat(updatedController.consume(replacement2.getId()).isApproved()).isFalse();
assertThat(updatedController.getQuota(jobReference).getQuota()).isEqualTo(19);
}
use of com.netflix.titus.api.jobmanager.model.job.Task in project titus-control-plane by Netflix.
the class TaskScenarioBuilder method expectTaskOnAgent.
public TaskScenarioBuilder expectTaskOnAgent() {
Task task = getTask();
logger.info("[{}] Expecting task {} on agent", discoverActiveTest(), task.getId());
kubeCluster.schedule();
expectStateAndReasonUpdateSkipOther(TaskStatus.TaskState.Launched, "SCHEDULED");
kubeCluster.moveToStartInitiatedState(task.getId());
return this;
}
use of com.netflix.titus.api.jobmanager.model.job.Task in project titus-control-plane by Netflix.
the class TaskScenarioBuilder method expectAllTasksInKube.
public TaskScenarioBuilder expectAllTasksInKube() {
Task task = getTask();
logger.info("[{}] Expecting task {} Kube", discoverActiveTest(), task.getId());
try {
await().timeout(TIMEOUT_MS, TimeUnit.MILLISECONDS).until(() -> kubeCluster.getPods().containsKey(task.getId()));
} catch (Exception e) {
throw e;
}
return this;
}
use of com.netflix.titus.api.jobmanager.model.job.Task in project titus-control-plane by Netflix.
the class TaskScenarioBuilder method assertTaskUpdate.
public TaskScenarioBuilder assertTaskUpdate(Consumer<Task> assertFun) {
Task task = expectTaskUpdate(update -> true, update -> true, "N/A");
assertFun.accept(task);
return this;
}
use of com.netflix.titus.api.jobmanager.model.job.Task in project titus-control-plane by Netflix.
the class TaskScenarioBuilder method completeKillInitiated.
public TaskScenarioBuilder completeKillInitiated() {
Task task = getTask();
Preconditions.checkState(task.getStatus().getState() == TaskState.KillInitiated, "Expected task in KillInitiated state");
kubeCluster.moveToFinishedSuccess(task.getId());
return this;
}
Aggregations