Search in sources :

Example 1 with GrpcJobManagementModelConverters

use of com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobManagementModelConverters 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();
}
Also used : Random(java.util.Random) ArrayList(java.util.ArrayList) GrpcJobManagementModelConverters(com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobManagementModelConverters) JobQuery(com.netflix.titus.grpc.protogen.JobQuery) Job(com.netflix.titus.grpc.protogen.Job) JobQueryResult(com.netflix.titus.grpc.protogen.JobQueryResult) Test(org.junit.Test)

Aggregations

Job (com.netflix.titus.grpc.protogen.Job)1 JobQuery (com.netflix.titus.grpc.protogen.JobQuery)1 JobQueryResult (com.netflix.titus.grpc.protogen.JobQueryResult)1 GrpcJobManagementModelConverters (com.netflix.titus.runtime.endpoint.v3.grpc.GrpcJobManagementModelConverters)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 Test (org.junit.Test)1