use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class MoveTaskTest method testMoveWithStoreUpdateFailure.
@Test
public void testMoveWithStoreUpdateFailure() {
JobDescriptor<ServiceJobExt> jobDescriptor = oneTaskServiceJobDescriptor();
String targetJobId = startNewJob(jobDescriptor).getJobId();
JobScenarioBuilder sourceJobBuilder = startNewJob(jobDescriptor);
String sourceJobId = sourceJobBuilder.getJobId();
try {
sourceJobBuilder.advance().breakStore().allTasks(tasks -> assertThat(tasks).hasSize(1)).moveTask(0, 0, sourceJobId, targetJobId);
} catch (Exception e) {
assertThat(ExceptionExt.toMessageChain(e)).contains("Store is broken");
}
jobsScenarioBuilder.getJobScenario(0).allTasks(tasks -> assertThat(tasks).hasSize(1));
jobsScenarioBuilder.getJobScenario(1).allTasks(tasks -> assertThat(tasks).hasSize(1));
}
use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class MoveTaskTest method testMoveWithInvalidTargetJob.
@Test
public void testMoveWithInvalidTargetJob() {
JobDescriptor<ServiceJobExt> jobDescriptor = oneTaskServiceJobDescriptor();
JobScenarioBuilder sourceJobBuilder = startNewJob(jobDescriptor);
String sourceJobId = sourceJobBuilder.getJobId();
String targetJobId = startNewJob(oneTaskBatchJobDescriptor()).getJobId();
try {
sourceJobBuilder.moveTask(0, 0, sourceJobId, targetJobId);
} catch (JobManagerException e) {
assertThat(e.getErrorCode()).isEqualTo(JobManagerException.ErrorCode.NotServiceJob);
}
}
use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class MoveTaskTest method testMoveTimeout.
@Test
public void testMoveTimeout() {
JobDescriptor<ServiceJobExt> jobDescriptor = oneTaskServiceJobDescriptor();
JobScenarioBuilder sourceJobBuilder = startNewJob(jobDescriptor);
String sourceJobId = sourceJobBuilder.getJobId();
String targetJobId = startNewJob(jobDescriptor).getJobId();
sourceJobBuilder.advance().slowStore().inTask(0, 0, task -> {
ExtTestSubscriber<Void> testSubscriber = new ExtTestSubscriber<>();
jobsScenarioBuilder.getJobOperations().moveServiceTask(sourceJobId, targetJobId, task.getId(), callMetadata).timeout(1, TimeUnit.SECONDS, testScheduler).subscribe(testSubscriber);
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
assertThat(testSubscriber.isError()).isTrue();
assertThat(testSubscriber.getError()).isInstanceOf(TimeoutException.class);
});
}
use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class ServiceJobSchedulingTest method testJobScaleDown.
@Test
public void testJobScaleDown() {
Capacity newCapacity = Capacity.newBuilder().withMin(0).withDesired(1).withMax(5).build();
JobDescriptor<ServiceJobExt> twoTaskJob = changeServiceJobCapacity(oneTaskServiceJobDescriptor(), 2);
jobsScenarioBuilder.scheduleJob(twoTaskJob, jobScenario -> jobScenario.expectJobEvent().advance().inActiveTasks((taskIdx, resubmit) -> ScenarioTemplates.acceptTask(taskIdx, resubmit)).template(ScenarioTemplates.changeJobCapacity(newCapacity)).advance().firstTaskMatch(task -> task.getStatus().getState() == TaskState.KillInitiated, matchingTask -> {
assertThat(matchingTask.getStatus().getReasonCode()).isEqualTo(TaskStatus.REASON_SCALED_DOWN);
}));
}
use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class ServiceJobSchedulingTest method testJobScaleDownWithParallelTerminateAndShrink.
@Test
public void testJobScaleDownWithParallelTerminateAndShrink() {
JobDescriptor<ServiceJobExt> twoTaskJob = changeServiceJobCapacity(oneTaskServiceJobDescriptor(), 2);
Capacity newCapacity = Capacity.newBuilder().withMin(0).withDesired(0).withMax(5).build();
jobsScenarioBuilder.withConcurrentStoreUpdateLimit(1).scheduleJob(twoTaskJob, jobScenario -> jobScenario.expectJobEvent().advance().inActiveTasks((taskIdx, resubmit) -> ScenarioTemplates.acceptTask(taskIdx, resubmit)).inActiveTasks((taskIdx, resubmit) -> ScenarioTemplates.startTask(taskIdx, resubmit, TaskState.Started)).changeCapacity(newCapacity).allTasks(tasks -> tasks.forEach(jobScenario::killTaskAndShrinkNoWait)).advance().advance().advance().assertServiceJob(job -> {
Capacity capacity = job.getJobDescriptor().getExtensions().getCapacity();
assertThat(capacity.getMin()).isEqualTo(0);
assertThat(capacity.getDesired()).isEqualTo(0);
}));
}
Aggregations