Search in sources :

Example 1 with HealthCheckResponse

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

the class AggregatingHealthServiceTest method grpcErrors.

@Test
public void grpcErrors() {
    cellOne.getServiceRegistry().addService(new CellWithHealthStatus(ok("one")));
    cellTwo.getServiceRegistry().addService(new HealthGrpc.HealthImplBase() {

        @Override
        public void check(HealthCheckRequest request, StreamObserver<HealthCheckResponse> responseObserver) {
            responseObserver.onError(Status.DEADLINE_EXCEEDED.asRuntimeException());
        }
    });
    AssertableSubscriber<HealthCheckResponse> subscriber = service.check(HealthCheckRequest.newBuilder().build()).test();
    subscriber.awaitTerminalEvent(10, TimeUnit.SECONDS);
    subscriber.assertNoErrors();
    subscriber.assertValueCount(1);
    HealthCheckResponse response = subscriber.getOnNextEvents().get(0);
    assertThat(response.getStatus()).isEqualTo(NOT_SERVING);
    assertThat(response.getDetailsCount()).isEqualTo(2);
    List<ServerStatus> errors = response.getDetailsList().stream().filter(ServerStatus::hasError).collect(Collectors.toList());
    assertThat(errors).hasSize(1);
    assertThat(errors.get(0).getError().getCell()).isEqualTo("two");
    assertThat(errors.get(0).getError().getErrorCode()).isEqualTo(DEADLINE_EXCEEDED.toString());
}
Also used : HealthGrpc(com.netflix.titus.grpc.protogen.HealthGrpc) HealthCheckResponse(com.netflix.titus.grpc.protogen.HealthCheckResponse) ServerStatus(com.netflix.titus.grpc.protogen.HealthCheckResponse.ServerStatus) HealthCheckRequest(com.netflix.titus.grpc.protogen.HealthCheckRequest) Test(org.junit.Test)

Example 2 with HealthCheckResponse

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

the class HealthCommand method execute.

@Override
public void execute(CommandContext context) {
    HealthGrpc.HealthBlockingStub client = HealthGrpc.newBlockingStub(context.createChannel());
    try {
        HealthCheckResponse response = client.check(HealthCheckRequest.newBuilder().build());
        logger.info(PrettyPrinters.print(response));
    } catch (Exception e) {
        ErrorReports.handleReplyError("Error querying status", e);
    }
}
Also used : HealthGrpc(com.netflix.titus.grpc.protogen.HealthGrpc) HealthCheckResponse(com.netflix.titus.grpc.protogen.HealthCheckResponse)

Example 3 with HealthCheckResponse

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

the class HealthTest method healthStatus.

@Test(timeout = TEST_TIMEOUT_MS)
public void healthStatus() throws Exception {
    TestStreamObserver<HealthCheckResponse> testStreamObserver = new TestStreamObserver<>();
    titusStackResource.getOperations().getHealthClient().check(HealthCheckRequest.newBuilder().build(), testStreamObserver);
    HealthCheckResponse response = testStreamObserver.takeNext(10, TimeUnit.SECONDS);
    assertThat(testStreamObserver.hasError()).isFalse();
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(SERVING);
    assertThat(response.getDetailsCount()).isGreaterThan(0);
    assertThat(response.getDetails(0).hasDetails()).isTrue();
    HealthCheckResponse.Details details = response.getDetails(0).getDetails();
    assertThat(details.getStatus()).isEqualTo(SERVING);
    assertThat(details.hasUptime()).isTrue();
    assertThat(details.hasElectionTimestamp()).isTrue();
    assertThat(details.hasActivationTime()).isTrue();
    assertThat(details.hasActivationTimestamp()).isTrue();
}
Also used : TestStreamObserver(com.netflix.titus.testkit.grpc.TestStreamObserver) HealthCheckResponse(com.netflix.titus.grpc.protogen.HealthCheckResponse) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Example 4 with HealthCheckResponse

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

the class AggregatingHealthServiceTest method allCellsOK.

@Test
public void allCellsOK() {
    cellOne.getServiceRegistry().addService(new CellWithHealthStatus(ok("one")));
    cellTwo.getServiceRegistry().addService(new CellWithHealthStatus(ok("two")));
    AssertableSubscriber<HealthCheckResponse> subscriber = service.check(HealthCheckRequest.newBuilder().build()).test();
    subscriber.awaitTerminalEvent(10, TimeUnit.SECONDS);
    subscriber.assertNoErrors();
    subscriber.assertValueCount(1);
    HealthCheckResponse response = subscriber.getOnNextEvents().get(0);
    assertThat(response.getStatus()).isEqualTo(SERVING);
    assertThat(response.getDetailsCount()).isEqualTo(2);
    assertThat(response.getDetails(0).hasDetails()).isTrue();
    assertThat(response.getDetails(1).hasDetails()).isTrue();
    Set<String> cellsSeen = response.getDetailsList().stream().map(s -> s.getDetails().getCell()).collect(Collectors.toSet());
    assertThat(cellsSeen).contains("one", "two");
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) AnonymousCallMetadataResolver(com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver) ManagedChannel(io.grpc.ManagedChannel) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) HealthCheckRequest(com.netflix.titus.grpc.protogen.HealthCheckRequest) Durations(com.google.protobuf.util.Durations) AssertableSubscriber(rx.observers.AssertableSubscriber) StreamObserver(io.grpc.stub.StreamObserver) HealthGrpc(com.netflix.titus.grpc.protogen.HealthGrpc) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Map(java.util.Map) Details(com.netflix.titus.grpc.protogen.HealthCheckResponse.Details) Status(io.grpc.Status) Before(org.junit.Before) Clocks(com.netflix.titus.common.util.time.Clocks) HealthCheckResponse(com.netflix.titus.grpc.protogen.HealthCheckResponse) NOT_SERVING(com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.NOT_SERVING) Cell(com.netflix.titus.api.federation.model.Cell) SERVING(com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.SERVING) Set(java.util.Set) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) ServerStatus(com.netflix.titus.grpc.protogen.HealthCheckResponse.ServerStatus) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) DEADLINE_EXCEEDED(io.grpc.Status.Code.DEADLINE_EXCEEDED) Rule(org.junit.Rule) Optional(java.util.Optional) GrpcServerRule(io.grpc.testing.GrpcServerRule) TestClock(com.netflix.titus.common.util.time.TestClock) Collections(java.util.Collections) Mockito.reset(org.mockito.Mockito.reset) Mockito.mock(org.mockito.Mockito.mock) HealthCheckResponse(com.netflix.titus.grpc.protogen.HealthCheckResponse) Test(org.junit.Test)

Example 5 with HealthCheckResponse

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

the class AggregatingHealthServiceTest method allCellsFailing.

@Test
public void allCellsFailing() {
    cellOne.getServiceRegistry().addService(new CellWithHealthStatus(failing("one")));
    cellTwo.getServiceRegistry().addService(new CellWithHealthStatus(failing("two")));
    AssertableSubscriber<HealthCheckResponse> subscriber = service.check(HealthCheckRequest.newBuilder().build()).test();
    subscriber.awaitTerminalEvent(10, TimeUnit.SECONDS);
    subscriber.assertNoErrors();
    subscriber.assertValueCount(1);
    HealthCheckResponse response = subscriber.getOnNextEvents().get(0);
    assertThat(response.getStatus()).isEqualTo(NOT_SERVING);
    assertThat(response.getDetailsCount()).isEqualTo(2);
    assertThat(response.getDetails(0).hasDetails()).isTrue();
    assertThat(response.getDetails(1).hasDetails()).isTrue();
    Set<String> cellsSeen = response.getDetailsList().stream().map(s -> s.getDetails().getCell()).collect(Collectors.toSet());
    assertThat(cellsSeen).contains("one", "two");
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) AnonymousCallMetadataResolver(com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver) ManagedChannel(io.grpc.ManagedChannel) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) HealthCheckRequest(com.netflix.titus.grpc.protogen.HealthCheckRequest) Durations(com.google.protobuf.util.Durations) AssertableSubscriber(rx.observers.AssertableSubscriber) StreamObserver(io.grpc.stub.StreamObserver) HealthGrpc(com.netflix.titus.grpc.protogen.HealthGrpc) GrpcConfiguration(com.netflix.titus.federation.startup.GrpcConfiguration) Map(java.util.Map) Details(com.netflix.titus.grpc.protogen.HealthCheckResponse.Details) Status(io.grpc.Status) Before(org.junit.Before) Clocks(com.netflix.titus.common.util.time.Clocks) HealthCheckResponse(com.netflix.titus.grpc.protogen.HealthCheckResponse) NOT_SERVING(com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.NOT_SERVING) Cell(com.netflix.titus.api.federation.model.Cell) SERVING(com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.SERVING) Set(java.util.Set) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) ServerStatus(com.netflix.titus.grpc.protogen.HealthCheckResponse.ServerStatus) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) DEADLINE_EXCEEDED(io.grpc.Status.Code.DEADLINE_EXCEEDED) Rule(org.junit.Rule) Optional(java.util.Optional) GrpcServerRule(io.grpc.testing.GrpcServerRule) TestClock(com.netflix.titus.common.util.time.TestClock) Collections(java.util.Collections) Mockito.reset(org.mockito.Mockito.reset) Mockito.mock(org.mockito.Mockito.mock) HealthCheckResponse(com.netflix.titus.grpc.protogen.HealthCheckResponse) Test(org.junit.Test)

Aggregations

HealthCheckResponse (com.netflix.titus.grpc.protogen.HealthCheckResponse)7 Test (org.junit.Test)6 HealthGrpc (com.netflix.titus.grpc.protogen.HealthGrpc)5 Cell (com.netflix.titus.api.federation.model.Cell)4 HealthCheckRequest (com.netflix.titus.grpc.protogen.HealthCheckRequest)4 ServerStatus (com.netflix.titus.grpc.protogen.HealthCheckResponse.ServerStatus)4 Durations (com.google.protobuf.util.Durations)3 Clocks (com.netflix.titus.common.util.time.Clocks)3 TestClock (com.netflix.titus.common.util.time.TestClock)3 GrpcConfiguration (com.netflix.titus.federation.startup.GrpcConfiguration)3 Details (com.netflix.titus.grpc.protogen.HealthCheckResponse.Details)3 NOT_SERVING (com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.NOT_SERVING)3 SERVING (com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.SERVING)3 AnonymousCallMetadataResolver (com.netflix.titus.runtime.endpoint.metadata.AnonymousCallMetadataResolver)3 ManagedChannel (io.grpc.ManagedChannel)3 Status (io.grpc.Status)3 DEADLINE_EXCEEDED (io.grpc.Status.Code.DEADLINE_EXCEEDED)3 StreamObserver (io.grpc.stub.StreamObserver)3 GrpcServerRule (io.grpc.testing.GrpcServerRule)3 Collections (java.util.Collections)3