Testing strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorks
Upcoming SlideShare
Loading in...5
×
 

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

on

  • 468 views

 

Statistics

Views

Total Views
468
Views on SlideShare
468
Embed Views
0

Actions

Likes
1
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Brief Intro <br /> There has been a shift in service based architectures over the last few years towards smaller, more focussed &quot;micro&quot; services. There are many benefits with this approach such as the ability to independently deploy, scale and maintain each component.  <br /> 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. <br />
  • Ask the audience <br />
  • 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. <br />
  • - as good as having different teams, working on different services <br />
  • - top down <br /> - having UI test <br /> - brittleness <br /> - high maintenance <br /> - slow feedback <br /> - big bang <br /> - testing after the fact (app is ready & done) <br /> - hybrid/context <br /> - mix of approaches <br /> - bottom up <br />
  • 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. <br />

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

  • Testing Strategies for Micro-services Architecture Ketan Soni Jesal Mistry June 2014
  • 2 What is a micro-service?
  • 3 Example I want to purchase a product from an e-commerce website View slide
  • 4 Monolithi c system MasterCard / VisaLogistics Cart Catalog Authentication Payment Fulfilment E-commerce website View slide
  • 5 Unix philosophy: Write programs that do one thing and  do it well.
  • 6 Micro- Services system MasterCard / VisaLogistics Cart Service Payment Service Authentication Service Fulfilment Service Catalog Service E-commerce website
  • 7 Challenges in testing Distributed system complexity •  Inter service communication •  Asynchronous nature •  Dependency management Challenges in testing
  • 8 Testing Strategies Top-down Big Bang Hybrid / Context Driven Bottom-up
  • 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 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory Bottom-up testing
  • 11 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
  • 12 Unit Test Layer • Test the domain • Should focus on the code under test • Maximum test coverage
  • 13 Unit Test Layer Authentication Service Payment Service Catalog Service Unit tests - addItem - removeItem - verifyCreditCard Cart Service Fulfilment Service
  • 14 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
  • 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 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 Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory Test Pyramid
  • 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 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 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
  • 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 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 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
  • 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 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 Test Pyramid Unit Contract E2E Integration UI Consumer Driven Contract Manual / Exploratory
  • 27 References • Logging • Inter - Service effects • Gracefully handle errors • Look & Feel Manual / Exploratory
  • 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 Questions ?