@Test public void healthNotServing() throws Exception { // Generate a unique in-process server name. String serverName = InProcessServerBuilder.generateName(); HealthCheckAggregator hca = mock(HealthCheckAggregator.class); CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class); HealthCheckStatus hcs = mock(HealthCheckStatus.class); when(hcs.isHealthy()).thenReturn(false); when(hcsf.get()).thenReturn(hcs); when(hca.check()).thenReturn(hcsf); HealthServiceImpl healthyService = new HealthServiceImpl(hca); addService(serverName, healthyService); HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub( // Create a client channel and register for automatic graceful shutdown. grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build())); HealthCheckResponse reply = blockingStub.check(HealthCheckRequest.newBuilder().build()); assertEquals(HealthCheckResponse.ServingStatus.NOT_SERVING, reply.getStatus()); }
assert builder != null; builder.setService("Tiller"); final HealthCheckResponseOrBuilder response = health.check(builder.build()); assert response != null; final ServingStatus status = response.getStatus();
assert builder != null; builder.setService("Tiller"); final HealthCheckResponseOrBuilder response = health.check(builder.build()); assert response != null; final ServingStatus status = response.getStatus();
@java.lang.Override protected HealthBlockingStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { return new HealthBlockingStub(channel, callOptions); }
@java.lang.Override protected HealthBlockingStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { return new HealthBlockingStub(channel, callOptions); }
/** */ public io.grpc.health.v1.HealthProto.HealthCheckResponse check(io.grpc.health.v1.HealthProto.HealthCheckRequest request) { return blockingUnaryCall( getChannel(), getCheckMethod(), getCallOptions(), request); } }
/** */ public io.grpc.health.v1.HealthProto.HealthCheckResponse check(io.grpc.health.v1.HealthProto.HealthCheckRequest request) { return blockingUnaryCall( getChannel(), getCheckMethod(), getCallOptions(), request); } }
/** * Creates a new blocking-style stub that supports unary and streaming output calls on the service */ public static HealthBlockingStub newBlockingStub( io.grpc.Channel channel) { return new HealthBlockingStub(channel); }
/** */ public io.grpc.health.v1.HealthProto.HealthCheckResponse check(io.grpc.health.v1.HealthProto.HealthCheckRequest request) { return blockingUnaryCall( getChannel(), getCheckMethod(), getCallOptions(), request); } }
/** * Creates a new blocking-style stub that supports unary and streaming output calls on the service */ public static HealthBlockingStub newBlockingStub( io.grpc.Channel channel) { return new HealthBlockingStub(channel); }
@java.lang.Override protected HealthBlockingStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { return new HealthBlockingStub(channel, callOptions); }
/** * Creates a new blocking-style stub that supports unary and streaming output calls on the service */ public static HealthBlockingStub newBlockingStub( io.grpc.Channel channel) { return new HealthBlockingStub(channel); }
@Test public void healthServing() throws Exception { // Generate a unique in-process server name. String serverName = InProcessServerBuilder.generateName(); HealthCheckAggregator hca = mock(HealthCheckAggregator.class); CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class); HealthCheckStatus hcs = mock(HealthCheckStatus.class); when(hcs.isHealthy()).thenReturn(true); when(hcsf.get()).thenReturn(hcs); when(hca.check()).thenReturn(hcsf); HealthServiceImpl healthyService = new HealthServiceImpl(hca); addService(serverName, healthyService); HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub( // Create a client channel and register for automatic graceful shutdown. grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build())); HealthCheckResponse reply = blockingStub.check(HealthCheckRequest.newBuilder().build()); assertEquals(HealthCheckResponse.ServingStatus.SERVING, reply.getStatus()); }
@Test public void healthException() throws Exception { // Generate a unique in-process server name. String serverName = InProcessServerBuilder.generateName(); HealthCheckAggregator hca = mock(HealthCheckAggregator.class); CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class); when(hcsf.get()).thenThrow(InterruptedException.class); when(hca.check()).thenReturn(hcsf); HealthServiceImpl healthyService = new HealthServiceImpl(hca); addService(serverName, healthyService); HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub( // Create a client channel and register for automatic graceful shutdown. grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build())); thrown.expect(StatusRuntimeException.class); thrown.expect(hasProperty("status", is(Status.INTERNAL))); blockingStub.check(HealthCheckRequest.newBuilder().build()); }