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

What is the difference between the system properties pactbroker.providerBranch and pact.provider.branch? #1576

Open snukone opened 2 years ago

snukone commented 2 years ago

If you check this page, you will see the description for both properties: https://github.com/pact-foundation/pact-jvm/blob/master/docs/system-properties.md

But what i dont understand is the following:

In the page above the providerBranch is claimed as needed for evaluation. But here its stated that it is used when publishing the verification result - no word about evaluation: https://github.com/pact-foundation/pact-jvm/blob/c410df7c007b3c9462fbc6ab6915c2a125a877e4/provider/junit5/README.md#pending-pact-support-version-410-and-later (pactbroker.providerTags is the same usecase as pactbroker.providerBranch) or here https://github.com/pact-foundation/pact-jvm/blob/master/provider/src/main/kotlin/au/com/dius/pact/provider/junitsupport/loader/PactBrokerLoader.kt#L225-L228. If i am not setting the pactbroker.providerBranch property, i havent got any error message like implemented in the last link yet.

Furthermore its states on another page, that the pactbroker.providerBranch is related to matchingBranch key of the consumer version selector: https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown (providerVersionBranch should contain the value of pactbroker.providerBranch if i am right).

Im a bit confused and not sure if this is the right place to ask this question because it isnt an real issue. In case e.g. stackoverflow would be the better place to state the question please let me know. Hope someone can help me with understanding the difference between the two properties exactly.

For myself i have understand it like this:

Im using Pact-JVM 4.3.9 and Pactbroker 2.93.2.

Thanks for your help in advance.

snukone commented 2 years ago

Dear @bethesque and @uglyog, maybe you have a second to verify if this statement is correct:

When this system properties are set, the verification is done for pacts where the provider 'Provider' is part of and ... :

When publishing the verificaton results, this system properties are important for setting provider version and provider branch: -Dpact.verifier.publishResults=true \ -Dpact.provider.version=123456 \ -Dpact.provider.branch=feature/new-rest-endpoint

rholshausen commented 2 years ago

There is unfortunate duplication of properties there, and I think it was done by duplicating what was there for tags.

pactbroker.providerBranch is only used when fetching Pacts from a Pact broker from a JUnit test. This property needs to be deprecated.

I would recommend setting both to the same value.

snukone commented 2 years ago

Thank you very much for your advise and your time! I updated my configuration in the first comment.

I tested running the provider verification without setting pactbroker.providerBranch - i am getting no error (but i expected one as implemented here: https://github.com/pact-foundation/pact-jvm/blob/f927119bf37d5903425423fc0ab0652b5b29d548/provider/src/main/kotlin/au/com/dius/pact/provider/ProviderInfo.kt#L122-L125 ) . What is happening when i didnt setup the property?

Could you shortly explain what the property pactbroker.providerBranch is used for within the pact broker? I have red a lot of the documentation but i dont understand the exact meaing. Maybe would be an example good to go:

Example:

  1. New consumer pact -> published to pact-broker with consumer branch feature/x
  2. Automatically verified from provider in git-branch master -> failed with provider branch master
  3. New provider feature-branch feature/y for implementing changed pact -> whats happending by setting pactbroker.providerBranch=feature/y when running the junit verification tests and keeping all the other properties as stated in my first comment but without pactbroker.includeWipPactsSince?