Search in sources :

Example 1 with HealthCheckRequest

use of com.netflix.titus.grpc.protogen.HealthCheckRequest 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)

Aggregations

HealthCheckRequest (com.netflix.titus.grpc.protogen.HealthCheckRequest)1 HealthCheckResponse (com.netflix.titus.grpc.protogen.HealthCheckResponse)1 ServerStatus (com.netflix.titus.grpc.protogen.HealthCheckResponse.ServerStatus)1 HealthGrpc (com.netflix.titus.grpc.protogen.HealthGrpc)1 Test (org.junit.Test)1