use of com.netflix.titus.grpc.protogen.JobQuery in project titus-control-plane by Netflix.
the class AggregatingJobServiceGatewayTest method findJobsMergesAllCellsIntoSingleResult.
@Test
public void findJobsMergesAllCellsIntoSingleResult() {
Random random = new Random();
final List<Job> cellOneSnapshot = new ArrayList<>();
final List<Job> cellTwoSnapshot = new ArrayList<>();
for (int i = 0; i < 5; i++) {
cellOneSnapshot.addAll(dataGenerator.newBatchJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob));
cellTwoSnapshot.addAll(dataGenerator.newBatchJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob));
cellOneSnapshot.addAll(dataGenerator.newServiceJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob));
cellTwoSnapshot.addAll(dataGenerator.newServiceJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob));
clock.advanceTime(1, TimeUnit.MINUTES);
}
cellOne.getServiceRegistry().addService(new CellWithFixedJobsService(cellOneSnapshot, cellOneUpdates.serialize()));
cellTwo.getServiceRegistry().addService(new CellWithFixedJobsService(cellTwoSnapshot, cellTwoUpdates.serialize()));
JobQuery query = JobQuery.newBuilder().setPage(toGrpcPage(Page.unlimited())).build();
final AssertableSubscriber<JobQueryResult> testSubscriber = service.findJobs(query, UNDEFINED_CALL_METADATA).test();
testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
testSubscriber.assertNoErrors().assertCompleted();
testSubscriber.assertValueCount(1);
final List<JobQueryResult> results = testSubscriber.getOnNextEvents();
assertThat(results).hasSize(1);
// expect stackName to have changed
List<Job> expected = Stream.concat(cellOneSnapshot.stream(), cellTwoSnapshot.stream()).sorted(JobManagerCursors.jobCursorOrderComparator()).map(this::withStackName).collect(Collectors.toList());
assertThat(results.get(0).getItemsList()).containsExactlyElementsOf(expected);
}
use of com.netflix.titus.grpc.protogen.JobQuery in project titus-control-plane by Netflix.
the class AggregatingJobServiceGatewayTest method findJobsWithFailingCell.
@Test
public void findJobsWithFailingCell() {
List<Job> cellTwoSnapshot = new ArrayList<>();
for (int i = 0; i < 5; i++) {
cellTwoSnapshot.addAll(dataGenerator.newBatchJobs(5, GrpcJobManagementModelConverters::toGrpcJob));
cellTwoSnapshot.addAll(dataGenerator.newServiceJobs(5, GrpcJobManagementModelConverters::toGrpcJob));
clock.advanceTime(1, TimeUnit.MINUTES);
}
cellOne.getServiceRegistry().addService(new CellWithFailingJobManagementService());
cellTwo.getServiceRegistry().addService(new CellWithFixedJobsService(cellTwoSnapshot, cellTwoUpdates.serialize()));
JobQuery query = JobQuery.newBuilder().setPage(toGrpcPage(Page.unlimited())).build();
final AssertableSubscriber<JobQueryResult> testSubscriber = service.findJobs(query, UNDEFINED_CALL_METADATA).test();
testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
testSubscriber.assertError(Status.INTERNAL.asRuntimeException().getClass());
testSubscriber.assertNoValues();
}
use of com.netflix.titus.grpc.protogen.JobQuery in project titus-control-plane by Netflix.
the class AggregatingJobServiceGatewayWithSingleCellTest method findJobsAddsStackName.
@Test
public void findJobsAddsStackName() {
Random random = new Random();
final List<Job> cellSnapshot = new ArrayList<>();
for (int i = 0; i < 5; i++) {
cellSnapshot.addAll(dataGenerator.newBatchJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob));
cellSnapshot.addAll(dataGenerator.newServiceJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob));
clock.advanceTime(1, TimeUnit.MINUTES);
}
cell.getServiceRegistry().addService(new CellWithFixedJobsService(cellSnapshot, PublishSubject.create()));
JobQuery query = JobQuery.newBuilder().setPage(toGrpcPage(Page.unlimited())).build();
final AssertableSubscriber<JobQueryResult> testSubscriber = service.findJobs(query, UNDEFINED_CALL_METADATA).test();
testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
testSubscriber.assertNoErrors().assertCompleted();
testSubscriber.assertValueCount(1);
final List<JobQueryResult> results = testSubscriber.getOnNextEvents();
assertThat(results).hasSize(1);
// expect stackName to have changed
List<Job> expected = cellSnapshot.stream().sorted(JobManagerCursors.jobCursorOrderComparator()).map(this::withStackName).collect(Collectors.toList());
assertThat(results.get(0).getItemsList()).containsExactlyElementsOf(expected);
}
use of com.netflix.titus.grpc.protogen.JobQuery in project titus-control-plane by Netflix.
the class JobManagementSpringResourceTest method testFindJobs.
@Test
public void testFindJobs() throws Exception {
JobQuery forwardedRequest = JobQuery.newBuilder().putFilteringCriteria("filter1", "value1").setPage(NEXT_PAGE_OF_2).build();
JobQueryResult expectedResult = JobQueryResult.newBuilder().setPagination(paginationOf(NEXT_PAGE_OF_2)).addAllItems(asList(JOB_1, JOB_2)).build();
when(jobServiceGatewayMock.findJobs(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Observable.just(expectedResult));
JobQueryResult entity = SpringMockMvcUtil.doPaginatedGet(mockMvc, "/api/v3/jobs", JobQueryResult.class, NEXT_PAGE_OF_2, "filter1", "value1");
assertThat(entity).isEqualTo(expectedResult);
verify(jobServiceGatewayMock, times(1)).findJobs(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
use of com.netflix.titus.grpc.protogen.JobQuery in project titus-control-plane by Netflix.
the class AggregatingJobServiceGatewayTest method findJobsEmptyPage.
@Test
public void findJobsEmptyPage() {
Random random = new Random();
final List<Job> cellOneSnapshot = new ArrayList<>();
final List<Job> cellTwoSnapshot = new ArrayList<>();
for (int i = 0; i < 5; i++) {
Iterables.addAll(cellOneSnapshot, Iterables.concat(dataGenerator.newBatchJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob), dataGenerator.newServiceJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob)));
Iterables.addAll(cellTwoSnapshot, Iterables.concat(dataGenerator.newBatchJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob), dataGenerator.newServiceJobs(random.nextInt(10), GrpcJobManagementModelConverters::toGrpcJob)));
clock.advanceTime(1, TimeUnit.MINUTES);
}
cellOne.getServiceRegistry().addService(new CellWithFixedJobsService(cellOneSnapshot, cellOneUpdates.serialize()));
cellTwo.getServiceRegistry().addService(new CellWithFixedJobsService(cellTwoSnapshot, cellTwoUpdates.serialize()));
JobQuery query = JobQuery.newBuilder().setPage(toGrpcPage(Page.empty())).build();
final AssertableSubscriber<JobQueryResult> testSubscriber = service.findJobs(query, UNDEFINED_CALL_METADATA).test();
testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
testSubscriber.assertNoErrors().assertCompleted();
testSubscriber.assertValueCount(1);
final List<JobQueryResult> results = testSubscriber.getOnNextEvents();
assertThat(results).hasSize(1);
assertThat(results.get(0).getItemsList()).isEmpty();
assertThat(results.get(0).getPagination().getHasMore()).isFalse();
}
Aggregations