Search in sources :

Example 6 with GetAllLoadBalancersResult

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);
}
Also used : GetAllLoadBalancersResult(com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult) GetAllLoadBalancersRequest(com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 7 with GetAllLoadBalancersResult

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();
    });
}
Also used : Set(java.util.Set) GetAllLoadBalancersResult(com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Example 8 with GetAllLoadBalancersResult

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;
}
Also used : TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) GetAllLoadBalancersResult(com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult) GetAllLoadBalancersRequest(com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest)

Aggregations

GetAllLoadBalancersResult (com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult)8 Test (org.junit.Test)6 JobLoadBalancer (com.netflix.titus.api.loadbalancer.model.JobLoadBalancer)3 GetAllLoadBalancersRequest (com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest)2 BaseIntegrationTest (com.netflix.titus.master.integration.BaseIntegrationTest)2 IntegrationTest (com.netflix.titus.testkit.junit.category.IntegrationTest)2 Set (java.util.Set)2 GetJobLoadBalancersResult (com.netflix.titus.grpc.protogen.GetJobLoadBalancersResult)1 TestStreamObserver (com.netflix.titus.testkit.grpc.TestStreamObserver)1 HashSet (java.util.HashSet)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1