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

Consumer is null when using ConsumerVersionSelector #1244

Closed anddreiu closed 4 years ago

anddreiu commented 4 years ago

I have an issue when using tags on my pact files. I am using pact jvm 4.1.10, Pact Broker 2.68.1 and I am using JUnit to run the Provider tests. I am trying to use tags to retrieve the correct pact file when running the Provider tests for a specific consumer. So I've applied the below consumerVersionSelectors:

@PactBroker(consumerVersionSelectors = { @VersionSelector(tag = "prod", consumer = "consumerName") }

Unfortunately, the pact file retrieved is the latest one published in Pact Broker and it looks like it does not see the consumer that I've indicated above. Also the retrieved pact file does not have prod tag.

2020-11-11 06:39:28.637 DEBUG [PactBrokerLoader.kt] Loading pacts from pact broker for provider providerName and consumer version selectors [ConsumerVersionSelector(tag=prod, latest=true, consumer=null, fallbackTag=)]
Verifying a pact between consumerName and providerName
  Notices:
    1) The pact at https://pactbroker/pacts/provider/providerName/consumer/consumerName/pact-version/64fr34ca943bbg242432we3f9hwe43c34r25wef2 is being verified because it matches the following configured selection criterion: latest pact for a consumer version tagged 'prod'

As @uglyog mentioned on slack, it looks like a defect because the consumer is null:

[ConsumerVersionSelector(tag=prod, latest=true, consumer=null, fallbackTag=)]

Thank you

anddreiu commented 4 years ago

I've just tried to use the deprecated version of this:

@PactBroker(consumers = "consumerName", tags = "prod"

In this case the right consumer is taken (see below), but the retrieved pact is not the correct one:

2020-11-11 09:08:24.084 DEBUG [PactBrokerLoader.kt] Loading pacts from pact broker for provider providerName and consumerName version selectors [ConsumerVersionSelector(tag=prod, latest=true, consumer=consumerName, fallbackTag=null)]

The retrieved pact is the latest one, even if this does not have 'prod' tag. Very weird

uglyog commented 4 years ago

4.1.11 has been released

anddreiu commented 4 years ago

Thanks @uglyog. This looks to be fixed now, but I think there is another issue because I am still not able to select the correct Pact file using tags. I've raised another issue for that: https://github.com/pact-foundation/pact-jvm/issues/1249.

Thanks