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

Function testExceedMsgLimit

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

Source from the content-addressed store, hash-verified

2302}
2303
2304func testExceedMsgLimit(t *testing.T, e env) {
2305 te := newTest(t, e)
2306 maxMsgSize := 1024
2307 te.maxServerMsgSize, te.maxClientMsgSize = newInt(maxMsgSize), newInt(maxMsgSize)
2308 te.startServer(&testServer{security: e.security})
2309 defer te.tearDown()
2310 tc := testgrpc.NewTestServiceClient(te.clientConn())
2311
2312 largeSize := int32(maxMsgSize + 1)
2313 const smallSize = 1
2314
2315 largePayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, largeSize)
2316 if err != nil {
2317 t.Fatal(err)
2318 }
2319 smallPayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, smallSize)
2320 if err != nil {
2321 t.Fatal(err)
2322 }
2323
2324 // Make sure the server cannot receive a unary RPC of largeSize.
2325 req := &testpb.SimpleRequest{
2326 ResponseType: testpb.PayloadType_COMPRESSABLE,
2327 ResponseSize: smallSize,
2328 Payload: largePayload,
2329 }
2330
2331 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
2332 defer cancel()
2333 if _, err := tc.UnaryCall(ctx, req); err == nil || status.Code(err) != codes.ResourceExhausted {
2334 t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, error code: %s", err, codes.ResourceExhausted)
2335 }
2336 // Make sure the client cannot receive a unary RPC of largeSize.
2337 req.ResponseSize = largeSize
2338 req.Payload = smallPayload
2339 if _, err := tc.UnaryCall(ctx, req); err == nil || status.Code(err) != codes.ResourceExhausted {
2340 t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, error code: %s", err, codes.ResourceExhausted)
2341 }
2342
2343 // Make sure the server cannot receive a streaming RPC of largeSize.
2344 stream, err := tc.FullDuplexCall(te.ctx)
2345 if err != nil {
2346 t.Fatalf("%v.FullDuplexCall(_) = _, %v, want <nil>", tc, err)
2347 }
2348 respParam := []*testpb.ResponseParameters{
2349 {
2350 Size: 1,
2351 },
2352 }
2353
2354 sreq := &testpb.StreamingOutputCallRequest{
2355 ResponseType: testpb.PayloadType_COMPRESSABLE,
2356 ResponseParameters: respParam,
2357 Payload: largePayload,
2358 }
2359 if err := stream.Send(sreq); err != nil {
2360 t.Fatalf("%v.Send(%v) = %v, want <nil>", stream, sreq, err)
2361 }

Callers 1

TestExceedMsgLimitMethod · 0.85

Calls 13

UnaryCallMethod · 0.95
FullDuplexCallMethod · 0.95
newPayloadFunction · 0.85
CodeMethod · 0.80
newTestFunction · 0.70
newIntFunction · 0.70
FatalMethod · 0.65
FatalfMethod · 0.65
SendMethod · 0.65
RecvMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45

Tested by

no test coverage detected