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

Function testCompressorRegister

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

Source from the content-addressed store, hash-verified

593}
594
595func 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
650type badGzipCompressor struct{}
651

Callers 1

Calls 13

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
RecvMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45

Tested by

no test coverage detected