I n s i g h t s i n t o
TESTING MICROSERVICES
AGENDA
2
What is Microservice Architecture ?
What each Service made of ?
Ensuring Test Coverage and Getting Faster feedback
Discuss some real time scenarios and my learnings
Q & A
MICROSERVICES ARCHITECTURE
3
KEY TAKEAWAYS
4
Modelled around the business domain
Small and Focused
Loosely Coupled
Language Neutral
De-centralized governance and data management
Microservices are :
A SERVICE IS MADE OF
5
Resource
Service Layer/
Domain
Repository
Data Mapper
Gateway
External
Datastore
Services
GENERIC MICROSERVICES
Application Boundary
Service
A
Service
C
Service
B
Event Streaming
<Asynchronous
Call>
<Synchronous Call>
API
Gateway
Front
End
MICROSERVICES
ARCHITECTURE
OR
LEGACY SYSTEM
TESTING THE UNIT
7
Resource
Service Layer/
Domain
Repository
Data Mapper
Gateway
- unit
UNIT TESTING is to test
behaviour of a single testable
unit.
TESTING THE COMMUNICATION PATH
8
Resource
Service Layer/
Domain
Repository
Data Mapper
Gateway
- Integration Path
Datastore
Event Streaming
<Asynchronous
Call>
Integration Testing is
to test communication
path and collaboration
between different
modules usually
data store and External
components.
INTEGRATION PROBLEM
Service A Service B
Service
B
Test 1
Test 2
Test 3
Application Boundary
Slow and less
reliable approach
CONSUMER DRIVEN CONTRACT TEST
USING PACT
Service A Service B
ProviderConsumer
PACT
<HTTP request>
<Expected HTTP Response>
(Mock HTTP Server)
<Replay Request>
<Assert HTTP Response>
Application Boundary
Record
Replay
Replay
{accountNumber : 100}
{
firstName : A,
surName : B
}
TEST END-TO-END BEHAVIOUR
Application Boundary
Service
A
Service
C
Service
B
Event Streaming
<Asynchronous
Call>
<Synchronous Call>
API
Gateway
Test
End to End TESTING is to test application as a whole in a way actual
user will be using it.
MICROSERVICES
ARCHITECTURE
OR
LEGACY SYSTEM
END-TO-END TEST SHOULD BE
12
Low in number as possible
Test it the way, User will be using it i.e. User Journey
Include test in Build pipeline to get faster feedback
Data-independent Test
TEST PYRAMID
13
Unit Test
Integration Test
Contract Test
End -to - End Test
Exploratory
Testing
MY LEARNINGS FROM REAL TIME SCENARIOS
14
Ensure status codes are returned correctly
Ensure you always test through flaky endpoints i.e.API Gateway / Externally
Exposed endpoint
Test whether Application still work if one of the instance of
service/Database/Event Streaming is down
Test whether logs generated are meaningful and simple to understand
to retrospect
, as Its all about asking the right questionBEING AGILE HELPED ME
Build verification Test gives you lot of confidence
DEPLOYMENT PROCESS
15
REFERENCES
16
Microservices - Martin Fowler
https://www.youtube.com/watch?v=wgdBVIX9ifA
Test strategy for Microservices
https://martinfowler.com/articles/microservice-testing/
Introduction - Pact
www.pact.io/
THANK YOU

Testing microservices

  • 1.
    I n si g h t s i n t o TESTING MICROSERVICES
  • 2.
    AGENDA 2 What is MicroserviceArchitecture ? What each Service made of ? Ensuring Test Coverage and Getting Faster feedback Discuss some real time scenarios and my learnings Q & A
  • 3.
  • 4.
    KEY TAKEAWAYS 4 Modelled aroundthe business domain Small and Focused Loosely Coupled Language Neutral De-centralized governance and data management Microservices are :
  • 5.
    A SERVICE ISMADE OF 5 Resource Service Layer/ Domain Repository Data Mapper Gateway External Datastore Services
  • 6.
    GENERIC MICROSERVICES Application Boundary Service A Service C Service B EventStreaming <Asynchronous Call> <Synchronous Call> API Gateway Front End MICROSERVICES ARCHITECTURE OR LEGACY SYSTEM
  • 7.
    TESTING THE UNIT 7 Resource ServiceLayer/ Domain Repository Data Mapper Gateway - unit UNIT TESTING is to test behaviour of a single testable unit.
  • 8.
    TESTING THE COMMUNICATIONPATH 8 Resource Service Layer/ Domain Repository Data Mapper Gateway - Integration Path Datastore Event Streaming <Asynchronous Call> Integration Testing is to test communication path and collaboration between different modules usually data store and External components.
  • 9.
    INTEGRATION PROBLEM Service AService B Service B Test 1 Test 2 Test 3 Application Boundary Slow and less reliable approach
  • 10.
    CONSUMER DRIVEN CONTRACTTEST USING PACT Service A Service B ProviderConsumer PACT <HTTP request> <Expected HTTP Response> (Mock HTTP Server) <Replay Request> <Assert HTTP Response> Application Boundary Record Replay Replay {accountNumber : 100} { firstName : A, surName : B }
  • 11.
    TEST END-TO-END BEHAVIOUR ApplicationBoundary Service A Service C Service B Event Streaming <Asynchronous Call> <Synchronous Call> API Gateway Test End to End TESTING is to test application as a whole in a way actual user will be using it. MICROSERVICES ARCHITECTURE OR LEGACY SYSTEM
  • 12.
    END-TO-END TEST SHOULDBE 12 Low in number as possible Test it the way, User will be using it i.e. User Journey Include test in Build pipeline to get faster feedback Data-independent Test
  • 13.
    TEST PYRAMID 13 Unit Test IntegrationTest Contract Test End -to - End Test Exploratory Testing
  • 14.
    MY LEARNINGS FROMREAL TIME SCENARIOS 14 Ensure status codes are returned correctly Ensure you always test through flaky endpoints i.e.API Gateway / Externally Exposed endpoint Test whether Application still work if one of the instance of service/Database/Event Streaming is down Test whether logs generated are meaningful and simple to understand to retrospect , as Its all about asking the right questionBEING AGILE HELPED ME Build verification Test gives you lot of confidence
  • 15.
  • 16.
    REFERENCES 16 Microservices - MartinFowler https://www.youtube.com/watch?v=wgdBVIX9ifA Test strategy for Microservices https://martinfowler.com/articles/microservice-testing/ Introduction - Pact www.pact.io/
  • 17.