use of com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult in project titus-control-plane by Netflix.
the class LoadBalancerSpringResourceTest method testGetAllLoadBalancers.
@Test
public void testGetAllLoadBalancers() throws Exception {
GetAllLoadBalancersRequest request = GetAllLoadBalancersRequest.newBuilder().setPage(NEXT_PAGE_OF_1).build();
GetAllLoadBalancersResult response = GetAllLoadBalancersResult.newBuilder().setPagination(SpringMockMvcUtil.paginationOf(NEXT_PAGE_OF_1)).addJobLoadBalancers(GET_JOB_LOAD_BALANCERS_RESULT).build();
when(serviceMock.getAllLoadBalancers(request, JUNIT_REST_CALL_METADATA)).thenReturn(Observable.just(response));
GetAllLoadBalancersResult entity = SpringMockMvcUtil.doPaginatedGet(mockMvc, "/api/v3/loadBalancers", GetAllLoadBalancersResult.class, NEXT_PAGE_OF_1);
assertThat(entity).isEqualTo(response);
verify(serviceMock, times(1)).getAllLoadBalancers(request, JUNIT_REST_CALL_METADATA);
}
use of com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult in project titus-control-plane by Netflix.
the class LoadBalancerGrpcTest method testGetAllLoadBalancerPagesWithCursor.
@Test(timeout = TEST_TIMEOUT_MS)
public void testGetAllLoadBalancerPagesWithCursor() throws Exception {
int numJobs = 75;
int numLbs = 7;
Map<String, Set<LoadBalancerId>> verificationMap = LoadBalancerTests.putLoadBalancersPerJob(numJobs, numLbs, putLoadBalancerWithJobId);
int pageSize = 3;
String cursor = "";
GetAllLoadBalancersResult result;
do {
result = LoadBalancerTests.getAllLoadBalancers(buildPageSupplier(cursor, 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
logger.info("checking lb {} exists for job {} - {}", loadBalancerId.getId(), jobId, verificationMap.get(jobId).contains(loadBalancerId));
assertThat(verificationMap.get(jobId).remove(loadBalancerId)).isTrue();
});
});
cursor = result.getPagination().getCursor();
} 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 LoadBalancerTests method getAllLoadBalancers.
/**
* Common testing helper that gets all load balancers for a given page range, ensures the gRPC
* request was successful, and returns the page result.
*/
public static GetAllLoadBalancersResult getAllLoadBalancers(Supplier<Page> pageSupplier, BiConsumer<GetAllLoadBalancersRequest, TestStreamObserver<GetAllLoadBalancersResult>> getAllLoadBalancers) {
GetAllLoadBalancersRequest request = GetAllLoadBalancersRequest.newBuilder().setPage(pageSupplier.get()).build();
TestStreamObserver<GetAllLoadBalancersResult> getResponse = new TestStreamObserver<>();
getAllLoadBalancers.accept(request, getResponse);
GetAllLoadBalancersResult result = null;
try {
result = getResponse.takeNext(TIMEOUT_MS, TimeUnit.MILLISECONDS);
} catch (Exception e) {
logger.error("Exception in getAllLoadBalancers", e);
assert false;
}
assertThat(getResponse.hasError()).isFalse();
return result;
}
Aggregations