Testing strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorks

9,013 views

Published on

Published in: Technology
0 Comments
21 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
9,013
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
230
Comments
0
Likes
21
Embeds 0
No embeds

No notes for slide
  • Brief Intro
    There has been a shift in service based architectures over the last few years towards smaller, more focussed "micro" services. There are many benefits with this approach such as the ability to independently deploy, scale and maintain each component. 
    Our team has spent the last two years building and deploying more than 10 micro services into production, and we plan to create a few more. Here we would like to discuss a number of approaches and testing strategies for managing the testing of independently deployable components.
  • Ask the audience
  • A system built using micro-services is a system that is built up of small, lightweight services, where each performs a single function. The services are arranged in independently deployable groups and communicate with each other via a well defined interface and work together to provide business value.
  • - as good as having different teams, working on different services
  • - top down
    - having UI test
    - brittleness
    - high maintenance
    - slow feedback
    - big bang
    - testing after the fact (app is ready & done)
    - hybrid/context
    - mix of approaches
    - bottom up
  • The goal of these tests is to execute as much of the application code as possible as quickly as possible. The basic idea is to run up all your services in memory and connect them via in memory http pipes.
  • Testing strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorks

    1. 1. Testing Strategies for Micro-services Architecture Ketan Soni Jesal Mistry June 2014
    2. 2. 2 What is a micro-service?
    3. 3. 3 Example I want to purchase a product from an e-commerce website
    4. 4. 4 Monolithi c system MasterCard / VisaLogistics Cart Catalog Authentication Payment Fulfilment E-commerce website
    5. 5. 5 Unix philosophy: Write programs that do one thing and  do it well.
    6. 6. 6 Micro- Services system MasterCard / VisaLogistics Cart Service Payment Service Authentication Service Fulfilment Service Catalog Service E-commerce website
    7. 7. 7 Challenges in testing Distributed system complexity •  Inter service communication •  Asynchronous nature •  Dependency management Challenges in testing
    8. 8. 8 Testing Strategies Top-down Big Bang Hybrid / Context Driven Bottom-up
    9. 9. 9 Our Approach Bottom-up testing • Test the domain • Tests closer to the code • Integrate Early • Use Mocks / Stubs • Focus is on Test Pyramid • Helps visualize/categorize test coverage better
    10. 10. 10 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory Bottom-up testing
    11. 11. 11 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
    12. 12. 12 Unit Test Layer • Test the domain • Should focus on the code under test • Maximum test coverage
    13. 13. 13 Unit Test Layer Authentication Service Payment Service Catalog Service Unit tests - addItem - removeItem - verifyCreditCard Cart Service Fulfilment Service
    14. 14. 14 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
    15. 15. 15 Contract Test Layer • Test one end-point at a time • Treat the service as a black box • These tests are end to end within the bounds of the service • Assertion are on response e.g. JSON body • Stub out the dependencies Contract Test Layer
    16. 16. 16 Contract Test Layer Contract Test Layer Contract tests POST /cart/{:product_id} HTTP Request HTTP Response JSON ….... Cart Service Mock Authentication Service Mock Catalog Service Mock Fulfilment Service Mock Payment Service
    17. 17. 17 Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory Test Pyramid
    18. 18. 18 End to End Integration Test layer • Test End to End user journey to make sure that the business flow works as expected • These covers interaction of all the available services End to End Integration Test Layer
    19. 19. 19 End to End Integration Test layer E2E Integration tests Cart Service Place an order Payment Service Authentication Service Catalog Service Fulfilment Service Verify that the order is placed Mock Logistics Mock Mastercard End to End Integration Test Layer
    20. 20. 20 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
    21. 21. 21 Consumer Driven Contract Test layer • In case of third-party system, we had tests to make sure that external systems behave the way we expect them to. Consumer Driven Contract Test Layer
    22. 22. 22 Consumer Driven Contract Test layer Consumer Driven Contract tests MasterCard / Visa Service Consumer Driven Contract Test Layer Verify Credit Card HTTP Request HTTP Response Success
    23. 23. 23 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
    24. 24. 24 UI Test Layer • For the UI layer, we wrote tests for the End to End user journey which also covered the external 3rd party interactions • UI tests were minimal
    25. 25. 25 UI Test Layer User Interface Journey tests Authentication Service Fulfilment Service Payment Service Cart Service As a user I should be able to purchase a mobile from a website UI MasterCard / Visa Logistics
    26. 26. 26 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
    27. 27. 27 References • Logging • Inter - Service effects • Gracefully handle errors • Look & Feel Manual / Exploratory
    28. 28. 28 References • http://en.wikipedia.org/wiki/Unix • http://davidmorgantini.blogspot.co.uk/2014/03/microservices- effective-testing.html • http://martinfowler.com/articles/microservices.html • https://github.com/tobyclemson References
    29. 29. 29 Questions ?

    ×