(t *testing.T, e env)
| 165 | } |
| 166 | |
| 167 | func 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 | |
| 224 | func (s) TestIdentityEncoding(t *testing.T) { |
no test coverage detected