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

Function setupServer

test/healthcheck_test.go:143–163  ·  view source on GitHub ↗
(t *testing.T, watchFunc healthWatchFunc)

Source from the content-addressed store, hash-verified

141}
142
143func setupServer(t *testing.T, watchFunc healthWatchFunc) (*grpc.Server, net.Listener, *testHealthServer) {
144 t.Helper()
145
146 lis, err := net.Listen("tcp", "localhost:0")
147 if err != nil {
148 t.Fatalf("net.Listen() failed: %v", err)
149 }
150
151 var ts *testHealthServer
152 if watchFunc != nil {
153 ts = newTestHealthServerWithWatchFunc(watchFunc)
154 } else {
155 ts = newTestHealthServer()
156 }
157 s := grpc.NewServer()
158 healthgrpc.RegisterHealthServer(s, ts)
159 testgrpc.RegisterTestServiceServer(s, &testServer{})
160 go s.Serve(lis)
161 t.Cleanup(func() { s.Stop() })
162 return s, lis, ts
163}
164
165type clientConfig struct {
166 balancerName string

Calls 6

ServeMethod · 0.95
StopMethod · 0.95
NewServerFunction · 0.92
newTestHealthServerFunction · 0.85
FatalfMethod · 0.65

Tested by

no test coverage detected