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

Function testCompressOK

test/compressor_test.go:167–222  ·  view source on GitHub ↗
(t *testing.T, e env)

Source from the content-addressed store, hash-verified

165}
166
167func testCompressOK(t *testing.T, e env) {
168 te := newTest(t, e)
169 te.serverCompression = true
170 te.clientCompression = true
171 te.startServer(&testServer{security: e.security})
172 defer te.tearDown()
173 tc := testgrpc.NewTestServiceClient(te.clientConn())
174
175 // Unary call
176 const argSize = 271828
177 const respSize = 314159
178 payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, argSize)
179 if err != nil {
180 t.Fatal(err)
181 }
182 req := &testpb.SimpleRequest{
183 ResponseType: testpb.PayloadType_COMPRESSABLE,
184 ResponseSize: respSize,
185 Payload: payload,
186 }
187 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
188 defer cancel()
189 ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs("something", "something"))
190 if _, err := tc.UnaryCall(ctx, req); err != nil {
191 t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, <nil>", err)
192 }
193 // Streaming RPC
194 stream, err := tc.FullDuplexCall(ctx)
195 if err != nil {
196 t.Fatalf("%v.FullDuplexCall(_) = _, %v, want <nil>", tc, err)
197 }
198 respParam := []*testpb.ResponseParameters{
199 {
200 Size: 31415,
201 },
202 }
203 payload, err = newPayload(testpb.PayloadType_COMPRESSABLE, int32(31415))
204 if err != nil {
205 t.Fatal(err)
206 }
207 sreq := &testpb.StreamingOutputCallRequest{
208 ResponseType: testpb.PayloadType_COMPRESSABLE,
209 ResponseParameters: respParam,
210 Payload: payload,
211 }
212 if err := stream.Send(sreq); err != nil {
213 t.Fatalf("%v.Send(%v) = %v, want <nil>", stream, sreq, err)
214 }
215 stream.CloseSend()
216 if _, err := stream.Recv(); err != nil {
217 t.Fatalf("%v.Recv() = %v, want <nil>", stream, err)
218 }
219 if _, err := stream.Recv(); err != io.EOF {
220 t.Fatalf("%v.Recv() = %v, want io.EOF", stream, err)
221 }
222}
223
224func (s) TestIdentityEncoding(t *testing.T) {

Callers 1

TestCompressOKMethod · 0.85

Calls 14

UnaryCallMethod · 0.95
FullDuplexCallMethod · 0.95
NewOutgoingContextFunction · 0.92
PairsFunction · 0.92
newPayloadFunction · 0.85
newTestFunction · 0.70
FatalMethod · 0.65
FatalfMethod · 0.65
SendMethod · 0.65
CloseSendMethod · 0.65
RecvMethod · 0.65
startServerMethod · 0.45

Tested by

no test coverage detected