MCPcopy
hub / github.com/grpc/grpc-go / TestHealthCheckHealthServerNotRegistered

Method TestHealthCheckHealthServerNotRegistered

test/healthcheck_test.go:256–283  ·  view source on GitHub ↗

If Watch returns Unimplemented, then the ClientConn should go into READY state.

(t *testing.T)

Source from the content-addressed store, hash-verified

254
255// If Watch returns Unimplemented, then the ClientConn should go into READY state.
256func (s) TestHealthCheckHealthServerNotRegistered(t *testing.T) {
257 grpctest.ExpectError("Subchannel health check is unimplemented at server side, thus health check is disabled")
258 s := grpc.NewServer()
259 lis, err := net.Listen("tcp", "localhost:0")
260 if err != nil {
261 t.Fatalf("failed to listen due to err: %v", err)
262 }
263 go s.Serve(lis)
264 defer s.Stop()
265
266 cc, r := setupClient(t, nil)
267 r.UpdateState(resolver.State{
268 Addresses: []resolver.Address{{Addr: lis.Addr().String()}},
269 ServiceConfig: parseServiceConfig(t, r, fmt.Sprintf(`{
270 "healthCheckConfig": {
271 "serviceName": "foo"
272 },
273 "loadBalancingConfig": [{"%s":{}}]
274 }`, roundrobin.Name))})
275
276 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
277 defer cancel()
278 testutils.AwaitNotState(ctx, t, cc, connectivity.Idle)
279 testutils.AwaitNotState(ctx, t, cc, connectivity.Connecting)
280 if s := cc.GetState(); s != connectivity.Ready {
281 t.Fatalf("ClientConn is in %v state, want READY", s)
282 }
283}
284
285// In the case of a goaway received, the health check stream should be terminated and health check
286// function should exit.

Callers

nothing calls this directly

Calls 12

ExpectErrorFunction · 0.92
NewServerFunction · 0.92
AwaitNotStateFunction · 0.92
setupClientFunction · 0.85
parseServiceConfigFunction · 0.70
FatalfMethod · 0.65
ServeMethod · 0.65
StopMethod · 0.65
UpdateStateMethod · 0.65
StringMethod · 0.65
GetStateMethod · 0.65
AddrMethod · 0.45

Tested by

no test coverage detected