Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Consumer-driven contracts: avoid microservices integration hell! (LondonCD - Oct 2016)

1,057 views

Published on

Talk from Oct 11th 2016 at LondonCD (https://www.meetup.com/London-Continuous-Delivery)

Autonomy and isolation are some of the core values of microservices, allowing for independent changes and independent deployments. As loosely coupled services interact on interfaces managed under different life-cycles and even different teams, making sure that a simple change did not break the application can turn into an integration nightmare.

Consumer-Driven Contracts testing brings an alternative integration testing approach for distributed systems, relying less on live-like integration environments and more on making interactions explicit and quickly verifiable.

This talk cover how Newsweaver (https://www.newsweaver.com/email-overview) has made CDCs part of its pipeline with Pact and how it improved collaboration and confidence between teams when designing APIs.

Published in: Technology
  • Be the first to comment

Consumer-driven contracts: avoid microservices integration hell! (LondonCD - Oct 2016)

  1. 1. Consumer-driven contracts Avoid microservices integration hell! @PierreVincent Oct 11th, 2016
  2. 2. Pierre Vincent Technical Team Lead at Newsweaver techblog.newsweaver.com @PierreVincent
  3. 3. From this... … to this.
  4. 4. Login Service User Service API GET /users/pierre { "user": "pierre", "name": "Pierre Vincent", "role": "publisher" } 200 OK How do we test this?
  5. 5. Running in Prod Tests Pass in Build Implement changes Deployed in Prod User Service Login Service ! ✓ ✓ ✓ ✓ ✓ { ... "role": "editor" } { ... "roles": ["publisher","editor"] } Running in Prod ✓ ✓
  6. 6. Maybe we should have tested before deploying to production…? Tested what though?
  7. 7. Users Service Login Service IP Check Service Token Gen Service Cert/Key Service Login Frontend We only wanted to test this bit!
  8. 8. Contract Login Service User Service API Authentication Team Users Team
  9. 9. [docs.pact.io] PACT Specification Verification philosophy: Tolerant Reader Implementation guidelines Implementations
  10. 10. Login Service User Service A P I Pact Mock Server Authentication Team Users Team Pact Consumer Unit Test Define interaction Trigger interaction Generate Pact Pact Provider Test Share Pact Replay interaction Replay & Verify Play & Record
  11. 11. Consumer Provider Assumption Request Expected Response Login Service User Service Given that user 'pierre' exists Method GET Path /users/pierre Headers Accept: application/json Status 200 Headers Content-Type: application/json Body { "user": "pierre", "name": "Pierre Vincent", "role": "publisher" } Interaction
  12. 12. Authentication Dev Team Users Dev Team CMS Dev Team Billing Dev Team Pact Broker PACT PACT PACT PACT PACT PACT PACTPACT PACT PACT
  13. 13. Pact Broker Dependency Graphs Living documentation by example ✓ Versioning ✓ Tagging ✓ REST Api Build/Deployment Pipeline integration
  14. 14. Provider pipeline Implement changes Get Pacts from Broker Replay & Verify Interactions Deploy Service Build Deploy to EU PROD-EU Get Pacts from Broker Replay & Verify Interactions Stop deployment of incompatible Provider Stop introduction of breaking change PROD-US PROD-EU
  15. 15. Consumer pipeline Implement changes Generate Pacts (Build) Push Pacts to Broker Tag Pacts Each Provider verifies Pacts Deploy Service Tag Pacts Build Deploy to EU HEAD Stop deployment of incompatible Consumer HEAD PROD-EU
  16. 16. Caution: side-effects may include teams collaborating on API design
  17. 17. Provider state setup for each interaction Confidence comes from coverage: don’t limit to happy paths Automation within deployment pipeline isn’t trivial What’s the catch…?
  18. 18. After 2 years of CDCs... Increased confidence when coding & deploying ✓ Collaborative API design ✓ Living API documentation ✓
  19. 19. Pact docs.pact.io, github.com/pact-foundation Pact Broker github.com/bethesque/pact_broker Try it out! “Pact Matrix” (Beth Skurrie) rea.tech/enter-the-pact-matrix-or-how-to-decouple-the-release- cycles-of-your-microservices Why should you use CDC for microservices integration tests techblog.newsweaver.com/why-should-you-use-consumer-driven-contracts-for-microservices- integration-tests Sharing CDCs with Pact Broker techblog.newsweaver.com/sharing-consumer-driven-contracts-with-pact-broker More reading...
  20. 20. techblog.newsweaver.com Questions? @PierreVincent

×