Search in sources :

Example 1 with TaskKillRequest

use of com.netflix.titus.grpc.protogen.TaskKillRequest in project titus-control-plane by Netflix.

the class JobManagementSpringResourceTest method taskKillTask.

@Test
public void taskKillTask() throws Exception {
    TaskKillRequest forwardedRequest = TaskKillRequest.newBuilder().setTaskId(TASK_ID_1).setShrink(true).setPreventMinSizeUpdate(true).build();
    when(jobServiceGatewayMock.killTask(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Completable.complete());
    SpringMockMvcUtil.doDelete(mockMvc, String.format("/api/v3/tasks/%s", TASK_ID_1), "shrink", "true", "preventMinSizeUpdate", "true");
    verify(jobServiceGatewayMock, times(1)).killTask(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
Also used : TaskKillRequest(com.netflix.titus.grpc.protogen.TaskKillRequest) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Example 2 with TaskKillRequest

use of com.netflix.titus.grpc.protogen.TaskKillRequest in project titus-control-plane by Netflix.

the class AggregatingJobServiceGatewayTest method killTask.

@Test
public void killTask() {
    Random random = new Random();
    List<Task> cellOneSnapshot = new ArrayList<>(dataGenerator.newServiceJobWithTasks());
    List<Task> cellTwoSnapshot = new ArrayList<>(dataGenerator.newBatchJobWithTasks());
    CellWithFixedTasksService cellOneService = new CellWithFixedTasksService(cellOneSnapshot);
    CellWithFixedTasksService cellTwoService = new CellWithFixedTasksService(cellTwoSnapshot);
    cellOne.getServiceRegistry().addService(cellOneService);
    cellTwo.getServiceRegistry().addService(cellTwoService);
    Task killInCellOne = cellOneSnapshot.get(random.nextInt(cellOneSnapshot.size()));
    Task killInCellTwo = cellTwoSnapshot.get(random.nextInt(cellTwoSnapshot.size()));
    assertThat(cellOneService.currentTasks()).containsKey(killInCellOne.getId());
    assertThat(cellTwoService.currentTasks()).containsKey(killInCellTwo.getId());
    TaskKillRequest cellOneRequest = TaskKillRequest.newBuilder().setTaskId(killInCellOne.getId()).setShrink(false).build();
    AssertableSubscriber<Void> testSubscriber = service.killTask(cellOneRequest, UNDEFINED_CALL_METADATA).test();
    testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
    testSubscriber.assertNoErrors();
    testSubscriber.assertNoValues();
    testSubscriber.assertCompleted();
    assertThat(cellOneService.currentTasks()).doesNotContainKey(killInCellOne.getId());
    assertThat(cellTwoService.currentTasks()).doesNotContainKey(killInCellOne.getId());
    testSubscriber.unsubscribe();
    TaskKillRequest cellTwoRequest = TaskKillRequest.newBuilder().setTaskId(killInCellTwo.getId()).setShrink(false).build();
    testSubscriber = service.killTask(cellTwoRequest, UNDEFINED_CALL_METADATA).test();
    testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
    testSubscriber.assertNoErrors();
    testSubscriber.assertNoValues();
    testSubscriber.assertCompleted();
    assertThat(cellOneService.currentTasks()).doesNotContainKey(killInCellTwo.getId());
    assertThat(cellTwoService.currentTasks()).doesNotContainKey(killInCellTwo.getId());
    testSubscriber.unsubscribe();
}
Also used : Task(com.netflix.titus.grpc.protogen.Task) Random(java.util.Random) TaskKillRequest(com.netflix.titus.grpc.protogen.TaskKillRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

TaskKillRequest (com.netflix.titus.grpc.protogen.TaskKillRequest)2 Test (org.junit.Test)2 Task (com.netflix.titus.grpc.protogen.Task)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1