Testing & deploying microservices - XP Days Ukraine 2014

Post on 12-Jul-2015

617 views 1 download

Tags:

Transcript of Testing & deploying microservices - XP Days Ukraine 2014

TESTING & DEPLOYING MICROSERVICESSam Newman XP Days Ukraine, December 2014

1

@samnewman#xpdays

Accounts

Returns

Invoicing

Shipping

Inventory

Customer Service

@samnewman#xpdays

Accounts

Returns

Invoicing

Shipping

Inventory

Customer Service

Small Autonomous services that work together

@samnewman#xpdays

Independently Releasable

@samnewman#xpdays

Testing

Deployment

@samnewman#xpdays

Host

Service

@samnewman#xpdays

Host

Service

Host

Service Service

Service Service

VS

@samnewman#xpdays

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

VS

@samnewman#xpdays

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

VS

@samnewman#xpdays

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

Fewer Side-effects

VS

@samnewman#xpdays

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

Fewer Side-effects

VS

Enforces Interdependence

@samnewman#xpdays

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

Fewer Side-effectsLower host-management overhead

VS

Enforces Interdependence

@samnewman#xpdays

Host

Service

Host

Service Service

Service Service

Much Easier To Reason About

Easier To Provision

Fewer Side-effectsCheaper!

Lower host-management overhead

VS

Enforces Interdependence

@samnewman#xpdays

Reducing Host Management Overhead?

@samnewman#xpdays

API-driven Host Provisioning

@samnewman#xpdays

Virtualisation Platforms

@samnewman#xpdays

VMWare

Virtualisation Platforms

@samnewman#xpdays

VMWareAWS

Digital Ocean

Virtualisation Platforms

@samnewman#xpdays

Step 0: Provision Host

@samnewman#xpdays

Step 0: Provision Host

Step 1: Configure Host

@samnewman#xpdays

Step 0: Provision Host

Step 2: Install Service

Step 1: Configure Host

@samnewman#xpdays

Step 0: Provision Host

Step 2: Install Service

Step 1: Configure Host

@samnewman#xpdays

@samnewman#xpdays

STANDARD VIRTUALISATION

@samnewman#xpdays

Machine

STANDARD VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

STANDARD VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Hypervisor

STANDARD VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Hypervisor

VM

STANDARD VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Hypervisor

VM

OS

STANDARD VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Hypervisor

VM

OS

Apps

STANDARD VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Hypervisor

VM

OS

AppsPacker Image

STANDARD VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Hypervisor

VM

OS

Apps

VM

OS

AppsPacker Image

STANDARD VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Hypervisor

VM

OS

Apps

VM

OS

Apps

VM

OS

AppsPacker Image

STANDARD VIRTUALISATION

@samnewman#xpdays

Ansible

Puppet

Chef

@samnewman#xpdays

Ansible

Puppet

Chef

@samnewman#xpdays

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

@samnewman#xpdays

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

@samnewman#xpdays

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

@samnewman#xpdays

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

Fast Spin-up

@samnewman#xpdays

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

Fast Spin-up

Provider Agnostic

@samnewman#xpdays

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

Fast Spin-up

Provider Agnostic

Feedback Can Suffer

@samnewman#xpdays

Ansible

Puppet

Chef

AWS

Digital Ocean

OpenStack

VMWare

Vagrant

Immutable Servers

Fast Spin-up

Provider Agnostic

Feedback Can Suffer

Cycle Time

@samnewman#xpdays

Immutable Servers

@samnewman#xpdays

Cost?

@samnewman#xpdays

Machine

Base OS

Hypervisor

VM

OS

Apps

VM

OS

Apps

VM

OS

Apps

@samnewman#xpdays

Machine

Base OS

Hypervisor

VM

OS

Apps

VM

OS

Apps

VM

OS

Apps

Expensive!

@samnewman#xpdays

@samnewman#xpdays

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Container

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Container

OS

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Container

OS

Apps

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Container

OS

Apps

Container

OS

Apps

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Container

OS

Apps

Container

OS

Apps

Container

OS

Apps

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Container

OS

Apps

Container

OS

Apps

Container

OS

Apps Linux Only

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Container

OS

Apps

Container

OS

Apps

Container

OS

Apps

Same Kernel

Linux Only

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Container

OS

Apps

Container

OS

Apps

Container

OS

Apps

Same Kernel

Linux OnlyFine-grained control

CONTAINER VIRTUALISATION

@samnewman#xpdays

Machine

Base OS

Container

OS

Apps

Container

OS

Apps

Container

OS

Apps

Same Kernel

Linux OnlyFine-grained control

Very fast to provision

CONTAINER VIRTUALISATION

@samnewman#xpdays

@samnewman#xpdays

DOCKER

@samnewman#xpdays

DOCKER

Machine

@samnewman#xpdays

DOCKER

Machine

Base OS

@samnewman#xpdays

DOCKER

Machine

Base OS

Docker

@samnewman#xpdays

DOCKER

Machine

Base OS

Docker

Apps

@samnewman#xpdays

DOCKER

Machine

Base OS

Docker

Apps Apps

@samnewman#xpdays

DOCKER

Machine

Base OS

Docker

Apps Apps Apps

@samnewman#xpdays

DOCKER

Machine

Base OS

Docker

Apps Apps Apps

Docker Image Registry

@samnewman#xpdays

DOCKER

Machine

Base OS

Docker

Apps Apps Apps

Docker Image Registry

@samnewman#xpdays

DOCKER

Machine

Base OS

Docker

Apps Apps Apps

Docker Image Registry

@samnewman#xpdays

@samnewman#xpdays

@samnewman#xpdays

Semi-permanent Servers

@samnewman#xpdays

Semi-permanent Servers

Image-based Deployments

@samnewman#xpdays

Semi-permanent Servers

Image-based Deployments

Docker

@samnewman#xpdays

@samnewman#xpdays

@samnewman#xpdays

@samnewman#xpdays

kubernetes

@samnewman#xpdays

Testing

@samnewman#xpdays

Unit

Service

UI

MIKE COHN’S TEST PYRAMID

@samnewman#xpdays

Unit

Service

UI

MIKE COHN’S TEST PYRAMID

Increasing Scope

More Confidence

@samnewman#xpdays

Unit

Service

UI

MIKE COHN’S TEST PYRAMID

Increasing Scope

More Confidence

Faster!

Better Isolation

@samnewman#geecon25

DB

Unit

UI

Service

@samnewman#geecon25

DB

Unit

UI

Service

@samnewman#geecon26

DB

Unit

UI

Service

@samnewman#geecon26

DB

Unit

UI

Service

@samnewman#geecon27

DB

Unit

UI

Service

@samnewman#geecon27

DB

Unit

UI

Service

@samnewman#geecon27

DB

Unit

UI

Service

@samnewman#xpdays

InventoryAccounts

Returns

Invoicing

Shipping

Customer Service

@samnewman#xpdays

InventoryAccounts

Returns

Invoicing

Shipping

Customer Service

Inventory

@samnewman#xpdays

InventoryAccounts

Returns

Invoicing

Shipping

Customer Service

Inventory

@samnewman#xpdays

Inventory Accounts

Mountebank http://www.mbtest.org

@samnewman#xpdays

InventoryAccountsStub

Mountebank http://www.mbtest.org

@samnewman#xpdays

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman#xpdays

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman#xpdays

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman#xpdays

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman#xpdays

Shipping

InventoryAccounts

Returns

Invoicing

Customer Service

@samnewman#xpdays

@samnewman#xpdays

Browsers

@samnewman#xpdays

Timing

Browsers

@samnewman#xpdays

Provisioning of Environments

Timing

Browsers

@samnewman#xpdays

Provisioning of Environments

Networks

Timing

Browsers

@samnewman#xpdays

Deployment

Provisioning of Environments

Networks

Timing

Browsers

@samnewman#xpdays

Deployment

Provisioning of Environments

Networks

Timing

Browsers Diagnosis

@samnewman#xpdays

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman#xpdays

Expectations

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman#xpdays

Expectations

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman#xpdays

Expectations

Prod

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman#xpdays

Expectations

Prod

Shipping Inventory

CONSUMER-DRIVEN CONTRACTS

@samnewman#xpdays

@samnewman#xpdays

https://github.com/realestate-com-au/pact

@samnewman#xpdays

No Integration Tests?

@samnewman#xpdays

Journeys

@samnewman#xpdays

Testing

@samnewman#xpdays

Testing

S/M TestsBuild Large Tests

@samnewman#xpdays

Testing

S/M TestsBuild Large Tests

@samnewman#xpdays

Testing

S/M TestsBuild Large Tests Production

@samnewman#xpdays

Testing

S/M TestsBuild Large Tests Production

Monitoring & Alerting

@samnewman#xpdays

Testing

S/M TestsBuild Large Tests Production

Monitoring & Alerting

Testers

@samnewman#xpdays

Testing

S/M TestsBuild Large Tests Production

Monitoring & Alerting

Testers Operations

@samnewman#xpdays

Monitoring & AlertingTesting

@samnewman#xpdays

Prod

Prod

Prod

Prod

@samnewman#xpdays

Prod

Prod

Prod

Prod

QA

@samnewman#xpdays

Monitoring & Alerting

Testing

@samnewman#xpdays

Monitoring & Alerting

Testing

@samnewman#xpdays

Monitoring & Alerting

Testing

@samnewman#xpdays

Monitoring & Alerting

Testing

@samnewman#xpdays

@samnewman#xpdays

@samnewman#xpdays

SEMANTIC MONITORING

@samnewman#xpdayshttps://www.flickr.com/photos/robdray/3138644233

@samnewman#xpdays

Testing

Deployment

@samnewman#xpdays

Testing

Deployment

One-server per host

@samnewman#xpdays

Testing

Deployment

One-server per host

Image/docker based artefacts

@samnewman#xpdays

Testing

Deployment

One-server per host Immutable ServersImage/docker

based artefacts

@samnewman#xpdays

Testing

Pre-Release Validation

Consumer-driven Contracts

Isolated Service Tests

Journey Tests

Deployment

One-server per host Immutable ServersImage/docker

based artefacts

@samnewman#xpdays

Testing

Post-Release Validation

Semantic Monitoring

Pre-Release Validation

Consumer-driven Contracts

Isolated Service Tests

Journey Tests

Deployment

One-server per host Immutable ServersImage/docker

based artefacts

@samnewman#xpdays

Sam Newman

Building MicroservicesDESIGNING FINE-GRAINED SYSTEMS

http://buildingmicroservices.com/

Code: AUTHD

@samnewman#xpdays

http://lanyrd.com/profile/samnewman/

Sam Newman @samnewman

THANKS!