pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Results from Verification triggered by webhook not published to pact broker #1798

Closed s1apped closed 3 months ago

s1apped commented 4 months ago

Hello,

Looks like there is an issue with publishing verifications results triggered by webhook to pact broker. @YOU54F was kind enough to take a look and was able to recreate it on pact flow. Here is the link to full thread https://pact-foundation.slack.com/archives/C9UN99H24/p1716450450193459.

I'm setting below properties

'pact.provider.branch'                        = $PACT_PROVIDER_BRANCH
'pactbroker.providerBranch'                   = $PACT_PROVIDER_BRANCH 
'pact.provider.version'                       = $PACT_PROVIDER_VERSION
'pactbroker.enablePending'                    = false    
'pact.verifier.publishResults'                = true
'pact.filter.pacturl'                         = $PACT_URL
'pact.filter.consumers'                       = pact-consumer

Verification jobs are triggered properly and contract passed by PACT_URL is being used but results are not published back image

mefellows commented 3 months ago

Pretty sure by filtering consumers, the verification results are invalid and are not sent. I can see why you may want the interim results up there (a work in progress verification for a given consumer) but IIRC the semantics are currently undefined so this is the safer course of action.

mefellows commented 3 months ago

There should be a log of sorts if this is the case, sharing your test output and any additional DEBUG logs might help.

s1apped commented 3 months ago

I was using WIP and Pending for verification but it was problematic because it executed tests for every provider consumer feature branch combination instead of only for main and deployed.

I used this property based on: https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406

but maybe it's outdated?

mefellows commented 3 months ago

Thanks, will need the maintainer to confirm this behaviour then.

s1apped commented 3 months ago

wondering if it has something to do with default selectors?

2024-06-04 14:30:28.796468 I [7:puma srv tp 002] PactBroker::Api::Resources::ProviderPactsForVerification -- Fetching pacts for verification by pact-producer -- { :provider_name => "pact-producer", :params => { "consumerVersionSelectors" => [], "includePendingStatus" => false } }
2024-06-04 14:30:28.799830 D [7:puma srv tp 002] PactBroker::Pacts::PactsForVerificationRepository -- Default selectors -- [{:main_branch=>true, :consumer=>"pact-consumer"}, {:currently_deployed=>true}, {:currently_supported=>true}]
mefellows commented 3 months ago

Just confirming you also have set @AllowOverridePactUrl on your test class?

s1apped commented 3 months ago

Yes. Tests are using Pact from url but results aren't published

mefellows commented 3 months ago

Oh, did you get to the bottom of it?

s1apped commented 3 months ago

hey. yep huge overlook on my end and obvious problem. I was missing override url annotation on class which I was sure was extending class with annotation. This was causing 1 test using different contract url which was causing pact to calculate different calculateInteractionHash so publish didn’t trigger because not all pacts were verified.. Sorry for the fuss and I really appreciate your help!

mefellows commented 3 months ago

Ah! So you mean this annotation?

Good to know, and glad it's all sorted (also, phew!).

s1apped commented 3 months ago

Unfortunately yes :(

mefellows commented 3 months ago

No worries - we've all been there!