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

Function startBackendsForBalancerSwitch

test/balancer_switching_test.go:103–122  ·  view source on GitHub ↗

startBackendsForBalancerSwitch spins up a bunch of stub server backends exposing the TestService. Returns a cleanup function to be invoked by the caller.

(t *testing.T)

Source from the content-addressed store, hash-verified

101// exposing the TestService. Returns a cleanup function to be invoked by the
102// caller.
103func startBackendsForBalancerSwitch(t *testing.T) ([]*stubserver.StubServer, func()) {
104 t.Helper()
105
106 backends := make([]*stubserver.StubServer, backendCount)
107 for i := 0; i < backendCount; i++ {
108 backend := &stubserver.StubServer{
109 EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) { return &testpb.Empty{}, nil },
110 }
111 if err := backend.StartServer(); err != nil {
112 t.Fatalf("Failed to start backend: %v", err)
113 }
114 t.Logf("Started TestService backend at: %q", backend.Address)
115 backends[i] = backend
116 }
117 return backends, func() {
118 for _, b := range backends {
119 b.Stop()
120 }
121 }
122}
123
124// TestBalancerSwitch_Basic tests the basic scenario of switching from one LB
125// policy to another, as specified in the service config.

Calls 4

StartServerMethod · 0.95
FatalfMethod · 0.65
LogfMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected