Tatiana
06/05/2023, 8:02 PMcan-i-deploy
tool.
I have the following situation:
Provider (P) has long and slow pipeline, consumer (C) has small and quick pipeline.
P1 deployed to staging. C1 deployed to staging too. Pact between C1 and P1 was verified successfully.
Provider pushed some changes to the main
branch with v2 and the pipeline is running.
Meanwhile, consumer pushed changes too (pact wasn’t changed) and triggers verification on the provider side against the provider’s main
branch with v2, in the end verification passed.
Consumer is ready to deploy (provider’s pipeline with v2 still running), however can-i-deploy
tool fails, because it can’t find verification record between P1 and C2. P1 is the latest deployed version of our provider on staging.
Should can-i-deploy
fail in the case when pact wasn’t changed and provider v2 hasn’t beed deployed yet?Tatiana
06/05/2023, 8:04 PMThis happens when two or more application versions publish the same Pact contract. Duplicate detection is done by hashing the pact file. Note that application versions publishing the same pact contract don't need to be consecutive.
Allowing multiple consumer versions to point to one pact contract file has the major advantage that verifications don't need to be repeated when contracts haven't changed. In the diagram above, a provider that has been verified against consumer version 0.0.0 is automatically considered to have been verified against consumer version 0.0.1. This is particularly useful when working on feature branches.
Matt (pactflow.io / pact-js / pact-go)
triggers verification on the provider side against the provider’swhy did it trigger a verification? If you’re using the the ‘contract requiring verification published’ event then it wouldn’t trigger if it didn’t require verification. This implies it would. It’s worth checking to see if there are any changes between the versions in your consumer contract. This can occasionally happen if you use dynamic matchers without specifying examples (the framework will insert random values in that case) which will invalidate the pre-verification statusbranch with v2, in the end verification passed.main
Tatiana
06/05/2023, 11:50 PMwhy did it trigger a verification?I don’t use pact webhooks. I trigger provider verification every time when merge request is opened or changes pushed to the
main
branch in a consumer, and I trigger it as a downstream pipeline.
I am thinking maybe I should trigger it only when changes introduced in pacts 🤔Tatiana
06/05/2023, 11:53 PMIt’s worth checking to see if there are any changes between the versions in your consumer contract. This can occasionally happen if you use dynamic matchers without specifying examples (the framework will insert random values in that case) which will invalidate the pre-verification statusIf there is no changes between contracts, should
can-i-deploy
fail in my case? (I’m sure there are no changes, but I’ll double check)Matt (pactflow.io / pact-js / pact-go)
I am thinking maybe I should trigger it only when changes introduced in pactsah - you should use webhooks if you can! They are clever enough to do it for you 🙂
Matt (pactflow.io / pact-js / pact-go)
If there is no changes between contracts, shouldwithout knowing the flags you are giving to the CLI it’s hard to say, but in general if a contract hasn’t changed between consumer versions for the same provider version then it should be pre-verified and not fail.fail in my case? (I’m sure there are no changes, but I’ll double check)can-i-deploy
Tatiana
06/06/2023, 12:45 AMif a contract hasn’t changed between consumer versions for the same provider versionI use commit sha as a version for both consumer and provider. I have C1 and P1 verified and deployed. Then I have C2 and P1 where contract is the same as between C1 and P1, so contract should be pre-verified and can-i-deploy should pass, is it correct?
Tatiana
06/06/2023, 12:47 AMscript:
- >-
pact-broker can-i-deploy
--pacticipant="my-service"
--version="$CI_COMMIT_SHA"
--to-environment="$ENVIRONMENT"
--broker-base-url="$PACT_FLOW_BASE_URL"
--broker-token="$PACT_FLOW_KEY"
--verbose
verification:
script:
- >-
pact-verifier
--hostname="app"
--broker-url="$PACT_FLOW_BASE_URL"
--token="$PACT_FLOW_KEY"
--loglevel="info"
--provider-branch="$CI_COMMIT_REF_SLUG"
--provider-version="$CI_COMMIT_SHA"
--provider-tags="$CI_COMMIT_REF_NAME"
--provider-name="dummy-microservice-provider"
--filter-consumer="$CONSUMER_NAME"
--publish
Matt (pactflow.io / pact-js / pact-go)
Tatiana
06/06/2023, 1:03 AMpb:diff-previous-distinct
endpoint in the HAL browser for me, maybe something changed?Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Tatiana
06/06/2023, 1:38 AMMatt (pactflow.io / pact-js / pact-go)