How to test microservices and stay sane

How to test microservices and stay sane

Microservices shine in many aspects, but testability. Whenever you deploy a service, no matter how small it is, as long as it has dependencies, you have to keep them in mind. By definition, microservices have lots of dependencies and makes you appreciate how easy it is to test integration in a monolithic code base. There is a concept of contract testing that makes testing microservices a breeze. In the presentation, it's shown on an example of Pact, an open source library with adapters for many popular languages.

D61dc9b919be0bfb6d956bf7a6ee7292?s=128

Tatiana Shepeleva

June 02, 2019
Tweet

Transcript

  1. How to test microservices and stay sane Tatiana Shepeleva @

    Toptal
  2. !2 toptal.com

  3. What are microservices?

  4. What are microservices?

  5. What are microservices? • “Lightweight” API • Independently releasable •

    Have separate test suites
  6. What are microservices? • “Lightweight” API • Independently releasable •

    Have separate test suites (but really?)
  7. How to know if you can deploy?

  8. Bored meme!

  9. None
  10. Super end-to-end tests

  11. None
  12. None
  13. None
  14. None
  15. Cons • Expensive and complex infrastructure • Time consuming •

    Flaky
  16. Contract tests

  17. What is contract?

  18. None
  19. None
  20. None
  21. B has changed and you have end-to-end tests

  22. B has changed and you have contract tests

  23. Cons • Expensive and complex infrastructure ✅ • Time consuming

    ✅ • Flaky ✅
  24. Also catch • Inconsistency in API • Typos

  25. It’s not a silver bullet tho

  26. docs.pact.io

  27. Pact • Support different languages (Ruby, JS, Go, PHP, Python,

    JVM) • Framework-agnostic • Language-agnostic contract (JSON)
  28. Storage for contracts • Your CI • Your codebase (projects)

    • Pact Broker
  29. Pact Broker • Docker image is ready • Webhooks to

    trigger checks or notifications • can-i-deploy tool
  30. Pact Broker PactBroker PactFlow

  31. None
  32. None
  33. None
  34. None
  35. None
  36. None
  37. None
  38. The end Tatiana Shepeleva tati.engineer