Testing at the boundaries

Using Consumer Driven Contracts to keep your microservices in sync

https://github.com/Fitzoh/testing-at-the-boundaries

Andrew Fitzgerald (@Fitzoh)

Fuse by Cardinal Health

Agenda

how I got here

quick CDC intro

show, don't tell

ok, tell

do it yourself

microservices: lessons learned

:D D:
faster deployments automation required
fits in (human) memory tracing requests
code ownership code duplication
testing testing

testing service to service interactions

stand up the world

mock out dependencies

CDC terms

provider

consumer

contract

consumer driven contracts

Demo!

pact contract

js consumer

spring boot provider

POST username and password to /login

401 + error message for invalid credentials

200 + object w/ token and username for valid credentials

get things working, then see how to safely evolve over time

Common CDC framework features

mock server for consumer tests

generated tests for provider

final artifacts generated by running tests

mechanism for managing contract files

Be conservative in what you do, be liberal in what you accept from others https://en.wikipedia.org/wiki/Robustness_principle

Postel's law

Postel's law illustration

http://martinfowler.com/articles/microservice-testing/#testing-contract-diagram

CDC frameworks

roll your own

"... we want to point out that consumer-driven contract testing is a technique and an attitude that requires no special tool to implement" https://www.thoughtworks.com/radar/techniques/consumer-driven-contract-testing

Pact

"We love frameworks like Pact because they make proper contract tests easier to implement in certain contexts" https://www.thoughtworks.com/radar/techniques/consumer-driven-contract-testing
ruby jvm .net js go swift etc.

pact broker

messaging

multiple languages

Spring Cloud Contract

first class spring support

reusable stubs

service discovery

messaging

https://github.com/Fitzoh/testing-at-the-boundaries

homework

Martin Fowler CDC article

Martin Fowler microservices testing slides

Pact docs

SCC docs

@MGrzejszczak SCC talk

shout outs

Marcin Grzejszczak (SCC maintainer)

Ronald Holshausen (pact-jvm maintainer)