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

Function startBackends

balancer/leastrequest/leastrequest_test.go:122–143  ·  view source on GitHub ↗
(t *testing.T, numBackends int)

Source from the content-addressed store, hash-verified

120}
121
122func startBackends(t *testing.T, numBackends int) []*stubserver.StubServer {
123 backends := make([]*stubserver.StubServer, 0, numBackends)
124 // Construct and start working backends.
125 for i := 0; i < numBackends; i++ {
126 backend := &stubserver.StubServer{
127 EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) {
128 return &testpb.Empty{}, nil
129 },
130 FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
131 <-stream.Context().Done()
132 return nil
133 },
134 }
135 if err := backend.StartServer(); err != nil {
136 t.Fatalf("Failed to start backend: %v", err)
137 }
138 t.Logf("Started good TestService backend at: %q", backend.Address)
139 t.Cleanup(func() { backend.Stop() })
140 backends = append(backends, backend)
141 }
142 return backends
143}
144
145// setupBackends spins up three test backends, each listening on a port on
146// localhost. The three backends always reply with an empty response with no

Callers 2

setupBackendsFunction · 0.70

Calls 6

StartServerMethod · 0.95
StopMethod · 0.95
ContextMethod · 0.65
FatalfMethod · 0.65
LogfMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected