diff --git a/test/compressor_test.go b/test/compressor_test.go index 298ae38ec1b5..0a629bcecdb5 100644 --- a/test/compressor_test.go +++ b/test/compressor_test.go @@ -801,7 +801,9 @@ func (f *fakeCompressor) Decompress(io.Reader) (io.Reader, error) { } func (f *fakeCompressor) Name() string { - return "fake-gzip" + // Use the name of an existing compressor to avoid interactions with other + // tests since compressors can't be un-registered. + return "gzip" } type nopWriteCloser struct { @@ -817,6 +819,10 @@ func (nopWriteCloser) Close() error { // max receive message size restricted to 99 bytes. The test verifies that the // client receives a ResourceExhausted response from the server. func (s) TestDecompressionExceedsMaxMessageSize(t *testing.T) { + oldC := encoding.GetCompressor("gzip") + defer func() { + encoding.RegisterCompressor(oldC) + }() const messageLen = 100 encoding.RegisterCompressor(&fakeCompressor{decompressedMessageSize: messageLen}) ss := &stubserver.StubServer{ @@ -833,7 +839,7 @@ func (s) TestDecompressionExceedsMaxMessageSize(t *testing.T) { defer cancel() req := &testpb.SimpleRequest{Payload: &testpb.Payload{}} - _, err := ss.Client.UnaryCall(ctx, req, grpc.UseCompressor("fake-gzip")) + _, err := ss.Client.UnaryCall(ctx, req, grpc.UseCompressor("gzip")) if got, want := status.Code(err), codes.ResourceExhausted; got != want { t.Errorf("Client.UnaryCall(%+v) returned status %v, want %v", req, got, want) }