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

Method TestServiceConfigMaxMsgSize

test/end2end_test.go:1385–1638  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1383}
1384
1385func (s) TestServiceConfigMaxMsgSize(t *testing.T) {
1386 e := tcpClearRREnv
1387 r := manual.NewBuilderWithScheme("whatever")
1388
1389 // Setting up values and objects shared across all test cases.
1390 const smallSize = 1
1391 const largeSize = 1024
1392 const extraLargeSize = 2048
1393
1394 smallPayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, smallSize)
1395 if err != nil {
1396 t.Fatal(err)
1397 }
1398 largePayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, largeSize)
1399 if err != nil {
1400 t.Fatal(err)
1401 }
1402 extraLargePayload, err := newPayload(testpb.PayloadType_COMPRESSABLE, extraLargeSize)
1403 if err != nil {
1404 t.Fatal(err)
1405 }
1406
1407 // Case1: sc set maxReqSize to 2048 (send), maxRespSize to 2048 (recv).
1408 te1 := testServiceConfigSetup(t, e)
1409 defer te1.tearDown()
1410
1411 te1.resolverScheme = r.Scheme()
1412 te1.startServer(&testServer{security: e.security})
1413 cc1 := te1.clientConn(grpc.WithResolvers(r))
1414
1415 addrs := []resolver.Address{{Addr: te1.srvAddr}}
1416 sc := parseServiceConfig(t, r, `{
1417 "methodConfig": [
1418 {
1419 "name": [
1420 {
1421 "service": "grpc.testing.TestService",
1422 "method": "UnaryCall"
1423 },
1424 {
1425 "service": "grpc.testing.TestService",
1426 "method": "FullDuplexCall"
1427 }
1428 ],
1429 "maxRequestMessageBytes": 2048,
1430 "maxResponseMessageBytes": 2048
1431 }
1432 ]
1433}`)
1434 r.UpdateState(resolver.State{Addresses: addrs, ServiceConfig: sc})
1435 tc := testgrpc.NewTestServiceClient(cc1)
1436
1437 req := &testpb.SimpleRequest{
1438 ResponseType: testpb.PayloadType_COMPRESSABLE,
1439 ResponseSize: int32(extraLargeSize),
1440 Payload: smallPayload,
1441 }
1442

Callers

nothing calls this directly

Calls 15

UnaryCallMethod · 0.95
FullDuplexCallMethod · 0.95
NewBuilderWithSchemeFunction · 0.92
WithResolversFunction · 0.92
WaitForReadyFunction · 0.92
newPayloadFunction · 0.85
testServiceConfigSetupFunction · 0.85
GetMethodConfigMethod · 0.80
CodeMethod · 0.80
parseServiceConfigFunction · 0.70
newIntFunction · 0.70
FatalMethod · 0.65

Tested by

no test coverage detected