Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Testing Microservices Architectures

527 views

Published on

Arquitecturas de microservicios se han adoptado cada vez más por la industria y es, cada día más, una realidad en LATAM.
La capacidad de implementar componentes desacoplados alrededor de un contexto de negócio bien definido, mantener y paralelizar sus desarrollos en varios equipos autónomos son sólo algunos de los beneficios responsables de esta adopción.

Sin embargo, este tipo de arquitectura presenta desafíos a estrategias de pruebas convencionales, principalmente debido a los diferentes puntos de integración existentes.

En esta charla vamos a discutir diferentes estrategias de pruebas para hacer frente a estos desafíos, siempre tratando de contextualizar con nuestras peculiaridades en LATAM

Published in: Software

Testing Microservices Architectures

  1. 1. TESTING MICROSERVICES ARCHITECTURES Renan Martins @renan89 1
  2. 2. DEFINITION 2 “Micro services are small, autonomous services that work together"
  3. 3. SMALL 3 Focused on Doing One Thing Well
  4. 4. AUTONOMOUS 4 Need to be able to change independently of each other, and be deployed by themselves without requiring consumers to change.
  5. 5. AM I DOING IT RIGHT? 5 Can you make a change to a service and deploy it by itself without changing anything else?
  6. 6. 6 KEY BENEFITS OF MICRO SERVICES ARCHITECTURES
  7. 7. TECHNOLOGY HETEROGENEITY 7 The right tool for each job! POSTS <<ruby>> FRIENDS <<golang>> PICTURES <<java>> <<Document Store>> <<graph DB>> <<Blob Store>>
  8. 8. RESILIENCE 8 We can build systems that handle the total failure of services and degrade functionality accordingly
  9. 9. SCALING PICTURES POSTS FRIENDS
  10. 10. EASE OF DEPLOYMENT Deploys are faster, independent and problems can be isolated more easily
  11. 11. ORGANIZATIONAL ALIGNMENT INVOICING SERVICE INVENTORY SERVICE Smaller teams and smaller codebases Conway's Law
  12. 12. COMPOSABILITY AND REPLACEABILITY
  13. 13. COMPOSABILITY AND REPLACEABILITY MONOLITHIC ECOM SYSTEM
  14. 14. COMPOSABILITY AND REPLACEABILITY MONOLITHIC ECOM SYSTEM PROFILE MODULE
  15. 15. COMPOSABILITY AND REPLACEABILITY MONOLITHIC ECOM SYSTEM PROFILE MODULE
  16. 16. COMPOSABILITY AND REPLACEABILITY MONOLITHIC ECOM SYSTEM PROFILE MODULE HTTPS
  17. 17. COMPOSABILITY AND REPLACEABILITY MONOLITHIC ECOM SYSTEM PROFILE MODULE New Point of Sale HTTPS
  18. 18. COMPOSABILITY AND REPLACEABILITY MONOLITHIC ECOM SYSTEM PROFILE MODULE New Point of Sale HTTPS HTTP
  19. 19. COMPOSABILITY AND REPLACEABILITY MONOLITHIC ECOM SYSTEM PROFILE MODULE New Point of Sale HTTPS HTTP Affiliate Store HTTPS
  20. 20. 13 NO
  21. 21. YOU MUST BE THIS TALL TO USE MICRO SERVICES http://martinfowler.com/bliki/MicroservicePrerequisites.html
  22. 22. MONOLITH FIRST 15 http://martinfowler.com/bliki/MonolithFirst.html
  23. 23. 16 TESTS
  24. 24. 17 TEST AUTOMATION CLOSER TO THE USER CLOSER TO THE DEVELOPER $$$ SLOWER / FEWER $ FASTER / MORE USER JOURNEY UI INTEGRATION UNIT Connection of UI tests to a persona like flow through the system Testing on the level of the users - incl. browser, network, databases, external systems, … Tests of multiple integrated method Tests of single methods without dependencies
  25. 25. 18 CODE PRODUCTION Unit, Integration, end to end tests, smoke tests, etc.. Consumers
  26. 26. 19 HOW DOES IT RELATE TO MICRO SERVICES ARCHITECTURES ?
  27. 27. ANATOMY OF A MICROSERVICE 20http://martinfowler.com/articles/microservice-testing/
  28. 28. UNIT TESTING MICROSERVICES 21 Domain - We should focus on testing the behavior, observing changes on its state. Gateways, Resources and Persistence - We should focus on the interactions and collaboration (Mocks, test doubles) http://martinfowler.com/articles/microservice-testing/
  29. 29. INTEGRATION TESTS - PERSISTENCE E GATEWAYS 22http://martinfowler.com/articles/microservice-testing/
  30. 30. COMPONENT TESTS - IN PROCESS 23http://martinfowler.com/articles/microservice-testing/
  31. 31. COMPONENT TESTS - OUT OF PROCESS 24http://martinfowler.com/articles/microservice-testing/
  32. 32. COMPONENT TESTS - HOW TO SIMULATE EXTERNAL SERVICES? 25 Mock your APIs for fast, robust and comprehensive testing mountebank - over the wire test doubles
  33. 33. COMPONENT TESTS - HOW TO SIMULATE EXTERNAL SERVICES? 26
  34. 34. COMPONENT TESTS - HOW TO SIMULATE EXTERNAL SERVICES? 26
  35. 35. COMPONENT TESTS - HOW TO SIMULATE EXTERNAL SERVICES? 26 test
  36. 36. COMPONENT TESTS - HOW TO SIMULATE EXTERNAL SERVICES? 26 test Configure the stubs
  37. 37. COMPONENT TESTS - HOW TO SIMULATE EXTERNAL SERVICES? 26 test Configure the stubs
  38. 38. COMPONENT TESTS - HOW TO SIMULATE EXTERNAL SERVICES? 26 test SMTP TCP Stub HTTP Configure the stubs
  39. 39. COMPONENT TESTS - HOW TO SIMULATE EXTERNAL SERVICES? 26 test Your application SMTP TCP Stub HTTP Configure the stubs
  40. 40. COMPONENT TESTS - HOW TO SIMULATE EXTERNAL SERVICES? 26 test Your application SMTP TCP Stub HTTP Configure the stubs
  41. 41. COMPONENT TESTS - PROBLEMS WITH STUBS 27
  42. 42. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Your application Stub / Imposter Test
  43. 43. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving Your application Stub / Imposter Test
  44. 44. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving Your application Stub / Imposter Test
  45. 45. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving Your application Stub / Imposter Test Becomes invalid!
  46. 46. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving Your application Stub / Imposter Test Becomes invalid!
  47. 47. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving BECOMES INVALID! Your application Stub / Imposter Test Becomes invalid!
  48. 48. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving BECOMES INVALID! Your application Stub / Imposter Test Becomes invalid!
  49. 49. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving BECOMES INVALID! Your application Stub / Imposter Test Becomes invalid!
  50. 50. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving BECOMES INVALID! Your application Stub / Imposter Test Becomes invalid!
  51. 51. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving BECOMES INVALID! Your application Stub / Imposter Test Becomes invalid!
  52. 52. COMPONENT TESTS - PROBLEMS WITH STUBS 27 Service constantly evolving How frequently do you change your stubs? BECOMES INVALID! Your application Stub / Imposter Test Becomes invalid!
  53. 53. CONTRACT TESTS 28 Service constantly evolving
  54. 54. CONSUMER DRIVEN CONTRACTS 29
  55. 55. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving
  56. 56. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving Service's Continuous Integration Pipeline
  57. 57. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving Service's Continuous Integration Pipeline
  58. 58. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT Service's Continuous Integration Pipeline
  59. 59. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION Service's Continuous Integration Pipeline
  60. 60. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT Service's Continuous Integration Pipeline
  61. 61. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT CONTRACT Service's Continuous Integration Pipeline
  62. 62. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT CONTRACT Service's Continuous Integration Pipeline
  63. 63. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT CONTRACT Service's Continuous Integration Pipeline
  64. 64. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT CONTRACT Service's Continuous Integration Pipeline
  65. 65. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT CONTRACT Service's Continuous Integration Pipeline
  66. 66. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT CONTRACT Service's Continuous Integration Pipeline
  67. 67. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT CONTRACT Service's Continuous Integration Pipeline
  68. 68. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT CONTRACT Service's Continuous Integration Pipeline
  69. 69. CONSUMER DRIVEN CONTRACTS 29 Service constantly evolving UNIT INTEGRATION COMPONENT CONTRACT Deploy! Service's Continuous Integration Pipeline
  70. 70. CONSUMER DRIVEN CONTRACTS - IMPLEMENTATIONS 30 https://github.com/realestate-com-au/pact
  71. 71. END TO END TESTS - BLACK BOX 31
  72. 72. END TO END TESTS - BLACK BOX 31
  73. 73. END TO END TESTS - BLACK BOX 31 1 4 2 3 5 6 7 8
  74. 74. END TO END TESTS - BLACK BOX 31 1 4 2 3 5 6 7 8
  75. 75. END TO END TESTS - BLACK BOX 31 1 4 2 3 5 6 7 8
  76. 76. END TO END TESTS - BLACK BOX 31 1 4 2 3 5 6 7 8 GOOD LUCK!
  77. 77. END TO END TESTING MICRO SERVICES ARCHITECTURES 32 Avoid the need for end-to-end tests wherever possible
  78. 78. END TO END TESTING MICRO SERVICES ARCHITECTURES 33 Test User Journeys, not stories
  79. 79. END TO END TESTING MICRO SERVICES ARCHITECTURES 34 Make sure your end to end tests are independent of existing data
  80. 80. CI PIPELINE - QUICK FEEDBACK VS COST 35 UNIT INTEGRATION CONTRACT COMPONENT JOURNEYS
  81. 81. WE COVERED THE WHOLE PYRAMID. ARE WE DONE YET? 36
  82. 82. WE COVERED THE WHOLE PYRAMID. ARE WE DONE YET? 36 Nope.
  83. 83. WE COVERED THE WHOLE PYRAMID. ARE WE DONE YET? 36 Nope. Testing in production!
  84. 84. TESTING IN PRODUCTION 37 Deploy vs Release BLUE GREEN DEPLOYMENT
  85. 85. TESTING IN PRODUCTION 37 Deploy vs Release BLUE GREEN DEPLOYMENT
  86. 86. TESTING IN PRODUCTION 37 Deploy vs Release BLUE GREEN DEPLOYMENT SERVICE V1
  87. 87. TESTING IN PRODUCTION 37 Deploy vs Release BLUE GREEN DEPLOYMENT SERVICE V1
  88. 88. TESTING IN PRODUCTION 37 Deploy vs Release BLUE GREEN DEPLOYMENT SERVICE V1 SERVICE V2
  89. 89. TESTING IN PRODUCTION 37 Deploy vs Release BLUE GREEN DEPLOYMENT SERVICE V1 SERVICE V2
  90. 90. TESTING IN PRODUCTION 37 Deploy vs Release BLUE GREEN DEPLOYMENT SERVICE V1 SERVICE V2
  91. 91. TESTING IN PRODUCTION 37 Deploy vs Release BLUE GREEN DEPLOYMENT SERVICE V1 SERVICE V2
  92. 92. CANARY RELEASE 38
  93. 93. CANARY RELEASE 38
  94. 94. CANARY RELEASE 38
  95. 95. CANARY RELEASE 38 SERVICE V1
  96. 96. CANARY RELEASE 38 SERVICE V1
  97. 97. CANARY RELEASE 38 SERVICE V1 SERVICE V2
  98. 98. CANARY RELEASE 38 SERVICE V1 SERVICE V2
  99. 99. CANARY RELEASE 38 SERVICE V1 SERVICE V2
  100. 100. CANARY RELEASE 38 SERVICE V1 SERVICE V2
  101. 101. CANARY RELEASE 38 SERVICE V1 SERVICE V2 15% 85%
  102. 102. MEAN TIME TO RECOVER 39 Tests are very important to reduce the amount of defects in our systems. However, it's important to acknowledge that bugs will always happen in production. 
 How fast we can recover from them will help determining our success!
  103. 103. TECH RADAR RECOMMENDS! 40 http://www.thoughtworks.com/radar
  104. 104. rmartins@thoughtworks.com ¡MUCHAS GRACIAS!

×