Hi again, when running provider verification, i su...
# pact-jvm
t
Hi again, when running provider verification, i supply the pact.provider.version as
mvn -DpipelineBuild=true --activate-profiles maven-profile,provider-pact-test -Dpackbroker.scheme=http -Dpactbroker.host=localhost -Dpactbroker.port=9292 -Dpactbroker.auth.username=pact_workshop -Dpactbroker.auth.password=pact_workshop -Dpact.provider.version="7.0.36-$(git rev-parse --short HEAD)" -Dpactbroker.enablePending=false -Dpact.verifier.publishResults=true --projects 60000-demo-service/demo-service --also-make -f all-modules-pom.xml clean verify
and i see pact tries to verify this version of provider against all versions of consumer. Is there a way to tell pact to verify a particular version of the provider against one version of the consumer? I saw the Consumer Version Selector page (https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors) but it does not take the version (tag, branch, environment are supported) and I don't see it accept consumerVersionSelectors params (i checked with mvn help:describe -DgroupId=au.com.dius.pact.provider -DartifactId=maven -Dversion=4.1.17 -Ddetail=true)
u
I don't think you can specify a single consumer version
t
Ok, I think I can tag the consumer when I publish the pact. Do you have an example of specifying consumerVersionSelectors for provider verification on mvn command?
t
Thank you, i checked your link and also found this https://docs.pact.io/implementation_guides/jvm/provider/junit5#using-an-annotated-method-with-a-builder so i added the static method to return the SelectorBuilder like this:
Copy code
@PactBrokerConsumerVersionSelectors
public static SelectorBuilder consumerVersionSelectors() {
    return new SelectorBuilder()
            .branch(System.getProperty("pact.consumer.branch"));
}
and acording to the doc, the LATEST version from a particular branch of each consumer will be selected. However when the provider test run with this selector, i see it validates against ALL versions from the given branch of each consumer:
is this because the content of the 2 pacts (84a31e06 and c22dca51) are the same? thus the validation result is applied to both consumer versions?
u
Yes, the verification is applied to all versions with the same Pact file
t
Thank you for confirming. I just got another problem: I have one git branch B with both the consumers and the providers (mono repo). My CI/CD runs the consumer test first then the provider verification. When the branch is pushed at commit X, the CI/CD pipeline starts. By the time the consumer test finish and consumer pact at version X is pushed to branch B, another commit Y has been pushed to branch B and thus a 2nd CI/CD pipeline starts. By the time the provider X verification starts, the LATEST consumer pacts in broker are a mix of X and Y, thus the provider X is validates against some consumer pact Y. Is there anyway to prevent this?