use of com.netflix.titus.api.relocation.model.TaskRelocationPlan in project titus-control-plane by Netflix.
the class MustBeRelocatedSelfManagedTaskCollectorStepTest method testOriginalPlanIsReturnedOnEachInvocation.
@Test
public void testOriginalPlanIsReturnedOnEachInvocation() {
Job<BatchJobExt> job = TestDataFactory.newBatchJob("job1", 1, newSelfManagedDisruptionBudget(1_000));
relocationConnectorStubs.addJob(job);
Task task = jobOperations.getTasks().get(0);
relocationConnectorStubs.place(TestDataFactory.REMOVABLE_INSTANCE_GROUP_ID, task);
Map<String, TaskRelocationPlan> firstResult = step.collectTasksThatMustBeRelocated();
assertThat(firstResult).hasSize(1);
TaskRelocationPlan first = firstResult.get(task.getId());
((TestClock) titusRuntime.getClock()).advanceTime(1, TimeUnit.SECONDS);
Map<String, TaskRelocationPlan> secondResult = step.collectTasksThatMustBeRelocated();
assertThat(secondResult).hasSize(1);
TaskRelocationPlan second = secondResult.get(task.getId());
assertThat(first).isEqualTo(second);
}
use of com.netflix.titus.api.relocation.model.TaskRelocationPlan in project titus-control-plane by Netflix.
the class MustBeRelocatedTaskStoreUpdateStepTest method testCreateOrUpdate.
@Test
public void testCreateOrUpdate() {
when(store.getAllTaskRelocationPlans()).thenReturn(Mono.just(Collections.emptyMap()));
MustBeRelocatedTaskStoreUpdateStep step = new MustBeRelocatedTaskStoreUpdateStep(configuration, store, transactionLog, titusRuntime);
Job<BatchJobExt> job = TestDataFactory.newBatchJob("job1", 1, newSelfManagedDisruptionBudget(1_000));
relocationConnectorStubs.addJob(job);
relocationConnectorStubs.place(TestDataFactory.REMOVABLE_INSTANCE_GROUP_ID, jobOperations.getTasks().get(0));
when(store.createOrUpdateTaskRelocationPlans(anyList())).thenReturn(Mono.just(Collections.singletonMap("task1", Optional.empty())));
TaskRelocationPlan taskRelocationPlan = oneMigrationPlan();
Map<String, TaskRelocationPlan> storeResult = step.persistChangesInStore(Collections.singletonMap(taskRelocationPlan.getTaskId(), taskRelocationPlan));
assertThat(storeResult).hasSize(1);
verify(store, times(1)).createOrUpdateTaskRelocationPlans(Collections.singletonList(taskRelocationPlan));
// No try again with the same data, and make sure no store update is executed
Map<String, TaskRelocationPlan> storeResultRepeated = step.persistChangesInStore(Collections.singletonMap(taskRelocationPlan.getTaskId(), taskRelocationPlan));
assertThat(storeResultRepeated).hasSize(1);
verify(store, times(1)).createOrUpdateTaskRelocationPlans(Collections.singletonList(taskRelocationPlan));
}
use of com.netflix.titus.api.relocation.model.TaskRelocationPlan in project titus-control-plane by Netflix.
the class MustBeRelocatedTaskStoreUpdateStepTest method testRemove.
@Test
public void testRemove() {
TaskRelocationPlan taskRelocationPlan = oneMigrationPlan();
when(store.getAllTaskRelocationPlans()).thenReturn(Mono.just(Collections.singletonMap(taskRelocationPlan.getTaskId(), taskRelocationPlan)));
MustBeRelocatedTaskStoreUpdateStep step = new MustBeRelocatedTaskStoreUpdateStep(configuration, store, transactionLog, titusRuntime);
when(store.removeTaskRelocationPlans(Collections.singleton(taskRelocationPlan.getTaskId()))).thenReturn(Mono.just(Collections.singletonMap("task1", Optional.empty())));
step.persistChangesInStore(Collections.emptyMap());
verify(store, times(1)).removeTaskRelocationPlans(Collections.singleton(taskRelocationPlan.getTaskId()));
// No try again with the same data, and make sure no store update is executed
step.persistChangesInStore(Collections.emptyMap());
verify(store, times(1)).removeTaskRelocationPlans(Collections.singleton(taskRelocationPlan.getTaskId()));
}
use of com.netflix.titus.api.relocation.model.TaskRelocationPlan in project titus-control-plane by Netflix.
the class TaskEvictionStepTest method testSuccessfulEviction.
@Test
public void testSuccessfulEviction() {
Job<BatchJobExt> job = TestDataFactory.newBatchJob("job1", 1, newSelfManagedDisruptionBudget(1_000));
relocationConnectorStubs.addJob(job);
relocationConnectorStubs.setQuota("job1", 1);
Task task = jobOperations.getTasks().get(0);
relocationConnectorStubs.place(TestDataFactory.REMOVABLE_INSTANCE_GROUP_ID, task);
TaskRelocationPlan taskRelocationPlan = oneMigrationPlan().toBuilder().withTaskId(task.getId()).build();
Map<String, TaskRelocationStatus> result = step.evict(Collections.singletonMap(task.getId(), taskRelocationPlan));
assertThat(result).hasSize(1);
TaskRelocationStatus relocationStatus = result.get(task.getId());
assertThat(relocationStatus.getTaskId()).isEqualTo(task.getId());
assertThat(relocationStatus.getStatusCode()).isEqualTo(TaskRelocationStatus.STATUS_CODE_TERMINATED);
assertThat(relocationStatus.getTaskRelocationPlan()).isEqualTo(taskRelocationPlan);
}
use of com.netflix.titus.api.relocation.model.TaskRelocationPlan in project titus-control-plane by Netflix.
the class TaskMigrationDeschedulerTest method testSelfMigrationAfterDeadline.
@Test
public void testSelfMigrationAfterDeadline() {
Task job1Task0 = jobOperations.getTasks("job1").get(0);
relocationConnectorStubs.place("removable1", job1Task0);
relocationConnectorStubs.setQuota("job1", 1);
TaskRelocationPlan job1Task0Plan = TaskRelocationPlan.newBuilder().withTaskId(job1Task0.getId()).withRelocationTime(clock.wallTime() - 1).build();
Optional<Pair<TitusNode, List<Task>>> results = newDescheduler(Collections.singletonMap(job1Task0.getId(), job1Task0Plan)).nextBestMatch();
assertThat(results).isNotEmpty();
}
Aggregations