Hello all, continuing integrating PACT to an exist...
# pact-js
z
Hello all, continuing integrating PACT to an existing project with Node, I have so far succeeded to pass the consumer test + publish the first PACT. The pact state in pact flow is unverified. I have few questions : 1-When I launch provider test it fails. I am setting
publishVerificationResult: true,
Shouldn't PACT publish the results even if it's failing and set the verification as failed? For now as I said earlier my pact flow displays Unverified status with Verified at never. 2-I am running PACT test with vi test which is already used in my project. I am a bit confused on how to read, analyse and debug PACT logs and reports? for now I am getting a long command output with some error but it's really hard to read and to follow here is part of my output :
024-04-07T23:44:36.822159Z ERROR ThreadId(02) verify_provider_async: pact_verifier: Failed to load pact - No pacts found for provider 'MyTransferProvider' matching the given consumer version selectors in pact broker '<https://notabene.pactflow.io/>'
Failures:
2024-04-07T23:44:36.991267Z TRACE tokio-runtime-worker hyper::proto::h2::client: client::dispatch::Sender dropped
2024-04-07T23:44:36.991269Z TRACE tokio-runtime-worker verify_provider_async:Connection{peer=Client}:poll: h2::proto::connection: connection.state=Open
1) Failed to load pact - No pacts found for provider 'MyTransferProvider' matching the given consumer version selectors in pact broker '**********.io'
There were 1 pact failures
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
FAIL  *****/******/******action-provider.test.ts > Transfers provider tests > a request for a new transfer > sends a valid transfer
Error: Verfication failed
❯ .yarn/unplugged/@pact-foundation-pact-core-npm-14.3.3-0e1950cbed/node_modules/@pact-foundation/pact-core/src/verifier/nativeVerifier.ts:52:20
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files  1 failed (1)
Tests  1 failed (1)
Start at  01:44:33
Duration  3.04s (transform 22ms, setup 0ms, collect 291ms, tests 2.47s, environment 0ms, prepare 50ms)
m
If it can’t find any pacts to verify, there are no verification results to attach to the contract
To get more readable logs, I’d set the log level to
INFO
or perhaps even justn
ERROR
. Trace level logs will be too verbose for everyday use
1
z
Hey Matt, I think that the issue is rather it can't match between consumer and producer based on the version of each in order to match it in broker.
m
The issue is that your selectors in the verification process do not discover any pacts. You should review which selectors match up with the pacts you wish to verify
Hey Matt, I think that the issue is rather it can’t match between consumer and producer based on the version of each in order to match it in broker.
perhaps, but you wouldn’t normally select on versions
what are your selectors now? And what is the state of the pact you wish to verify?
z
the status is unverified it has never been verified.
The provider does not get a version in pact broker the consumer does though
I am setting my provider version to :
providerVersion: versionFromGitTag(),
I have debugged locally and the version is assigned correctly
But I don't know why it's not sent back to pact flow
As for selector for simplicity I just left matching branch
consumerVersionSelectors: [
{
matchingBranch: true,
},
],
});
m
what branch was the consumer published as? What branch is the provider?
z
as my goal for now is 1-Get the provider results uploaded to pact flow 2-Pass the pact
same branch for both
m
I have debugged locally and the version is assigned correctly
what are you trying to do with versions? Versions are not related to matching behaviour - they describe the version of the application you are publishing (consumer side) or verifying (provider side).
z
I am just trying to version the provider and the consumer.
m
as my goal for now is 1-Get the provider results uploaded to pact flow 2-Pass the pact
the problem is it’s not finding any pacts to verify, so problem #1 is getting you consumer selectors right.
Can you please show a screenshot of your contract overview page?
z
consumer selectors?
sure
m
Thanks.
please show me your provider verification config. In fact, if you have the trace logs from before, attach those. That will definitively show what was sent to the broker
z
sure I will switch back to the broker as I changed to local to overcome the issue then will share with you in a sec.
👍 1
please have a look, it's expected for the request I am sending to fail.
m
sorry, these aren’t TRACE level logs. They seem to be at INFO level
z
oh my bad
one sec
m
> 2024-04-08T011934.417123Z TRACE ThreadId(02) verify_provider_async:fetch_pacts{source=[BrokerWithDynamicConfiguration { provider_name: “MyTransferProvider”, broker_url: “https://notabene.pactflow.io/”, enable_pending: false, include_wip_pacts_since: None, provider_tags: [], provider_branch: Some(“master”), selectors: [ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: None, deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: None, branch: None, matching_branch: Some(true) }], auth: Some(Token(“4JS6HaNmFvoMAaXkLkYm1A”)), links: [] }] consumers=[] provider=ProviderInfo { name: “MyTransferProvider”, protocol: “http”, host: “localhost”, port: Some(56604), path: “/”, transports: [ProviderTransport { transport: “http”, port: Some(56604), path: Some(“/”), scheme: None }] }}:fetch_pact{source=BrokerWithDynamicConfiguration { provider_name: “MyTransferProvider”, broker_url: “https://notabene.pactflow.io/”, enable_pending: false, include_wip_pacts_since: None, provider_tags: [], provider_branch: Some(“master”), selectors: [ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: None, deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: None, branch: None, matching_branch: Some(true) }], auth: Some(Token(“4JS6HaNmFvoMAaXkLkYm1A”)), links: [] } provider=ProviderInfo { name: “MyTransferProvider”, protocol: “http”, host: “localhost”, port: Some(56604), path: “/”, transports: [ProviderTransport { transport: “http”, port: Some(56604), path: Some(“/”), scheme: None }] }}: pact_verifier:pact broker post_json(url=‘https://notabene.pactflow.io/pacts/provider/MyTransferProvider/for-verification’, body=‘{“includePendingStatus”false,“consumerVersionSelectors”[{“matchingBranch”true}],“providerVersionBranch”“master”}’) This line shows the branch of the provider is
master
. The consumer published to a different branch
pact-integration
, so the
matchingBranch
selector has not found any pacts
z
oh!
i am getting provider version Branch from here :
got it for this error
thanks Matt that helps better analysing the logs
👍 1
m
is
GIT_BRANCH
set as an environment variable?
My guess is no
z
no it's not 🙂
I can now see the PACT failing on PACT flow 🙂
🎉 1
thanks a lot for your support
m
No worries!
If you haven’t already, the CI/CD workshop is worth going through (and nirvana guide)
see👇(howtolearn)
s
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops
z
Nice will surely have to go through theses too! Thanks for sharing
🙌 1