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)
| 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. |
| 172 | func (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. |
nothing calls this directly
no test coverage detected