Adam Witko
07/10/2023, 2:53 PMYousaf Nabi (pactflow.io)
Adam Witko
07/10/2023, 2:58 PMconst failIfNoPactsFound = false
const coreOptions: PactMessageProviderOptions = {
messageProviders: options.messageProviders,
publishVerificationResult: options.pipelineExecution,
provider: options.provider,
pactBrokerUsername: options.authentication.username,
pactBrokerPassword: options.authentication.password,
providerVersion: options.version,
providerVersionBranch: options.branch,
logLevel: options.logLevel || 'error',
failIfNoPactsFound,
}
const buildOptions = {
pactBrokerUrl: config.pactBrokerUrl,
enablePending: true,
consumerVersionSelectors: [
{
mainBranch: true,
},
{ deployedOrReleased: true },
{ matchingBranch: true },
],
includeWipPactsSince: options.workInProgressPactsSince,
}
const verifierOptions = options.pactUrl
? { ...coreOptions, pactUrls: [options.pactUrl], ...customOptions }
: { ...coreOptions, ...buildOptions, ...customOptions }
const verifier = new MessageProviderPact(verifierOptions)
return verifier.verify()
So as the pactUrl is specified, it omits the buildOptions therefore it doesn't verify any pending pacts, wip pacts, or have any consumer version selectors. The verification when the provider is being changed and ensuring it's not breaking any existing pacts is great, it's when the pact url is specified and there are multiple providers in this one repository.Adam Witko
07/10/2023, 2:59 PMpactUrls and those are the only pacts you will verify, the providers specified in the pact contract contents must match the provider being ran 😕Yousaf Nabi (pactflow.io)
provider option and instead verify whatever is in the url, when doing an url based verification
it isn’t acting as a filter, as you are expecting, I would need to check the source.
there is a consumer filter pactffi_verifier_set_consumer_filters where you can filter consumers, again not sure if that takes effect if the pact url is set, or just on dynamically fetched pacts, we would need to check the pact-js verifier code and the rust verifier code.Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
``` const verifierOptions = options.pactUrl
? { ...coreOptions, pactUrls: [options.pactUrl], ...customOptions }
: { ...coreOptions, ...buildOptions, ...customOptions }```This looks right to me. sounds like you have a pact url called
example consumer-blah-provider-a
provider opt of provider-b
and your expectation is that it shouldn’t run a test?Yousaf Nabi (pactflow.io)
We have 2 providers in one repository and when the pact url is specified and we run that verifier flow, it’s executing against more than the single provider the pact specifies within the consumer contract.I think I need a bit more detail around this. When is the pact url being specified how do you isolate the verifications between the two separate providers, that reside in the same codebase are they using the same file?
Adam Witko
07/10/2023, 3:28 PMso when the pact url is used, I assume this is being invoked by a webhook?Yes. Each provider in this single repository has its own webhook. This URL is an example of the PACT_URL being provided by the webhook invoked triggerd https://pact-broker.localhost.io/pacts/provider/provider-a/consumer/consumer-a/pact-versi[…]3e074effa27e9192f566/metadata/Y3ZuPWNiZGNjZmEyJnc9dHJ1ZQ.
Are you receiving one single webhook?Yes, each provider in this repository has its own webhook defined and will specify in the url the provider it is so provider-a or provider-b. I am receiving 1 webhook triggered pipeline with the above url. So no mention anywhere in the pipeline being triggered of
provider-b .
provider opt ofprovider-b
and your expectation is that it shouldn’t run a test?Yes exactly that. The above url is being specified and running the 'webhook verify flow' in our pipeline. It is running each of the unique provider verification test files in the repo with the pact url. The provider that has a different matching name than what's in that URL (i.e. url says provider-a but provider-b is executing too) or within the contract file itself is being executed and failing. `provider-a`verification is running as expected and passing but
provider-b is also being executed and failing.
how do you isolate the verifications between the two separate providers, that reside in the same codebase are they using the same file?So they are two completely separate verification test files that use the options specified https://pact-foundation.slack.com/archives/C9VBGLUM9/p1689001131963479?thread_ts=1689000821.597169&cid=C9VBGLUM9 and the only major difference is the provider name and any messageProviders/stateHandlers. Unless I am missing a simple way to support multiple providers in the same project each with their own unique webhook (1 webhook per provider) then I think there may be only one solution. When the pact url is specified there needs to be manual filtering of which provider verification test files to run as it doesn't look like the pact url provider or the provider within the consumer contract are checked when the provider is ran.
Yousaf Nabi (pactflow.io)
Adam Witko
07/10/2023, 3:43 PMAdam Witko
07/10/2023, 3:49 PMAdam Witko
07/11/2023, 7:36 AMAdam Witko
07/11/2023, 7:38 AMTimothy Jones
07/11/2023, 10:17 AMTimothy Jones
07/11/2023, 10:17 AMMatt (pactflow.io / pact-js / pact-go)
provider name was previously only used as a selector to discover pacts in the broker, and not for much elseMatt (pactflow.io / pact-js / pact-go)
Timothy Jones
07/11/2023, 10:19 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
--filter-provider (by default) or have that as an explicit optionTimothy Jones
07/11/2023, 10:30 AMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
that would be assumption too, that filtered shouldn’t be publishable.Should that apply to all filters, filtered desc vs filtered consumer
Timothy Jones
07/11/2023, 11:25 AMthat would be assumption too, that filtered shouldn’t be publishable.It definitely shouldn’t, because if you filter the contract, you’re not adhering to the expectations of the consumer.
Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Timothy Jones
07/11/2023, 11:26 AMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)