Search in sources :

Example 6 with GetJobLoadBalancersResult

use of com.netflix.titus.grpc.protogen.GetJobLoadBalancersResult in project titus-control-plane by Netflix.

the class AggregatingLoadBalancerServiceTest method getJobLoadBalancersWithOneFailingCell.

@Test
public void getJobLoadBalancersWithOneFailingCell() {
    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<GetJobLoadBalancersResult> resultSubscriber = service.getLoadBalancers(JobId.newBuilder().setId(JOB_1).build(), JUNIT_REST_CALL_METADATA).test();
    resultSubscriber.awaitValueCount(1, 1, TimeUnit.SECONDS);
    resultSubscriber.assertNoErrors();
    final List<GetJobLoadBalancersResult> onNextEvents = resultSubscriber.getOnNextEvents();
    assertThat(onNextEvents).hasSize(1);
    final List<LoadBalancerId> loadBalancersList = onNextEvents.get(0).getLoadBalancersList();
    final List<String> resultLoadBalancers = loadBalancersList.stream().map(loadBalancerId -> loadBalancerId.getId()).collect(Collectors.toList());
    assertThat(resultLoadBalancers).contains(LB_1, LB_2);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) GetJobLoadBalancersResult(com.netflix.titus.grpc.protogen.GetJobLoadBalancersResult) Arrays(java.util.Arrays) GetAllLoadBalancersRequest(com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest) LoadBalancerId(com.netflix.titus.grpc.protogen.LoadBalancerId) AnonymousCallMetadataResolver(com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver) ManagedChannel(io.grpc.ManagedChannel) Java6Assertions.assertThat(org.assertj.core.api.Java6Assertions.assertThat) AddLoadBalancerRequest(com.netflix.titus.grpc.protogen.AddLoadBalancerRequest) GetAllLoadBalancersResult(com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Observable(rx.Observable) Collections.singletonList(java.util.Collections.singletonList) AssertableSubscriber(rx.observers.AssertableSubscriber) JUNIT_REST_CALL_METADATA(com.netflix.titus.testkit.junit.spring.SpringMockMvcUtil.JUNIT_REST_CALL_METADATA) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Map(java.util.Map) RemoveLoadBalancerRequest(com.netflix.titus.grpc.protogen.RemoveLoadBalancerRequest) Status(io.grpc.Status) Before(org.junit.Before) JobLoadBalancer(com.netflix.titus.api.loadbalancer.model.JobLoadBalancer) Cell(com.netflix.titus.api.federation.model.Cell) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) Page(com.netflix.titus.grpc.protogen.Page) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Rule(org.junit.Rule) Optional(java.util.Optional) GrpcServerRule(io.grpc.testing.GrpcServerRule) Collections(java.util.Collections) JobId(com.netflix.titus.grpc.protogen.JobId) Mockito.mock(org.mockito.Mockito.mock) GetJobLoadBalancersResult(com.netflix.titus.grpc.protogen.GetJobLoadBalancersResult) LoadBalancerId(com.netflix.titus.grpc.protogen.LoadBalancerId) JobLoadBalancer(com.netflix.titus.api.loadbalancer.model.JobLoadBalancer) Test(org.junit.Test)

Example 7 with GetJobLoadBalancersResult

use of com.netflix.titus.grpc.protogen.GetJobLoadBalancersResult in project titus-control-plane by Netflix.

the class LoadBalancerResourceTest method getJobLoadBalancersTest.

@Test
public void getJobLoadBalancersTest() {
    GetJobLoadBalancersResult expectedResult = GetJobLoadBalancersResult.newBuilder().build();
    when(loadBalancerService.getLoadBalancers(any(), any())).thenReturn(Observable.just(expectedResult));
    GetJobLoadBalancersResult actualResult = loadBalancerResource.getJobLoadBalancers(TEST_JOB_ID);
    assertEquals(expectedResult, actualResult);
}
Also used : GetJobLoadBalancersResult(com.netflix.titus.grpc.protogen.GetJobLoadBalancersResult) Test(org.junit.Test)

Aggregations

GetJobLoadBalancersResult (com.netflix.titus.grpc.protogen.GetJobLoadBalancersResult)7 Test (org.junit.Test)6 JobLoadBalancer (com.netflix.titus.api.loadbalancer.model.JobLoadBalancer)4 JobId (com.netflix.titus.grpc.protogen.JobId)3 LoadBalancerId (com.netflix.titus.grpc.protogen.LoadBalancerId)3 Cell (com.netflix.titus.api.federation.model.Cell)1 GrpcConfiguration (com.netflix.titus.federation.startup.GrpcConfiguration)1 AddLoadBalancerRequest (com.netflix.titus.grpc.protogen.AddLoadBalancerRequest)1 GetAllLoadBalancersRequest (com.netflix.titus.grpc.protogen.GetAllLoadBalancersRequest)1 GetAllLoadBalancersResult (com.netflix.titus.grpc.protogen.GetAllLoadBalancersResult)1 Page (com.netflix.titus.grpc.protogen.Page)1 RemoveLoadBalancerRequest (com.netflix.titus.grpc.protogen.RemoveLoadBalancerRequest)1 AnonymousCallMetadataResolver (com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver)1 TestStreamObserver (com.netflix.titus.testkit.grpc.TestStreamObserver)1 JUNIT_REST_CALL_METADATA (com.netflix.titus.testkit.junit.spring.SpringMockMvcUtil.JUNIT_REST_CALL_METADATA)1 ManagedChannel (io.grpc.ManagedChannel)1 Status (io.grpc.Status)1 GrpcServerRule (io.grpc.testing.GrpcServerRule)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1