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

Pact consumer-driven contract testing extension #27729

Closed
holly-cummins opened this issue Sep 5, 2022 · 10 comments · Fixed by quarkiverse/quarkiverse-devops#95
Closed

Pact consumer-driven contract testing extension #27729

holly-cummins opened this issue Sep 5, 2022 · 10 comments · Fixed by quarkiverse/quarkiverse-devops#95
Labels

Comments

@holly-cummins
Copy link
Contributor

holly-cummins commented Sep 5, 2022

Description

Pact is a widely-recommended framework for consumer-driven contract testing. Because Quarkus is optimised for microservices and consumer-driven contract tests are an important part of a microservices development workflow, Pact is particularly relevant for Quarkus.

Why is an extension needed? Functional issues

Although it is possible to use Pact with Quarkus (see https://github.com/skattela/pact-workshop-jvm-quarkus and https://github.com/holly-cummins/house-of-microservices-quarkus-contract-testing-sample), Pact tests do not work in continuous testing mode.

  • Pact relies on Kotlin and is affected by classloading issues. See, for example, a reference to Pact problems on a broader issue about Kotlin classloading. The Pact issues need a bigger fix than just including the quarkus-kotlin extension.
  • Pact tests also have problems if they store contracts in a local resources folder.

Usability enhancements

Although fixing the functional issues is most important, there are also a range of enhancements that could improve the Pact user experience:

  • Eliminating the need to @BeforeEach a context.setTarget(new HttpTestTarget("localhost", 8081)) on every test
  • Quarkus-style configuration of pact location and broker
  • Dev UI view of contract contents and status
  • Potentially, integration with other frameworks such as RestAssured, WireMock and OpenAPI. This is a complex area with existing activity and a number of existing converters.

Interested in this extension, please +1 via the emoji/reaction feature of GitHub (top right).

Configuration suggestion

pact.rootDir: # [existing system property, where to write generated pacts]
pact.writer.overwrite: # [existing system property, whether to overwrite generated pacts]
pact.readFrom: # [new property, universal config for pact location to eliminate need for per-test config, see https://docs.pact.io/implementation_guides/jvm/provider/junit#pact-source]

Additional context

This has been requested up occasionally in the broader community.

There was a long discussion on the google groups a year ago.

See also, for example, https://lightrun.com/answers/quarkusio-quarkus-consumer-driven-contracts-integrationsupport: "CDC is a big part of our Spring Boot microservice qa process, and it would be very desirable to have an equivalent in quarkus."

Note also that Pact is not the only contract testing option; Spring has Spring contract, although it is not as polyglot as Pact. It is also possible to use tools such as Schemathesis, Prism, and OpenAPI in combination (see a tutorial here).

@holly-cummins holly-cummins added the kind/extension-proposal Discuss and Propose new extensions label Sep 5, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 5, 2022

/cc @evanchooly, @geoand

@holly-cummins
Copy link
Contributor Author

I've got a prototype extension written which fixes the classloading issues, before anyone rushes off to try and fix. :)

@gsmet
Copy link
Member

gsmet commented Sep 5, 2022

It would be hosted in the Quarkiverse, right?

@holly-cummins
Copy link
Contributor Author

It would be hosted in the Quarkiverse, right?

That's my intention.

@holly-cummins
Copy link
Contributor Author

This should also have the "area/testing" label.

@holly-cummins
Copy link
Contributor Author

See also #6276, which is arguably a duplicate of this but which I missed in my searches (and this one has the extension-proposal issue type).

@holly-cummins
Copy link
Contributor Author

It might also be possible to address #22611 with an extension but that would need a lot of thought.

@holly-cummins
Copy link
Contributor Author

Could you do the repository-making, @gastaldi? :) Unless there are any objections?

@gastaldi
Copy link
Contributor

gastaldi commented Sep 23, 2022

@holly-cummins only if you don't mind waiting for me to return from my PTO on October😛

Could you create a PR in the quarkiverse-devops repo according to https://github.com/quarkiverse/quarkiverse-devops#workflow-for-new-repositories?

Here is an example: quarkiverse/quarkiverse-devops#91

@holly-cummins
Copy link
Contributor Author

https://github.com/quarkiverse/quarkus-pact/ is the new home of the extension.

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

Successfully merging a pull request may close this issue.

4 participants