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

Function testStreamsQuotaRecovery

test/end2end_test.go:4277–4342  ·  view source on GitHub ↗
(t *testing.T, e env)

Source from the content-addressed store, hash-verified

4275}
4276
4277func 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

Callers 1

Calls 15

StreamingInputCallMethod · 0.95
UnaryCallMethod · 0.95
WaitForReadyFunction · 0.92
newPayloadFunction · 0.85
declareLogNoiseMethod · 0.80
CodeMethod · 0.80
WaitMethod · 0.80
newTestFunction · 0.70
FatalfMethod · 0.65
AddMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected