SlideShare a Scribd company logo
1 of 35
Download to read offline
Consumer Driven Contracts
and Your Microservice
Architecture
Marcin Grzejszczak, Pivotal
@mgrzejszczak
Spring Cloud developer at Spring Cloud (Pivotal)
Working mostly on Spring Cloud Sleuth
and Spring Cloud Contract
Automation freak
About me
Twitter: @mgrzejszczak
Blog: http://toomuchcoding.com
Introduction
Demo
Summary
Agenda
● Producer
○ service that exposes an API
● Consumer
○ service that consumes the API of the producer
● Contract
○ agreement between producer and consumer how the API will look like
● Consumer Driven Contracts
○ approach where the consumer drives the changes of the API of the producer
Introduction
● Stub validity & reusability in the integration tests
● Nice API creation
Introduction
What problems are we trying to solve?
Introduction
Typical situation
HTTP
CONSUMER PRODUCER
Introduction
How to write a test for it?
HTTP
CONSUMER PRODUCER
Introduction
Stub validity & reusability
WE’RE ON THE CONSUMER SIDE!!
CONSUMER OWNS THE STUB
DEFINITIONS
Introduction
Stub validity & reusability
Introduction
Stub validity & reusability
10
Introduction
Stub validity & reusability
11
Introduction
Stub validity & reusability
12
Introduction
Stub validity & reusability
13
● My tests fail cause I’m shooting a request at a non existant URL
● I rewrote all my code to work with the new URL
● The unit and integration tests pass
● Now we deploy to an environment
where real integrations will take place...
Introduction
So now what?
Introduction
Ooops...
Stubs that were used in the build phase have nothing to do with the real API!!
Introduction
What went wrong?
HTTP
CONSUMER PRODUCER
TEST
OK
HTTP
CONSUMER PRODUCER
REALITY
WAT?!
● Stubs reside with the consumer
● Consumer controls the stubbing process
● How are you sure that the stubs are valid?
● What if other teams want to reuse those stubs?
Introduction
Stub validity & reusability
● It’s the consumer that uses the API
● Consumers should take part in the creation of the API of the producer
● The producer’s API change should be driven by consumers
Introduction
Nice API creation
Introduction
Nice API creation - no cooperation results
Introduction
Nice API creation - no cooperation results
Demo
Potential answer
Spring Cloud Contract
● Consumer
○ service that gets beer requests
○ has to ask another service if the client can get the beer
● Producer
○ service that checks if the client is old enough to buy beer
● Feature
○ if the user is too young - the beer will not be sold
○ otherwise the beer will be granted
Demo
What are we going to code?
Introduction
What are we going to code?
I’m 22 give me a beer
CONSUMER PRODUCER
There you go!
Can he get the beer?
Yes!
Introduction
What are we going to code?
I’m 17 give me a beer
CONSUMER PRODUCER
Get lost!
Can he get the beer?
No!
Introduction
What are we going to code?
BLACK TERMINAL
BLACK IDE
CONSUMER
WHITE TERMINAL
WHITE IDE
PRODUCER
Demo
DEMO
Summary
Consumer’s offline
work
Consumer Phase 1 Consumer Phase 2
Consumer’s switching
to online
Producer phase
Producer’s
implementing the
feature
Summary
Consumer flow 1
• starts TDD - writes the test for the feature
• clones producer code to change the API locally
• in the cloned producer code converts contracts into stubs and installs
them locally
• in the consumer code turns Stub Runner to offline mode
• configures Stub Runner to download stubs of the producer
• red - green - refactor on the API and tests
• repeats the process until the tests are green and API acceptable
• files a PR to the producer with the contract proposal
Summary
Producer flow
• takes over the PR
• writes the missing implementation that will make the autogenerated tests pass
• merges PR and deploys the JARs with the app and the stubs
Summary
Consumer flow 2
• switches off the Stub Runner’s offline mode once the producer uploads the
stubs
• configure Stub Runner by providing the URL to a repo with stubs
• will have its test broken if the producer makes any breaking changes of the API
With Spring Cloud Contract and Consumer Driven Contracts:
● we’ve created an API that suits the consumer and the producer
● expectations were defined by readable contracts
● expectations were tested against the producer
● producer stubs can be reused by consumers
● starting and setting stubs is fully automated
Summary
Why use Spring Cloud Contract Verifier?
● Possibility to do CDC with messaging
● Clear and easy to use, statically typed DSL
● Automatic generation of tests from the defined Contract
● Stub Runner functionality - the stubs are automatically downloaded at runtime from
Nexus / Artifactory
● Spring Cloud integration - no discovery service is needed for integration tests
● Integration with Cloud Foundry - Stub Runner Boot
● Possibility to keep all contracts in a single repo
Summary
Demo
Spring Cloud Contract repo
Spring Cloud Contract documentation
Spring Cloud Contract Gitter
Producer sample
Client sample
LINKS
Thank you!
Marcin Grzejszczak
Pivotal
mgrzejszczak@pivotal.io
mgrzejszczak

More Related Content

What's hot

Integration testing with PACT
Integration testing with PACTIntegration testing with PACT
Integration testing with PACTKnoldus Inc.
 
Overview of API Management Architectures
Overview of API Management ArchitecturesOverview of API Management Architectures
Overview of API Management ArchitecturesNordic APIs
 
Continuous integration
Continuous integrationContinuous integration
Continuous integrationhugo lu
 
Open API and API Management - Introduction and Comparison of Products: TIBCO ...
Open API and API Management - Introduction and Comparison of Products: TIBCO ...Open API and API Management - Introduction and Comparison of Products: TIBCO ...
Open API and API Management - Introduction and Comparison of Products: TIBCO ...Kai Wähner
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CIOlinData
 
API Management architect presentation
API Management architect presentationAPI Management architect presentation
API Management architect presentationsflynn073
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Lars Thorup
 
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...Red Gate Software
 
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...Edureka!
 
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...apidays
 
Continuous integration
Continuous integrationContinuous integration
Continuous integrationamscanne
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICDKnoldus Inc.
 
Consumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACTConsumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACTVodqaBLR
 
API Best Practices Webinar: Metrics - What to Measure
API Best Practices Webinar:  Metrics - What to MeasureAPI Best Practices Webinar:  Metrics - What to Measure
API Best Practices Webinar: Metrics - What to MeasureApigee | Google Cloud
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github ActionsKnoldus Inc.
 
Git,Github,How to host using Github
Git,Github,How to host using GithubGit,Github,How to host using Github
Git,Github,How to host using GithubSujata Regoti
 
Cloud-based Performance & Web Load Testing
Cloud-based Performance & Web Load TestingCloud-based Performance & Web Load Testing
Cloud-based Performance & Web Load TestingInCycleSoftware
 
DevOps & Security: Here & Now
DevOps & Security: Here & NowDevOps & Security: Here & Now
DevOps & Security: Here & NowCheckmarx
 

What's hot (20)

Integration testing with PACT
Integration testing with PACTIntegration testing with PACT
Integration testing with PACT
 
Salesforce x DevOps 101.pdf
Salesforce x DevOps 101.pdfSalesforce x DevOps 101.pdf
Salesforce x DevOps 101.pdf
 
Overview of API Management Architectures
Overview of API Management ArchitecturesOverview of API Management Architectures
Overview of API Management Architectures
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
 
Open API and API Management - Introduction and Comparison of Products: TIBCO ...
Open API and API Management - Introduction and Comparison of Products: TIBCO ...Open API and API Management - Introduction and Comparison of Products: TIBCO ...
Open API and API Management - Introduction and Comparison of Products: TIBCO ...
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
 
API Management architect presentation
API Management architect presentationAPI Management architect presentation
API Management architect presentation
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
Everything You Need to Know About the 2019 DORA Accelerate State of DevOps Re...
 
CI CD Basics
CI CD BasicsCI CD Basics
CI CD Basics
 
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
 
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
apidays Paris 2022 - API design best practices, Ryan Clifford & Ros Bennis, F...
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICD
 
Consumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACTConsumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACT
 
API Best Practices Webinar: Metrics - What to Measure
API Best Practices Webinar:  Metrics - What to MeasureAPI Best Practices Webinar:  Metrics - What to Measure
API Best Practices Webinar: Metrics - What to Measure
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Git,Github,How to host using Github
Git,Github,How to host using GithubGit,Github,How to host using Github
Git,Github,How to host using Github
 
Cloud-based Performance & Web Load Testing
Cloud-based Performance & Web Load TestingCloud-based Performance & Web Load Testing
Cloud-based Performance & Web Load Testing
 
DevOps & Security: Here & Now
DevOps & Security: Here & NowDevOps & Security: Here & Now
DevOps & Security: Here & Now
 

Viewers also liked

Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG
Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUGConsumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG
Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUGMarcin Grzejszczak
 
Microservices Tracing With Spring Cloud and Zipkin @Szczecin JUG
Microservices Tracing With Spring Cloud and Zipkin @Szczecin JUGMicroservices Tracing With Spring Cloud and Zipkin @Szczecin JUG
Microservices Tracing With Spring Cloud and Zipkin @Szczecin JUGMarcin Grzejszczak
 
Microservices Tracing with Spring Cloud and Zipkin
Microservices Tracing with Spring Cloud and ZipkinMicroservices Tracing with Spring Cloud and Zipkin
Microservices Tracing with Spring Cloud and ZipkinMarcin Grzejszczak
 
Microservices: Consumer Driven Contracts in Practice
Microservices: Consumer Driven Contracts in PracticeMicroservices: Consumer Driven Contracts in Practice
Microservices: Consumer Driven Contracts in PracticeQaiser Mazhar
 
Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)Rob Crowley
 
Microservices Tracing with Spring Cloud and Zipkin (devoxx)
Microservices Tracing with Spring Cloud and Zipkin (devoxx)Microservices Tracing with Spring Cloud and Zipkin (devoxx)
Microservices Tracing with Spring Cloud and Zipkin (devoxx)Marcin Grzejszczak
 
Consumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice ArchitectureConsumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice ArchitectureMarcin Grzejszczak
 
Consumer Driven Contracts for microservices
Consumer Driven Contracts for microservicesConsumer Driven Contracts for microservices
Consumer Driven Contracts for microservicesReshmi Krishna
 
Microservices Tracing With Spring Cloud and Zipkin @CybercomDEV
Microservices Tracing With Spring Cloud and Zipkin @CybercomDEVMicroservices Tracing With Spring Cloud and Zipkin @CybercomDEV
Microservices Tracing With Spring Cloud and Zipkin @CybercomDEVMarcin Grzejszczak
 
Lightening Talk: Auckland Continuous Delivery Meetup [Sept 2014] - Pact: Cons...
Lightening Talk: Auckland Continuous Delivery Meetup [Sept 2014] - Pact: Cons...Lightening Talk: Auckland Continuous Delivery Meetup [Sept 2014] - Pact: Cons...
Lightening Talk: Auckland Continuous Delivery Meetup [Sept 2014] - Pact: Cons...Peter Sellars
 
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...Pierre Vincent
 
Principles of Modern Application Architecture
Principles of Modern Application ArchitecturePrinciples of Modern Application Architecture
Principles of Modern Application ArchitectureRajesh RV
 
How to generate a rest application - DevFest Vienna 2016
How to generate a rest application - DevFest Vienna 2016How to generate a rest application - DevFest Vienna 2016
How to generate a rest application - DevFest Vienna 2016johannes_fiala
 
Swagger 2.0: Latest and Greatest
Swagger 2.0: Latest and GreatestSwagger 2.0: Latest and Greatest
Swagger 2.0: Latest and GreatestLaunchAny
 
Microservices - firststatedot.net - 13-oct-15
Microservices - firststatedot.net - 13-oct-15Microservices - firststatedot.net - 13-oct-15
Microservices - firststatedot.net - 13-oct-15Kevin Buckley
 
MicroProfile Devoxx.us
MicroProfile Devoxx.usMicroProfile Devoxx.us
MicroProfile Devoxx.usjclingan
 
Microservice architecture case study
Microservice architecture case studyMicroservice architecture case study
Microservice architecture case studyRudra Tripathy
 
Java EE Microservices
Java EE MicroservicesJava EE Microservices
Java EE Microservicesjclingan
 

Viewers also liked (20)

Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG
Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUGConsumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG
Consumer Driven Contracts and Your Microservice Architecture @ Warsaw JUG
 
Microservices Tracing With Spring Cloud and Zipkin @Szczecin JUG
Microservices Tracing With Spring Cloud and Zipkin @Szczecin JUGMicroservices Tracing With Spring Cloud and Zipkin @Szczecin JUG
Microservices Tracing With Spring Cloud and Zipkin @Szczecin JUG
 
Microservices Tracing with Spring Cloud and Zipkin
Microservices Tracing with Spring Cloud and ZipkinMicroservices Tracing with Spring Cloud and Zipkin
Microservices Tracing with Spring Cloud and Zipkin
 
Microservices: Consumer Driven Contracts in Practice
Microservices: Consumer Driven Contracts in PracticeMicroservices: Consumer Driven Contracts in Practice
Microservices: Consumer Driven Contracts in Practice
 
Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)Consumer Driven Contracts (DDD Perth 2016)
Consumer Driven Contracts (DDD Perth 2016)
 
Microservices Tracing with Spring Cloud and Zipkin (devoxx)
Microservices Tracing with Spring Cloud and Zipkin (devoxx)Microservices Tracing with Spring Cloud and Zipkin (devoxx)
Microservices Tracing with Spring Cloud and Zipkin (devoxx)
 
Consumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice ArchitectureConsumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice Architecture
 
Consumer Driven Contracts for microservices
Consumer Driven Contracts for microservicesConsumer Driven Contracts for microservices
Consumer Driven Contracts for microservices
 
Microservices Tracing With Spring Cloud and Zipkin @CybercomDEV
Microservices Tracing With Spring Cloud and Zipkin @CybercomDEVMicroservices Tracing With Spring Cloud and Zipkin @CybercomDEV
Microservices Tracing With Spring Cloud and Zipkin @CybercomDEV
 
Lightening Talk: Auckland Continuous Delivery Meetup [Sept 2014] - Pact: Cons...
Lightening Talk: Auckland Continuous Delivery Meetup [Sept 2014] - Pact: Cons...Lightening Talk: Auckland Continuous Delivery Meetup [Sept 2014] - Pact: Cons...
Lightening Talk: Auckland Continuous Delivery Meetup [Sept 2014] - Pact: Cons...
 
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
Consumer-driven contracts: avoid microservices integration hell! (MuCon Londo...
 
Principles of Modern Application Architecture
Principles of Modern Application ArchitecturePrinciples of Modern Application Architecture
Principles of Modern Application Architecture
 
LiveCoding
LiveCodingLiveCoding
LiveCoding
 
How to generate a rest application - DevFest Vienna 2016
How to generate a rest application - DevFest Vienna 2016How to generate a rest application - DevFest Vienna 2016
How to generate a rest application - DevFest Vienna 2016
 
Swagger 2.0: Latest and Greatest
Swagger 2.0: Latest and GreatestSwagger 2.0: Latest and Greatest
Swagger 2.0: Latest and Greatest
 
Microservices - firststatedot.net - 13-oct-15
Microservices - firststatedot.net - 13-oct-15Microservices - firststatedot.net - 13-oct-15
Microservices - firststatedot.net - 13-oct-15
 
MicroProfile Devoxx.us
MicroProfile Devoxx.usMicroProfile Devoxx.us
MicroProfile Devoxx.us
 
Microservice architecture case study
Microservice architecture case studyMicroservice architecture case study
Microservice architecture case study
 
Java EE Microservices
Java EE MicroservicesJava EE Microservices
Java EE Microservices
 
Cloud Security
Cloud Security Cloud Security
Cloud Security
 

Similar to Spring Cloud Contract And Your Microservice Architecture

Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...
Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...
Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...VMware Tanzu
 
Collaborative Contract Driven Development
Collaborative Contract Driven DevelopmentCollaborative Contract Driven Development
Collaborative Contract Driven DevelopmentBilly Korando
 
[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIs
[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIs[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIs
[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIsWSO2
 
Api management best practices with wso2 api manager
Api management best practices with wso2 api managerApi management best practices with wso2 api manager
Api management best practices with wso2 api managerChanaka Fernando
 
Continuous Delivery at Snyk
Continuous Delivery at SnykContinuous Delivery at Snyk
Continuous Delivery at SnykAnton Drukh
 
TDD for Microservices
TDD for MicroservicesTDD for Microservices
TDD for MicroservicesVMware Tanzu
 
Coordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud ContractCoordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud ContractOmri Spector
 
5 Pillars of Building Enterprise0grade APIs
5 Pillars of Building Enterprise0grade APIs5 Pillars of Building Enterprise0grade APIs
5 Pillars of Building Enterprise0grade APIsWSO2
 
API Kompatibilität durch Consumer-Driven Contracts und CI/CD
API Kompatibilität durch Consumer-Driven Contracts und CI/CDAPI Kompatibilität durch Consumer-Driven Contracts und CI/CD
API Kompatibilität durch Consumer-Driven Contracts und CI/CDOPEN KNOWLEDGE GmbH
 
Leveraging Async APIs to deliver cross domain agile collaboration
Leveraging Async APIs to deliver cross domain agile collaboration Leveraging Async APIs to deliver cross domain agile collaboration
Leveraging Async APIs to deliver cross domain agile collaboration Nuwan Dias
 
[apidays Live Australia] Leveraging Async APIs to deliver Cross Domain Agile ...
[apidays Live Australia] Leveraging Async APIs to deliver Cross Domain Agile ...[apidays Live Australia] Leveraging Async APIs to deliver Cross Domain Agile ...
[apidays Live Australia] Leveraging Async APIs to deliver Cross Domain Agile ...WSO2
 
How can Enterprises benefit from GitOps.pdf
How can  Enterprises benefit from GitOps.pdfHow can  Enterprises benefit from GitOps.pdf
How can Enterprises benefit from GitOps.pdfOpsTree solutions
 
Why You Should Be Doing Contract-First API Development
Why You Should Be Doing Contract-First API DevelopmentWhy You Should Be Doing Contract-First API Development
Why You Should Be Doing Contract-First API DevelopmentDevenPhillips
 
Consumer-Driven Contract Testing With Postman
Consumer-Driven Contract Testing With PostmanConsumer-Driven Contract Testing With Postman
Consumer-Driven Contract Testing With PostmanPostman
 
INTERFACE, by apidays - How to Win Friends and Influence People with API First
INTERFACE, by apidays - How to Win Friends and Influence People with API FirstINTERFACE, by apidays - How to Win Friends and Influence People with API First
INTERFACE, by apidays - How to Win Friends and Influence People with API Firstapidays
 
Building an API Factory: Turn your APIs into Products
Building an API Factory: Turn your APIs into ProductsBuilding an API Factory: Turn your APIs into Products
Building an API Factory: Turn your APIs into ProductsNuwan Dias
 
London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023AnuragSharma900
 
How_to_create_modular_microservice_test_projects.pdf
How_to_create_modular_microservice_test_projects.pdfHow_to_create_modular_microservice_test_projects.pdf
How_to_create_modular_microservice_test_projects.pdfskimorod
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileC4Media
 

Similar to Spring Cloud Contract And Your Microservice Architecture (20)

Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...
Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...
Consumer Driven Contracts like TDD to the API - Olga Maciaszek-Sharma & Marci...
 
Collaborative Contract Driven Development
Collaborative Contract Driven DevelopmentCollaborative Contract Driven Development
Collaborative Contract Driven Development
 
[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIs
[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIs[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIs
[WSO2 Integration Summit Bern 2019] Transforming Your Business through APIs
 
Api management best practices with wso2 api manager
Api management best practices with wso2 api managerApi management best practices with wso2 api manager
Api management best practices with wso2 api manager
 
Continuous Delivery at Snyk
Continuous Delivery at SnykContinuous Delivery at Snyk
Continuous Delivery at Snyk
 
TDD for Microservices
TDD for MicroservicesTDD for Microservices
TDD for Microservices
 
Coordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud ContractCoordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud Contract
 
Effective API Design
Effective API DesignEffective API Design
Effective API Design
 
5 Pillars of Building Enterprise0grade APIs
5 Pillars of Building Enterprise0grade APIs5 Pillars of Building Enterprise0grade APIs
5 Pillars of Building Enterprise0grade APIs
 
API Kompatibilität durch Consumer-Driven Contracts und CI/CD
API Kompatibilität durch Consumer-Driven Contracts und CI/CDAPI Kompatibilität durch Consumer-Driven Contracts und CI/CD
API Kompatibilität durch Consumer-Driven Contracts und CI/CD
 
Leveraging Async APIs to deliver cross domain agile collaboration
Leveraging Async APIs to deliver cross domain agile collaboration Leveraging Async APIs to deliver cross domain agile collaboration
Leveraging Async APIs to deliver cross domain agile collaboration
 
[apidays Live Australia] Leveraging Async APIs to deliver Cross Domain Agile ...
[apidays Live Australia] Leveraging Async APIs to deliver Cross Domain Agile ...[apidays Live Australia] Leveraging Async APIs to deliver Cross Domain Agile ...
[apidays Live Australia] Leveraging Async APIs to deliver Cross Domain Agile ...
 
How can Enterprises benefit from GitOps.pdf
How can  Enterprises benefit from GitOps.pdfHow can  Enterprises benefit from GitOps.pdf
How can Enterprises benefit from GitOps.pdf
 
Why You Should Be Doing Contract-First API Development
Why You Should Be Doing Contract-First API DevelopmentWhy You Should Be Doing Contract-First API Development
Why You Should Be Doing Contract-First API Development
 
Consumer-Driven Contract Testing With Postman
Consumer-Driven Contract Testing With PostmanConsumer-Driven Contract Testing With Postman
Consumer-Driven Contract Testing With Postman
 
INTERFACE, by apidays - How to Win Friends and Influence People with API First
INTERFACE, by apidays - How to Win Friends and Influence People with API FirstINTERFACE, by apidays - How to Win Friends and Influence People with API First
INTERFACE, by apidays - How to Win Friends and Influence People with API First
 
Building an API Factory: Turn your APIs into Products
Building an API Factory: Turn your APIs into ProductsBuilding an API Factory: Turn your APIs into Products
Building an API Factory: Turn your APIs into Products
 
London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023London-MuleSoft-Meetup-April-19-2023
London-MuleSoft-Meetup-April-19-2023
 
How_to_create_modular_microservice_test_projects.pdf
How_to_create_modular_microservice_test_projects.pdfHow_to_create_modular_microservice_test_projects.pdf
How_to_create_modular_microservice_test_projects.pdf
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 

More from Marcin Grzejszczak

Consumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice ArchitectureConsumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice ArchitectureMarcin Grzejszczak
 
Continuous Deployment of your Application @jSession#5
Continuous Deployment of your Application @jSession#5Continuous Deployment of your Application @jSession#5
Continuous Deployment of your Application @jSession#5Marcin Grzejszczak
 
Continuous Deployment of your Application @JUGtoberfest
Continuous Deployment of your Application @JUGtoberfestContinuous Deployment of your Application @JUGtoberfest
Continuous Deployment of your Application @JUGtoberfestMarcin Grzejszczak
 
Continuous Deployment To The Cloud @DevoxxPL 2017
Continuous Deployment To The Cloud @DevoxxPL 2017 Continuous Deployment To The Cloud @DevoxxPL 2017
Continuous Deployment To The Cloud @DevoxxPL 2017 Marcin Grzejszczak
 
Continuous Deployment To The Cloud
Continuous Deployment To The CloudContinuous Deployment To The Cloud
Continuous Deployment To The CloudMarcin Grzejszczak
 
Consumer Driven Contracts To Enable API Evolution @Geecon
Consumer Driven Contracts To Enable API Evolution @GeeconConsumer Driven Contracts To Enable API Evolution @Geecon
Consumer Driven Contracts To Enable API Evolution @GeeconMarcin Grzejszczak
 
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...Marcin Grzejszczak
 
Microservices - enough with theory, let's do some code @Geecon Prague 2015
Microservices - enough with theory, let's do some code @Geecon Prague 2015Microservices - enough with theory, let's do some code @Geecon Prague 2015
Microservices - enough with theory, let's do some code @Geecon Prague 2015Marcin Grzejszczak
 
Stick to the rules - Consumer Driven Contracts. 2015.07 Confitura
Stick to the rules - Consumer Driven Contracts. 2015.07 ConfituraStick to the rules - Consumer Driven Contracts. 2015.07 Confitura
Stick to the rules - Consumer Driven Contracts. 2015.07 ConfituraMarcin Grzejszczak
 
Do you think you're doing microservice architecture? What about infrastructur...
Do you think you're doing microservice architecture? What about infrastructur...Do you think you're doing microservice architecture? What about infrastructur...
Do you think you're doing microservice architecture? What about infrastructur...Marcin Grzejszczak
 
Introduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transformsIntroduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transformsMarcin Grzejszczak
 

More from Marcin Grzejszczak (12)

Consumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice ArchitectureConsumer Driven Contracts and Your Microservice Architecture
Consumer Driven Contracts and Your Microservice Architecture
 
Continuous Deployment of your Application @jSession#5
Continuous Deployment of your Application @jSession#5Continuous Deployment of your Application @jSession#5
Continuous Deployment of your Application @jSession#5
 
Continuous Deployment of your Application @JUGtoberfest
Continuous Deployment of your Application @JUGtoberfestContinuous Deployment of your Application @JUGtoberfest
Continuous Deployment of your Application @JUGtoberfest
 
Continuous Deployment To The Cloud @DevoxxPL 2017
Continuous Deployment To The Cloud @DevoxxPL 2017 Continuous Deployment To The Cloud @DevoxxPL 2017
Continuous Deployment To The Cloud @DevoxxPL 2017
 
Continuous Deployment To The Cloud
Continuous Deployment To The CloudContinuous Deployment To The Cloud
Continuous Deployment To The Cloud
 
Consumer Driven Contracts To Enable API Evolution @Geecon
Consumer Driven Contracts To Enable API Evolution @GeeconConsumer Driven Contracts To Enable API Evolution @Geecon
Consumer Driven Contracts To Enable API Evolution @Geecon
 
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
 
Spring Cloud’s Groovy
Spring Cloud’s GroovySpring Cloud’s Groovy
Spring Cloud’s Groovy
 
Microservices - enough with theory, let's do some code @Geecon Prague 2015
Microservices - enough with theory, let's do some code @Geecon Prague 2015Microservices - enough with theory, let's do some code @Geecon Prague 2015
Microservices - enough with theory, let's do some code @Geecon Prague 2015
 
Stick to the rules - Consumer Driven Contracts. 2015.07 Confitura
Stick to the rules - Consumer Driven Contracts. 2015.07 ConfituraStick to the rules - Consumer Driven Contracts. 2015.07 Confitura
Stick to the rules - Consumer Driven Contracts. 2015.07 Confitura
 
Do you think you're doing microservice architecture? What about infrastructur...
Do you think you're doing microservice architecture? What about infrastructur...Do you think you're doing microservice architecture? What about infrastructur...
Do you think you're doing microservice architecture? What about infrastructur...
 
Introduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transformsIntroduction to Groovy runtime metaprogramming and AST transforms
Introduction to Groovy runtime metaprogramming and AST transforms
 

Recently uploaded

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Recently uploaded (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

Spring Cloud Contract And Your Microservice Architecture

  • 1. Consumer Driven Contracts and Your Microservice Architecture Marcin Grzejszczak, Pivotal @mgrzejszczak
  • 2. Spring Cloud developer at Spring Cloud (Pivotal) Working mostly on Spring Cloud Sleuth and Spring Cloud Contract Automation freak About me Twitter: @mgrzejszczak Blog: http://toomuchcoding.com
  • 4. ● Producer ○ service that exposes an API ● Consumer ○ service that consumes the API of the producer ● Contract ○ agreement between producer and consumer how the API will look like ● Consumer Driven Contracts ○ approach where the consumer drives the changes of the API of the producer Introduction
  • 5. ● Stub validity & reusability in the integration tests ● Nice API creation Introduction What problems are we trying to solve?
  • 7. Introduction How to write a test for it? HTTP CONSUMER PRODUCER
  • 8. Introduction Stub validity & reusability WE’RE ON THE CONSUMER SIDE!! CONSUMER OWNS THE STUB DEFINITIONS
  • 14. ● My tests fail cause I’m shooting a request at a non existant URL ● I rewrote all my code to work with the new URL ● The unit and integration tests pass ● Now we deploy to an environment where real integrations will take place... Introduction So now what?
  • 16. Stubs that were used in the build phase have nothing to do with the real API!! Introduction What went wrong? HTTP CONSUMER PRODUCER TEST OK HTTP CONSUMER PRODUCER REALITY WAT?!
  • 17. ● Stubs reside with the consumer ● Consumer controls the stubbing process ● How are you sure that the stubs are valid? ● What if other teams want to reuse those stubs? Introduction Stub validity & reusability
  • 18. ● It’s the consumer that uses the API ● Consumers should take part in the creation of the API of the producer ● The producer’s API change should be driven by consumers Introduction Nice API creation
  • 19. Introduction Nice API creation - no cooperation results
  • 20. Introduction Nice API creation - no cooperation results
  • 22. ● Consumer ○ service that gets beer requests ○ has to ask another service if the client can get the beer ● Producer ○ service that checks if the client is old enough to buy beer ● Feature ○ if the user is too young - the beer will not be sold ○ otherwise the beer will be granted Demo What are we going to code?
  • 23. Introduction What are we going to code? I’m 22 give me a beer CONSUMER PRODUCER There you go! Can he get the beer? Yes!
  • 24. Introduction What are we going to code? I’m 17 give me a beer CONSUMER PRODUCER Get lost! Can he get the beer? No!
  • 25. Introduction What are we going to code? BLACK TERMINAL BLACK IDE CONSUMER WHITE TERMINAL WHITE IDE PRODUCER
  • 27. Summary Consumer’s offline work Consumer Phase 1 Consumer Phase 2 Consumer’s switching to online Producer phase Producer’s implementing the feature
  • 28. Summary Consumer flow 1 • starts TDD - writes the test for the feature • clones producer code to change the API locally • in the cloned producer code converts contracts into stubs and installs them locally • in the consumer code turns Stub Runner to offline mode • configures Stub Runner to download stubs of the producer • red - green - refactor on the API and tests • repeats the process until the tests are green and API acceptable • files a PR to the producer with the contract proposal
  • 29. Summary Producer flow • takes over the PR • writes the missing implementation that will make the autogenerated tests pass • merges PR and deploys the JARs with the app and the stubs
  • 30. Summary Consumer flow 2 • switches off the Stub Runner’s offline mode once the producer uploads the stubs • configure Stub Runner by providing the URL to a repo with stubs • will have its test broken if the producer makes any breaking changes of the API
  • 31. With Spring Cloud Contract and Consumer Driven Contracts: ● we’ve created an API that suits the consumer and the producer ● expectations were defined by readable contracts ● expectations were tested against the producer ● producer stubs can be reused by consumers ● starting and setting stubs is fully automated Summary
  • 32. Why use Spring Cloud Contract Verifier? ● Possibility to do CDC with messaging ● Clear and easy to use, statically typed DSL ● Automatic generation of tests from the defined Contract ● Stub Runner functionality - the stubs are automatically downloaded at runtime from Nexus / Artifactory ● Spring Cloud integration - no discovery service is needed for integration tests ● Integration with Cloud Foundry - Stub Runner Boot ● Possibility to keep all contracts in a single repo Summary
  • 33. Demo
  • 34. Spring Cloud Contract repo Spring Cloud Contract documentation Spring Cloud Contract Gitter Producer sample Client sample LINKS