7. 7
Challenges
in testing Distributed system complexity
• Inter service communication
• Asynchronous nature
• Dependency management
Challenges
in testing
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
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
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
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
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
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
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
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
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.