use of com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder in project titus-control-plane by Netflix.
the class MoveTaskTest method testMoveWithIncompatibleTargetJob.
@Test
public void testMoveWithIncompatibleTargetJob() {
JobDescriptor<ServiceJobExt> jobDescriptor = oneTaskServiceJobDescriptor();
JobScenarioBuilder sourceJobBuilder = startNewJob(jobDescriptor);
String sourceJobId = sourceJobBuilder.getJobId();
JobDescriptor<ServiceJobExt> incompatible = jobDescriptor.but(descriptor -> descriptor.getContainer().but(container -> container.getImage().toBuilder().withName("other/image").build()));
String targetJobId = startNewJob(incompatible).getJobId();
try {
sourceJobBuilder.moveTask(0, 0, sourceJobId, targetJobId);
} catch (JobManagerException e) {
assertThat(e.getErrorCode()).isEqualTo(JobManagerException.ErrorCode.JobsNotCompatible);
assertThat(e.getMessage()).contains("container.image.name");
}
}
use of com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder in project titus-control-plane by Netflix.
the class TaskRetryPolicyTest method testRetryPolicyResetIfTaskInStartedStateLongEnough.
private void testRetryPolicyResetIfTaskInStartedStateLongEnough(JobDescriptor<?> jobWithRetries, int retryLimit) {
JobScenarioBuilder jobScenario = runJob(jobWithRetries);
failRetryableTask(EXPONENTIAL_DELAYS_SEC, TimeUnit.SECONDS, retryLimit - 1);
// Start the active task, and keep it running long enough to reset retryer
jobScenario.template(ScenarioTemplates.startTask(0, retryLimit - 1, TaskState.Started)).advance(5, TimeUnit.MINUTES);
// Now fail the task again, and expect it to restart immediately.
jobScenario.template(ScenarioTemplates.failRetryableTask(0, retryLimit - 1, 0));
}
use of com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder in project titus-control-plane by Netflix.
the class TaskRetryPolicyTest method batchRunAndFail.
private void batchRunAndFail(JobDescriptor<BatchJobExt> jobWithRetries, int[] delays, TimeUnit timeUnit) {
int retryLimit = jobWithRetries.getExtensions().getRetryPolicy().getRetries();
JobScenarioBuilder jobScenario = runJob(jobWithRetries);
failRetryableTask(delays, timeUnit, retryLimit);
jobScenario.advance().template(ScenarioTemplates.failLastBatchRetryableTask(0, retryLimit));
}
use of com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder 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.master.jobmanager.service.integration.scenario.JobScenarioBuilder 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);
}
}
Aggregations