#ATAGTR2017
16th 17th March
Test Approach for Re-engineering Legacy
Applications based on Micro-service
Architecture
Sandhya Sasidharan
ThoughtWorks Technologies
WHAT IS A MICRO-SERVICE BASED ARCHITECTURE?
▫ A method of developing software applications as a suite of
independently deployable, small, modular services in which each service
runs a unique process and communicates through a well-defined,
lightweight mechanism to serve a business goal
WITH EASE COMES OVERHEAD AS WELL
One Business Feature
-Multiple services
WITH EASE COMES OVERHEAD AS WELL
Testing becomes Complex and Cumbersome
5
Case Study
UNDERSTANDING THE INTEGRATION POINTS
6
‣ Identify direct upstream & downstream dependencies
‣ Understand the business domain and business processes
‣ Build safety net for the legacy / existing parts
‣ Understand the roadmap of the evolution
PLAN YOUR TESTS
7
End to End Tests
‣ Create contract level / service level tests
‣ Use stubs/mocks
‣ Provides faster feedback to development
team
‣ Provides early safety net
‣ Minimises co-ordination constraints with
other teams
‣ Separates ownership
‣ Based on assumptions and agreements
Lower level tests
‣ Trigger a business action from an
upstream system
‣ See the data/information being
consumed
‣ Provides more confidence to
stakeholders
‣ Requires heavy co-ordination with
other teams
‣ Creates constraints
‣ Slower
CONTRACTS
Provider
Consumer1 Consumer2
Column Data type
Id Int
Name Varchar
Category Double
(not Nullable)
Price Float
Column Data type
Id Int
Name Varchar
Category Double
(not Nullable)
Column Data type
Id Int
Price Float
TEMPLATE VERIFICATION
9
[
{
"article_unit": string,
"category": {
"id": integer,
"name": string
},
"sub_category": {
"id": integer,
"name": string
},
"article_weight": integer,
"name": string,
"id": integer,
“frozen”: boolean
}
]
End Point Provides
[
{
"category": {
"id": integer,
"name": string
},
"sub_category": {
"id": integer,
"name": string
},
"name": string,
"id": integer,
“frozen”: boolean
}
]
Consumer Requires
RESPONSE VERIFICATION
10
[
{
"article_unit": "C",
"category": {
"id": 1,
"name": "SALMON"
},
"article_weight": 500,
“brand_name": "SALMON",
"id": 123,
“frozen”: true
}
]
- request:
url: /articles/123.json
method: GET
file: articles/GET_articleId.json
- request:
url: /articles/456.json
method: GET
file: articles/GET_articleId.json
[
{
"article_unit": "X",
"category": {
"id": 456,
"name": "CHOCOLATE"
},
“article_weight": ,
“brand_name": "CADBURY",
"id": 456,
“frozen”: false
}
]
11
Template verification
Response
Verifications
E2E
12
Huge Data
13
‣ Understand the data model and representations
‣ Identify the Quantum of variations
‣ Understand the boundary of the systems
‣ Apply the Pareto principle (80-20 rule)
UNDERSTANDING DATA
APPROACHES TO SETUP TEST DATA
14
Database Dump Base Seed Data
&
Modify as needed
Setup data
for each test
Using existing services
15
16
SCALABLE TEST MODEL
17
‣ Model the tests and test data in such a way that re-work is minimised
• Using object-oriented techniques
• Understanding and representing the domain well
‣ Separate tests into tiers based on complexity and feedback cycle
‣ Use continuous integration techniques
‣ Fail fast and loud on dependency changes
18
SAMPLE PIPELINE
SOME TESTING CHALLENGES
19
‣ Keeping up with the evolution of the dependent business processes
‣ Enthusiastic development team adding more E2E tests slowing the feedback cycle
‣ Frequent re-balancing of the tests
‣ Maintaining test data sanity
Agile Testing Alliance Global Testing Retreat 2017
THANK YOU
Reference for Implementation
https://martinfowler.com/articles/consumerDrivenContracts.html

ATAGTR2017 Test Approach for Re-engineering Legacy Applications based on Micro-service Architecture

  • 1.
    #ATAGTR2017 16th 17th March TestApproach for Re-engineering Legacy Applications based on Micro-service Architecture Sandhya Sasidharan ThoughtWorks Technologies
  • 2.
    WHAT IS AMICRO-SERVICE BASED ARCHITECTURE? ▫ A method of developing software applications as a suite of independently deployable, small, modular services in which each service runs a unique process and communicates through a well-defined, lightweight mechanism to serve a business goal
  • 3.
    WITH EASE COMESOVERHEAD AS WELL One Business Feature -Multiple services
  • 4.
    WITH EASE COMESOVERHEAD AS WELL Testing becomes Complex and Cumbersome
  • 5.
  • 6.
    UNDERSTANDING THE INTEGRATIONPOINTS 6 ‣ Identify direct upstream & downstream dependencies ‣ Understand the business domain and business processes ‣ Build safety net for the legacy / existing parts ‣ Understand the roadmap of the evolution
  • 7.
    PLAN YOUR TESTS 7 Endto End Tests ‣ Create contract level / service level tests ‣ Use stubs/mocks ‣ Provides faster feedback to development team ‣ Provides early safety net ‣ Minimises co-ordination constraints with other teams ‣ Separates ownership ‣ Based on assumptions and agreements Lower level tests ‣ Trigger a business action from an upstream system ‣ See the data/information being consumed ‣ Provides more confidence to stakeholders ‣ Requires heavy co-ordination with other teams ‣ Creates constraints ‣ Slower
  • 8.
    CONTRACTS Provider Consumer1 Consumer2 Column Datatype Id Int Name Varchar Category Double (not Nullable) Price Float Column Data type Id Int Name Varchar Category Double (not Nullable) Column Data type Id Int Price Float
  • 9.
    TEMPLATE VERIFICATION 9 [ { "article_unit": string, "category":{ "id": integer, "name": string }, "sub_category": { "id": integer, "name": string }, "article_weight": integer, "name": string, "id": integer, “frozen”: boolean } ] End Point Provides [ { "category": { "id": integer, "name": string }, "sub_category": { "id": integer, "name": string }, "name": string, "id": integer, “frozen”: boolean } ] Consumer Requires
  • 10.
    RESPONSE VERIFICATION 10 [ { "article_unit": "C", "category":{ "id": 1, "name": "SALMON" }, "article_weight": 500, “brand_name": "SALMON", "id": 123, “frozen”: true } ] - request: url: /articles/123.json method: GET file: articles/GET_articleId.json - request: url: /articles/456.json method: GET file: articles/GET_articleId.json [ { "article_unit": "X", "category": { "id": 456, "name": "CHOCOLATE" }, “article_weight": , “brand_name": "CADBURY", "id": 456, “frozen”: false } ]
  • 11.
  • 12.
  • 13.
    13 ‣ Understand thedata model and representations ‣ Identify the Quantum of variations ‣ Understand the boundary of the systems ‣ Apply the Pareto principle (80-20 rule) UNDERSTANDING DATA
  • 14.
    APPROACHES TO SETUPTEST DATA 14 Database Dump Base Seed Data & Modify as needed Setup data for each test Using existing services
  • 15.
  • 16.
  • 17.
    SCALABLE TEST MODEL 17 ‣Model the tests and test data in such a way that re-work is minimised • Using object-oriented techniques • Understanding and representing the domain well ‣ Separate tests into tiers based on complexity and feedback cycle ‣ Use continuous integration techniques ‣ Fail fast and loud on dependency changes
  • 18.
  • 19.
    SOME TESTING CHALLENGES 19 ‣Keeping up with the evolution of the dependent business processes ‣ Enthusiastic development team adding more E2E tests slowing the feedback cycle ‣ Frequent re-balancing of the tests ‣ Maintaining test data sanity
  • 20.
    Agile Testing AllianceGlobal Testing Retreat 2017 THANK YOU Reference for Implementation https://martinfowler.com/articles/consumerDrivenContracts.html

Editor's Notes

  • #6 After detailed workshops with the stakeholders, identify the correct sub-system Use Strangulation to re-engineer piece by piece Work with product teams to identify an optimal place to start Ensure the chosen sub-system is complex enough to try Build scaffolds (i.e. safety nets) to minimise impact to BaU Understanding the Integration points Why testing integration points are critical? Understand the interconnect between sub-systems Data flow is impacted Incorrect assumptions and agreements can result in data & commercial loss Also to prevent Blame games on different teams
  • #12 Slightly different from the normal test pyramid Template verification - Verification the data parameters Pact tests - Testing various data combinations E2E - Mostly UI based. Triggered from the dependent systems
  • #13  In any large enterprise project, the volume of data is huge Multiple MS need to work together and exchange messages/data to deliver one business feature
  • #14  why golden data set? depending on the scenario, we may need different variety / volumes of data to test the one that gives the optimum coverage with the optimum volume` (80-20 rule) identify the quantum of variations Evolves over a period of time
  • #15 Test data and tests evolve
  • #16 Next comes building a Safety net What is a safety net? Importance of a safety net Helps the dev team to move faster without fear of change Alerts the team when there is a dependency failure / change
  • #17 Considerations for building a safety net Can re-work be avoided? NO. but it can be minimised Rework can be caused due to evolving dependent systems
  • #18 Why scalable test model? - Minimum effort - Keeping upto the timelines
  • #19 Various pipelines giving fast feedback Information can be radiated to dependent teams easily Slow running tests can be scheduled to run at regular intervals Provides traceability of failures