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

Uh, Does This Thing Actually Work? Modern Microservices Testing

Uh, Does This Thing Actually Work? Modern Microservices Testing

To realise the promise of microservices, individual services must be independently deployable, and they should be deployed often. But that’s easier said than done. Releases take confidence. How does a business achieve enough confidence to release often without getting bogged down in manual QA bottlenecks? Is automating tests too expensive? How do services know if they’ve made a breaking change? If the individual microservices all work, does that mean the system works? This talk discuss microservices testing strategies and explore some of the modern tools which make testing easier and better. And there’s a demo: Holly will show Pact contract testing, test containers, and Quarkus’s continuous testing and dev services support.

Holly Cummins

August 31, 2022
Tweet

More Decks by Holly Cummins

Other Decks in Programming

Transcript

  1. disclaimer: I am not a tester … or even a

    test specialist. but that’s ok! testing is every developer’s job.
  2. #Quarkus @holly_cummins Netflix microservice architecture “microservices makes testing easy! the

    thing I have to test is so small!” if you only test the points, and not the lines … does the thing work?
  3. @holly_cummins #RedHat tools evolve end-to-end tests unit tests integration tests

    low effort high realism tests with application server
  4. @holly_cummins #RedHat tools evolve end-to-end tests unit tests integration tests

    low effort high realism tests with application server test REST endpoints
  5. @holly_cummins #RedHat tools evolve end-to-end tests unit tests integration tests

    low effort high realism tests with application server test REST endpoints
  6. @holly_cummins #RedHat “why have I spent half a day writing

    mocks just so I can write a unit test?” the limitations of unit tests
  7. @holly_cummins #RedHat the limitations of unit tests “why do my

    colleagues tell me my code is broken, even though my unit tests all pass?”
  8. @holly_cummins #RedHat our code our mock our code their actual

    code tests ✔ why mocks aren’t enough
  9. @holly_cummins #RedHat our code our mock our code their actual

    code tests ✔ reality ✘ why mocks aren’t enough
  10. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers all code that serialises or deserialises data
  11. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls all code that serialises or deserialises data
  12. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls queues ETL all code that serialises or deserialises data
  13. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls filesystem config, etc queues ETL all code that serialises or deserialises data
  14. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services other services filesystem config, etc queues ETL all code that serialises or deserialises data
  15. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services filesystem config, etc queues ETL all code that serialises or deserialises data
  16. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services filesystem config, etc queues ETL all code that serialises or deserialises data
  17. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services filesystem config, etc queues ETL all code that serialises or deserialises data
  18. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services filesystem config, etc queues ETL all code that serialises or deserialises data
  19. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services filesystem config, etc queues ETL all code that serialises or deserialises data
  20. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services filesystem config, etc queues ETL all code that serialises or deserialises data
  21. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services filesystem config, etc queues ETL all code that serialises or deserialises data
  22. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services filesystem config, etc queues ETL all code that serialises or deserialises data
  23. @holly_cummins #RedHat what needs integration tests? our service rest api

    usage by consumers db calls external applications colleague’s services filesystem config, etc queues ETL all code that serialises or deserialises data
  24. @holly_cummins #RedHat “why do I keep getting failures in production

    even though everything looked fine in staging?” Photo by Eggs&Beer, Flickr
  25. @holly_cummins #RedHat staging staging ✔ why staging is not enough

    our service other services other services other services other services
  26. @holly_cummins #RedHat staging staging ✔ production ✘ why staging is

    not enough our service other services other services other services other services our service production other services other services other services other services
  27. @holly_cummins #RedHat the test trophy end-to-end tests unit tests integration

    tests low effort high realism testing in production
  28. @holly_cummins #RedHat the test trophy end-to-end tests unit tests integration

    tests low effort high realism static tests testing in production
  29. @holly_cummins #RedHat a waste winning confidence effort quality expense hard

    work, but valuable cheap and cheerful unit tests integration tests
  30. @holly_cummins #RedHat a waste winning confidence effort quality expense hard

    work, but valuable cheap and cheerful unit tests integration tests e2e tests
  31. @holly_cummins #RedHat a waste confidence effort quality expense hard work,

    but valuable cheap and cheerful unit tests integration tests e2e tests static tests
  32. @holly_cummins #RedHat a waste confidence effort quality expense hard work,

    but valuable cheap and cheerful unit tests integration tests e2e tests testing in production static tests
  33. @holly_cummins #RedHat a waste confidence effort quality expense hard work,

    but valuable cheap and cheerful unit tests integration tests e2e tests testing in production static tests YMMV
  34. @holly_cummins #RedHat a waste confidence effort quality expense hard work,

    but valuable cheap and cheerful unit tests integration tests e2e tests testing in production static tests YMMV
  35. @holly_cummins #RedHat a waste confidence effort quality expense hard work,

    but valuable cheap and cheerful unit tests integration tests e2e tests testing in production static tests YMMV
  36. @holly_cummins #RedHat a waste confidence effort quality expense hard work,

    but valuable cheap and cheerful unit tests integration tests e2e tests testing in production static tests YMMV
  37. @holly_cummins #RedHat a waste confidence effort quality expense hard work,

    but valuable cheap and cheerful unit tests integration tests e2e tests testing in production static tests
  38. @holly_cummins #RedHat a waste confidence effort quality expense hard work,

    but valuable cheap and cheerful unit tests integration tests e2e tests testing in production static tests constantly question the value of your tests
  39. @holly_cummins #RedHat confidence effort unit tests integration tests e2e tests

    testing in production static tests all integration tests are not created equal
  40. @holly_cummins #RedHat confidence effort unit tests integration tests e2e tests

    testing in production static tests integration tests all integration tests are not created equal
  41. @holly_cummins #RedHat confidence effort unit tests integration tests e2e tests

    testing in production static tests integration tests all integration tests are not created equal integration tests
  42. @holly_cummins #RedHat confidence effort unit tests integration tests e2e tests

    testing in production static tests integration tests all integration tests are not created equal integration tests integration tests
  43. @holly_cummins #RedHat confidence effort unit tests integration tests e2e tests

    testing in production static tests integration tests all integration tests are not created equal integration tests integration tests integration tests
  44. @holly_cummins #RedHat confidence effort unit tests integration tests e2e tests

    testing in production static tests all integration tests are not created equal integration tests contract tests integration tests integration tests
  45. @holly_cummins #RedHat confidence effort unit tests integration tests e2e tests

    testing in production static tests all integration tests are not created equal contract tests sandbox tests integration tests integration tests
  46. @holly_cummins #RedHat confidence effort unit tests integration tests e2e tests

    testing in production static tests all integration tests are not created equal contract tests sandbox tests testcontainers tests integration tests
  47. @holly_cummins #RedHat approaches to integration tests our service rest api

    external applications filesystem colleague’s services colleague’s services colleague’s services external applications
  48. @holly_cummins #RedHat approaches to integration tests our service rest api

    external applications filesystem colleague’s services colleague’s services colleague’s services external applications mock all the things
  49. @holly_cummins #RedHat “why have I spent half a day writing

    mocks just so I can write a cleanly-scoped integration test?”
  50. @holly_cummins #RedHat approaches to integration tests our service rest api

    db calls external applications filesystem config, etc queues ETL colleague’s services colleague’s services colleague’s services external applications
  51. @holly_cummins #RedHat approaches to integration tests our service rest api

    db calls external applications filesystem config, etc queues ETL colleague’s services colleague’s services colleague’s services external applications
  52. @holly_cummins #RedHat approaches to integration tests our service rest api

    db calls external applications filesystem config, etc queues ETL colleague’s services colleague’s services colleague’s services external applications containerise all the things
  53. @holly_cummins #RedHat approaches to integration tests our service rest api

    db calls external applications filesystem config, etc queues ETL colleague’s services colleague’s services colleague’s services external applications containerise all the things
  54. @holly_cummins #RedHat “I can’t bring up my dev stack …

    on my brand new Apple laptop with a M1 chip and 64GB of RAM.” - fintech developer
  55. @holly_cummins #RedHat “I can’t bring up my dev stack …

    on my brand new Apple laptop with a M1 chip and 64GB of RAM.” digression: if this is you • maybe testing is only part of your problem • … and Quarkus could help :) - fintech developer
  56. @holly_cummins #RedHat “I have to do all this shell scripting

    and manual process and orchestration before I can write a test or do development.”
  57. @holly_cummins #RedHat approaches to integration tests our service rest api

    external applications filesystem colleague’s services colleague’s services colleague’s services external applications remote sandbox remote system + remote deploy
  58. @holly_cummins #RedHat approaches to integration tests our service rest api

    external applications filesystem colleague’s services colleague’s services colleague’s services external applications remote system with telepresence
  59. @holly_cummins #RedHat approaches to integration tests our service rest api

    external applications filesystem colleague’s services colleague’s services colleague’s services external applications remocal sandbox remote system with telepresence
  60. @holly_cummins #RedHat approaches to integration tests our service rest api

    external applications filesystem colleague’s services colleague’s services colleague’s services external applications remocal sandbox remote system with telepresence
  61. @holly_cummins #RedHat approaches to integration tests our service rest api

    external applications filesystem colleague’s services colleague’s services colleague’s services external applications shared remocal sandbox remote system with telepresence and per-request isolation
  62. @holly_cummins #RedHat pitfalls: • it all works great – until

    a test changes some state, eg • writing to a db • adding a user to a security provider • getting IP whitelists when running locally is tricky
  63. @holly_cummins #RedHat approaches to integration tests our service rest api

    db calls external applications filesystem config, etc queues ETL colleague’s services colleague’s services colleague’s services external applications
  64. @holly_cummins #RedHat approaches to integration tests our service rest api

    db calls external applications filesystem config, etc queues ETL colleague’s services colleague’s services colleague’s services external applications
  65. @holly_cummins #RedHat approaches to integration tests our service rest api

    db calls external applications filesystem config, etc queues ETL colleague’s services colleague’s services colleague’s services external applications testcontainers
  66. @holly_cummins #RedHat approaches to integration tests our service rest api

    db calls external applications filesystem config, etc queues ETL colleague’s services colleague’s services colleague’s services external applications testcontainers
  67. @holly_cummins #RedHat approaches to integration tests our service rest api

    external applications filesystem colleague’s services colleague’s services colleague’s services external applications
  68. @holly_cummins #RedHat approaches to integration tests our service rest api

    external applications filesystem colleague’s services colleague’s services colleague’s services external applications contract test (for services who will talk to you)
  69. @holly_cummins #RedHat our code our mock our code their actual

    code tests ✔ why mocks aren’t enough
  70. @holly_cummins #RedHat our code our mock our code their actual

    code tests ✔ reality ✘ why mocks aren’t enough
  71. @holly_cummins #RedHat our code their code contract test mock functional

    test our tests ✔ their tests ✔ reality ✔ why mocks aren’t enough
  72. @holly_cummins #RedHat our code their code contract test mock functional

    test our tests ✔ their tests ✘ reality ✘ why mocks aren’t enough
  73. @holly_cummins #RedHat our code their code contract test mock functional

    test our tests ✘ their tests ✔ reality ✘ why mocks aren’t enough
  74. #RedHat @holly_cummins demo recap: • consumer-driven contract testing can save

    your bacon • pact is a mock for the consumer • pact is a functional test for the producer • shared json contracts aligns expectations across services
  75. @holly_cummins #RedHat pitfalls of contract testing: • we have to

    talk to the other team • our consumers can break our CI?! • versions • pact is hard to grok • testing the mock • but I’ve invested in wiremock • duplicated tests is overhead
  76. @holly_cummins #RedHat contract testing options: • pact.io • spring contract

    • OpenAPI schema validation + mock generation • prism • schemathesis
  77. @holly_cummins #RedHat confidence effort integration testing landscape mock all the

    services testcontainers remote sandbox remocal sandbox contract tests local orchestration