SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Microservices testing:
Consumer driven
contracts using Pact
By Prashant Kalkar & Paresh Mahajan
Essence of Testing
Reducing the feedback loop
How can we shorten the loop?
● Automation
● Scheduled builds - Continuous Integration
● Test segregation
Larger the loop more costly it is.
Build Pipeline
Test pyramid
Testing challenges in Microservices
● Revisiting the testing terms
● Do we need any other types of test?
● Does the system works end-to-end?
Test pyramid in case of Microservices
Component Tests
Tests a single service as black box. External services are stubbed.
Challenges in Component Tests
Integration tests
Issues with Integration tests
● Difficult to setup due to service dependency graph
● Can quickly increase in numbers for large number of services
● If setup incorrectly can be brittle to maintain
● Some stubs can be used but integration with real service still needs to be
covered in some other tests
● Stubs needs to be kept up to date to keep these tests relevant/useful
End to End tests
Issues with E2E tests
● Slow feedback
● Test data setup difficult
● Brittle, non-deterministic tests
● Harder to debug the test failure
● Parallel execution difficult to achieve
● No good way of scheduling them
Is there any golden mean which will allow us faster
execution as well as will give us more confidence if the
system works as a whole?
Consumer Driven Contracts
Consumer Driven Contracts (CDC)
● A CDC framework allow us to use the stub during component tests but also
provide a way to ensure that the service will work with actual services.
How CDC framework works:
Contract / Pact
stored between
Consumer & Producer
Contract/Pact
Executed Against
Example in Discussion
Consumer Provider
Consumer Test (Order Service)
Provider Test (User Service)
Demo
● Order service tests
● User service tests
CDC benefits
● Consumer component tests can be reused for CDC
● Solves the issues of stale stubs
● Provides end to end test benefits without extra cost
● Faster Feedback
● Can be part of Consumer and Producer (independent) pipelines
● Producer can be tested againsts all the Consumers
Avoid Pitfalls
Beware of Contract Coupling
● Contracts only contains fields required by Consumer. (It may not be same
as Producer’s entire response)
● When tested against producer extra fields in response are ignored
● Leads to loose coupling between consumers and producers
● Pact CDC framework implements Postel’s law while doing Pact verification
Releasability
What We Test Vs What We Release Monolith
What we Test Vs What We Release -
Microservices
Compatibility
CDC testing between latest services is not sufficient.
How to answer ‘Can I deploy/release this service in Production?’
Pact tagging
● Pact allows us to tag application versions.
● An application/service version can be tagged as say DEV or PROD.
● Pact broker maintains a compatibility matrix between applications.
Pact Matrix
Producer and Releasability
Latest
Dev
Prod
TAGS
2. Execute all pacts against the Producer
Consumer and
Releasability
1. Run tests
2. New Pacts published
3. Triggered by Webhook
Releasability and Pipeline Demo
● Consumer pipeline
● Provider pipeline
● Non compatible change in Provider
● Deploy Provider and Consumer till production
● Non compatible changes in consumer
● Provider fix as per new consumer contract
● Deploy new Provider to DEV
● Deploy new Consumer to DEV (can-i-deploy pass)
● Deploy new Consumer to PROD (can-i-deploy fail)
● Consumer changes (Pre-verified Contracts)
Thank you!
Git repositories:
https://github.com/prashant-ee/cdc-pact-expert-talk/
https://github.com/prashant-ee/user-service
https://github.com/prashant-ee/order-service

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (19)

Testing in java
Testing in javaTesting in java
Testing in java
 
Quality Assurance
Quality AssuranceQuality Assurance
Quality Assurance
 
Learning to Enjoy Unit Testing
Learning to Enjoy Unit TestingLearning to Enjoy Unit Testing
Learning to Enjoy Unit Testing
 
Integration testing in Scaled agile projects
Integration testing in Scaled agile projectsIntegration testing in Scaled agile projects
Integration testing in Scaled agile projects
 
Test Automation - Everything You Need To Know
Test Automation - Everything You Need To KnowTest Automation - Everything You Need To Know
Test Automation - Everything You Need To Know
 
Performance testing
Performance testingPerformance testing
Performance testing
 
Rob Baarda - Are Real Test Metrics Predictive for the Future?
Rob Baarda - Are Real Test Metrics Predictive for the Future?Rob Baarda - Are Real Test Metrics Predictive for the Future?
Rob Baarda - Are Real Test Metrics Predictive for the Future?
 
Presentation Test Driven Development
Presentation Test Driven DevelopmentPresentation Test Driven Development
Presentation Test Driven Development
 
Continuous performance: Load testing for developers with gatling
Continuous performance: Load testing for developers with gatlingContinuous performance: Load testing for developers with gatling
Continuous performance: Load testing for developers with gatling
 
Introduction to TDD and BDD
Introduction to TDD and BDDIntroduction to TDD and BDD
Introduction to TDD and BDD
 
Tips To Follow For A Simple QA Process
Tips To Follow For A Simple QA ProcessTips To Follow For A Simple QA Process
Tips To Follow For A Simple QA Process
 
How To Become A Good Agile Tester?
How To Become A Good Agile Tester?How To Become A Good Agile Tester?
How To Become A Good Agile Tester?
 
Deliver Fast, Break Nothing Via Effective Building Developer and Tester Colla...
Deliver Fast, Break Nothing Via Effective Building Developer and Tester Colla...Deliver Fast, Break Nothing Via Effective Building Developer and Tester Colla...
Deliver Fast, Break Nothing Via Effective Building Developer and Tester Colla...
 
Testing Metrics
Testing MetricsTesting Metrics
Testing Metrics
 
Reactive Performance Testing
Reactive Performance TestingReactive Performance Testing
Reactive Performance Testing
 
Load Testing Strategy 101
Load Testing Strategy 101Load Testing Strategy 101
Load Testing Strategy 101
 
USER ACCEPTANCE TESTING
USER ACCEPTANCE TESTINGUSER ACCEPTANCE TESTING
USER ACCEPTANCE TESTING
 
Testing
TestingTesting
Testing
 
Performance testing
Performance testing Performance testing
Performance testing
 

Ähnlich wie Microservices testing consumer driven contracts using pact

Acceptance test driven development
Acceptance test driven developmentAcceptance test driven development
Acceptance test driven development
Editor Jacotech
 
8220 sad inquiry
8220 sad inquiry8220 sad inquiry
8220 sad inquiry
bbass03
 

Ähnlich wie Microservices testing consumer driven contracts using pact (20)

Modern Testing Strategies for Evolving Ecosystems
Modern Testing Strategies for Evolving EcosystemsModern Testing Strategies for Evolving Ecosystems
Modern Testing Strategies for Evolving Ecosystems
 
Testing microservices, contract testing
Testing microservices, contract testingTesting microservices, contract testing
Testing microservices, contract testing
 
Integration testing with PACT
Integration testing with PACTIntegration testing with PACT
Integration testing with PACT
 
Acceptance test driven development
Acceptance test driven developmentAcceptance test driven development
Acceptance test driven development
 
Testing Microservices
Testing MicroservicesTesting Microservices
Testing Microservices
 
Performance Testing in the Agile Lifecycle
Performance Testing in the Agile LifecyclePerformance Testing in the Agile Lifecycle
Performance Testing in the Agile Lifecycle
 
Whitepaper : Testing Micro Services Part I & Part 2
Whitepaper : Testing Micro Services Part I & Part 2Whitepaper : Testing Micro Services Part I & Part 2
Whitepaper : Testing Micro Services Part I & Part 2
 
Consumer-Driven Contract Testing With Postman
Consumer-Driven Contract Testing With PostmanConsumer-Driven Contract Testing With Postman
Consumer-Driven Contract Testing With Postman
 
Sarah Geisinger - Continious Testing Metrics That Matter.pdf
Sarah Geisinger - Continious Testing Metrics That Matter.pdfSarah Geisinger - Continious Testing Metrics That Matter.pdf
Sarah Geisinger - Continious Testing Metrics That Matter.pdf
 
Testing Strategy To Test A Ticketing Platform
Testing Strategy To Test A Ticketing PlatformTesting Strategy To Test A Ticketing Platform
Testing Strategy To Test A Ticketing Platform
 
Monolithic to Microservices Architecture - STM 6
Monolithic to Microservices Architecture - STM 6Monolithic to Microservices Architecture - STM 6
Monolithic to Microservices Architecture - STM 6
 
INTEGRATION TESTING
INTEGRATION TESTINGINTEGRATION TESTING
INTEGRATION TESTING
 
Introduce Test Harness for Direct To Consumer Solutions.pdf
Introduce Test Harness for Direct To Consumer Solutions.pdfIntroduce Test Harness for Direct To Consumer Solutions.pdf
Introduce Test Harness for Direct To Consumer Solutions.pdf
 
Testing strategies and best practices using MUnit
Testing strategies and best practices using MUnitTesting strategies and best practices using MUnit
Testing strategies and best practices using MUnit
 
Mobile application testing
Mobile application testingMobile application testing
Mobile application testing
 
Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)Unit testing (Exploring the other side as a tester)
Unit testing (Exploring the other side as a tester)
 
8220 sad inquiry
8220 sad inquiry8220 sad inquiry
8220 sad inquiry
 
Test Driven Development – What Works And What Doesn’t
Test Driven Development – What Works And What Doesn’t Test Driven Development – What Works And What Doesn’t
Test Driven Development – What Works And What Doesn’t
 
DevOps Workshop - Addressing Quality Challenges of Highly Complex and Integra...
DevOps Workshop - Addressing Quality Challenges of Highly Complex and Integra...DevOps Workshop - Addressing Quality Challenges of Highly Complex and Integra...
DevOps Workshop - Addressing Quality Challenges of Highly Complex and Integra...
 
Consumer contract testing
Consumer contract testingConsumer contract testing
Consumer contract testing
 

Mehr von Prashant Kalkar

Mehr von Prashant Kalkar (9)

Design principles to modularise a monolith codebase.pptx
Design principles to modularise a monolith codebase.pptxDesign principles to modularise a monolith codebase.pptx
Design principles to modularise a monolith codebase.pptx
 
GDCR 2022.pptx.pdf
GDCR 2022.pptx.pdfGDCR 2022.pptx.pdf
GDCR 2022.pptx.pdf
 
Exploring the flow of network traffic through kubernetes cluster.pptx
Exploring the flow of network traffic through kubernetes cluster.pptxExploring the flow of network traffic through kubernetes cluster.pptx
Exploring the flow of network traffic through kubernetes cluster.pptx
 
Uncover the mysteries of infrastructure as code (iac)!
Uncover the mysteries of infrastructure as code (iac)!Uncover the mysteries of infrastructure as code (iac)!
Uncover the mysteries of infrastructure as code (iac)!
 
AWS ECS workshop
AWS ECS workshopAWS ECS workshop
AWS ECS workshop
 
Immutable infrastructure with Terraform
Immutable infrastructure with TerraformImmutable infrastructure with Terraform
Immutable infrastructure with Terraform
 
Hibernate
HibernateHibernate
Hibernate
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
 

Kürzlich hochgeladen

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Kürzlich hochgeladen (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Microservices testing consumer driven contracts using pact

Hinweis der Redaktion

  1. Agile projects - CI, Auto, In the modern agile testing, essentially all the practices we follow are towards reducing the feedback loop.
  2. Test segregation - having different types of tests at different levels
  3. It is equally important to execute different types of tests at different levels and in the build pipeline Pipeline design lesser execution cost at earlier level
  4. Best of both We are further reducing the feedback loop More tests at unit level, faster and easy to maintain Less end 2 end tests - which are slow, brittle and requires high maintenance
  5. Revisiting the testing terms: Redefine in terms in case of micro-services world.. E.g. what is integration test in a MS world? Do we need any other types of test? Component test which will test one service as a black box Does the system works end-to-end? Which will give me more confidence
  6. Best of both We are further reducing the feedback loop More tests at unit level, faster and easy to maintain Less end 2 end tests - which are slow, brittle and requires high maintenance
  7. Benefits of component tests: Easy to set up No need of dedicated environment Readymade modern framework support e.g springboot, spring
  8. Benefits of component tests: Easy to set up No need of dedicated environment Readymade modern framework support e.g springboot, spring
  9. Setup cost
  10. Define the consumer, provider. Contractors created from consumers point of view. Owned by consumers. Provider has to fulfill those contracts.
  11. Clear the target folders mvn clean install Will generate the PACT files under target folder
  12. WSDL Postal’s Law: Be conservative in what you send, be liberal in what you accept