Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contracts not found after upgrading au.com.dius.pact.consumer:junit5 to a version over 4.x.x #1845

Closed
GinjuCosmin opened this issue Dec 13, 2024 · 2 comments

Comments

@GinjuCosmin
Copy link

GinjuCosmin commented Dec 13, 2024

Hello guys!

I've tried to update the library of my provider test wrote it in Kotlin with Junit5 from:
testImplementation 'au.com.dius:pact-jvm-provider-junit5_2.12:3.6.16'
to the newest version: 'au.com.dius.pact.provider:junit5:4.6.16'

(I'm using a gradle task) and I can see now that the provider test is failing with:
No Pact files were found to verify Provider: ev_replacement Source: Pact Broker https://pact-broker-01.X.net:443 consumerVersionSelectors=[Selector(tag=version1, latest=true, consumer=ev_article, fallbackTag=)] au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify

The test is annotated like this:
`@Provider("ev_replacement")

@ExtendWith(PactVerificationInvocationContextProvider::class)
@PactBroker(
host = "pact-broker-01.X.net",
scheme = "https",
port = "443",
consumerVersionSelectors = [
VersionSelector(tag = "version1", latest = "true", consumer="ev_article")
]
)`

And it simply doesn't find the contract anymore. I spend 2 days on this.
I've played and changed all this parameters multiple times. I can confirm that the contract is posted in Pact broker with the tag version1, with version 0.0.1.
Why I'm getting every time that the contract doesn't exists?

The contract was generated and posted to pact broker using: testImplementation 'au.com.dius.pact.consumer:junit5:4.6.16'

If I'm using:
@PactUrl(
urls = ["https://pact-broker-01.X.net/pacts/provider/ev_replacement/consumer/ev_article/version/0.0.1"]
)
the provider test pass without errors, but I cannot publish the results back to pact broker because it expects an object of this type: BrokerUrlSource, and not UrlSource

Whats wrong with all the library version over 4.x.x? I've tested with different 4.x.x version and I'm getting the same result.

Can someone please help me with this issue? I'm really blocked right now

@rholshausen
Copy link
Contributor

Whats wrong with all the library version over 4.x.x?

Huh!

3.6.x was first released in 2018. So what you are asking is why do my pact tests and broker configured to work in 2018 not work with Pact test from 2024. Because things have changed.

Pact-JVM does not control what Pacts get verified. It passes the request on to the Pact Broker, which then returns the Pacts to be verified. So the issue is why is your Pact broker not returning the Pacts you expect?

One of the issues is the use of tags has been deprecated and it uses branches now. See https://docs.pact.io/blog/2021/07/04/why-we-are-getting-rid-of-tags

You can try update your work flow to use branches, but it needs to do this on all sides to work (consumer and provider). You also need to check what version of the Pact Broker you are running.

The other thing is to add debug logs, change some values and see what requests are being made to your Pact Broker and what it is responding with. For instance, try removing consumer="ev_article" and check the logs. The Pact Broker knows who the consumers of your provider are, there is no need to tell it.

@GinjuCosmin
Copy link
Author

GinjuCosmin commented Dec 16, 2024

Indeed, that was the reason, the old pact broker instance that wasn't maintained at all and no one knew about it. We just created an up to date pact broker instance. I will close this issue. And thanks for your suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants