use of com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult in project titus-control-plane by Netflix.
the class AggregatingLoadBalancerServiceTest method getAllLoadBalancersNoPagination.
@Test
public void getAllLoadBalancersNoPagination() {
JobLoadBalancer jobLoadBalancer1 = new JobLoadBalancer(JOB_1, LB_1);
JobLoadBalancer jobLoadBalancer2 = new JobLoadBalancer(JOB_2, LB_2);
final CellWithLoadBalancers cellWithLoadBalancersOne = new CellWithLoadBalancers(singletonList(jobLoadBalancer1));
final CellWithLoadBalancers cellWithLoadBalancersTwo = new CellWithLoadBalancers(singletonList(jobLoadBalancer2));
cellOne.getServiceRegistry().addService(cellWithLoadBalancersOne);
cellTwo.getServiceRegistry().addService(cellWithLoadBalancersTwo);
final AssertableSubscriber<GetAllLoadBalancersResult> resultSubscriber = service.getAllLoadBalancers(GetAllLoadBalancersRequest.newBuilder().setPage(Page.newBuilder().setPageNumber(0).setPageSize(10)).build(), JUNIT_REST_CALL_METADATA).test();
resultSubscriber.awaitValueCount(1, 1, TimeUnit.SECONDS);
resultSubscriber.assertNoErrors();
final List<GetAllLoadBalancersResult> onNextEvents = resultSubscriber.getOnNextEvents();
assertThat(onNextEvents).hasSize(1);
assertThat(onNextEvents.get(0).getJobLoadBalancersCount()).isEqualTo(2);
}
use of com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult in project titus-control-plane by Netflix.
the class LoadBalancerGrpcTest method testGetAllLoadBalancerPages.
@Test(timeout = TEST_TIMEOUT_MS)
public void testGetAllLoadBalancerPages() throws Exception {
int numJobs = 75;
int numLbs = 7;
Map<String, Set<LoadBalancerId>> verificationMap = LoadBalancerTests.putLoadBalancersPerJob(numJobs, numLbs, putLoadBalancerWithJobId);
int pageSize = 3;
int currentPageNum = 0;
GetAllLoadBalancersResult result;
do {
result = LoadBalancerTests.getAllLoadBalancers(buildPageSupplier(currentPageNum, pageSize), getAllLoadBalancers);
result.getJobLoadBalancersList().forEach(getJobLoadBalancersResult -> {
String jobId = getJobLoadBalancersResult.getJobId();
assertThat(verificationMap.containsKey(jobId)).isTrue();
getJobLoadBalancersResult.getLoadBalancersList().forEach(loadBalancerId -> {
// Mark the load balancer as checked
assertThat(verificationMap.get(jobId).remove(loadBalancerId)).isTrue();
});
});
currentPageNum++;
} while (result.getPagination().getHasMore());
// Make sure that all of the data was checked
verificationMap.forEach((jobId, loadBalancerSet) -> {
assertThat(loadBalancerSet.isEmpty()).isTrue();
});
}
use of com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult in project titus-control-plane by Netflix.
the class LoadBalancerResourceTest method getAllJobsTest.
@Test
public void getAllJobsTest() {
GetAllLoadBalancersResult expectedResult = GetAllLoadBalancersResult.newBuilder().build();
when(uriInfo.getQueryParameters()).thenReturn(getDefaultPageParameters());
when(loadBalancerService.getAllLoadBalancers(any(), any())).thenReturn(Observable.just(expectedResult));
GetAllLoadBalancersResult actualResult = loadBalancerResource.getAllLoadBalancers(uriInfo);
assertEquals(expectedResult, actualResult);
}
use of com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult in project titus-control-plane by Netflix.
the class GrpcModelConverters method toGetAllLoadBalancersResult.
public static GetAllLoadBalancersResult toGetAllLoadBalancersResult(List<JobLoadBalancer> jobLoadBalancerList, Pagination runtimePagination) {
GetAllLoadBalancersResult.Builder allLoadBalancersResult = GetAllLoadBalancersResult.newBuilder();
allLoadBalancersResult.setPagination(toGrpcPagination(runtimePagination));
// We expect the list to be in a sorted-by-jobId order and iterate as such
GetJobLoadBalancersResult.Builder getJobLoadBalancersResultBuilder = GetJobLoadBalancersResult.newBuilder();
Set<String> addedJobIds = new HashSet<>();
for (JobLoadBalancer jobLoadBalancer : jobLoadBalancerList) {
String jobId = jobLoadBalancer.getJobId();
// Check if we're processing a new Job ID
if (!addedJobIds.contains(jobId)) {
// Add any previous JobID's result if it existed
if (getJobLoadBalancersResultBuilder.getLoadBalancersBuilderList().size() > 0) {
allLoadBalancersResult.addJobLoadBalancers(getJobLoadBalancersResultBuilder.build());
}
getJobLoadBalancersResultBuilder = GetJobLoadBalancersResult.newBuilder().setJobId(jobId);
addedJobIds.add(jobId);
}
getJobLoadBalancersResultBuilder.addLoadBalancers(LoadBalancerId.newBuilder().setId(jobLoadBalancer.getLoadBalancerId()).build());
}
if (getJobLoadBalancersResultBuilder.getLoadBalancersBuilderList().size() > 0) {
allLoadBalancersResult.addJobLoadBalancers(getJobLoadBalancersResultBuilder.build());
}
return allLoadBalancersResult.build();
}
use of com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult in project titus-control-plane by Netflix.
the class AggregatingLoadBalancerServiceTest method getLoadBalancersWithOneFailingCell.
@Test
public void getLoadBalancersWithOneFailingCell() {
JobLoadBalancer jobLoadBalancer1 = new JobLoadBalancer(JOB_1, LB_1);
JobLoadBalancer jobLoadBalancer2 = new JobLoadBalancer(JOB_1, LB_2);
final CellWithLoadBalancers cellWithLoadBalancersOne = new CellWithLoadBalancers(Arrays.asList(jobLoadBalancer1, jobLoadBalancer2));
cellOne.getServiceRegistry().addService(cellWithLoadBalancersOne);
cellTwo.getServiceRegistry().addService(new CellWithFailingLoadBalancers(Status.INTERNAL));
final AssertableSubscriber<GetAllLoadBalancersResult> resultSubscriber = service.getAllLoadBalancers(GetAllLoadBalancersRequest.newBuilder().setPage(Page.newBuilder().setPageSize(10)).build(), JUNIT_REST_CALL_METADATA).test();
resultSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
resultSubscriber.assertNoValues();
final List<Throwable> onErrorEvents = resultSubscriber.getOnErrorEvents();
assertThat(onErrorEvents).hasSize(1);
assertThat(Status.fromThrowable(onErrorEvents.get(0))).isEqualTo(Status.INTERNAL);
}
Aggregations