use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class JobSubmitAndControlBasicTest method testSubmitBatchJobWithEfsMount.
/**
* Verify batch job submit with the expected state transitions. Verify agent receives proper EFS mount data.
*/
@Test(timeout = 30_000)
public void testSubmitBatchJobWithEfsMount() {
EfsMount efsMount1 = ContainersGenerator.efsMounts().getValue().toBuilder().withMountPoint("/data/logs").build();
EfsMount efsMount2 = ContainersGenerator.efsMounts().skip(1).getValue().toBuilder().withMountPoint("/data").build();
List<EfsMount> efsMounts = asList(efsMount1, efsMount2);
List<EfsMount> expectedOrder = asList(efsMount2, efsMount1);
JobDescriptor<BatchJobExt> jobWithEfs = ONE_TASK_BATCH_JOB.but(jd -> jd.getContainer().but(c -> c.getContainerResources().toBuilder().withEfsMounts(efsMounts)));
jobsScenarioBuilder.schedule(jobWithEfs, jobScenarioBuilder -> jobScenarioBuilder.template(ScenarioTemplates.startTasksInNewJob()).assertEachPod(podWithEfsMounts(expectedOrder), "Container not assigned the expected EFS mount").allTasks(ScenarioTemplates.completeTask()).template(ScenarioTemplates.jobFinished()).expectJobEventStreamCompletes());
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class RateLimiterInterceptorTest method testRateLimiting.
@Test
public void testRateLimiting() throws Exception {
Job<BatchJobExt> job = batchJobs(JobDescriptorGenerator.oneTaskBatchJobDescriptor()).getValue();
// Use all tokens
EntityHolder nextRoot = EntityHolder.newRoot("root", job);
for (int i = 0; i < BUCKET_SIZE; i++) {
assertThat(rateLimiterInterceptor.executionLimits(nextRoot)).isEqualTo(BUCKET_SIZE - i);
ModelAction updateAction = executeRateLimitedAction(SampleTitusChangeActions.successfulJob());
nextRoot = updateAction.apply(nextRoot).get().getRight();
}
assertThat(rateLimiterInterceptor.executionLimits(nextRoot)).isEqualTo(0);
// Refill
testClock.advanceTime(REFILL_INTERVAL_MS, TimeUnit.MILLISECONDS);
assertThat(rateLimiterInterceptor.executionLimits(nextRoot)).isEqualTo(1);
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt 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.jobmanager.model.job.ext.BatchJobExt 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.jobmanager.model.job.ext.BatchJobExt 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);
}
Aggregations