SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
Automated Testing in
a World of Interdependence:
Service Virtualisation for the Modern Age
TestWorksConf Workshop, 7th October
Benji Hooper, Daniel Bryant, John Davenport, Tom Cunliffe
About Specto Workshops
• This slide deck is an excerpt from a workshop delivered as part of the
test automation TestWorksConf
• http://testworksconf.com/talk/automated-testing-in-a-world-of-interdependence
• The Specto team run public and private workshops (contact@specto.io)
• All aspects of test automation
• Microservice testing and service virtualisation with Hoverfly
• Incorporating FR / NFR testing into a build pipeline
Testing is kind of important.
Knight Capital, 2012
$440m loss
Neiman Marcus, Black Friday 2015
IPO cancelled
Stock trading disruption
12 hour outage
Royal Bank of Scotland, 2012
Transactions disrupted worldwide
£500m in fines and
compensation
OK - very important.
In any complex distributed system…
… testing an individual
component in isolation
is difficult….
… and test automation is
sometimes impossible
Agenda
• Group flip-chart sessions (30 minutes)
• Introduction to service virtualization (20 minutes)
• Hands-on session (50 minutes)
• Wrap up
Group flip-chart session
• Equal-sized groups:
• 1 facilitator - Edze, Tom, Daniel, Benji and John
• 1 scribe
• 1 presenter
• 30 minutes
• 10-15 minutes: read the scenario & discuss issues
• 4 presentations of 4 minutes - your main issues and solutions
The busy QA / developer’s guide to
service virtualisation
credit to @mogronalol 10
Resources
shopfront
stockmanager
productcatalogue
Payments
Fraud
Cost
credit to @mogronalol 11
credit to @mogronalol 12
Licensing
Consumer
Producer
Consumer
Producer
Third party Cost
credit to @mogronalol 13
Dependency Constraints
Consumer
Producer
Consumer
Producer
credit to @mogronalol 14
Flakey Dependencies
Consumer
Producer
Consumer
Producer
credit to @mogronalol 15
Doesn't exist
Consumer
?
credit to @mogronalol 16
Non Deterministic
assertThat(booking.getDate())
.isEqualTo(LocalDate.of(2013,1,8));
Consumer
Booking
Service
Consumer
Booking
Service
Consumer
Booking
Service {
“date” : “2013-01-08”,
…
}
{
“date” : “2016-02-07”,
…
}
credit to @mogronalol 17
Fault Injection
Consumer
Producer
Consumer
Producer
4xx, 5xx, timeouts
Operationally
challenging to trigger
faults
credit to @mogronalol 18
Service Virtualisation
• Emulation of real service
• Non-intrusive
• Lightweight - or should be
credit to @mogronalol 19
Service Virtualisation
Consumer Producer
Virtual
Producer
credit to @mogronalol 20
Creating Data
Consumer Producer
Service
Virtualisation
Tool
credit to @mogronalol 21
Creating Data
https://github.com/tomakehurst/wiremock
credit to @mogronalol 22
Proxy Mode
Consumer Producer
Service
Virtualisation
Tool
credit to @mogronalol 23
Webserver / Facade Mode
Consumer Producer
Service
Virtualisation
Tool
credit to @mogronalol 24
Not Mocking
Service Under Test
Mocking
Dependant Service
Http
Virtual Service
Mocks bleed into the
architectural boundary of
your application
credit to @mogronalol 25
Open Source Tooling
credit to @mogronalol 26
Record and replay
Consumer
External
Producer
Service
Virtualisati
on Tool
credit to @mogronalol 27
JUnit Example
@Rule
public HoverflyRule hoverflyRule = HoverflyRule.inCaptureMode(“src/test/
resources/external.json").build();
@Test

public void shouldBeAbleToRetrieveABooking() throws URISyntaxException {

// Given

final int bookingId = 1;



// When

final Booking booking = bookingServiceGateway.getBooking(bookingId);



// Then

assertThat(booking.getCustomer()).isEqualTo(“Andrew Morgan”);
assertThat(booking.getDate()).isEqualTo(LocalDate.of(2016,3,1));

}
credit to @mogronalol 28
JUnit Example
{

"data": [

{

"request": {

"path": "/api/bookings/1",

"method": "GET",

"destination": "www.my-test.com",

"query": null,

"body": ""

},

"response": {

"status": 200,

"body": “{”customer”:”Andrew Morgan", ”date”:
”2016-03-01”}}}”,

"headers": {

"Content-Type": [

"application/json"

]

}

}

}

]

}
credit to @mogronalol 29
JUnit Example
@Test

public void shouldBeAbleToRetrieveABooking() throws URISyntaxException {

// Given

final int bookingId = 1;



// When

final Booking booking = bookingServiceGateway.getBooking(bookingId);



// Then

assertThat(booking.getCustomer()).isEqualTo(“Andrew Morgan”);
assertThat(booking.getDate()).isEqualTo(LocalDate.of(2016,3,1));

}
@Rule
public HoverflyRule hoverflyRule =
HoverflyRule.buildFromClassPathResource(“external.json").build();
credit to @mogronalol 30
Advantages
• Isolation
• Flaky dependencies
• Rate limiting
• Deterministic
• Licensing
credit to @mogronalol 31
Deployment and Infrastructure
Consumer
External
Producer
Virtual
Service
Internal
Producer
Internal
Producer
Internal
Producer
Virtual
Service
Virtual
Service
Virtual
Service
credit to @mogronalol 32
CLI Example
$ hoverctl start —proxy-port 8080
$ hoverctl import accounts-service-simulation.json
$ hoverctl start —proxy-port 8081
$ hoverctl import payments-service-simulation.json
$ curl http://www.account-service.com/api/v1/accounts/1 —proxy http://
localhost:8080
[{"name":"foo"}]
$ curl http://www.payment-service.com/api/v1/payments/1 -proxy http://
localhost:8081
[{“amount":"£23.27"}]
Hands-on session
• Exercise 1: Explore an application that needs testing
and create the simulations required to test it
independently
• Exercise 2: Test the circuit breakers in an application
using Hoverfly
• Code available:
• https://github.com/benjih/oreilly-docker-java-shopping
• Edze, Tom, Daniel, Benji and John will be around for
help if needed (and feel free to work with others!)
Let’s wrap this up…
If you create simulations of components…
… then individual components can be
tested in isolation.
A simulation of a component behaves
like the real thing…
… it misbehaves like the real thing…
So you can create a realistic, repeatable
test environment…
… and automate all the things.
github.com/SpectoLabs/hoverfly
specto.io/blog
We run public and private training workshops:
contact@specto.io

Weitere ähnliche Inhalte

Ähnlich wie SpectoLabs Xebia TestWorks Conf October 2016

Simulating APIs for Effective Testing: (Micro)Service Virtualisation for the ...
Simulating APIs for Effective Testing: (Micro)Service Virtualisation for the ...Simulating APIs for Effective Testing: (Micro)Service Virtualisation for the ...
Simulating APIs for Effective Testing: (Micro)Service Virtualisation for the ...Andrew Morgan
 
deliver:Agile 2019 "Testing Microservices: From Development to Production
deliver:Agile 2019 "Testing Microservices: From Development to Productiondeliver:Agile 2019 "Testing Microservices: From Development to Production
deliver:Agile 2019 "Testing Microservices: From Development to ProductionDaniel Bryant
 
Continuous Performance Testing
Continuous Performance TestingContinuous Performance Testing
Continuous Performance TestingC4Media
 
IoT Guildford Meetup#27: EU H2020 F-Interop project open call
IoT Guildford Meetup#27: EU H2020 F-Interop project open callIoT Guildford Meetup#27: EU H2020 F-Interop project open call
IoT Guildford Meetup#27: EU H2020 F-Interop project open callMicheleNati
 
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발 [Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발 Yunho Maeng
 
Testing Applications—For the Cloud and in the Cloud
Testing Applications—For the Cloud and in the CloudTesting Applications—For the Cloud and in the Cloud
Testing Applications—For the Cloud and in the CloudTechWell
 
Vertical Slicing Architectures
Vertical Slicing ArchitecturesVertical Slicing Architectures
Vertical Slicing ArchitecturesVictor Rentea
 
'Test Automation in the Cloud' with Jonathon Wright
'Test Automation in the Cloud' with Jonathon Wright'Test Automation in the Cloud' with Jonathon Wright
'Test Automation in the Cloud' with Jonathon WrightTEST Huddle
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsNuno Caneco
 
How to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happyHow to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happyIordanis (Jordan) Giannakakis
 
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...Daniel Bryant
 
Testing strategies in microservices
Testing strategies in microservicesTesting strategies in microservices
Testing strategies in microservicesGeekNightHyderabad
 
Manoj kolhe - Continuous Integration Testing
Manoj kolhe - Continuous Integration TestingManoj kolhe - Continuous Integration Testing
Manoj kolhe - Continuous Integration TestingManoj Kolhe
 
Accelerate Agile Development with Service Virtualization - Czech Test
Accelerate Agile Development with Service Virtualization - Czech TestAccelerate Agile Development with Service Virtualization - Czech Test
Accelerate Agile Development with Service Virtualization - Czech TestParasoft
 
Dynatrace - Red Hat workshop : Monolith to Microservices
Dynatrace - Red Hat workshop : Monolith to MicroservicesDynatrace - Red Hat workshop : Monolith to Microservices
Dynatrace - Red Hat workshop : Monolith to MicroservicesSteve Caron
 
Tools. Techniques. Trouble?
Tools. Techniques. Trouble?Tools. Techniques. Trouble?
Tools. Techniques. Trouble?Testplant
 
OpenStack Sydney summit - OpenStack HA and Testing
OpenStack Sydney summit - OpenStack HA and TestingOpenStack Sydney summit - OpenStack HA and Testing
OpenStack Sydney summit - OpenStack HA and TestingSampath Priyankara
 
VMworld 2013: Automating the Software Defined Data Center: How Do I Get Started
VMworld 2013: Automating the Software Defined Data Center: How Do I Get Started VMworld 2013: Automating the Software Defined Data Center: How Do I Get Started
VMworld 2013: Automating the Software Defined Data Center: How Do I Get Started VMworld
 

Ähnlich wie SpectoLabs Xebia TestWorks Conf October 2016 (20)

Simulating APIs for Effective Testing: (Micro)Service Virtualisation for the ...
Simulating APIs for Effective Testing: (Micro)Service Virtualisation for the ...Simulating APIs for Effective Testing: (Micro)Service Virtualisation for the ...
Simulating APIs for Effective Testing: (Micro)Service Virtualisation for the ...
 
deliver:Agile 2019 "Testing Microservices: From Development to Production
deliver:Agile 2019 "Testing Microservices: From Development to Productiondeliver:Agile 2019 "Testing Microservices: From Development to Production
deliver:Agile 2019 "Testing Microservices: From Development to Production
 
Continuous Performance Testing
Continuous Performance TestingContinuous Performance Testing
Continuous Performance Testing
 
IoT Guildford Meetup#27: EU H2020 F-Interop project open call
IoT Guildford Meetup#27: EU H2020 F-Interop project open callIoT Guildford Meetup#27: EU H2020 F-Interop project open call
IoT Guildford Meetup#27: EU H2020 F-Interop project open call
 
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발 [Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발
 
Testing Applications—For the Cloud and in the Cloud
Testing Applications—For the Cloud and in the CloudTesting Applications—For the Cloud and in the Cloud
Testing Applications—For the Cloud and in the Cloud
 
Vertical Slicing Architectures
Vertical Slicing ArchitecturesVertical Slicing Architectures
Vertical Slicing Architectures
 
TechTalk: Get to Know Perfecto
TechTalk: Get to Know Perfecto TechTalk: Get to Know Perfecto
TechTalk: Get to Know Perfecto
 
'Test Automation in the Cloud' with Jonathon Wright
'Test Automation in the Cloud' with Jonathon Wright'Test Automation in the Cloud' with Jonathon Wright
'Test Automation in the Cloud' with Jonathon Wright
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystems
 
How to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happyHow to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happy
 
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
 
Microservices in AUTO1 by Alexander Egurtsov
Microservices in AUTO1 by Alexander EgurtsovMicroservices in AUTO1 by Alexander Egurtsov
Microservices in AUTO1 by Alexander Egurtsov
 
Testing strategies in microservices
Testing strategies in microservicesTesting strategies in microservices
Testing strategies in microservices
 
Manoj kolhe - Continuous Integration Testing
Manoj kolhe - Continuous Integration TestingManoj kolhe - Continuous Integration Testing
Manoj kolhe - Continuous Integration Testing
 
Accelerate Agile Development with Service Virtualization - Czech Test
Accelerate Agile Development with Service Virtualization - Czech TestAccelerate Agile Development with Service Virtualization - Czech Test
Accelerate Agile Development with Service Virtualization - Czech Test
 
Dynatrace - Red Hat workshop : Monolith to Microservices
Dynatrace - Red Hat workshop : Monolith to MicroservicesDynatrace - Red Hat workshop : Monolith to Microservices
Dynatrace - Red Hat workshop : Monolith to Microservices
 
Tools. Techniques. Trouble?
Tools. Techniques. Trouble?Tools. Techniques. Trouble?
Tools. Techniques. Trouble?
 
OpenStack Sydney summit - OpenStack HA and Testing
OpenStack Sydney summit - OpenStack HA and TestingOpenStack Sydney summit - OpenStack HA and Testing
OpenStack Sydney summit - OpenStack HA and Testing
 
VMworld 2013: Automating the Software Defined Data Center: How Do I Get Started
VMworld 2013: Automating the Software Defined Data Center: How Do I Get Started VMworld 2013: Automating the Software Defined Data Center: How Do I Get Started
VMworld 2013: Automating the Software Defined Data Center: How Do I Get Started
 

Kürzlich hochgeladen

PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 

Kürzlich hochgeladen (20)

PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 

SpectoLabs Xebia TestWorks Conf October 2016

  • 1. Automated Testing in a World of Interdependence: Service Virtualisation for the Modern Age TestWorksConf Workshop, 7th October Benji Hooper, Daniel Bryant, John Davenport, Tom Cunliffe
  • 2. About Specto Workshops • This slide deck is an excerpt from a workshop delivered as part of the test automation TestWorksConf • http://testworksconf.com/talk/automated-testing-in-a-world-of-interdependence • The Specto team run public and private workshops (contact@specto.io) • All aspects of test automation • Microservice testing and service virtualisation with Hoverfly • Incorporating FR / NFR testing into a build pipeline
  • 3. Testing is kind of important.
  • 4. Knight Capital, 2012 $440m loss Neiman Marcus, Black Friday 2015 IPO cancelled Stock trading disruption 12 hour outage Royal Bank of Scotland, 2012 Transactions disrupted worldwide £500m in fines and compensation
  • 5. OK - very important.
  • 6. In any complex distributed system… … testing an individual component in isolation is difficult…. … and test automation is sometimes impossible
  • 7. Agenda • Group flip-chart sessions (30 minutes) • Introduction to service virtualization (20 minutes) • Hands-on session (50 minutes) • Wrap up
  • 8. Group flip-chart session • Equal-sized groups: • 1 facilitator - Edze, Tom, Daniel, Benji and John • 1 scribe • 1 presenter • 30 minutes • 10-15 minutes: read the scenario & discuss issues • 4 presentations of 4 minutes - your main issues and solutions
  • 9. The busy QA / developer’s guide to service virtualisation
  • 10. credit to @mogronalol 10 Resources shopfront stockmanager productcatalogue Payments Fraud Cost
  • 12. credit to @mogronalol 12 Licensing Consumer Producer Consumer Producer Third party Cost
  • 13. credit to @mogronalol 13 Dependency Constraints Consumer Producer Consumer Producer
  • 14. credit to @mogronalol 14 Flakey Dependencies Consumer Producer Consumer Producer
  • 15. credit to @mogronalol 15 Doesn't exist Consumer ?
  • 16. credit to @mogronalol 16 Non Deterministic assertThat(booking.getDate()) .isEqualTo(LocalDate.of(2013,1,8)); Consumer Booking Service Consumer Booking Service Consumer Booking Service { “date” : “2013-01-08”, … } { “date” : “2016-02-07”, … }
  • 17. credit to @mogronalol 17 Fault Injection Consumer Producer Consumer Producer 4xx, 5xx, timeouts Operationally challenging to trigger faults
  • 18. credit to @mogronalol 18 Service Virtualisation • Emulation of real service • Non-intrusive • Lightweight - or should be
  • 19. credit to @mogronalol 19 Service Virtualisation Consumer Producer Virtual Producer
  • 20. credit to @mogronalol 20 Creating Data Consumer Producer Service Virtualisation Tool
  • 21. credit to @mogronalol 21 Creating Data https://github.com/tomakehurst/wiremock
  • 22. credit to @mogronalol 22 Proxy Mode Consumer Producer Service Virtualisation Tool
  • 23. credit to @mogronalol 23 Webserver / Facade Mode Consumer Producer Service Virtualisation Tool
  • 24. credit to @mogronalol 24 Not Mocking Service Under Test Mocking Dependant Service Http Virtual Service Mocks bleed into the architectural boundary of your application
  • 25. credit to @mogronalol 25 Open Source Tooling
  • 26. credit to @mogronalol 26 Record and replay Consumer External Producer Service Virtualisati on Tool
  • 27. credit to @mogronalol 27 JUnit Example @Rule public HoverflyRule hoverflyRule = HoverflyRule.inCaptureMode(“src/test/ resources/external.json").build(); @Test
 public void shouldBeAbleToRetrieveABooking() throws URISyntaxException {
 // Given
 final int bookingId = 1;
 
 // When
 final Booking booking = bookingServiceGateway.getBooking(bookingId);
 
 // Then
 assertThat(booking.getCustomer()).isEqualTo(“Andrew Morgan”); assertThat(booking.getDate()).isEqualTo(LocalDate.of(2016,3,1));
 }
  • 28. credit to @mogronalol 28 JUnit Example {
 "data": [
 {
 "request": {
 "path": "/api/bookings/1",
 "method": "GET",
 "destination": "www.my-test.com",
 "query": null,
 "body": ""
 },
 "response": {
 "status": 200,
 "body": “{”customer”:”Andrew Morgan", ”date”: ”2016-03-01”}}}”,
 "headers": {
 "Content-Type": [
 "application/json"
 ]
 }
 }
 }
 ]
 }
  • 29. credit to @mogronalol 29 JUnit Example @Test
 public void shouldBeAbleToRetrieveABooking() throws URISyntaxException {
 // Given
 final int bookingId = 1;
 
 // When
 final Booking booking = bookingServiceGateway.getBooking(bookingId);
 
 // Then
 assertThat(booking.getCustomer()).isEqualTo(“Andrew Morgan”); assertThat(booking.getDate()).isEqualTo(LocalDate.of(2016,3,1));
 } @Rule public HoverflyRule hoverflyRule = HoverflyRule.buildFromClassPathResource(“external.json").build();
  • 30. credit to @mogronalol 30 Advantages • Isolation • Flaky dependencies • Rate limiting • Deterministic • Licensing
  • 31. credit to @mogronalol 31 Deployment and Infrastructure Consumer External Producer Virtual Service Internal Producer Internal Producer Internal Producer Virtual Service Virtual Service Virtual Service
  • 32. credit to @mogronalol 32 CLI Example $ hoverctl start —proxy-port 8080 $ hoverctl import accounts-service-simulation.json $ hoverctl start —proxy-port 8081 $ hoverctl import payments-service-simulation.json $ curl http://www.account-service.com/api/v1/accounts/1 —proxy http:// localhost:8080 [{"name":"foo"}] $ curl http://www.payment-service.com/api/v1/payments/1 -proxy http:// localhost:8081 [{“amount":"£23.27"}]
  • 33. Hands-on session • Exercise 1: Explore an application that needs testing and create the simulations required to test it independently • Exercise 2: Test the circuit breakers in an application using Hoverfly • Code available: • https://github.com/benjih/oreilly-docker-java-shopping • Edze, Tom, Daniel, Benji and John will be around for help if needed (and feel free to work with others!)
  • 35. If you create simulations of components… … then individual components can be tested in isolation.
  • 36. A simulation of a component behaves like the real thing… … it misbehaves like the real thing… So you can create a realistic, repeatable test environment… … and automate all the things.
  • 37. github.com/SpectoLabs/hoverfly specto.io/blog We run public and private training workshops: contact@specto.io