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

Method TestRecvBufferPoolUnary

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

Source from the content-addressed store, hash-verified

132}
133
134func (s) TestRecvBufferPoolUnary(t *testing.T) {
135 // TODO: See above
136 t.SkipNow()
137 tcs := []struct {
138 name string
139 callOpts []grpc.CallOption
140 }{
141 {
142 name: "default",
143 },
144 {
145 name: "useCompressor",
146 callOpts: []grpc.CallOption{
147 grpc.UseCompressor(gzip.Name),
148 },
149 },
150 }
151
152 for _, tc := range tcs {
153 t.Run(tc.name, func(t *testing.T) {
154 const largeSize = 1024
155
156 ss := &stubserver.StubServer{
157 UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
158 return &testpb.SimpleResponse{
159 Payload: &testpb.Payload{
160 Body: make([]byte, largeSize),
161 },
162 }, nil
163 },
164 }
165
166 pool := &checkBufferPool{}
167 sopts := []grpc.ServerOption{experimental.BufferPool(pool)}
168 dopts := []grpc.DialOption{experimental.WithBufferPool(pool)}
169 if err := ss.Start(sopts, dopts...); err != nil {
170 t.Fatalf("Error starting endpoint server: %v", err)
171 }
172 defer ss.Stop()
173
174 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
175 defer cancel()
176
177 const reqCount = 10
178 for i := 0; i < reqCount; i++ {
179 if _, err := ss.Client.UnaryCall(
180 ctx,
181 &testpb.SimpleRequest{
182 Payload: &testpb.Payload{
183 Body: make([]byte, largeSize),
184 },
185 },
186 tc.callOpts...,
187 ); err != nil {
188 t.Fatalf("ss.Client.UnaryCall failed: %v", err)
189 }
190 }
191

Callers

nothing calls this directly

Calls 7

StartMethod · 0.95
StopMethod · 0.95
UseCompressorFunction · 0.92
BufferPoolFunction · 0.92
WithBufferPoolFunction · 0.92
FatalfMethod · 0.65
UnaryCallMethod · 0.65

Tested by

no test coverage detected