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

Method TestRecvBufferPoolStream

experimental/shared_buffer_pool_test.go:48–132  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46const defaultTestTimeout = 10 * time.Second
47
48func (s) TestRecvBufferPoolStream(t *testing.T) {
49 // TODO: How much of this test can be preserved now that buffer reuse happens at
50 // the codec and HTTP/2 level?
51 t.SkipNow()
52 tcs := []struct {
53 name string
54 callOpts []grpc.CallOption
55 }{
56 {
57 name: "default",
58 },
59 {
60 name: "useCompressor",
61 callOpts: []grpc.CallOption{
62 grpc.UseCompressor(gzip.Name),
63 },
64 },
65 }
66
67 for _, tc := range tcs {
68 t.Run(tc.name, func(t *testing.T) {
69 const reqCount = 10
70
71 ss := &stubserver.StubServer{
72 FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
73 for i := 0; i < reqCount; i++ {
74 preparedMsg := &grpc.PreparedMsg{}
75 if err := preparedMsg.Encode(stream, &testpb.StreamingOutputCallResponse{
76 Payload: &testpb.Payload{
77 Body: []byte{'0' + uint8(i)},
78 },
79 }); err != nil {
80 return err
81 }
82 stream.SendMsg(preparedMsg)
83 }
84 return nil
85 },
86 }
87
88 pool := &checkBufferPool{}
89 sopts := []grpc.ServerOption{experimental.BufferPool(pool)}
90 dopts := []grpc.DialOption{experimental.WithBufferPool(pool)}
91 if err := ss.Start(sopts, dopts...); err != nil {
92 t.Fatalf("Error starting endpoint server: %v", err)
93 }
94 defer ss.Stop()
95
96 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
97 defer cancel()
98
99 stream, err := ss.Client.FullDuplexCall(ctx, tc.callOpts...)
100 if err != nil {
101 t.Fatalf("ss.Client.FullDuplexCall failed: %v", err)
102 }
103
104 var ngot int
105 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 15

EncodeMethod · 0.95
StartMethod · 0.95
StopMethod · 0.95
LenMethod · 0.95
StringMethod · 0.95
UseCompressorFunction · 0.92
BufferPoolFunction · 0.92
WithBufferPoolFunction · 0.92
SendMsgMethod · 0.65
FatalfMethod · 0.65
FullDuplexCallMethod · 0.65
RecvMethod · 0.65

Tested by

no test coverage detected