Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Confidently Releasing Microservices With Consumer Driven Contracts

Confidently Releasing Microservices With Consumer Driven Contracts

Many teams working with microservices need confidence they don't break functionality when making changes. System integration tests, functional tests, and sometimes manual tests are older ways to obtain that confidence. These processes may take more than 1 day or even more if different teams or a different company own the services.

To ensure the same level of confidence and speed up delivery, we can create Contracts for integrations between consumers and providers. Contracts created by consumer services need to pass with every build going in production to guarantee the integrations between systems/services work fine. Checking these contracts in a CI/CD pipeline makes feedback loops even faster.

A Contract is a collection of agreements between a Consumer and a Provider that describes the interactions that can take place between them. Consumer Driven Contracts (CDCs) is a pattern that drives the development of the Providers from its Consumer's point of view. It is TDD for microservices.

This talk covers an end to end demo of contract testing between two microservices to show how to release microservices with confidence, get early feedback, speed up delivery, and comparison with other testing strategies.

E77ef1c6601bcfe1cd6a568490eef974?s=128

Gopinath Langote

March 22, 2019
Tweet

Transcript

  1. GopinathLangote Confidently Releasing Microservices With Consumer Driven Contracts Software Engineer

  2. Confidently Releasing Microservices With Consumer Driven Contracts

  3. Confidently Releasing Microservices With Consumer Driven Contracts

  4. Confidently Releasing Microservices With Consumer Driven Contracts

  5. Confidently Releasing Microservices With Consumer Driven Contracts Client / Consumer

    Server / Provider
  6. Confidently Releasing Microservices With Consumer Driven Contracts

  7. Payments Team Growth Team Problem Statement

  8. Refactoring

  9. Unit Tests Mocked Integration Tests Functional Tests Manual Tests Test

    Pyramid
  10. Unit Test Limited to method level Not aware of other

    service Trustworthy
  11. Mocked Integration Test

  12. Mocked User Service Not aware of other service Changes No

    Feedback Loop Trustworthy Mocked Integration Test
  13. Real User Service Time Consuming Longer Feedback Loop Trustworthy Functional

    Test
  14. Manual Test

  15. Unit Tests Contract Test Functional Manual Tests Test Pyramid

  16. Account Service Consumer Service Contract Test User Service Producer Service

    Payments Team Growth Team
  17. Consumer Contract Test Register expectation Request Account Service User Service

    Mock Contract Server TEST Response Contract File
  18. User Service Get the contracts Assert the expectations from consumer

    Consumer Provider Mock Contract Server Account Service Provider Verification
  19. Initialize Mock Server

  20. Setup Expectations

  21. Running Test

  22. Demo Consumer Contract Test

  23. Get the contracts Assert the expectations from consumer Provider Service

    Provider Verification
  24. Provider Verification

  25. Demo Provider Verification

  26. Provider State

  27. Setup Provider State

  28. CDC In Action

  29. Test As Part Of Source Code Separate Contract Test Code

    Consumer Test
  30. Cloud Storage Contract Brokers Contract Sharing

  31. Contract Verification Test External tools Provider Verification

  32. Against Current Build Provider Verification In CI Against Stable Build

  33. Tools

  34. 1. JVM 2. .Net 3. Ruby 4. Go 5. JavaScript

    6. Python 7. Php 8. Swift You can implement you own https://pact.io Pact
  35. Other Tool janus VCR PACTO

  36. Convince Me https://docs.pact.io/faq/convinceme

  37. Resources https://github.com/gopinath-langote/Pact-JVM-Implementation https://pact.io https://martinfowler.com/articles/microservice-testing/ https://www.martinfowler.com/articles/consumerDrivenContracts.html

  38. Questions?

  39. Thank You GopinathLangote