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

Function testMaxMsgSizeServerAPI

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

Source from the content-addressed store, hash-verified

1988}
1989
1990func testMaxMsgSizeServerAPI(t *testing.T, e env) {
1991 te := newTest(t, e)
1992 te.userAgent = testAppUA
1993 te.maxServerReceiveMsgSize = newInt(1024)
1994 te.maxServerSendMsgSize = newInt(1024)
1995 te.declareLogNoise(
1996 "Failed to dial : context canceled; please retry.",
1997 )
1998 te.startServer(&testServer{security: e.security})
1999
2000 defer te.tearDown()
2001 tc := testgrpc.NewTestServiceClient(te.clientConn())
2002
2003 const smallSize = 1
2004 const largeSize = 1024
2005 smallPayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, smallSize)
2006 if err != nil {
2007 t.Fatal(err)
2008 }
2009
2010 largePayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, largeSize)
2011 if err != nil {
2012 t.Fatal(err)
2013 }
2014 req := &testpb.SimpleRequest{
2015 ResponseType: testpb.PayloadType_COMPRESSABLE,
2016 ResponseSize: int32(largeSize),
2017 Payload: smallPayload,
2018 }
2019
2020 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
2021 defer cancel()
2022 // Test for unary RPC send.
2023 if _, err := tc.UnaryCall(ctx, req); err == nil || status.Code(err) != codes.ResourceExhausted {
2024 t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, error code: %s", err, codes.ResourceExhausted)
2025 }
2026
2027 // Test for unary RPC recv.
2028 req.Payload = largePayload
2029 req.ResponseSize = int32(smallSize)
2030 if _, err := tc.UnaryCall(ctx, req); err == nil || status.Code(err) != codes.ResourceExhausted {
2031 t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, error code: %s", err, codes.ResourceExhausted)
2032 }
2033
2034 respParam := []*testpb.ResponseParameters{
2035 {
2036 Size: int32(largeSize),
2037 },
2038 }
2039 sreq := &testpb.StreamingOutputCallRequest{
2040 ResponseType: testpb.PayloadType_COMPRESSABLE,
2041 ResponseParameters: respParam,
2042 Payload: smallPayload,
2043 }
2044
2045 // Test for streaming RPC send.
2046 stream, err := tc.FullDuplexCall(te.ctx)
2047 if err != nil {

Callers 1

Calls 14

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

Tested by

no test coverage detected