(t *testing.T, e env)
| 4275 | } |
| 4276 | |
| 4277 | func testStreamsQuotaRecovery(t *testing.T, e env) { |
| 4278 | te := newTest(t, e) |
| 4279 | te.declareLogNoise( |
| 4280 | "http2Client.notifyError got notified that the client transport was broken", |
| 4281 | "Conn.resetTransport failed to create client transport", |
| 4282 | "grpc: the connection is closing", |
| 4283 | ) |
| 4284 | te.maxStream = 1 // Allows 1 live stream. |
| 4285 | te.startServer(&testServer{security: e.security}) |
| 4286 | defer te.tearDown() |
| 4287 | |
| 4288 | cc := te.clientConn() |
| 4289 | tc := testgrpc.NewTestServiceClient(cc) |
| 4290 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 4291 | defer cancel() |
| 4292 | if _, err := tc.StreamingInputCall(ctx); err != nil { |
| 4293 | t.Fatalf("tc.StreamingInputCall(_) = _, %v, want _, <nil>", err) |
| 4294 | } |
| 4295 | // Loop until the new max stream setting is effective. |
| 4296 | for { |
| 4297 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestShortTimeout) |
| 4298 | _, err := tc.StreamingInputCall(ctx) |
| 4299 | cancel() |
| 4300 | if err == nil { |
| 4301 | time.Sleep(5 * time.Millisecond) |
| 4302 | continue |
| 4303 | } |
| 4304 | if status.Code(err) == codes.DeadlineExceeded { |
| 4305 | break |
| 4306 | } |
| 4307 | t.Fatalf("tc.StreamingInputCall(_) = _, %v, want _, %s", err, codes.DeadlineExceeded) |
| 4308 | } |
| 4309 | |
| 4310 | var wg sync.WaitGroup |
| 4311 | for i := 0; i < 10; i++ { |
| 4312 | wg.Add(1) |
| 4313 | go func() { |
| 4314 | defer wg.Done() |
| 4315 | payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, 314) |
| 4316 | if err != nil { |
| 4317 | t.Error(err) |
| 4318 | return |
| 4319 | } |
| 4320 | req := &testpb.SimpleRequest{ |
| 4321 | ResponseType: testpb.PayloadType_COMPRESSABLE, |
| 4322 | ResponseSize: 1592, |
| 4323 | Payload: payload, |
| 4324 | } |
| 4325 | // No rpc should go through due to the max streams limit. |
| 4326 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestShortTimeout) |
| 4327 | defer cancel() |
| 4328 | if _, err := tc.UnaryCall(ctx, req, grpc.WaitForReady(true)); status.Code(err) != codes.DeadlineExceeded { |
| 4329 | t.Errorf("tc.UnaryCall(_, _) = _, %v, want _, %s", err, codes.DeadlineExceeded) |
| 4330 | } |
| 4331 | }() |
| 4332 | } |
| 4333 | wg.Wait() |
| 4334 |
no test coverage detected