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.09k stars 480 forks source link

The order of pactbroker.consumerversionselectors.tags is relevant in regards to whether a consumer contract gets found or not #1238

Closed sydseter closed 4 years ago

sydseter commented 4 years ago

dependencies:

<dependency>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>junit</artifactId>
<version>4.1.9</version>
</dependency>
<dependency>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>spring</artifactId>
<version>4.1.9</version>
</dependency>

Given that a provider is using a consumer tag "v2" that hasn't been published yet and given that the contract published under v1 still is identical with v2, then the following seems to happen depending on whether the non-existing consumer tag comes first or last.

mvn pact:publish -Dpactbroker.host=localhost -Dpactbroker.port=9292 -Dpact.consumer.tags="v1"

mvn clean install -Dpactbroker.consumerversionselectors.tags="v2, v1" -Dpactbroker.providerTags="v2" -Dpactbroker.host=localhost -Dpactbroker.port=9292

[ERROR]  TestEngine with ID 'junit-vintage' failed to discover tests

mvn clean install -Dpactbroker.consumerversionselectors.tags="v1, v2" -Dpactbroker.providerTags="v2" -Dpactbroker.host=localhost -Dpactbroker.port=9292

[INFO] au.com.dius.pact.provider.DefaultVerificationReporter - Published verification result of 'au.com.dius.pact.core.pactbroker.TestResult$Ok@64136a29' for consumer

What I would have expected:

When -Dpactbroker.consumerversionselectors.tags="v2, v1" is specified then I would expect the pact provider to ignore the non-existing v2 tag and download v1 for verification.

What shouldn't happen:

the pact provider verification failing because one of the consumer tags hasn,t been published to the broker yet.

uglyog commented 4 years ago

I am unable to replicate this. I've tested with our broker (version 2.68.1), and it works the same way regardless of the order of the tags. Can you confirm the version of the broker you are using?

sydseter commented 4 years ago

I am using 2.66. I’ll upgrade to 2.68.1 and get back to you.

sydseter commented 4 years ago

verified working when using the 2.68.1 version