Search in sources :

Example 1 with JobScenarioBuilder

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");
    }
}
Also used : ScenarioTemplates(com.netflix.titus.master.jobmanager.service.integration.scenario.ScenarioTemplates) ExtTestSubscriber(com.netflix.titus.testkit.rx.ExtTestSubscriber) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) CollectionsExt(com.netflix.titus.common.util.CollectionsExt) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JobDescriptorGenerator.oneTaskBatchJobDescriptor(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskBatchJobDescriptor) TimeoutException(java.util.concurrent.TimeoutException) JobFunctions(com.netflix.titus.api.jobmanager.model.job.JobFunctions) JobScenarioBuilder(com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder) Test(org.junit.Test) JobsScenarioBuilder(com.netflix.titus.master.jobmanager.service.integration.scenario.JobsScenarioBuilder) TestScheduler(rx.schedulers.TestScheduler) TaskState(com.netflix.titus.api.jobmanager.model.job.TaskState) TimeUnit(java.util.concurrent.TimeUnit) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException) ExceptionExt(com.netflix.titus.common.util.ExceptionExt) CallMetadata(com.netflix.titus.api.model.callmetadata.CallMetadata) JobDescriptorGenerator.oneTaskServiceJobDescriptor(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskServiceJobDescriptor) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException) JobScenarioBuilder(com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder) Test(org.junit.Test)

Example 2 with JobScenarioBuilder

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));
}
Also used : JobScenarioBuilder(com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder)

Example 3 with JobScenarioBuilder

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));
}
Also used : JobScenarioBuilder(com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder)

Example 4 with JobScenarioBuilder

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));
}
Also used : ScenarioTemplates(com.netflix.titus.master.jobmanager.service.integration.scenario.ScenarioTemplates) ExtTestSubscriber(com.netflix.titus.testkit.rx.ExtTestSubscriber) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) CollectionsExt(com.netflix.titus.common.util.CollectionsExt) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JobDescriptorGenerator.oneTaskBatchJobDescriptor(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskBatchJobDescriptor) TimeoutException(java.util.concurrent.TimeoutException) JobFunctions(com.netflix.titus.api.jobmanager.model.job.JobFunctions) JobScenarioBuilder(com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder) Test(org.junit.Test) JobsScenarioBuilder(com.netflix.titus.master.jobmanager.service.integration.scenario.JobsScenarioBuilder) TestScheduler(rx.schedulers.TestScheduler) TaskState(com.netflix.titus.api.jobmanager.model.job.TaskState) TimeUnit(java.util.concurrent.TimeUnit) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException) ExceptionExt(com.netflix.titus.common.util.ExceptionExt) CallMetadata(com.netflix.titus.api.model.callmetadata.CallMetadata) JobDescriptorGenerator.oneTaskServiceJobDescriptor(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskServiceJobDescriptor) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) JobScenarioBuilder(com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder) TimeoutException(java.util.concurrent.TimeoutException) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException) Test(org.junit.Test)

Example 5 with JobScenarioBuilder

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);
    }
}
Also used : ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException) JobScenarioBuilder(com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder) Test(org.junit.Test)

Aggregations

JobScenarioBuilder (com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder)7 ServiceJobExt (com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt)4 Test (org.junit.Test)4 JobManagerException (com.netflix.titus.api.jobmanager.service.JobManagerException)3 ExtTestSubscriber (com.netflix.titus.testkit.rx.ExtTestSubscriber)3 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)2 JobFunctions (com.netflix.titus.api.jobmanager.model.job.JobFunctions)2 TaskState (com.netflix.titus.api.jobmanager.model.job.TaskState)2 CallMetadata (com.netflix.titus.api.model.callmetadata.CallMetadata)2 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)2 ExceptionExt (com.netflix.titus.common.util.ExceptionExt)2 JobsScenarioBuilder (com.netflix.titus.master.jobmanager.service.integration.scenario.JobsScenarioBuilder)2 ScenarioTemplates (com.netflix.titus.master.jobmanager.service.integration.scenario.ScenarioTemplates)2 JobDescriptorGenerator.oneTaskBatchJobDescriptor (com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskBatchJobDescriptor)2 JobDescriptorGenerator.oneTaskServiceJobDescriptor (com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskServiceJobDescriptor)2 TimeUnit (java.util.concurrent.TimeUnit)2 TimeoutException (java.util.concurrent.TimeoutException)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 TestScheduler (rx.schedulers.TestScheduler)2