SlideShare a Scribd company logo
1 of 37
Consumer Driven
Contracts
Remigiusz Dudek
Software Quality Engineer
Questions
• What problem we’re trying to solve?
• How the problem were solved so far?
• How we want to solve it with CDC?
• What other problems do we introduce?
End-to-end
testing in a
highly
distributed
environment
Deploy all services in
one environment
Automated or
Manual
Production
similarity
Environment
stability
Test analysis
Feedback loop
Environment as
bottleneck
Proper versions
Test isolation
Environment
Maintenance
Manual
Cost (low only in
small scales at
the beginning)
Deploy single service
with mocks
Production
similarity
Environment
Stability
Test analysis
Feedback loop
Environment as
bottleneck
Proper versions
Test isolation
Environment
maintenance
Cost
Testing in
general
https://martinfowler.com/articles/microservice-testing/
Testing in
general
https://martinfowler.com/articles/microservice-testing/
Consumer
Testing in
general
https://martinfowler.com/articles/microservice-testing/
Client
Producer
How to do it with CDC ?
• Prove that mocks are alike production
• If collaborator behaviour changes all parties should be informed
immediately
• Generate all the boilerplate code
tests
proving
contract
conformance
Stub
Boilerplate
Client
(Consumer)
Server
(Producer)
How?
1. Define problem
2. Define contract
3. Generate STUBs for Client (Consumer)
4. Use STUBs forClient’s tests
5. Generate tests for Server (Producer)
1. Define problem & prepare project
• https://start.spring.io/
• WEB
• Cloud ContractVerifier
• Cloud Contract Stub Runner
Trip Advisor
Hotel Advisor
Car rental
Advisor
Ticket
booking
Advisor
1. Define problem & prepare project
• https://start.spring.io/
• WEB
• Cloud ContractVerifier
• Cloud Contract Stub Runner
Trip Advisor
Hotel Advisor
Car rental
Advisor
Ticket
booking
Advisor
1. Contract dependencies
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-spec</artifactId>
</dependency>
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>1.1.1.RELEASE</version>
<extensions>true</extensions>
</plugin>
1. Contract description
Trip Advisor Hotel Advisor
GET /hotels?location=Krakow
{
"availableHotels": [
{
"id": "779",
"name": "Sheraton",
"address": "Kraków, ul. Jana Nowaka 1”
},
{
"id": "892",
"name": "Novotel",
"address": "Kraków, ul. Długa 5”
}
]
}
1. Contract
• Ignoring contract
• Passing value from file (starting from version
1.2.0)
• Executing method available in base class
• Creating response basing on data from requestContract.make {
ignored()
}
response {
status 200
body (execute("commandName(${fromRequest().body('some/string/path')})"))
headers {
contentType(applicationJson())
}
}
2. Generate STUBs
• Contract verifier plugin
• Generate and run tests
• Create and install STUBs
$> mvn clean install -DskipTests
3. Use STUBs for client tests
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
<scope>test</scope>
</dependency>
</dependencies>@AutoConfigureStubRunner(
ids = {"prv.dudekre:hotels-advisor:0.0.1-SNAPSHOT:stubs:6565"},
stubsPerConsumer = true,
consumerName = „tripAdvisor”,
workOffline = true)
4. Generate tests for Server (Producer)
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>1.1.1.RELEASE</version>
<extensions>true</extensions>
<configuration>
<contractDependency>
<groupId>prv.dudekre.cdc</groupId>
<artifactId>Hotel-advisor-contracts</artifactId>
<classifier>stubs</classifier>
<version>0.0.1-SNAPSHOT</version>
</contractDependency>
<contractsPath>META-INF/prv.dudekre.cdc/Hotel-advisor-contracts</contractsPath>
<contractsWorkOffline>true</contractsWorkOffline>
<baseClassMappings>
<baseClassMapping>
<contractPackageRegex>.*tripAdvisor.*</contractPackageRegex>
<baseClassFQN>prv.dudekre.cdc.contracts.HotelAdvisorBase</baseClassFQN>
</baseClassMapping>
</baseClassMappings>
</configuration>
</plugin>
$> mvn help:describe -Dplugin=org.springframework.cloud:spring-cloud-contract-maven-plugin
Name: Spring Cloud Contract Maven Plugin
Description: Spring Cloud Contract Maven Plugin
Group Id: org.springframework.cloud
Artifact Id: spring-cloud-contract-maven-plugin
Version: 1.1.2.RELEASE
Goal Prefix: spring-cloud-contract
This plugin has 5 goals:
spring-cloud-contract:convert
Convert Spring Cloud Contract Verifier contracts into WireMock stubs mappings.
This goal allows you to generate `stubs-jar` or execute
`spring-cloud-contract:run` with generated WireMock mappings.
spring-cloud-contract:generateStubs
Picks the converted .json files and creates a jar. Requires convert to be
executed first
spring-cloud-contract:generateTests
From the provided directory with contracts generates the acceptance tests on
the producer side
spring-cloud-contract:help
Display help information on spring-cloud-contract-maven-plugin.
Call mvn spring-cloud-contract:help -Ddetail=true -Dgoal=<goal-name> to
display parameter details.
spring-cloud-contract:run
Testing in
general
https://martinfowler.com/articles/microservice-testing/
Client
Producer
4. Generate tests for Server (Producer)
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {ContractTestConfiguration.class})
public abstract class HotelsBase {
@Autowired HotelAdvisorService hotelAdvisorService;
@Before
public void setup() {
RestAssuredMockMvc.standaloneSetup(
new HotelAdvisorController(hotelAdvisorService));
}
}
APIVersioning
• Semantic versioning
• Keep contracts for each version of API
• Consider maven classifiers to mark production/dev versions (mind that it
doesn’t match the original idea behind classifier concept)
• Keep contracts in separate module/repository (different release cycle)
Defer breaking change
• Tolerant reader pattern
• Expand and contract pattern (3 steps to unbreake API change)
• 6 steps to unbreak DB schema change in continous deployment
environment (if you’re not doing continuous deployment you can simplify
the algorithm and have only 5 steps)
Expand and
Contract
From Sam Newman’s book „Building Microservices”
5 steps algorithm
• 0. Service (v1.0) using old data
structure
• 1. Add new data structure (1st
DB change) incompatible with
the old one (omitt constrainsts)
5 steps algorithm
• 2. Deploy new version (v1.1) of
your service reading from old
structure and writing to old and
new
5 steps algorithm
• 3. Migrate all old data to new
structure (2nd DB change) and
add constraints to new data
structure
5 steps algorithm
• 4. Release new version of your
service (v1.2) reading from new
and writing to new data
structure
5 steps algorithm
• 4. Clean old data structures (3rd
DB change)
2 service releases
3 DB changes
6 steps algorithm
• 0. Service (v1.0) using old data
structure
• 1. Deploy new version of your
service (v1.1) marking record
that it created/updated (not
needed if not doing continuous
deployment)
6 steps algorithm
• 2. Add new data structure (1st
DB schema change)
incompatible with the old one
(omitt constrainsts)
6 steps algorithm
• 3. Deploy new version of your service
(1.2) with quite complex (simple if not
doing continuous deployment) data
creation/updating logic:
• Create new data in old and new
structure
• If old data is not marked and new data
does not exist, read from old and write
to old and new
• If old data is not marked and new data
exists, read from new and write to old
and new
• If old data is marked, read from old and
write to old and new and remove marker
6 steps algorithm
• 4. Migrate old data in case when
new data does not exist or old
data is marked and add
constraints to new data
structure
6 steps algorithm
• 5. Deploy new version (1.3) of
your service reading from new
and writing to new data
structure
6 steps algorithm
• 6. Remove old data structure
CDC Advanced
• State-based behaviour (http://wiremock.org/docs/stateful-behaviour/)

More Related Content

What's hot

谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testabilitydrewz lin
 
8\9 SSIS 2008R2_Training - Debugging_Package
8\9 SSIS 2008R2_Training - Debugging_Package8\9 SSIS 2008R2_Training - Debugging_Package
8\9 SSIS 2008R2_Training - Debugging_PackagePramod Singla
 
Qtp With Descriptive Programming
Qtp With Descriptive ProgrammingQtp With Descriptive Programming
Qtp With Descriptive ProgrammingKuldeep Sharma
 
Real-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFReal-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFPaul Stovell
 
Jenkins/Jmeter Configuration - Colombo Performance Test Meetup - 2016 April
Jenkins/Jmeter Configuration - Colombo Performance Test Meetup - 2016 AprilJenkins/Jmeter Configuration - Colombo Performance Test Meetup - 2016 April
Jenkins/Jmeter Configuration - Colombo Performance Test Meetup - 2016 Aprilnmadusanka
 
3.2\9 SSIS 2008R2_Training - ControlFlow Tasks
3.2\9 SSIS 2008R2_Training - ControlFlow Tasks3.2\9 SSIS 2008R2_Training - ControlFlow Tasks
3.2\9 SSIS 2008R2_Training - ControlFlow TasksPramod Singla
 
How to Record Scripts in JMeter? JMeter Script Recording Tutorial | Edureka
How to Record Scripts in JMeter? JMeter Script Recording Tutorial | EdurekaHow to Record Scripts in JMeter? JMeter Script Recording Tutorial | Edureka
How to Record Scripts in JMeter? JMeter Script Recording Tutorial | EdurekaEdureka!
 
Unit testing and MVVM in Silverlight
Unit testing and MVVM in SilverlightUnit testing and MVVM in Silverlight
Unit testing and MVVM in SilverlightDevnology
 
Using Jenkins and Jmeter to build a scalable Load Testing solution
Using Jenkins and Jmeter to build a scalable Load Testing solutionUsing Jenkins and Jmeter to build a scalable Load Testing solution
Using Jenkins and Jmeter to build a scalable Load Testing solutionRuslan Strazhnyk
 
Apache JMeter - A Brief Introduction
Apache JMeter - A Brief IntroductionApache JMeter - A Brief Introduction
Apache JMeter - A Brief Introductionagilitator
 
Performance testing with Apache JMeter
Performance testing with Apache JMeterPerformance testing with Apache JMeter
Performance testing with Apache JMeterRedBlackTree
 
Hp Load Runner Tutorial 1 How Do We Record An Application Using Load Runner
Hp Load Runner Tutorial 1   How Do We Record An Application Using Load RunnerHp Load Runner Tutorial 1   How Do We Record An Application Using Load Runner
Hp Load Runner Tutorial 1 How Do We Record An Application Using Load RunnerYogindernath Gupta
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And MavenPerconaPerformance
 
Jmeter interviewquestions
Jmeter interviewquestionsJmeter interviewquestions
Jmeter interviewquestionsgirichinna27
 
Mo 09 G3 Intez Ali Portfolio
Mo 09 G3 Intez Ali PortfolioMo 09 G3 Intez Ali Portfolio
Mo 09 G3 Intez Ali Portfoliointezali
 
Apache JMeter - A brief introduction
Apache JMeter - A brief introductionApache JMeter - A brief introduction
Apache JMeter - A brief introductionsilenceIT Inc.
 

What's hot (20)

谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability
 
LoadRunner walkthrough
LoadRunner walkthroughLoadRunner walkthrough
LoadRunner walkthrough
 
8\9 SSIS 2008R2_Training - Debugging_Package
8\9 SSIS 2008R2_Training - Debugging_Package8\9 SSIS 2008R2_Training - Debugging_Package
8\9 SSIS 2008R2_Training - Debugging_Package
 
Git course level 2
Git course   level 2Git course   level 2
Git course level 2
 
Qtp With Descriptive Programming
Qtp With Descriptive ProgrammingQtp With Descriptive Programming
Qtp With Descriptive Programming
 
Real-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFReal-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPF
 
Web service testing using QTP (UFT)
Web service testing using QTP (UFT)Web service testing using QTP (UFT)
Web service testing using QTP (UFT)
 
Jenkins/Jmeter Configuration - Colombo Performance Test Meetup - 2016 April
Jenkins/Jmeter Configuration - Colombo Performance Test Meetup - 2016 AprilJenkins/Jmeter Configuration - Colombo Performance Test Meetup - 2016 April
Jenkins/Jmeter Configuration - Colombo Performance Test Meetup - 2016 April
 
3.2\9 SSIS 2008R2_Training - ControlFlow Tasks
3.2\9 SSIS 2008R2_Training - ControlFlow Tasks3.2\9 SSIS 2008R2_Training - ControlFlow Tasks
3.2\9 SSIS 2008R2_Training - ControlFlow Tasks
 
How to Record Scripts in JMeter? JMeter Script Recording Tutorial | Edureka
How to Record Scripts in JMeter? JMeter Script Recording Tutorial | EdurekaHow to Record Scripts in JMeter? JMeter Script Recording Tutorial | Edureka
How to Record Scripts in JMeter? JMeter Script Recording Tutorial | Edureka
 
Unit testing and MVVM in Silverlight
Unit testing and MVVM in SilverlightUnit testing and MVVM in Silverlight
Unit testing and MVVM in Silverlight
 
Using Jenkins and Jmeter to build a scalable Load Testing solution
Using Jenkins and Jmeter to build a scalable Load Testing solutionUsing Jenkins and Jmeter to build a scalable Load Testing solution
Using Jenkins and Jmeter to build a scalable Load Testing solution
 
Apache JMeter - A Brief Introduction
Apache JMeter - A Brief IntroductionApache JMeter - A Brief Introduction
Apache JMeter - A Brief Introduction
 
Performance testing with Apache JMeter
Performance testing with Apache JMeterPerformance testing with Apache JMeter
Performance testing with Apache JMeter
 
Hp Load Runner Tutorial 1 How Do We Record An Application Using Load Runner
Hp Load Runner Tutorial 1   How Do We Record An Application Using Load RunnerHp Load Runner Tutorial 1   How Do We Record An Application Using Load Runner
Hp Load Runner Tutorial 1 How Do We Record An Application Using Load Runner
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
 
Jmeter interviewquestions
Jmeter interviewquestionsJmeter interviewquestions
Jmeter interviewquestions
 
Jmeter Walkthrough
Jmeter WalkthroughJmeter Walkthrough
Jmeter Walkthrough
 
Mo 09 G3 Intez Ali Portfolio
Mo 09 G3 Intez Ali PortfolioMo 09 G3 Intez Ali Portfolio
Mo 09 G3 Intez Ali Portfolio
 
Apache JMeter - A brief introduction
Apache JMeter - A brief introductionApache JMeter - A brief introduction
Apache JMeter - A brief introduction
 

Similar to [TestWarez 2017] Behavior Driven Development in a complex environment - Consumer Driven Contracts

Continuous Deployment of your Application @SpringOne
Continuous Deployment of your Application @SpringOneContinuous Deployment of your Application @SpringOne
Continuous Deployment of your Application @SpringOneciberkleid
 
performancetestingjmeter-121109061704-phpapp02
performancetestingjmeter-121109061704-phpapp02performancetestingjmeter-121109061704-phpapp02
performancetestingjmeter-121109061704-phpapp02Gopi Raghavendra
 
Performancetestingjmeter 121109061704-phpapp02
Performancetestingjmeter 121109061704-phpapp02Performancetestingjmeter 121109061704-phpapp02
Performancetestingjmeter 121109061704-phpapp02Shivakumara .
 
Database Change Management
Database Change Management Database Change Management
Database Change Management headspringlabs
 
Continuous Deployment to the cloud
Continuous Deployment to the cloudContinuous Deployment to the cloud
Continuous Deployment to the cloudVMware Tanzu
 
Expert guidance on migrating from magento 1 to magento 2
Expert guidance on migrating from magento 1 to magento 2Expert guidance on migrating from magento 1 to magento 2
Expert guidance on migrating from magento 1 to magento 2James Cowie
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf
 
Continuous Deployment of your Application @JUGtoberfest
Continuous Deployment of your Application @JUGtoberfestContinuous Deployment of your Application @JUGtoberfest
Continuous Deployment of your Application @JUGtoberfestMarcin Grzejszczak
 
Automated Regression Testing for Embedded Systems in Action
Automated Regression Testing for Embedded Systems in ActionAutomated Regression Testing for Embedded Systems in Action
Automated Regression Testing for Embedded Systems in ActionAANDTech
 
Performance testing and j meter
Performance testing and j meterPerformance testing and j meter
Performance testing and j meterPurna Chandar
 
Performance testing jmeter
Performance testing jmeterPerformance testing jmeter
Performance testing jmeterBhojan Rajan
 
Modernizing SQL Server the Right Way
Modernizing SQL Server the Right WayModernizing SQL Server the Right Way
Modernizing SQL Server the Right WayJuan Fabian
 
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...Simplilearn
 
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
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicDavid Solivan
 
Mercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin SlidesMercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin Slidestelab
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power pointjustmeanscsr
 
ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2onsoftwaretest
 
Django Proposal.pdf
Django Proposal.pdfDjango Proposal.pdf
Django Proposal.pdfdeepak474135
 

Similar to [TestWarez 2017] Behavior Driven Development in a complex environment - Consumer Driven Contracts (20)

Continuous Deployment of your Application @SpringOne
Continuous Deployment of your Application @SpringOneContinuous Deployment of your Application @SpringOne
Continuous Deployment of your Application @SpringOne
 
performancetestingjmeter-121109061704-phpapp02
performancetestingjmeter-121109061704-phpapp02performancetestingjmeter-121109061704-phpapp02
performancetestingjmeter-121109061704-phpapp02
 
Performancetestingjmeter 121109061704-phpapp02
Performancetestingjmeter 121109061704-phpapp02Performancetestingjmeter 121109061704-phpapp02
Performancetestingjmeter 121109061704-phpapp02
 
Database Change Management
Database Change Management Database Change Management
Database Change Management
 
Continuous Deployment to the cloud
Continuous Deployment to the cloudContinuous Deployment to the cloud
Continuous Deployment to the cloud
 
Expert guidance on migrating from magento 1 to magento 2
Expert guidance on migrating from magento 1 to magento 2Expert guidance on migrating from magento 1 to magento 2
Expert guidance on migrating from magento 1 to magento 2
 
Test automation
Test automationTest automation
Test automation
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release Pipelines
 
Continuous Deployment of your Application @JUGtoberfest
Continuous Deployment of your Application @JUGtoberfestContinuous Deployment of your Application @JUGtoberfest
Continuous Deployment of your Application @JUGtoberfest
 
Automated Regression Testing for Embedded Systems in Action
Automated Regression Testing for Embedded Systems in ActionAutomated Regression Testing for Embedded Systems in Action
Automated Regression Testing for Embedded Systems in Action
 
Performance testing and j meter
Performance testing and j meterPerformance testing and j meter
Performance testing and j meter
 
Performance testing jmeter
Performance testing jmeterPerformance testing jmeter
Performance testing jmeter
 
Modernizing SQL Server the Right Way
Modernizing SQL Server the Right WayModernizing SQL Server the Right Way
Modernizing SQL Server the Right Way
 
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
 
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
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs Public
 
Mercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin SlidesMercury Testdirector8.0 Admin Slides
Mercury Testdirector8.0 Admin Slides
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2ISTQB, ISEB Lecture Notes- 2
ISTQB, ISEB Lecture Notes- 2
 
Django Proposal.pdf
Django Proposal.pdfDjango Proposal.pdf
Django Proposal.pdf
 

More from Stowarzyszenie Jakości Systemów Informatycznych (SJSI)

More from Stowarzyszenie Jakości Systemów Informatycznych (SJSI) (20)

Star Trek: BDD Enterprise
Star Trek: BDD EnterpriseStar Trek: BDD Enterprise
Star Trek: BDD Enterprise
 
Model based testing as a BA tool
Model based testing as a BA toolModel based testing as a BA tool
Model based testing as a BA tool
 
Communication - Language of Leader
Communication - Language of LeaderCommunication - Language of Leader
Communication - Language of Leader
 
Miękkie umiejętności w pracy analityka biznesu
Miękkie umiejętności w pracy analityka biznesuMiękkie umiejętności w pracy analityka biznesu
Miękkie umiejętności w pracy analityka biznesu
 
Błędy w analizie z praktyki (nowe wydanie  )
Błędy w analizie z praktyki (nowe wydanie  )Błędy w analizie z praktyki (nowe wydanie  )
Błędy w analizie z praktyki (nowe wydanie  )
 
7 Skills for highly effective teams - workshop
7 Skills for highly effective teams - workshop7 Skills for highly effective teams - workshop
7 Skills for highly effective teams - workshop
 
Dancing with the devil - how to cooperate with a problematic customer
Dancing with the devil - how to cooperate with a problematic customerDancing with the devil - how to cooperate with a problematic customer
Dancing with the devil - how to cooperate with a problematic customer
 
Cosmic truths about software requirements
Cosmic truths about software requirementsCosmic truths about software requirements
Cosmic truths about software requirements
 
Zagraj w zaangażowanie
Zagraj w zaangażowanieZagraj w zaangażowanie
Zagraj w zaangażowanie
 
Analiza prawdziwie biznesowa - skąd biorą się projekty
Analiza prawdziwie biznesowa - skąd biorą się projektyAnaliza prawdziwie biznesowa - skąd biorą się projekty
Analiza prawdziwie biznesowa - skąd biorą się projekty
 
Internet of Things loves data - analysis of Industry 4.0
Internet of Things loves data - analysis of Industry 4.0Internet of Things loves data - analysis of Industry 4.0
Internet of Things loves data - analysis of Industry 4.0
 
Start with Accessibility: Why, How and What
Start with Accessibility: Why, How and WhatStart with Accessibility: Why, How and What
Start with Accessibility: Why, How and What
 
Agile business analyst
Agile business analystAgile business analyst
Agile business analyst
 
Analityk i architekt w czasach automatyzacji i robotyzacji biznesu
Analityk i architekt w czasach automatyzacji i robotyzacji biznesuAnalityk i architekt w czasach automatyzacji i robotyzacji biznesu
Analityk i architekt w czasach automatyzacji i robotyzacji biznesu
 
Jak sprzedać swój pomysł w 5 minut, czyli pitch deck dla BA
Jak sprzedać swój pomysł w 5 minut, czyli pitch deck dla BAJak sprzedać swój pomysł w 5 minut, czyli pitch deck dla BA
Jak sprzedać swój pomysł w 5 minut, czyli pitch deck dla BA
 
7 Skills for highly effective teams
7 Skills for highly effective teams7 Skills for highly effective teams
7 Skills for highly effective teams
 
[TestWarez 2017] Skomplikowane testowanie, skomplikowane terminy. Testowanie ...
[TestWarez 2017] Skomplikowane testowanie, skomplikowane terminy. Testowanie ...[TestWarez 2017] Skomplikowane testowanie, skomplikowane terminy. Testowanie ...
[TestWarez 2017] Skomplikowane testowanie, skomplikowane terminy. Testowanie ...
 
[TestWarez 2017] Przychodzi tester na rozmowę...
[TestWarez 2017] Przychodzi tester na rozmowę...[TestWarez 2017] Przychodzi tester na rozmowę...
[TestWarez 2017] Przychodzi tester na rozmowę...
 
[TestWarez 2017] A proper gun makes testing fun
[TestWarez 2017] A proper gun makes testing fun[TestWarez 2017] A proper gun makes testing fun
[TestWarez 2017] A proper gun makes testing fun
 
[TestWarez 2017] Zen testów wydajnościowych
[TestWarez 2017] Zen testów wydajnościowych[TestWarez 2017] Zen testów wydajnościowych
[TestWarez 2017] Zen testów wydajnościowych
 

Recently uploaded

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 

Recently uploaded (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 

[TestWarez 2017] Behavior Driven Development in a complex environment - Consumer Driven Contracts

  • 2. Questions • What problem we’re trying to solve? • How the problem were solved so far? • How we want to solve it with CDC? • What other problems do we introduce?
  • 4. Deploy all services in one environment Automated or Manual Production similarity Environment stability Test analysis Feedback loop Environment as bottleneck Proper versions Test isolation Environment Maintenance Manual Cost (low only in small scales at the beginning)
  • 5. Deploy single service with mocks Production similarity Environment Stability Test analysis Feedback loop Environment as bottleneck Proper versions Test isolation Environment maintenance Cost
  • 9. How to do it with CDC ? • Prove that mocks are alike production • If collaborator behaviour changes all parties should be informed immediately • Generate all the boilerplate code
  • 11. How? 1. Define problem 2. Define contract 3. Generate STUBs for Client (Consumer) 4. Use STUBs forClient’s tests 5. Generate tests for Server (Producer)
  • 12. 1. Define problem & prepare project • https://start.spring.io/ • WEB • Cloud ContractVerifier • Cloud Contract Stub Runner Trip Advisor Hotel Advisor Car rental Advisor Ticket booking Advisor
  • 13. 1. Define problem & prepare project • https://start.spring.io/ • WEB • Cloud ContractVerifier • Cloud Contract Stub Runner Trip Advisor Hotel Advisor Car rental Advisor Ticket booking Advisor
  • 15. 1. Contract description Trip Advisor Hotel Advisor GET /hotels?location=Krakow { "availableHotels": [ { "id": "779", "name": "Sheraton", "address": "Kraków, ul. Jana Nowaka 1” }, { "id": "892", "name": "Novotel", "address": "Kraków, ul. Długa 5” } ] }
  • 16. 1. Contract • Ignoring contract • Passing value from file (starting from version 1.2.0) • Executing method available in base class • Creating response basing on data from requestContract.make { ignored() } response { status 200 body (execute("commandName(${fromRequest().body('some/string/path')})")) headers { contentType(applicationJson()) } }
  • 17. 2. Generate STUBs • Contract verifier plugin • Generate and run tests • Create and install STUBs $> mvn clean install -DskipTests
  • 18. 3. Use STUBs for client tests <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-contract-stub-runner</artifactId> <scope>test</scope> </dependency> </dependencies>@AutoConfigureStubRunner( ids = {"prv.dudekre:hotels-advisor:0.0.1-SNAPSHOT:stubs:6565"}, stubsPerConsumer = true, consumerName = „tripAdvisor”, workOffline = true)
  • 19. 4. Generate tests for Server (Producer) <plugin> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-contract-maven-plugin</artifactId> <version>1.1.1.RELEASE</version> <extensions>true</extensions> <configuration> <contractDependency> <groupId>prv.dudekre.cdc</groupId> <artifactId>Hotel-advisor-contracts</artifactId> <classifier>stubs</classifier> <version>0.0.1-SNAPSHOT</version> </contractDependency> <contractsPath>META-INF/prv.dudekre.cdc/Hotel-advisor-contracts</contractsPath> <contractsWorkOffline>true</contractsWorkOffline> <baseClassMappings> <baseClassMapping> <contractPackageRegex>.*tripAdvisor.*</contractPackageRegex> <baseClassFQN>prv.dudekre.cdc.contracts.HotelAdvisorBase</baseClassFQN> </baseClassMapping> </baseClassMappings> </configuration> </plugin>
  • 20. $> mvn help:describe -Dplugin=org.springframework.cloud:spring-cloud-contract-maven-plugin Name: Spring Cloud Contract Maven Plugin Description: Spring Cloud Contract Maven Plugin Group Id: org.springframework.cloud Artifact Id: spring-cloud-contract-maven-plugin Version: 1.1.2.RELEASE Goal Prefix: spring-cloud-contract This plugin has 5 goals: spring-cloud-contract:convert Convert Spring Cloud Contract Verifier contracts into WireMock stubs mappings. This goal allows you to generate `stubs-jar` or execute `spring-cloud-contract:run` with generated WireMock mappings. spring-cloud-contract:generateStubs Picks the converted .json files and creates a jar. Requires convert to be executed first spring-cloud-contract:generateTests From the provided directory with contracts generates the acceptance tests on the producer side spring-cloud-contract:help Display help information on spring-cloud-contract-maven-plugin. Call mvn spring-cloud-contract:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. spring-cloud-contract:run
  • 22. 4. Generate tests for Server (Producer) @RunWith(SpringRunner.class) @ContextConfiguration(classes = {ContractTestConfiguration.class}) public abstract class HotelsBase { @Autowired HotelAdvisorService hotelAdvisorService; @Before public void setup() { RestAssuredMockMvc.standaloneSetup( new HotelAdvisorController(hotelAdvisorService)); } }
  • 23. APIVersioning • Semantic versioning • Keep contracts for each version of API • Consider maven classifiers to mark production/dev versions (mind that it doesn’t match the original idea behind classifier concept) • Keep contracts in separate module/repository (different release cycle)
  • 24. Defer breaking change • Tolerant reader pattern • Expand and contract pattern (3 steps to unbreake API change) • 6 steps to unbreak DB schema change in continous deployment environment (if you’re not doing continuous deployment you can simplify the algorithm and have only 5 steps)
  • 25. Expand and Contract From Sam Newman’s book „Building Microservices”
  • 26. 5 steps algorithm • 0. Service (v1.0) using old data structure • 1. Add new data structure (1st DB change) incompatible with the old one (omitt constrainsts)
  • 27. 5 steps algorithm • 2. Deploy new version (v1.1) of your service reading from old structure and writing to old and new
  • 28. 5 steps algorithm • 3. Migrate all old data to new structure (2nd DB change) and add constraints to new data structure
  • 29. 5 steps algorithm • 4. Release new version of your service (v1.2) reading from new and writing to new data structure
  • 30. 5 steps algorithm • 4. Clean old data structures (3rd DB change) 2 service releases 3 DB changes
  • 31. 6 steps algorithm • 0. Service (v1.0) using old data structure • 1. Deploy new version of your service (v1.1) marking record that it created/updated (not needed if not doing continuous deployment)
  • 32. 6 steps algorithm • 2. Add new data structure (1st DB schema change) incompatible with the old one (omitt constrainsts)
  • 33. 6 steps algorithm • 3. Deploy new version of your service (1.2) with quite complex (simple if not doing continuous deployment) data creation/updating logic: • Create new data in old and new structure • If old data is not marked and new data does not exist, read from old and write to old and new • If old data is not marked and new data exists, read from new and write to old and new • If old data is marked, read from old and write to old and new and remove marker
  • 34. 6 steps algorithm • 4. Migrate old data in case when new data does not exist or old data is marked and add constraints to new data structure
  • 35. 6 steps algorithm • 5. Deploy new version (1.3) of your service reading from new and writing to new data structure
  • 36. 6 steps algorithm • 6. Remove old data structure
  • 37. CDC Advanced • State-based behaviour (http://wiremock.org/docs/stateful-behaviour/)

Editor's Notes

  1. Environment stability - usually machines in such test environment are much weaker then in production or much higher burden is put on them - since we have hundreds of services, each is usually deployed independently hence you never know what is trully currently deployed on environment Proper versions - how to ensure that your service is tested against proper versions of other services (the ones that are deployed on prod) in such dynamic environment Environment as a bottleneck - Proper versions – one would have to deploy newest version of his service and ask to freeze the environment for the time of tests - test isolation – one would have to ask other teams no to perform their tests in order not to interfere Test analysis - if a test fails, you don’t really know which service failed, finding root cause is a nightmare
  2. Environment stability - usually machines in such test environment are much weaker then in production or much higher burden is put on them - since we have hundreds of services, each is usually deployed independently hence you never know what is trully currently deployed on environment Proper versions - how to ensure that your service is tested against proper versions of other services (the ones that are deployed on prod) in such dynamic environment Environment as a bottleneck - Proper versions – one would have to deploy newest version of his service and ask to freeze the environment for the time of tests - test isolation – one would have to ask other teams no to perform their tests in order not to interfere Test analysis - if a test fails, you don’t really know which service failed, finding root cause is a nightmare
  3. groupId:artifactId:version:classifier:port If you don’t provide the port then a random one will be picked If you don’t provide the classifier then the default one will be taken. If you don’t provide the version then the + will be passed and the latest one will be downloaded
  4. Configuration used to find a base class for all generated tests. The goal of the base class is to run the server under test.
  5. Classifier - The classifier allows to distinguish artifacts that were built from the same POM but differ in their content