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());
}
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);
}
}
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();
}
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");
}
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");
}
Aggregations