Search in sources :

Example 31 with ServiceJobExt

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));
}
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 32 with ServiceJobExt

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);
    }
}
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)

Example 33 with ServiceJobExt

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

Example 34 with ServiceJobExt

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);
    }));
}
Also used : RecordingCodeInvariants(com.netflix.titus.common.util.code.RecordingCodeInvariants) ScenarioTemplates(com.netflix.titus.master.jobmanager.service.integration.scenario.ScenarioTemplates) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) Job(com.netflix.titus.api.jobmanager.model.job.Job) ServiceJobProcesses(com.netflix.titus.api.jobmanager.model.job.ServiceJobProcesses) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) JobFunctions.changeServiceJobCapacity(com.netflix.titus.api.jobmanager.model.job.JobFunctions.changeServiceJobCapacity) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TaskStatus(com.netflix.titus.api.jobmanager.model.job.TaskStatus) 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) TaskState(com.netflix.titus.api.jobmanager.model.job.TaskState) Capacity(com.netflix.titus.api.jobmanager.model.job.Capacity) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) CONCURRENT_STORE_UPDATE_LIMIT(com.netflix.titus.master.jobmanager.service.integration.scenario.JobsScenarioBuilder.CONCURRENT_STORE_UPDATE_LIMIT) Assertions.fail(org.assertj.core.api.Assertions.fail) JobState(com.netflix.titus.api.jobmanager.model.job.JobState) After(org.junit.After) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException) JobDescriptorGenerator.oneTaskServiceJobDescriptor(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskServiceJobDescriptor) JobFunctions.changeServiceJobCapacity(com.netflix.titus.api.jobmanager.model.job.JobFunctions.changeServiceJobCapacity) Capacity(com.netflix.titus.api.jobmanager.model.job.Capacity) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) Test(org.junit.Test)

Example 35 with ServiceJobExt

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);
    }));
}
Also used : RecordingCodeInvariants(com.netflix.titus.common.util.code.RecordingCodeInvariants) ScenarioTemplates(com.netflix.titus.master.jobmanager.service.integration.scenario.ScenarioTemplates) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) Job(com.netflix.titus.api.jobmanager.model.job.Job) ServiceJobProcesses(com.netflix.titus.api.jobmanager.model.job.ServiceJobProcesses) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) JobFunctions.changeServiceJobCapacity(com.netflix.titus.api.jobmanager.model.job.JobFunctions.changeServiceJobCapacity) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TaskStatus(com.netflix.titus.api.jobmanager.model.job.TaskStatus) 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) TaskState(com.netflix.titus.api.jobmanager.model.job.TaskState) Capacity(com.netflix.titus.api.jobmanager.model.job.Capacity) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) CONCURRENT_STORE_UPDATE_LIMIT(com.netflix.titus.master.jobmanager.service.integration.scenario.JobsScenarioBuilder.CONCURRENT_STORE_UPDATE_LIMIT) Assertions.fail(org.assertj.core.api.Assertions.fail) JobState(com.netflix.titus.api.jobmanager.model.job.JobState) After(org.junit.After) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException) JobDescriptorGenerator.oneTaskServiceJobDescriptor(com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskServiceJobDescriptor) JobFunctions.changeServiceJobCapacity(com.netflix.titus.api.jobmanager.model.job.JobFunctions.changeServiceJobCapacity) Capacity(com.netflix.titus.api.jobmanager.model.job.Capacity) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) Test(org.junit.Test)

Aggregations

ServiceJobExt (com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt)42 Test (org.junit.Test)17 Capacity (com.netflix.titus.api.jobmanager.model.job.Capacity)13 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)13 Job (com.netflix.titus.api.jobmanager.model.job.Job)11 JobFunctions (com.netflix.titus.api.jobmanager.model.job.JobFunctions)8 Task (com.netflix.titus.api.jobmanager.model.job.Task)8 TaskState (com.netflix.titus.api.jobmanager.model.job.TaskState)8 List (java.util.List)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 Stopwatch (com.google.common.base.Stopwatch)6 Empty (com.google.protobuf.Empty)6 ServiceJobTask (com.netflix.titus.api.jobmanager.model.job.ServiceJobTask)6 JobManagerException (com.netflix.titus.api.jobmanager.service.JobManagerException)6 TestStreamObserver (com.netflix.titus.testkit.grpc.TestStreamObserver)6 JobState (com.netflix.titus.api.jobmanager.model.job.JobState)5 JobScenarioBuilder (com.netflix.titus.master.jobmanager.service.integration.scenario.JobScenarioBuilder)5 JobDescriptorGenerator.oneTaskServiceJobDescriptor (com.netflix.titus.testkit.model.job.JobDescriptorGenerator.oneTaskServiceJobDescriptor)5 ArrayList (java.util.ArrayList)5 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)4