(t *testing.T, e env)
| 593 | } |
| 594 | |
| 595 | func testCompressorRegister(t *testing.T, e env) { |
| 596 | te := newTest(t, e) |
| 597 | te.clientCompression = false |
| 598 | te.serverCompression = false |
| 599 | te.clientUseCompression = true |
| 600 | |
| 601 | te.startServer(&testServer{security: e.security}) |
| 602 | defer te.tearDown() |
| 603 | tc := testgrpc.NewTestServiceClient(te.clientConn()) |
| 604 | |
| 605 | // Unary call |
| 606 | const argSize = 271828 |
| 607 | const respSize = 314159 |
| 608 | payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, argSize) |
| 609 | if err != nil { |
| 610 | t.Fatal(err) |
| 611 | } |
| 612 | req := &testpb.SimpleRequest{ |
| 613 | ResponseType: testpb.PayloadType_COMPRESSABLE, |
| 614 | ResponseSize: respSize, |
| 615 | Payload: payload, |
| 616 | } |
| 617 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 618 | defer cancel() |
| 619 | ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs("something", "something")) |
| 620 | if _, err := tc.UnaryCall(ctx, req); err != nil { |
| 621 | t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, <nil>", err) |
| 622 | } |
| 623 | // Streaming RPC |
| 624 | stream, err := tc.FullDuplexCall(ctx) |
| 625 | if err != nil { |
| 626 | t.Fatalf("%v.FullDuplexCall(_) = _, %v, want <nil>", tc, err) |
| 627 | } |
| 628 | respParam := []*testpb.ResponseParameters{ |
| 629 | { |
| 630 | Size: 31415, |
| 631 | }, |
| 632 | } |
| 633 | payload, err = newPayload(testpb.PayloadType_COMPRESSABLE, int32(31415)) |
| 634 | if err != nil { |
| 635 | t.Fatal(err) |
| 636 | } |
| 637 | sreq := &testpb.StreamingOutputCallRequest{ |
| 638 | ResponseType: testpb.PayloadType_COMPRESSABLE, |
| 639 | ResponseParameters: respParam, |
| 640 | Payload: payload, |
| 641 | } |
| 642 | if err := stream.Send(sreq); err != nil { |
| 643 | t.Fatalf("%v.Send(%v) = %v, want <nil>", stream, sreq, err) |
| 644 | } |
| 645 | if _, err := stream.Recv(); err != nil { |
| 646 | t.Fatalf("%v.Recv() = %v, want <nil>", stream, err) |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | type badGzipCompressor struct{} |
| 651 |
no test coverage detected