(t *testing.T, e env)
| 212 | } |
| 213 | |
| 214 | func testServerGoAway(t *testing.T, e env) { |
| 215 | te := newTest(t, e) |
| 216 | te.userAgent = testAppUA |
| 217 | te.startServer(&testServer{security: e.security}) |
| 218 | defer te.tearDown() |
| 219 | |
| 220 | cc := te.clientConn() |
| 221 | tc := testgrpc.NewTestServiceClient(cc) |
| 222 | // Finish an RPC to make sure the connection is good. |
| 223 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 224 | defer cancel() |
| 225 | if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); err != nil { |
| 226 | t.Fatalf("TestService/EmptyCall(_, _) = _, %v, want _, <nil>", err) |
| 227 | } |
| 228 | ch := make(chan struct{}) |
| 229 | go func() { |
| 230 | te.srv.GracefulStop() |
| 231 | close(ch) |
| 232 | }() |
| 233 | // Loop until the server side GoAway signal is propagated to the client. |
| 234 | for { |
| 235 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestShortTimeout) |
| 236 | if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); err != nil && status.Code(err) != codes.DeadlineExceeded { |
| 237 | cancel() |
| 238 | break |
| 239 | } |
| 240 | cancel() |
| 241 | } |
| 242 | // A new RPC should fail. |
| 243 | ctx, cancel = context.WithTimeout(context.Background(), defaultTestTimeout) |
| 244 | defer cancel() |
| 245 | if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); status.Code(err) != codes.Unavailable && status.Code(err) != codes.Internal { |
| 246 | t.Fatalf("TestService/EmptyCall(_, _) = _, %v, want _, %s or %s", err, codes.Unavailable, codes.Internal) |
| 247 | } |
| 248 | <-ch |
| 249 | awaitNewConnLogOutput() |
| 250 | } |
| 251 | |
| 252 | func (s) TestServerGoAwayPendingRPC(t *testing.T) { |
| 253 | for _, e := range listTestEnv() { |
no test coverage detected