use of com.netflix.titus.grpc.protogen.JobCapacityUpdate in project titus-control-plane by Netflix.
the class AggregatingJobServiceGatewayTest method singleJobUpdates.
@Test
public void singleJobUpdates() {
Random random = new Random();
List<String> cellOneSnapshot = new ArrayList<>(dataGenerator.newServiceJobs(12)).stream().map(job -> job.getId()).collect(Collectors.toList());
List<String> cellTwoSnapshot = new ArrayList<>(dataGenerator.newBatchJobs(7)).stream().map(job -> job.getId()).collect(Collectors.toList());
CellWithJobIds cellOneService = new CellWithJobIds(cellOneSnapshot);
CellWithJobIds cellTwoService = new CellWithJobIds(cellTwoSnapshot);
cellOne.getServiceRegistry().addService(cellOneService);
cellTwo.getServiceRegistry().addService(cellTwoService);
String cellOneJobId = cellOneSnapshot.get(random.nextInt(cellOneSnapshot.size()));
String cellTwoJobId = cellTwoSnapshot.get(random.nextInt(cellTwoSnapshot.size()));
assertThat(cellOneService.containsCapacityUpdates(cellOneJobId)).isFalse();
assertThat(cellTwoService.containsCapacityUpdates(cellOneJobId)).isFalse();
JobCapacityUpdate cellOneUpdate = JobCapacityUpdate.newBuilder().setJobId(cellOneJobId).setCapacity(Capacity.newBuilder().setMax(1).setDesired(2).setMax(3).build()).build();
AssertableSubscriber<Void> testSubscriber = service.updateJobCapacity(cellOneUpdate, UNDEFINED_CALL_METADATA).test();
testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
testSubscriber.assertNoErrors();
testSubscriber.assertNoValues();
testSubscriber.assertCompleted();
assertThat(cellOneService.containsCapacityUpdates(cellOneJobId)).isTrue();
assertThat(cellTwoService.containsCapacityUpdates(cellOneJobId)).isFalse();
testSubscriber.unsubscribe();
JobCapacityUpdate cellTwoUpdate = JobCapacityUpdate.newBuilder().setJobId(cellTwoJobId).setCapacity(Capacity.newBuilder().setMax(2).setDesired(2).setMax(2).build()).build();
testSubscriber = service.updateJobCapacity(cellTwoUpdate, UNDEFINED_CALL_METADATA).test();
testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
testSubscriber.assertNoErrors();
testSubscriber.assertNoValues();
testSubscriber.assertCompleted();
assertThat(cellOneService.containsCapacityUpdates(cellTwoJobId)).isFalse();
assertThat(cellTwoService.containsCapacityUpdates(cellTwoJobId)).isTrue();
testSubscriber.unsubscribe();
}
use of com.netflix.titus.grpc.protogen.JobCapacityUpdate in project titus-control-plane by Netflix.
the class JobManagementSpringResourceTest method testSetInstances.
@Test
public void testSetInstances() throws Exception {
Capacity capacity = Capacity.newBuilder().setMin(1).setDesired(2).setMax(3).build();
JobCapacityUpdate forwardedRequest = JobCapacityUpdate.newBuilder().setJobId(JOB_ID_1).setCapacity(capacity).build();
when(jobServiceGatewayMock.updateJobCapacity(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Completable.complete());
SpringMockMvcUtil.doPut(mockMvc, String.format("/api/v3/jobs/%s/instances", JOB_ID_1), capacity);
verify(jobServiceGatewayMock, times(1)).updateJobCapacity(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
Aggregations