Nuno Frias
06/07/2022, 11:00 AMpact-go
and when running the provider verification I am noticing that the test hangs after the call to libpact_ffi
.
2022/06/02 13:09:55 [INFO] package libpact_ffi found
2022/06/02 13:09:55 [INFO] checking version 0.3.3 for lib libpact_ffi within semver range >= 0.1.2, < 1.0.0
2022/06/02 13:09:55 [INFO] checking version 0.3.3 of libpact_ffi against semver constraint >= 0.1.2, < 1.0.0
2022/06/02 13:09:55 [DEBUG] 0.3.3 satisfies constraints 0.3.3 >= 0.1.2, < 1.0.0
2022/06/02 13:09:55 [DEBUG] version check completed
2022/06/02 13:10:21 [DEBUG] starting new proxy with opts {http localhost:8080 0 [0x1036d5910] /__setup <nil>}
2022/06/02 13:10:21 [DEBUG] starting reverse proxy on port 49359
2022/06/02 13:10:21 [DEBUG] waiting for port 49359 to become available
2022/06/02 13:10:21 [DEBUG] pact provider verification
2022/06/02 13:10:21 [DEBUG] initialising rust mock server interface
2022/06/02 13:10:22 [DEBUG] waiting for port 49359 to become available
2022/06/02 13:10:24 [DEBUG] executing verifier FFI with args [--file /Users/nunofrias/Documents/repos/entitlement-orchestrator/cmd/pacts/reseller-entitlement-service-entitlement-orchestrator.json --hostname localhost --port 49359 --provider-name entitlement-orchestrator --loglevel trace]
Hangs here !
I proceeded to debug the rust ffi code and found that the exact point where it hangs is in the make_provider_request
function in <http://provider_client.rs|provider_client.rs>
, more precisely in:
let response = request.send()
.map_err(|err| anyhow!(err))
.and_then(native_response_to_pact_response)
.await?;
More curiously I have also noticed that the first time I run the provider verification after I start the terminal application, it succeeds. Subsequent verifications fails more often than not -- if I restart the command line the verification succeeds.
I would dearly appreciate some help as my knowledge of rust is rather basic.
Thank you.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
curl localhost:49359
or to the proxied target (the actual provider)?Nuno Frias
06/07/2022, 11:54 AMgo version go1.17.6 darwin/arm64
I am running on Mac OS 12 (and it is an M1 chip)
I suspect there are some processes outstanding. I am about to enable dtruss
(strace equivalent) to try and pinpoint the error.Nuno Frias
06/07/2022, 11:55 AMlocalhost:49359
and I see the server responses.Matt (pactflow.io / pact-js / pact-go)
Nuno Frias
06/07/2022, 11:57 AMv2.0.0-beta.11
Nuno Frias
06/07/2022, 11:57 AMv2.x.x
branch.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Nuno Frias
06/07/2022, 12:02 PMNuno Frias
06/07/2022, 12:02 PMNuno Frias
06/07/2022, 2:18 PMgit checkout 2.x.x
git pull
git apply pact_go_examples.diff
cd pact-go/examples
go test -run ^TestConsumerV3$ .
go test -tags provider -run ^TestV3HTTPProvider$
I am still working on setting up the GitHub actions (but let me know if the above suffices).Nuno Frias
06/07/2022, 3:02 PMNuno Frias
06/07/2022, 5:01 PMNuno Frias
06/07/2022, 7:41 PMNuno Frias
06/07/2022, 7:42 PMmacos-12
(which I hope behave similarly to my Mac).
https://github.com/nsfrias/pact-go-issue-repro-20220607/actions/runs/2456922279Nuno Frias
06/07/2022, 7:43 PMMatt (pactflow.io / pact-js / pact-go)
Nuno Frias
06/08/2022, 12:47 PMNuno Frias
06/08/2022, 1:10 PMMatt (pactflow.io / pact-js / pact-go)
➜ /tmp git clone <https://github.com/nsfrias/pact-go-issue-repro-20220607.git>
Cloning into 'pact-go-issue-repro-20220607'...
remote: Enumerating objects: 63, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 63 (delta 22), reused 48 (delta 11), pack-reused 0
Receiving objects: 100% (63/63), 26.85 KiB | 8.95 MiB/s, done.
Resolving deltas: 100% (22/22), done.
➜ /tmp cd pact-go-issue-repro-20220607
➜ pact-go-issue-repro-20220607 git:(main) go install <http://github.com/pact-foundation/pact-go/v2@2.x.x|github.com/pact-foundation/pact-go/v2@2.x.x>
go: downloading <http://github.com/pact-foundation/pact-go/v2|github.com/pact-foundation/pact-go/v2> v2.0.0-beta.11.0.20220607035712-b017cad30d3d
➜ pact-go-issue-repro-20220607 git:(main) pact-go -l DEBUG install
2022/06/09 15:54:22 [INFO] package libpact_ffi found
2022/06/09 15:54:22 [INFO] checking version 0.3.2 of libpact_ffi against semver constraint >= 0.3.0, < 1.0.0
2022/06/09 15:54:22 [DEBUG] 0.3.2 satisfies constraints 0.3.2 >= 0.3.0, < 1.0.0
2022/06/09 15:54:22 [INFO] package libpact_ffi is correctly installed
2022/06/09 15:54:22 [DEBUG] skip checking ffi version() call because FFI not loaded. This is expected when running the 'pact-go' command.
➜ pact-go-issue-repro-20220607 git:(main) go test -run "^TestConsumerV3$" consumer_test.go
go: downloading github.com/stretchr/testify v1.7.2
go: downloading github.com/golang/protobuf v1.3.3
ok command-line-arguments 0.846s
➜ pact-go-issue-repro-20220607 git:(main) go test -timeout 30s -run "^TestV3HTTPProvider$" .
ok example.com/m 3.618s
➜ pact-go-issue-repro-20220607 git:(main) go test -v -timeout 30s -run "^TestV3HTTPProvider$" .
=== RUN TestV3HTTPProvider
2022/06/09 15:55:26 [INFO] package libpact_ffi found
2022/06/09 15:55:26 [INFO] checking version 0.3.2 for lib libpact_ffi within semver range >= 0.1.2, < 1.0.0
2022/06/09 15:55:26 [INFO] checking version 0.3.2 of libpact_ffi against semver constraint >= 0.1.2, < 1.0.0
2022/06/09 15:55:26 [DEBUG] 0.3.2 satisfies constraints 0.3.2 >= 0.1.2, < 1.0.0
2022/06/09 15:55:26 [DEBUG] version check completed
2022/06/09 15:55:26 [DEBUG] starting new proxy with opts {http localhost:8111 0 [0x4390e60 0x4391160 0x461c1c0] /__setup <nil>}
2022/06/09 15:55:26 [DEBUG] starting reverse proxy on port 64647
2022/06/09 15:55:26 [DEBUG] waiting for port 64647 to become available
2022/06/09 15:55:26 [DEBUG] pact provider verification
2022/06/09 15:55:26 [DEBUG] initialising rust mock server interface
2022/06/09 15:55:26 [DEBUG] waiting for port 64647 to become available
2022/06/09 15:55:26 [DEBUG] executing verifier FFI with args [--file /tmp/pact-go-issue-repro-20220607/pacts/PactGoV3Consumer-V3Provider.json --hostname localhost --port 64647 --provider-name V3Provider --loglevel trace]
Given User foo exists
WARNING: State Change ignored as there is no state change URL provided
2022/06/09 15:55:28 [DEBUG] HOOK request filter
2022/06/09 15:55:28 [DEBUG] http reverse proxy received connection from [::1]:64653 on path /foobar?baz=bar&baz=bat&baz=baz
2022/06/09 15:55:28 [DEBUG] setting proxy to target
2022/06/09 15:55:28 [DEBUG] incoming request /foobar?baz=bar&baz=bat&baz=baz
2022/06/09 15:55:28 [DEBUG] outgoing request to target <http://localhost:8111/foobar?baz=bar&baz=bat&baz=baz>
2022/06/09 15:55:28 [TRACE] proxy outgoing request
POST /foobar?baz=bar&baz=bat&baz=baz HTTP/1.1
Host: localhost:8111
User-Agent: Pact Go
Content-Length: 76
Accept: */*
Accept-Encoding: gzip, deflate
Authorization: Bearer 1234
Authorization: Bearer 1234-dynamic-value
Content-Type: application/json
X-Forwarded-For: ::1
2022/06/09 15:55:28 [TRACE] proxied server response
HTTP/1.1 200 OK
Content-Length: 458
Content-Type: application/json
Date: Thu, 09 Jun 2022 05:55:28 GMT
{
"accountBalance": 123.76,
"datetime": "2020-01-01",
"equality": "a thing",
"id": 12,
"itemsMin": [
"thereshouldbe3ofthese",
"thereshouldbe3ofthese",
"thereshouldbe3ofthese"
],
"itemsMinMax": [
27,
27,
27,
27,
27
],
"lastName": "Sampson",
"name": "Billy",
"superstring": "foo",
"arrayContaining": [
"string",
1,
{
"foo": "bar"
}
]
}
2022/06/09 15:55:28 [DEBUG] executing after hook
2022/06/09 15:55:28 [DEBUG] HOOK after each
Given User foo exists
WARNING: State Change ignored as there is no state change URL provided
2022/06/09 15:55:28 [DEBUG] HOOK request filter
2022/06/09 15:55:28 [DEBUG] http reverse proxy received connection from [::1]:64656 on path /foobar?baz=bar&baz=bat&baz=baz
2022/06/09 15:55:28 [DEBUG] setting proxy to target
2022/06/09 15:55:28 [DEBUG] incoming request /foobar?baz=bar&baz=bat&baz=baz
2022/06/09 15:55:28 [DEBUG] outgoing request to target <http://localhost:8111/foobar?baz=bar&baz=bat&baz=baz>
2022/06/09 15:55:28 [TRACE] proxy outgoing request
POST /foobar?baz=bar&baz=bat&baz=baz HTTP/1.1
Host: localhost:8111
User-Agent: Pact Go
Content-Length: 76
Accept: */*
Accept-Encoding: gzip, deflate
Authorization: Bearer 1234
Authorization: Bearer 1234-dynamic-value
Content-Type: application/json
X-Forwarded-For: ::1
2022/06/09 15:55:28 [TRACE] proxied server response
HTTP/1.1 200 OK
Content-Length: 458
Content-Type: application/json
Date: Thu, 09 Jun 2022 05:55:28 GMT
{
"accountBalance": 123.76,
"datetime": "2020-01-01",
"equality": "a thing",
"id": 12,
"itemsMin": [
"thereshouldbe3ofthese",
"thereshouldbe3ofthese",
"thereshouldbe3ofthese"
],
"itemsMinMax": [
27,
27,
27,
27,
27
],
"lastName": "Sampson",
"name": "Billy",
"superstring": "foo",
"arrayContaining": [
"string",
1,
{
"foo": "bar"
}
]
}
2022/06/09 15:55:28 [DEBUG] executing after hook
2022/06/09 15:55:28 [DEBUG] HOOK after each
Given User foo exists
WARNING: State Change ignored as there is no state change URL provided
2022/06/09 15:55:29 [DEBUG] HOOK request filter
2022/06/09 15:55:29 [DEBUG] http reverse proxy received connection from [::1]:64659 on path /foobar?baz=bar&baz=bat&baz=baz
2022/06/09 15:55:29 [DEBUG] setting proxy to target
2022/06/09 15:55:29 [DEBUG] incoming request /foobar?baz=bar&baz=bat&baz=baz
2022/06/09 15:55:29 [DEBUG] outgoing request to target <http://localhost:8111/foobar?baz=bar&baz=bat&baz=baz>
2022/06/09 15:55:29 [TRACE] proxy outgoing request
POST /foobar?baz=bar&baz=bat&baz=baz HTTP/1.1
Host: localhost:8111
User-Agent: Pact Go
Content-Length: 76
Accept: */*
Accept-Encoding: gzip, deflate
Authorization: Bearer 1234
Authorization: Bearer 1234-dynamic-value
Content-Type: application/json
X-Forwarded-For: ::1
2022/06/09 15:55:29 [TRACE] proxied server response
HTTP/1.1 200 OK
Content-Length: 458
Content-Type: application/json
Date: Thu, 09 Jun 2022 05:55:29 GMT
{
"accountBalance": 123.76,
"datetime": "2020-01-01",
"equality": "a thing",
"id": 12,
"itemsMin": [
"thereshouldbe3ofthese",
"thereshouldbe3ofthese",
"thereshouldbe3ofthese"
],
"itemsMinMax": [
27,
27,
27,
27,
27
],
"lastName": "Sampson",
"name": "Billy",
"superstring": "foo",
"arrayContaining": [
"string",
1,
{
"foo": "bar"
}
]
}
2022/06/09 15:55:29 [DEBUG] executing after hook
2022/06/09 15:55:29 [DEBUG] HOOK after each
Verifying a pact between PactGoV3Consumer and V3Provider
A request to do a foo
returns a response which
has status code 200 (OK)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (OK)
Verifying a pact between PactGoV3Consumer and V3Provider
A request to do a foo
returns a response which
has status code 200 (OK)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (OK)
Verifying a pact between V3Consumer and V3Provider
A request to do a foo
returns a response which
has status code 200 (OK)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (OK)
=== RUN TestV3HTTPProvider/Provider_pact_verification
--- PASS: TestV3HTTPProvider (3.10s)
--- PASS: TestV3HTTPProvider/Provider_pact_verification (0.00s)
PASS
ok <http://example.com/m|example.com/m> 3.663s
Matt (pactflow.io / pact-js / pact-go)
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/matthew.fellows/Library/Caches/go-build"
GOENV="/Users/matthew.fellows/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/matthew.fellows/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/matthew.fellows/go"
GOPRIVATE=""
GOPROXY="<https://proxy.golang.org>,direct"
GOROOT="/usr/local/Cellar/go/1.18.2/libexec"
GOSUMDB="<http://sum.golang.org|sum.golang.org>"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.18.2/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/tmp/pact-go-issue-repro-20220607/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gl/c3f3yhws1mg754r_t7l5hfm80000gp/T/go-build2365344512=/tmp/go-build -gno-record-gcc-switches -fno-common"
Matt (pactflow.io / pact-js / pact-go)
Nuno Frias
06/10/2022, 8:54 AMNuno Frias
06/10/2022, 8:56 AMNuno Frias
06/10/2022, 8:56 AMgo env
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Nuno Frias
06/10/2022, 9:17 AMNuno Frias
06/10/2022, 9:18 AMMatt (pactflow.io / pact-js / pact-go)
Nuno Frias
06/10/2022, 9:20 AMNuno Frias
06/10/2022, 9:21 AMNuno Frias
06/10/2022, 9:25 AMcgo
config to run pact-go in linux arm64.
diff --git a/internal/native/lib.go b/internal/native/lib.go
index 9ece6b7..d4324ff 100644
--- a/internal/native/lib.go
+++ b/internal/native/lib.go
@@ -6,5 +6,6 @@ package native
#cgo darwin,amd64 LDFLAGS: -L/tmp -L/usr/local/lib -Wl,-rpath -Wl,/tmp -Wl,-rpath -Wl,/usr/local/lib -lpact_ffi
#cgo windows,amd64 LDFLAGS: -lpact_ffi
#cgo linux,amd64 LDFLAGS: -L/tmp -L/opt/pact/lib -L/usr/local/lib -Wl,-rpath -Wl,/opt/pact/lib -Wl,-rpath -Wl,/tmp -Wl,-rpath -Wl,/usr/local/lib -lpact_ffi
+#cgo linux,arm64 LDFLAGS: -L/tmp -L/opt/pact/lib -L/usr/local/lib -Wl,-rpath -Wl,/opt/pact/lib -Wl,-rpath -Wl,/tmp -Wl,-rpath -Wl,/usr/local/lib -lpact_ffi
*/
import "C"
Nuno Frias
06/10/2022, 9:26 AMMatt (pactflow.io / pact-js / pact-go)
Nuno Frias
06/10/2022, 9:30 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Nuno Frias
06/10/2022, 9:40 AMNuno Frias
06/10/2022, 9:41 AMMatt (pactflow.io / pact-js / pact-go)