Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Testing Java Microservices:
From Development to Production
Abraham Marin-Perez | Daniel Bryant
tl;dr
● Testing microservices brings additional challenges
● Pay special attention to integration surfaces
● Isolate servi...
Who are we?
@danielbryantuk
Tech Consultant and Writer
Product Architect at Datawire
Java Champion
Conference Tourist
@abr...
Types of tests
From Agile Testing, by Lisa Crispin and Janet Gregory
Challenges
● Cannot share a single environment: test locally
● Full ecosystem unsuitable for local testing
● Lack of contr...
Isolation
Isolating Parts
Third Party
Isolating Parts
Third Party
Isolating Parts: No Isolation
Third Party
Isolating Parts: Unowned Components
Third Party
Test Doubles
Test Doubles
Dummy objects: passed around but never actually used.
Fake objects: working implementations not suitable for ...
JUnit Example
API Simulation Thoughts
● Useful when a dependency is “expensive” to
access or tricky to mock
● Facilitates error handling...
Use simulations appropriately...
Sometime you need the real thing
Isolating Parts: Service Interaction
Third Party
Focused on
service/function
Focused on
system
Contract Tests
API Contracts
APIs are service contracts
Many are producer-driven
It’s possible to design outside-in:
Consumer-Driven Cont...
Consumer-Driven Contracts
Consumer-Driven Contract Frameworks
https://docs.pact.io/ https://cloud.spring.io/spring-cloud-contract/
Consumer-Driven Contract Thoughts
● Great in low trust or low communication organisations
○ Act as a cue for a conversatio...
https://bit.ly/2p68gBS
Components
Isolating Parts: Single Service
Third Party
Isolating Parts: Single Service
Isolating Parts: Single Service
Test
Doubles
Isolating Parts: Single Service
Isolating Parts: Single Service
+
Isolating Parts: Single Service
Fault Tolerance
Test double configured to fail
https://technology.cap-hpi.com/blog/unit-testing-what-benefits-you-can-reap/
Isolating Parts: Technicalities
Third Party
Isolating Parts: Technicalities
Test the Real Thing
Isolating Parts: Technicalities
Isolating Parts: Data
Test Data
● Low Volume
● Low Diversity
Production Data
● High Volume
● High Diversity
Isolating Parts: Data
Isolating Parts: Data
Marín
Argüelles
d’Hopital
Garçon
Castaña
Strauß
Fønss
Bård
かほる
Александр
สมชาย
Φραγκόπουλος
Isolating Parts: Data
www.owasp.org
https://www.owasp.org/index.php/C
ategory:OWASP_Top_Ten_Project
Security: Code
Security: Dependencies
Security: Container Images
github.com/arminc/clair-scanner
Conclusion
● Testing microservices brings additional challenges
● Pay special attention to integration surfaces
● Isolate ...
Thanks!
Some code samples:
https://github.com/orgs/continuous-delivery-in-java
(with more coming soon!)
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Prochain SlideShare
Chargement dans…5
×

Testing Java Microservices: From Development to Production

970 vues

Publié le

Testing microservices is challenging. Dividing a system into components (à la microservices) naturally creates inter-component dependencies, and each service has its own performance and fault-tolerance characteristics that need to be validated during development, the QA process, and continually in production. Attend this meetup to learn about the theory, techniques, and practices needed to overcome this challenge. You will:

• Get an introduction to the challenges of testing distributed microservice systems
• Learn how to isolate tests within a complex microservice ecosystem
• Hear about several tools for automating vulnerability and security scanning for code, dependencies, and deployment artifacts

Publié dans : Technologie
  • Soyez le premier à commenter

Testing Java Microservices: From Development to Production

  1. 1. Testing Java Microservices: From Development to Production Abraham Marin-Perez | Daniel Bryant
  2. 2. tl;dr ● Testing microservices brings additional challenges ● Pay special attention to integration surfaces ● Isolate services for loosely coupled tests ● Include tests that resemble production ● Make security testing a first-class citizen
  3. 3. Who are we? @danielbryantuk Tech Consultant and Writer Product Architect at Datawire Java Champion Conference Tourist @abrahammarin Developer, Consultant, Writer Associate of Equal Experts Software Plumber
  4. 4. Types of tests From Agile Testing, by Lisa Crispin and Janet Gregory
  5. 5. Challenges ● Cannot share a single environment: test locally ● Full ecosystem unsuitable for local testing ● Lack of control over third-party dependencies
  6. 6. Isolation
  7. 7. Isolating Parts Third Party
  8. 8. Isolating Parts Third Party
  9. 9. Isolating Parts: No Isolation Third Party
  10. 10. Isolating Parts: Unowned Components Third Party
  11. 11. Test Doubles
  12. 12. Test Doubles Dummy objects: passed around but never actually used. Fake objects: working implementations not suitable for production Stubs: provide canned answers to calls made during the test Spies: stubs that also record some information based on how they were called. Mocks: objects pre-programmed with expectations which form a specification of the calls they are expected to receive. Virtualisations: emulation of services, with expectations (not suitable for production)
  13. 13. JUnit Example
  14. 14. API Simulation Thoughts ● Useful when a dependency is “expensive” to access or tricky to mock ● Facilitates error handling tests when dependency failure modes are challenging to recreate ● Simulations can be fragile and/or complicated
  15. 15. Use simulations appropriately... Sometime you need the real thing
  16. 16. Isolating Parts: Service Interaction Third Party
  17. 17. Focused on service/function Focused on system Contract Tests
  18. 18. API Contracts APIs are service contracts Many are producer-driven It’s possible to design outside-in: Consumer-Driven Contracts
  19. 19. Consumer-Driven Contracts
  20. 20. Consumer-Driven Contract Frameworks https://docs.pact.io/ https://cloud.spring.io/spring-cloud-contract/
  21. 21. Consumer-Driven Contract Thoughts ● Great in low trust or low communication organisations ○ Act as a cue for a conversation ● Can be used to implement “TDD for the API” ● Resource intensive to create and maintain
  22. 22. https://bit.ly/2p68gBS
  23. 23. Components
  24. 24. Isolating Parts: Single Service Third Party
  25. 25. Isolating Parts: Single Service
  26. 26. Isolating Parts: Single Service Test Doubles
  27. 27. Isolating Parts: Single Service
  28. 28. Isolating Parts: Single Service +
  29. 29. Isolating Parts: Single Service Fault Tolerance Test double configured to fail
  30. 30. https://technology.cap-hpi.com/blog/unit-testing-what-benefits-you-can-reap/
  31. 31. Isolating Parts: Technicalities Third Party
  32. 32. Isolating Parts: Technicalities Test the Real Thing
  33. 33. Isolating Parts: Technicalities
  34. 34. Isolating Parts: Data Test Data ● Low Volume ● Low Diversity Production Data ● High Volume ● High Diversity
  35. 35. Isolating Parts: Data
  36. 36. Isolating Parts: Data Marín Argüelles d’Hopital Garçon Castaña Strauß Fønss Bård かほる Александр สมชาย Φραγκόπουλος
  37. 37. Isolating Parts: Data
  38. 38. www.owasp.org https://www.owasp.org/index.php/C ategory:OWASP_Top_Ten_Project
  39. 39. Security: Code
  40. 40. Security: Dependencies
  41. 41. Security: Container Images github.com/arminc/clair-scanner
  42. 42. Conclusion ● Testing microservices brings additional challenges ● Pay special attention to integration surfaces ● Isolate services for loosely coupled tests ● Include tests that resemble production ● Make security testing a first-class citizen
  43. 43. Thanks! Some code samples: https://github.com/orgs/continuous-delivery-in-java (with more coming soon!)

×