TESTING & 
DEPLOYING 
MICROSERVICES 
Sam Newman 
Flowcon, September 2014 
1
Customer 
Service 
Accounts 
Returns 
Invoicing 
Shipping 
Inventory 
@flowconsf @samnewman
Focused around a business 
domain 
Customer 
Service 
Accounts 
Returns 
Invoicing 
Shipping 
Inventory 
@flowconsf @samnewman
Focused around a business 
domain 
Customer 
Service 
Technology Agnostic API 
Accounts 
Returns 
Invoicing 
Shipping 
Inventory 
@flowconsf @samnewman
Focused around a business 
domain 
Customer 
Service 
Technology Agnostic API 
Small 
Accounts 
Returns 
Invoicing 
Shipping 
Inventory 
@flowconsf @samnewman
Independently 
Releasable 
@flowconsf @samnewman
Testing 
Deployment 
@flowconsf @samnewman
Service 
Host 
@flowconsf @samnewman
Service 
Host 
Service Service 
Service Service 
Host 
VS 
@flowconsf @samnewman
Service 
Host 
Service Service 
Service Service 
Host 
VS 
Much Easier To Reason About 
@flowconsf @samnewman
Service 
Host 
Service Service 
Service Service 
Host 
VS 
Much Easier To Reason About 
Easier To Provision 
@flowconsf @samnewman
Service 
Host 
Service Service 
Service Service 
Host 
VS 
Much Easier To Reason About 
Easier To Provision 
Fewer Side-effects 
@flowconsf @samnewman
Service 
Host 
Service Service 
Service Service 
Host 
VS 
Much Easier To Reason About 
Easier To Provision 
Fewer Side-effects 
Enforces Interdependence 
@flowconsf @samnewman
Service 
Host 
Service Service 
Service Service 
Host 
VS 
Much Easier To Reason About 
Easier To Provision 
Fewer Side-effects 
Lower host-management overhead 
Enforces Interdependence 
@flowconsf @samnewman
Service 
Host 
Service Service 
Service Service 
Host 
VS 
Much Easier To Reason About 
Easier To Provision 
Fewer Side-effects 
Lower host-management overhead 
Cheaper! 
Enforces Interdependence 
@flowconsf @samnewman
Reducing Host 
Management Overhead? 
@flowconsf @samnewman
API-driven Host 
Provisioning 
@flowconsf @samnewman
Virtualisation Platforms 
@flowconsf @samnewman
VMWare 
Virtualisation Platforms 
@flowconsf @samnewman
VMWare 
AWS 
Digital Ocean 
Virtualisation Platforms 
@flowconsf @samnewman
Step 0: 
Provision Host 
@flowconsf @samnewman
Step 0: 
Provision Host 
Step 1: 
Configure Host 
@flowconsf @samnewman
Step 0: 
Provision Host 
Step 1: 
Configure Host 
Step 2: 
Install Service 
@flowconsf @samnewman
Step 0: 
Provision Host 
Step 1: 
Configure Host 
Step 2: 
Install Service 
@flowconsf @samnewman
@flowconsf @samnewman
Ansible 
Puppet 
Chef 
@flowconsf @samnewman
Ansible 
Puppet 
Chef 
@flowconsf @samnewman
Ansible 
Puppet 
Chef 
AWS 
Digital Ocean 
OpenStack 
VMWare 
@flowconsf @samnewman
Ansible 
Puppet 
Chef 
AWS 
Digital Ocean 
OpenStack 
VMWare 
Vagrant 
@flowconsf @samnewman
Immutable Servers 
Ansible 
Puppet 
Chef 
AWS 
Digital Ocean 
OpenStack 
VMWare 
Vagrant 
@flowconsf @samnewman
Immutable Servers 
Fast Spin-up 
Ansible 
Puppet 
Chef 
AWS 
Digital Ocean 
OpenStack 
VMWare 
Vagrant 
@flowconsf @samnewman
Immutable Servers 
Fast Spin-up 
Provider Agnostic 
Ansible 
Puppet 
Chef 
AWS 
Digital Ocean 
OpenStack 
VMWare 
Vagrant 
@flowconsf @samnewman
Immutable Servers 
Fast Spin-up 
Provider Agnostic 
Ansible 
Puppet 
Chef 
AWS 
Digital Ocean 
OpenStack 
VMWare 
Vagrant 
Feedback Can Suffer 
@flowconsf @samnewman
Immutable Servers 
Fast Spin-up 
Provider Agnostic 
Ansible 
Puppet 
Chef 
AWS 
Digital Ocean 
OpenStack 
VMWare 
Vagrant 
Feedback Can Suffer 
Cycle Time 
@flowconsf @samnewman
Immutable Servers 
@flowconsf @samnewman
Cost? 
@flowconsf @samnewman
Apps 
OS 
VM 
Hypervisor 
Base OS 
Machine 
Apps 
OS 
VM 
Apps 
OS 
VM 
@flowconsf @samnewman
Apps 
OS 
VM 
Hypervisor 
Base OS 
Machine 
Apps 
OS 
VM 
Apps 
OS 
VM 
Expensive! 
@flowconsf @samnewman
@flowconsf @samnewman
@flowconsf @samnewman
DOCKER 
@flowconsf @samnewman
DOCKER 
Machine 
@flowconsf @samnewman
DOCKER 
Base OS 
Machine 
@flowconsf @samnewman
DOCKER 
Docker 
Base OS 
Machine 
@flowconsf @samnewman
DOCKER 
Docker 
Base OS 
Machine 
Apps 
@flowconsf @samnewman
DOCKER 
Apps Apps 
Docker 
Base OS 
Machine 
@flowconsf @samnewman
DOCKER 
Apps Apps Apps 
Docker 
Base OS 
Machine 
@flowconsf @samnewman
DOCKER 
Apps Apps Apps 
Docker 
Base OS 
Machine 
Docker Image Registry 
@flowconsf @samnewman
DOCKER 
Apps Apps Apps 
Docker 
Base OS 
Machine 
Docker Image Registry 
@flowconsf @samnewman
DOCKER 
Apps Apps Apps 
Docker 
Base OS 
Machine 
Docker Image Registry 
@flowconsf @samnewman
@flowconsf @samnewman
@flowconsf @samnewman
Semi-permanent Servers 
@flowconsf @samnewman
Semi-permanent Servers 
Image-based Deployments 
@flowconsf @samnewman
Semi-permanent Servers 
Image-based Deployments 
Docker 
@flowconsf @samnewman
Testing 
@flowconsf @samnewman
The Monolith 
DB 
@flowconsf @samnewman
The Monolith 
DB 
@flowconsf @samnewman
The Monolith 
DB 
@flowconsf @samnewman
The Monolith 
DB 
@flowconsf @samnewman
Shipping 
Inventory 
Customer 
Service 
Accounts 
Returns 
Invoicing 
@flowconsf @samnewman
Customer 
Service 
Accounts 
Returns 
Invoicing 
Shipping 
Inventory 
@flowconsf @samnewman
Customer 
Service 
Accounts 
Returns 
Invoicing 
Shipping 
Inventory 
@flowconsf @samnewman
Inventory Accounts 
Mountebank 
http://www.mbtest.org 
@flowconsf @samnewman
Inventory 
Accounts! 
Stub 
Mountebank 
http://www.mbtest.org 
@flowconsf @samnewman
Shipping 
Inventory 
Customer 
Service 
Accounts 
Returns 
Invoicing 
@flowconsf @samnewman
Shipping 
Inventory 
Customer 
Service 
Accounts 
Returns 
Invoicing 
@flowconsf @samnewman
Shipping 
Inventory 
Customer 
Service 
Accounts 
Returns 
Invoicing 
@flowconsf @samnewman
Shipping 
Inventory 
Customer 
Service 
Accounts 
Returns 
Invoicing 
@flowconsf @samnewman
Shipping 
Inventory 
Customer 
Service 
Accounts 
Returns 
Invoicing 
@flowconsf @samnewman
@flowconsf @samnewman
Browsers 
@flowconsf @samnewman
Timing 
Browsers 
@flowconsf @samnewman
Provisioning of Environments 
Timing 
Browsers 
@flowconsf @samnewman
Networks 
Provisioning of Environments 
Timing 
Browsers 
@flowconsf @samnewman
Deployment 
Networks 
Provisioning of Environments 
Timing 
Browsers 
@flowconsf @samnewman
Deployment 
Networks 
Provisioning of Environments 
Timing 
Browsers Diagnosis 
@flowconsf @samnewman
CONSUMER-DRIVEN CONTRACTS 
Shipping Inventory 
@flowconsf @samnewman
CONSUMER-DRIVEN CONTRACTS 
Shipping Inventory 
Expectations 
@flowconsf @samnewman
CONSUMER-DRIVEN CONTRACTS 
Shipping Inventory 
Expectations 
@flowconsf @samnewman
CONSUMER-DRIVEN CONTRACTS 
Shipping Inventory 
Expectations 
Prod 
@flowconsf @samnewman
CONSUMER-DRIVEN CONTRACTS 
Shipping Inventory 
Expectations 
Prod 
@flowconsf @samnewman
@flowconsf @samnewman
https://github.com/realestate-com-au/pact 
@flowconsf @samnewman
No Integration Tests? 
@flowconsf @samnewman
Journeys 
@flowconsf @samnewman
Testing 
@flowconsf @samnewman
Testing 
Build S/M Tests Large Tests 
@flowconsf @samnewman
Testing 
Build S/M Tests Large Tests 
@flowconsf @samnewman
Testing 
Build S/M Tests Large Tests Production 
@flowconsf @samnewman
Testing 
Monitoring & 
Alerting 
Build S/M Tests Large Tests Production 
@flowconsf @samnewman
Testing 
Monitoring & 
Alerting 
Build S/M Tests Large Tests Production 
Testers 
@flowconsf @samnewman
Testing 
Monitoring & 
Alerting 
Build S/M Tests Large Tests Production 
Testers Operations 
@flowconsf @samnewman
Monitoring & 
Alerting Testing 
@flowconsf @samnewman
Prod 
Prod 
Prod 
Prod 
@flowconsf @samnewman
Prod 
Prod 
Prod 
Prod 
QA 
@flowconsf @samnewman
Monitoring & 
Alerting 
Testing 
@flowconsf @samnewman
Monitoring & 
Alerting 
Testing 
@flowconsf @samnewman
Monitoring & 
Alerting 
Testing 
@flowconsf @samnewman
Monitoring & 
Alerting 
Testing 
@flowconsf @samnewman
@flowconsf @samnewman
@flowconsf @samnewman
SEMANTIC MONITORING 
@flowconsf @samnewman
@flowconsf @samnewman 
https://www.flickr.com/photos/robdray/3138644233
Deployment 
Testing 
@flowconsf @samnewman
Deployment 
Testing 
One-server 
per host 
@flowconsf @samnewman
Deployment 
Image/docker 
based artefacts 
Testing 
One-server 
per host 
@flowconsf @samnewman
Deployment 
One-server 
per host Immutable Servers Image/docker 
based artefacts 
Testing 
@flowconsf @samnewman
Deployment 
One-server 
per host Immutable Servers Image/docker 
based artefacts 
Testing 
Pre-Release 
Validation 
Single-server Tests 
Journey Tests 
Consumer-driven Contracts 
@flowconsf @samnewman
Deployment 
One-server 
per host Immutable Servers Image/docker 
based artefacts 
Testing 
Post-Release 
Validation 
Semantic Monitoring 
Pre-Release 
Validation 
Single-server Tests 
Journey Tests 
Consumer-driven Contracts 
@flowconsf @samnewman
37 
Building 
Microservices 
DESIGNING FINE-GRAINED SYSTEMS 
Sam Newman
THANKS! 
Any questions: 
@samnewman 
snewman@thoughtworks.com

Deploying and Testing Microservices