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

Method TestEndpoints_SharedAddress

balancer/weightedroundrobin/balancer_test.go:466–487  ·  view source on GitHub ↗

TestEndpoints_SharedAddress tests the case where two endpoints have the same address. The expected behavior is undefined, however the program should not crash.

(t *testing.T)

Source from the content-addressed store, hash-verified

464// address. The expected behavior is undefined, however the program should not
465// crash.
466func (s) TestEndpoints_SharedAddress(t *testing.T) {
467 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
468 defer cancel()
469
470 srv := startServer(t, reportCall)
471 sc := svcConfig(t, perCallConfig)
472 if err := srv.StartClient(grpc.WithDefaultServiceConfig(sc)); err != nil {
473 t.Fatalf("Error starting client: %v", err)
474 }
475
476 endpointsSharedAddress := []resolver.Endpoint{{Addresses: []resolver.Address{{Addr: srv.Address}}}, {Addresses: []resolver.Address{{Addr: srv.Address}}}}
477 srv.R.UpdateState(resolver.State{Endpoints: endpointsSharedAddress})
478
479 // Make some RPC's and make sure doesn't crash. It should go to one of the
480 // endpoints addresses, it's undefined which one it will choose and the load
481 // reporting might not work, but it should be able to make an RPC.
482 for i := 0; i < 10; i++ {
483 if _, err := srv.Client.EmptyCall(ctx, &testpb.Empty{}); err != nil {
484 t.Fatalf("EmptyCall failed with err: %v", err)
485 }
486 }
487}
488
489// TestEndpoints_MultipleAddresses tests WRR on endpoints with numerous
490// addresses. It configures WRR with two endpoints with one bad address followed

Callers

nothing calls this directly

Calls 7

WithDefaultServiceConfigFunction · 0.92
svcConfigFunction · 0.85
StartClientMethod · 0.80
startServerFunction · 0.70
FatalfMethod · 0.65
UpdateStateMethod · 0.65
EmptyCallMethod · 0.65

Tested by

no test coverage detected