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

Method TestStreamWorkers_GracefulStopAndStop

server_ext_test.go:172–187  ·  view source on GitHub ↗

Tests the case where the stream worker goroutine option is enabled, and both Stop() and GracefulStop() care called. This used to result in a close of a closed channel. This test verifies that there is no panic.

(t *testing.T)

Source from the content-addressed store, hash-verified

170// Stop() and GracefulStop() care called. This used to result in a close of a
171// closed channel. This test verifies that there is no panic.
172func (s) TestStreamWorkers_GracefulStopAndStop(t *testing.T) {
173 ss := stubserver.StartTestService(t, nil, grpc.NumStreamWorkers(uint32(runtime.NumCPU())))
174 defer ss.Stop()
175
176 if err := ss.StartClient(grpc.WithTransportCredentials(insecure.NewCredentials())); err != nil {
177 t.Fatalf("Failed to create client to stub server: %v", err)
178 }
179 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
180 defer cancel()
181 client := testgrpc.NewTestServiceClient(ss.CC)
182 if _, err := client.EmptyCall(ctx, &testpb.Empty{}); err != nil {
183 t.Fatalf("EmptyCall() failed: %v", err)
184 }
185
186 ss.S.GracefulStop()
187}
188
189// Tests the WaitForHandlers ServerOption by leaving an RPC running while Stop
190// is called, and ensures Stop doesn't return until the handler returns.

Callers

nothing calls this directly

Calls 9

EmptyCallMethod · 0.95
StartTestServiceFunction · 0.92
NumStreamWorkersFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92
StartClientMethod · 0.80
StopMethod · 0.65
FatalfMethod · 0.65
GracefulStopMethod · 0.65

Tested by

no test coverage detected