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

Method TestResolverServiceConfigBeforeAddressNotPanic

clientconn_test.go:463–477  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

461}
462
463func (s) TestResolverServiceConfigBeforeAddressNotPanic(t *testing.T) {
464 r := manual.NewBuilderWithScheme("whatever")
465
466 cc, err := NewClient(r.Scheme()+":///test.server", WithTransportCredentials(insecure.NewCredentials()), WithResolvers(r))
467 if err != nil {
468 t.Fatalf("grpc.NewClient() failed: %v", err)
469 }
470 defer cc.Close()
471 cc.Connect()
472 // SwitchBalancer before NewAddress. There was no balancer created, this
473 // makes sure we don't call close on nil balancerWrapper.
474 r.UpdateState(resolver.State{ServiceConfig: r.CC().ParseServiceConfig(grpclbServiceConfig)}) // This should not panic.
475
476 time.Sleep(time.Second) // Sleep to make sure the service config is handled by ClientConn.
477}
478
479func (s) TestResolverServiceConfigWhileClosingNotPanic(t *testing.T) {
480 for i := 0; i < 10; i++ { // Run this multiple times to make sure it doesn't panic.

Callers

nothing calls this directly

Calls 12

NewBuilderWithSchemeFunction · 0.92
NewCredentialsFunction · 0.92
WithTransportCredentialsFunction · 0.85
WithResolversFunction · 0.85
CCMethod · 0.80
NewClientFunction · 0.70
SchemeMethod · 0.65
FatalfMethod · 0.65
CloseMethod · 0.65
ConnectMethod · 0.65
UpdateStateMethod · 0.65
ParseServiceConfigMethod · 0.65

Tested by

no test coverage detected