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

Function testMaxMsgSizeClientAPI

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

Source from the content-addressed store, hash-verified

1901}
1902
1903func testMaxMsgSizeClientAPI(t *testing.T, e env) {
1904 te := newTest(t, e)
1905 te.userAgent = testAppUA
1906 // To avoid error on server side.
1907 te.maxServerSendMsgSize = newInt(5 * 1024 * 1024)
1908 te.maxClientReceiveMsgSize = newInt(1024)
1909 te.maxClientSendMsgSize = newInt(1024)
1910 te.declareLogNoise(
1911 "Failed to dial : context canceled; please retry.",
1912 )
1913 te.startServer(&testServer{security: e.security})
1914
1915 defer te.tearDown()
1916 tc := testgrpc.NewTestServiceClient(te.clientConn())
1917
1918 const smallSize = 1
1919 const largeSize = 1024
1920 smallPayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, smallSize)
1921 if err != nil {
1922 t.Fatal(err)
1923 }
1924
1925 largePayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, largeSize)
1926 if err != nil {
1927 t.Fatal(err)
1928 }
1929 req := &testpb.SimpleRequest{
1930 ResponseType: testpb.PayloadType_COMPRESSABLE,
1931 ResponseSize: int32(largeSize),
1932 Payload: smallPayload,
1933 }
1934
1935 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
1936 defer cancel()
1937 // Test for unary RPC recv.
1938 if _, err := tc.UnaryCall(ctx, req); err == nil || status.Code(err) != codes.ResourceExhausted {
1939 t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, error code: %s", err, codes.ResourceExhausted)
1940 }
1941
1942 // Test for unary RPC send.
1943 req.Payload = largePayload
1944 req.ResponseSize = int32(smallSize)
1945 if _, err := tc.UnaryCall(ctx, req); err == nil || status.Code(err) != codes.ResourceExhausted {
1946 t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, error code: %s", err, codes.ResourceExhausted)
1947 }
1948
1949 respParam := []*testpb.ResponseParameters{
1950 {
1951 Size: int32(largeSize),
1952 },
1953 }
1954 sreq := &testpb.StreamingOutputCallRequest{
1955 ResponseType: testpb.PayloadType_COMPRESSABLE,
1956 ResponseParameters: respParam,
1957 Payload: smallPayload,
1958 }
1959
1960 // Test for streaming RPC recv.

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