Hi team :wave: , I have been tasked by my company ...
# pactflow
l
Hi team 👋 , I have been tasked by my company to analyze and Introduce Pact contract testing to our workflows. We have some Questions in regards to Bi-directional Contract testing for Spring Boot Microservices. We have already set up a Consumer driven POC using below tools and Java JUnit tests. • Pact broker used with docker - https://github.com/pact-foundation/pact-broker-docker • Pact CLI tool - https://github.com/pact-foundation/pact_broker-client - (Download standalone source code as zip from https://github.com/pact-foundation/pact_broker-client/releases/tag/v1.65.0 ) 1. Considering that I didn't face any issues exercising the paid features mentioned here https://pactflow.io/pricing/ with an exception for SAMl integration, in the free versions above, why would I need the paid version? 2. How can I ensure that none of our developers are able to game the system somehow as we see some room for it? My particular question is that if Provider decides to write the pacts when consumer is not ready, How do I ensure that
can-i-deploy
is accurately telling me that both consumer and provider are in sync if I never ran the consumer test yet? 3. Continuation from point 2, Do I have to run both consumer and provider tests if consumer pact was developed after the provider test in order to release the consumer?(I think so but just wanted to confirm if there is a different approach or not) I may have more questions, which I can bring up as they brew. Could you please let me know if this is the right forum to bring these questions up, or if I should bring them up elsewhere.
đź‘‹ 1
m
Considering that I didn’t face any issues exercising the paid features mentioned here https://pactflow.io/pricing/ with an exception for SAMl integration, in the free versions above, why would I need the paid version?
If you want to use the bi-directional feature, this is only available in Pactflow. Is this your intent? We have features other than SAML in Pactflow, which you can see here. You can also see our public roadmap to see if what we’re working on is going to be useful to you.
How can I ensure that none of our developers are able to game the system somehow as we see some room for it? My particular question is that if Provider decides to write the pacts when consumer is not ready, How do I ensure that
can-i-deploy
is accurately telling me that both consumer and provider are in sync if I never ran the consumer test yet?
What do you mean by “provider writes the pacts”? Do you mean publishing their provider contract (an OAS) that is invalid?
Continuation from point 2, Do I have to run both consumer and provider tests if consumer pact was developed after the provider test in order to release the consumer?(I think so but just wanted to confirm if there is a different approach or not)
In the cases of BDCT no (because the OAS is not changing, getting the provider to re-publish the same OAS doesn’t give us any new information). With the Pact model, yes, because the provider must verify each contract individually
Could you please let me know if this is the right forum to bring these questions up, or if I should bring them up elsewhere
You’re in the right place 🙂
l
Hi @Matt (pactflow.io / pact-js / pact-go), I apologize for the delayed response. Yes I was looking for bi-directional feature.
https://pact-foundation.slack.com/archives/CLS16AVEE/p1660007379263709?thread_ts=1659998145.922109&cid=CLS16AVEE - If I only validate the consumer pact to OAS in BDCT, how would verification results be published to pact broker and how does
can-i-deploy
fit into this? This page isnt very clear about that. I conceptually understand the diagram but practically, I am making assumptions that I am not 100 percent sure of.
Consumer based contract test is quite straight forward, but If I wanted to have a Provider based contract test where provider code is developed first, this is the workflow I see happening without use of Swagger hub; 1. Provider creates the contract if provider is ready first or is in earlier development.(This is done first time or only when consumer is not ready or needs a change as a result of a broken contract) 2. Provider publishes the contract to broker.(This is done first time or only when consumer is not ready or needs a change as a result of a broken contract) 3. Provider validates the contract against its own open api spec json file generated during Integration tests(If executed before contract tests) or contract test generates it itself as a before test hook. - I almost have a working example for this with
swagger-mock-validater
. 4. Provider runs provider tests and publishes passing results to broker. - At this point Provider doesnt care about an actual consumer because there is none. 5. Provider publishes the open api spec json to artifactory. 6. Provider runs
can-i-deploy
pact CLI command to verify if provider is ready for release against the pact-broker. 7. Provider can release if step 1 to 6 are passing. 8. Consumer development begins and consumer writes a consumer contract. 9. Consumer retrieves the published provider open-api spec json from artifactory to validate pact against it using same tool as step 3. 10. Consumer publishes the contract to broker. 11. Consumer triggers the provider tests by cloning the provider repo with latest version specified in
gitops-version
and actually runs the provider tests to publish the verification results to pact broker.(May not be needed since a comparison with OAS is sufficient - Confirming with Pact team) 12. Consumer runs
can-i-deploy
to verify if consumer is ready for release. (May not be needed since a comparison with OAS is sufficient - Confirming with Pact team) 13. Consumer can release if steps 8-12 passed. 14. A month later, provider changes its code, breaking the contract but does not know it yet. 15. Provider repeats steps 3-6 to verify that its not breaking the contract with the consumer(This time it does care about consumer because a released or an active version of the consumer exists). 16. Provider fails on the repeated step 4 as the tests will fail because code was modified in step 14. 17. Teams coordinate the failure and decide if the fix needs to be on provider or consumer side. 18. If provider makes the fix, then contract is reverted to original content and steps 3-6 are repeated. If consumer has to fix, Then steps 1-12 are repeated and both provider and consumer are released together to ensure accurate interface in production.
m
Consumer triggers the provider tests by cloning the provider repo with latest version specified in
gitops-version
and actually runs the provider tests to publish the verification results to pact broker.(May not be needed since a comparison with OAS is sufficient - Confirming with Pact team)
Exactly. The OAS is the only information we need to ensure the consumer contract is compatible with the Provider contract - this is why you don’t need to trigger a provider build when a new consumer contract is published. Triggering a provider build is just going to result in the same OAS being published.
1. Consumer runs
can-i-deploy
to verify if consumer is ready for release. (May not be needed since a comparison with OAS is sufficient - Confirming with Pact team)
both provider and consumer should always run that command prior to deployment
Teams coordinate the failure and decide if the fix needs to be on provider or consumer side.
Yes, that too. Ideally, the provider uses an expand and contract pattern, and never breaks a consumer. But of course we live in the real world, and sometimes that’s not possible
l
Thank you Matt for the information. I will relay it to my team
👍 1
@Matt (pactflow.io / pact-js / pact-go) I needed some help with BDCT with pactflow. I wanted to check with you how contracts appear instead of pacts
Would you or someone from the team be able to meet with me for 15 to 30 mins?
m
I'm not sure I follow the question, what are you asking? How provider contracts are displayed?
l
I mean to ask if there is any practical documentation on bi-directional flow. Like api calls i need to make to upload open api spec and provider contract to pactflow
Actually, I will spend some time today to get it working. If I stumble upon any outstanding questions, I will reach out. Thanks Matt!
@Matt (pactflow.io / pact-js / pact-go) I got bidirectional flow started for two of our services in pactflow. We are a large organization with lots of micro-services so we will likely be headed towards the enterprise or paid version. I got the OAS uploaded from provider side and also see it in correct format in pactflow ui. But when I upload the consumer pact, I see this error.
It's only telling me about a validation failure. I don't see any obvious issues in the open api spec on the pactflow ui
m
If you could please DM the OAS to me we can take a look