(t *testing.T)
| 34 | ) |
| 35 | |
| 36 | func (s) TestStreamCleanup(t *testing.T) { |
| 37 | const initialWindowSize uint = 70 * 1024 // Must be higher than default 64K, ignored otherwise |
| 38 | const bodySize = 2 * initialWindowSize // Something that is not going to fit in a single window |
| 39 | const callRecvMsgSize uint = 1 // The maximum message size the client can receive |
| 40 | |
| 41 | ss := &stubserver.StubServer{ |
| 42 | UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { |
| 43 | return &testpb.SimpleResponse{Payload: &testpb.Payload{ |
| 44 | Body: make([]byte, bodySize), |
| 45 | }}, nil |
| 46 | }, |
| 47 | EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) { |
| 48 | return &testpb.Empty{}, nil |
| 49 | }, |
| 50 | } |
| 51 | if err := ss.Start(nil, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(int(callRecvMsgSize))), grpc.WithInitialWindowSize(int32(initialWindowSize))); err != nil { |
| 52 | t.Fatalf("Error starting endpoint server: %v", err) |
| 53 | } |
| 54 | defer ss.Stop() |
| 55 | |
| 56 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 57 | defer cancel() |
| 58 | if _, err := ss.Client.UnaryCall(ctx, &testpb.SimpleRequest{}); status.Code(err) != codes.ResourceExhausted { |
| 59 | t.Fatalf("should fail with ResourceExhausted, message's body size: %v, maximum message size the client can receive: %v", bodySize, callRecvMsgSize) |
| 60 | } |
| 61 | if _, err := ss.Client.EmptyCall(ctx, &testpb.Empty{}); err != nil { |
| 62 | t.Fatalf("should succeed, err: %v", err) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | func (s) TestStreamCleanupAfterSendStatus(t *testing.T) { |
| 67 | const initialWindowSize uint = 70 * 1024 // Must be higher than default 64K, ignored otherwise |
nothing calls this directly
no test coverage detected