Search in sources :

Example 11 with ExtTestSubscriber

use of com.netflix.titus.testkit.rx.ExtTestSubscriber 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 12 with ExtTestSubscriber

use of com.netflix.titus.testkit.rx.ExtTestSubscriber in project titus-control-plane by Netflix.

the class RateLimiterInterceptorTest method executeRateLimitedAction.

private ModelAction executeRateLimitedAction(TitusChangeAction changeAction) {
    ExtTestSubscriber<List<ModelActionHolder>> testSubscriber = new ExtTestSubscriber<>();
    rateLimiterInterceptor.apply(changeAction).apply().subscribe(testSubscriber);
    ModelAction updateAction = testSubscriber.takeNext().get(0).getAction();
    assertThat(updateAction).isInstanceOf(TitusModelAction.class);
    return updateAction;
}
Also used : ExtTestSubscriber(com.netflix.titus.testkit.rx.ExtTestSubscriber) TitusModelAction(com.netflix.titus.master.jobmanager.service.common.action.TitusModelAction) ModelAction(com.netflix.titus.common.framework.reconciler.ModelAction) List(java.util.List)

Example 13 with ExtTestSubscriber

use of com.netflix.titus.testkit.rx.ExtTestSubscriber in project titus-control-plane by Netflix.

the class JobScenarioBuilder method moveTask.

public JobScenarioBuilder moveTask(int taskIdx, int resubmit, String sourceJobId, String targetJobId) {
    Task task = findTaskInActiveState(taskIdx, resubmit);
    ExtTestSubscriber<Void> subscriber = new ExtTestSubscriber<>();
    jobOperations.moveServiceTask(sourceJobId, targetJobId, task.getId(), callMetadata).subscribe(subscriber);
    autoAdvanceUntilSuccessful(() -> checkOperationSubscriberAndThrowExceptionIfError(subscriber));
    return this;
}
Also used : Task(com.netflix.titus.api.jobmanager.model.job.Task) BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) ExtTestSubscriber(com.netflix.titus.testkit.rx.ExtTestSubscriber)

Example 14 with ExtTestSubscriber

use of com.netflix.titus.testkit.rx.ExtTestSubscriber in project titus-control-plane by Netflix.

the class JobScenarioBuilder method changeCapacity.

public JobScenarioBuilder changeCapacity(Capacity newCapacity) {
    ExtTestSubscriber<Void> subscriber = new ExtTestSubscriber<>();
    CapacityAttributes capacityAttributes = JobModel.newCapacityAttributes(newCapacity).build();
    jobOperations.updateJobCapacityAttributes(jobId, capacityAttributes, CHANGE_CAPACITY_CALL_METADATA).subscribe(subscriber);
    autoAdvanceUntilSuccessful(() -> checkOperationSubscriberAndThrowExceptionIfError(subscriber));
    return this;
}
Also used : ExtTestSubscriber(com.netflix.titus.testkit.rx.ExtTestSubscriber) CapacityAttributes(com.netflix.titus.api.jobmanager.model.job.CapacityAttributes)

Aggregations

ExtTestSubscriber (com.netflix.titus.testkit.rx.ExtTestSubscriber)14 Test (org.junit.Test)11 List (java.util.List)8 Task (com.netflix.titus.api.jobmanager.model.job.Task)4 JobChangeNotification (com.netflix.titus.grpc.protogen.JobChangeNotification)4 Job (com.netflix.titus.api.jobmanager.model.job.Job)3 TaskUpdateEvent (com.netflix.titus.api.jobmanager.model.job.event.TaskUpdateEvent)3 ChangeAction (com.netflix.titus.common.framework.reconciler.ChangeAction)3 EntityHolder (com.netflix.titus.common.framework.reconciler.EntityHolder)3 MultiEngineChangeAction (com.netflix.titus.common.framework.reconciler.MultiEngineChangeAction)3 Observable (rx.Observable)3 JobUpdateEvent (com.netflix.titus.api.jobmanager.model.job.event.JobUpdateEvent)2 ModelActionHolder (com.netflix.titus.common.framework.reconciler.ModelActionHolder)2 IntegrationNotParallelizableTest (com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)2 BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)1 CapacityAttributes (com.netflix.titus.api.jobmanager.model.job.CapacityAttributes)1 ServiceJobExt (com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt)1 MasterInstance (com.netflix.titus.api.supervisor.model.MasterInstance)1 MasterDescription (com.netflix.titus.api.supervisor.service.MasterDescription)1 ModelAction (com.netflix.titus.common.framework.reconciler.ModelAction)1