Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transport error when running gRPC provider verification in 2.x.x branch #260

Open
jasonltaylor opened this issue Jan 4, 2023 · 5 comments

Comments

@jasonltaylor
Copy link

Software versions

  • OS: Ubuntu Linux
  • Consumer Pact library: Pact Go v2.0.0-beta.17.0.20221222235702-6e805a539d1b
  • Provider Pact library: Pact Go v2.0.0-beta.17.0.20221222235702-6e805a539d1b
  • Golang Version: go version go1.19.2 linux/amd64
  • Golang environment:
    GO111MODULE=""
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/home/dev/.cache/go-build"
    GOENV="/home/dev/.config/go/env"
    GOEXE=""
    GOEXPERIMENT=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOINSECURE=""
    GOMODCACHE="/home/dev/go/pkg/mod"
    GONOPROXY="github.hpe.com"
    GONOSUMDB="github.hpe.com"
    GOOS="linux"
    GOPATH="/home/dev/go"
    GOPRIVATE="github.hpe.com"
    GOPROXY="https://proxy.golang.org,direct"
    GOROOT="/usr/local/go"
    GOSUMDB="sum.golang.org"
    GOTMPDIR=""
    GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
    GOVCS=""
    GOVERSION="go1.19.2"
    GCCGO="gccgo"
    GOAMD64="v1"
    AR="ar"
    CC="gcc"
    CXX="g++"
    CGO_ENABLED="1"
    GOMOD="/home/dev/ws/sc-authz/go.mod"
    GOWORK=""
    CGO_CFLAGS="-g -O2"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-g -O2"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-g -O2"
    PKG_CONFIG="pkg-config"
    GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4109696144=/tmp/go-build -gno-record-gcc-switches"

Expected behaviour

Pact provider verification for gRPC contract runs successfully.

Actual behaviour

Provider verification fails with transport error.

Steps to reproduce

Run gRPC contract tests with latest 2.x.x codebase. The tests pass when pinned to v2.0.0-beta.17 tag but fail if using the tip of the 2.x.x branch.

Relevent log files

2023/01/04 15:40:41 [ERROR] net/http: HTTP/1.x transport connection broken: malformed HTTP status code "\x00\xfe\x03\x00\x00\x00\x01\x00\x00\x04\b\x00\x00\x00\x00\x00\x00?\x00\x00"
2023/01/04 15:40:41 http: proxy error: net/http: HTTP/1.x transport connection broken: malformed HTTP status code "\x00\xfe\x03\x00\x00\x00\x01\x00\x00\x04\b\x00\x00\x00\x00\x00\x00?\x00\x00"
@mefellows
Copy link
Member

Thanks Jason. Do you have a particular setup you could share that produces this issue? We run gRPC examples as part of the build and I haven't seen this, so I'm guessing it's perhaps the use of request filters causing the proxy issues?

@jasonltaylor
Copy link
Author

Was able to narrow it down today. I wasn't explicitly passing the Transports to VerifyProvider which up until now had been working ok. If I add that in my provider verification is passing. Can get the pact-go example gRPC provider to fail with the same error by commenting that out:

$ git diff grpc_provider_test.go
diff --git a/examples/grpc/grpc_provider_test.go b/examples/grpc/grpc_provider_test.go
index 8b8c873..34d47ef 100644
--- a/examples/grpc/grpc_provider_test.go
+++ b/examples/grpc/grpc_provider_test.go
@@ -1,6 +1,3 @@
-//go:build provider
-// +build provider
-
 package grpc
 
 import (
@@ -30,12 +27,12 @@ func TestGrpcProvider(t *testing.T) {
 
        err := verifier.VerifyProvider(t, provider.VerifyRequest{
                ProviderBaseURL: "http://localhost:8222",
-               Transports: []provider.Transport{
-                       provider.Transport{
-                               Protocol: "grpc",
-                               Port:     8222,
-                       },
-               },
+               // Transports: []provider.Transport{
+               //      provider.Transport{
+               //              Protocol: "grpc",
+               //              Port:     8222,
+               //      },
+               // },
                Provider: "grpcprovider",
                PactFiles: []string{
                        filepath.ToSlash(fmt.Sprintf("%s/../pacts/grpcconsumer-grpcprovider.json", dir))

@YOU54F
Copy link
Member

YOU54F commented Jan 6, 2023

hmmm, I think I noticed this or something similar, where the transports are actually being picked up from the pact file, (in which the interaction specifies the protocol and plugin/plugin version)

not directly in testing pact-go, but generally testing the plugin framework

@mefellows
Copy link
Member

Thanks Jason. I think some documentation will help this, and possibly there is something we can do to guard in Pact Go.

Basically, the core will attempt to use the same transport for all plugins if others aren't given to it. That might be sensible, but the errors aren't exactly clear.

@jasonltaylor
Copy link
Author

ok - wasn't sure if just a regresssion since the client contract has the transport defined in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants