Consumer-Driven Contracts with Pact (Sydney API Days 2015)

79.658 visualizações

Publicada em

Microservices are all the rage right now. Breaking up code into small independent services has many
benefits, but on the downside, it increases the number of integration points, which increases the amount of
integration testing required.
How can we be confident that all our services will work correctly together, without being burdened by
complex and brittle integration tests? Learn how Pact solves this problem by using consumer driven
contracts.

Publicada em: Tecnologia
0 comentários
7 gostaram
Estatísticas
Notas
  • Seja o primeiro a comentar

Sem downloads
Visualizações
Visualizações totais
79.658
No SlideShare
0
A partir de incorporações
0
Número de incorporações
72.562
Ações
Compartilhamentos
0
Downloads
111
Comentários
0
Gostaram
7
Incorporações 0
Nenhuma incorporação

Nenhuma nota no slide

Consumer-Driven Contracts with Pact (Sydney API Days 2015)

  1. 1. Pacts to the rescue! Making your microservices play nicely together with Consumer Driven Contracts Beth Skurrie @bethesque / @pact_up bskurrie@dius.com.au
  2. 2. “Integrated tests are a scam. A self replicating virus that threatens the very health of your codebase, your sanity, and I'm not exaggerating when I say, your life.” - JB Rainsberger
  3. 3. Integrated Tests: The Problems ! Slow ! Easy to break ! Hard to fix ! Scales combinatorially 3 classes, 4 code paths each 4 * 4 * 4 = 64 tests
  4. 4. A B mock Test Symmetry… how it works
  5. 5. Test 1 Test 2 Test 3 Integrated tests
  6. 6. ! Lack of automated tools ! Relies on developer eternal vigilance ! Does not scale Test Symmetry: The Problem
  7. 7. Do we have the technology to achieve test symmetry? Posed to DiUS
  8. 8. Slower Easier to break Harder to fix Scales BADLY Lots of infrastructure False negativesLots of set up System Integration Tests
  9. 9. Pact to the rescue!!!
  10. 10. A B mock C P pact Pact… how it works
  11. 11. Slower Easier to break Harder to fix Scales BADLY Lots of infrastructure False negativesLots of set up System Integration Tests
  12. 12. Fast Stable Easy to debug Reliable No extra infrastructure Low setupScales linearly Pact
  13. 13. Better API design!
  14. 14. Arrange - set up mock server
  15. 15. Arrange - set up mock server
  16. 16. Arrange - set up mock server
  17. 17. Arrange - set up expectations
  18. 18. Arrange - set up expectations
  19. 19. Arrange - set up expectations
  20. 20. Act and Assert
  21. 21. Act and Assert
  22. 22. Act and Assert
  23. 23. Act and Assert
  24. 24. Act and Assert
  25. 25. Set up test data Consumer assumed: Provider complies:
  26. 26. Set up test data Consumer assumed: Provider complies:
  27. 27. Verify: Fail
  28. 28. Verify: Success!
  29. 29. Postel’s law
  30. 30. Sharing pacts
  31. 31. P publish pact latest pact C Pact Broker Pact Broker - Share pacts
  32. 32. Pact Broker - Autogenerated documentation
  33. 33. Pact Broker - Network graph
  34. 34. Support ! JSON is language independent ! Ruby ! JVM (Java and Scala) ! .net ! Javascript (consumer side, provider side WIP) ! Pact specification
  35. 35. “How is it working for you?”
  36. 36. Fast feedback in isolation + Early detection + Rapid recovery
  37. 37. Pact allows you to: ! Combine the advantages of integrated tests and test symmetry ! Mitigates the shortcomings of each method ! Allows you to modify components with agility - quick feedback on potential breakages ! Have confidence that all the services in your system will work together ! Throw away your integration tests!!!
  38. 38. Pact Makes your microservices play nicely together with Consumer Driven Contracts github.com/realestate-com-au/pact @pact_up Beth Skurrie bskurrie@dius.com.au @bethesque • Regular expressions & type based matching • Why doesn’t Pact use JSON Schema? • How to avoid versioning APIs • How to use Pact between teams • Should I use Pact for testing external APIs? • How not to do it • And moar!

×