MicroservicesMicroservices
&&
TestingTesting
MicroservicesMicroservices
&&
PainPain
David Dawson
CEO Simplicity Itself
London Microservices User Group
Founder & Lead
david.dawson@simplicityitself.com
@davidthecoder
What are
Microservices?
Isolation
Aspiration
Microservice
Architecture?
What is
Architecture?
Architecture
vs
Design
Limitless Options
For Design
Only a few
Architectures
What is
Architecture?
Architecture
Is Philosophy
Microservices
Philosophy?
and How It
Ruined the World
Perfection
Plato's
Theory of
Ideal Forms
Plato's
Theory of
Ideal Forms
Where did
this lead?
Where did
this lead?
TODO,
Petra
Perfection
Perfection
is a
LIE
No man ever steps in
the same river twice
No man ever steps in
the same river twice
- Heraclitus
(a long time ago)
- Heraclitus
(a long time ago)
Change
is
Reality
Optimise
for
Change
Stoicism
All done?
What Pains
You?
Testing?
Testing
Microservices
Testing
Microservices
Testing
Aspiration &
Network Isolation
A brief history of
Testing
The Swamp
Of Manual
Testing
xUnit,
“Classical”
TDD
circa 1989..
Aka
Stateist
TDD
What does this
look like?
Code Under
Test
Dep
(Stub?)
Dep
(Stub?)
Code Under
Test
Dep
(Stub?)
Dep
(Stub?)
invoke
Code Under
Test
Dep
(Stub?)
Dep
(Stub?)
assert
correct
response
invoke
Code Under
Test
Dep
(Stub?)
Dep
(Stub?)
assert
correct
response
invoke
algorithmic
Circa 2008-10(ish)
London
School
of TDD
Aka
“Mockist”
TDD
What does this
look like?
Code Under
Test
Dep
(Mock)
Dep
(Mock)
Code Under
Test
Dep
(Mock)
Dep
(Mock)
invoke
Code Under
Test
Dep
(Mock)
Dep
(Mock)
assert
correct
interaction
invoke
Code Under
Test
Dep
(Mock)
Dep
(Mock)
assert
correct
interaction
invoke
communication
Microservices?
Microservice
Design?
Entity Oriented
Microservices
1 * GET /awesome
2 * POST /hello
1 * GET /awesome
2 * POST /hello
Start up Mock Dependencies
Start service under test
Exercise ServiceExercise Service
Verify Mock Interactions
1 * GET /awesome
2 * POST /hello
Client Libraries, then Mock
Pro
Simple, In Process
Con
Doesn't exercise the full
Stack
Protocol Replay
Pro
Simple, In Process
Con
Schema Drift
Not Really a Mock
https://github.com/ozeias/go-vcr
https://relishapp.com/vcr/vcr/docs
http://freeside.co/betamax/
Mock Processes
Pro
Full Stack
Con
Schema Drift
Hard to Orchestrate
The Network Hates You
Remote Control
Set Expectations
Verify Expectations
Making Mock (/ Stub)
Processes
Orchestrating
Docker
Compose
docker-compose.yml
rabbitmq:
image: rabbitmq:3.5.4-management
service-under-test:
build: .
links:
- rabbitmq
test-with-deps:
image: simplicityitself/test-with-deps
links:
- rabbitmq
volumes:
- ./test-results:/app/test-results/
Orchestrating
Docker
Compose
docker-compose.yml
rabbitmq:
image: rabbitmq:3.5.4-management
service-under-test:
build: .
links:
- rabbitmq
test-with-deps:
image: simplicityitself/test-with-deps
links:
- rabbitmq
volumes:
- ./test-results:/app/test-results/
Orchestrating
Docker
Compose
docker-compose.yml
rabbitmq:
image: rabbitmq:3.5.4-management
service-under-test:
build: .
links:
- rabbitmq
test-with-deps:
image: simplicityitself/test-with-deps
links:
- rabbitmq
volumes:
- ./test-results:/app/test-results/
Orchestrating
Docker
Compose
docker-compose.yml
rabbitmq:
image: rabbitmq:3.5.4-management
service-under-test:
build: .
links:
- rabbitmq
test-with-deps:
image: simplicityitself/test-with-deps
links:
- rabbitmq
volumes:
- ./test-results:/app/test-results/
Orchestrating
Docker
Compose
> docker-compose run test-with-deps
> docker-compose stop
> ls test-results/
xunit.xml
Service
Virtualisation
Microservice
Design?
Flow Oriented
Microservices
Events
Order Placed
Events
Order Placed
Payment Taken
Events
Order Placed
Payment Taken
Email Sent
Events
Order Stream Events
Order Stream
Payment Stream
Events
Order Stream
Notification Stream
Payment Stream
Events
Order Stream Events
Order Stream Events
Order Stream Events
Order Stream Events
Order Stream Events
Order Stream Events
An Entity
Order Stream Events
Order
Service
Order Stream Events
Order
Service
Fraud
Service
Order Stream Events
Order
Service
Fraud
Service
Fulfillment
Order Stream
Notification Stream
Payment Stream
Events
Order Stream
Notification Stream
Payment Stream
Order Stream
Notification Stream
Payment Stream
Order Stream
Notification Stream
Payment Stream
Order Stream
Notification Stream
Payment Stream
Order Placed
Payment Taken
Email Sent Email Sent
Dependencies
Dependencies
Order Placed
Payment Taken
Email Sent Email Sent
Dependencies
Order Placed
Order Creation Service
Payment Taken
Payment Processor
Email Sent
Email
Gateway
Email Sent
Email
Gateway
Order Placed
Payment Taken
Email Sent Email Sent
Testing
Order Placed
Testing
Order Placed
Payment Taken
Email Sent Email Sent
A TEST
Testing!
Order Placed
Email Sent
A TEST Mock Payment
Service?
Order Stream
Notification Stream
Payment Stream
Testing!
Order Placed
Payment Taken
Email Sent Email Sent
A TEST
Testing!
Order Placed
Payment Taken
Email Sent Email Sent
A TEST
Set initial event chain state
Run service
Assert event chain end state
Event based test
Event Store
Event Chains (Graph DB is good)
Best for testing system state
mutation (commands)
Event based test
You'll need...
Classical
&
Mockist
For Microservices
Algorithmic
&
Interaction
For Microservices
David Dawson @davidthecoder
Questions?
david.dawson@simplicityitself.com
David Dawson @davidthecoder
Thanks
david.dawson@simplicityitself.com

Microservices Manchester: Testing Microservices: Pain or Opportunity? By David Dawson

Editor's Notes

  • #5 Isolation! Aspiration Evolution Ability to change
  • #7 Dan North Bounded/ Centred Community
  • #13 Not the solution! An approach to solving the problem. Tools to engage the world Sounds familiar.
  • #14 h
  • #15 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #17 Republic The world is a shadow of the real world of forms
  • #18 What's this?
  • #19 What's this?
  • #20 Took plato forms and expanded Generated lists of categories Gave rules for seperation Father of reductionism
  • #21 Petra Ancient city, in southern Jordan Very successful. Use a rock carved, or monolithic, architecture. Around 500 AD, earthquake broke the monolithic aqueducts. City abandoned.
  • #22 Petra Ancient city, in southern Jordan Very successful. Use a rock carved, or monolithic, architecture. Around 500 AD, earthquake broke the monolithic aqueducts. City abandoned. Catastrophic failure in the face of change, could never be rebuilt.
  • #30 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #32 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #33 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #34 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #35 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #36 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #37 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #38 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #39 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #40 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #41 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #42 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #43 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #44 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #45 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #46 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #47 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #48 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #49 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #50 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #51 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #52 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #53 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #54 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #55 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #56 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #57 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #58 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #59 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #60 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #61 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #62 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #63 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #64 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #65 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #66 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #67 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #68 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #69 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #70 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #71 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #72 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #73 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #74 Ask the audience. One big one.
  • #75 Ask the audience. One big one.
  • #76 Ask the audience. One big one.
  • #77 Ask the audience. One big one.
  • #78 Ask the audience. One big one.
  • #79 Ask the audience. One big one.
  • #80 Ask the audience. One big one.
  • #81 Ask the audience. One big one.
  • #82 Ask the audience. One big one.
  • #83 Ask the audience. One big one.
  • #84 Ask the audience. One big one.
  • #85 Ask the audience. One big one.
  • #86 Ask the audience. One big one.
  • #87 Ask the audience. One big one.
  • #88 Ask the audience. One big one.
  • #89 Ask the audience. One big one.
  • #90 Ask the audience. One big one.
  • #91 Ask the audience. One big one.
  • #92 Ask the audience. One big one.
  • #93 Ask the audience. One big one.
  • #94 Ask the audience. One big one.
  • #95 Ask the audience. One big one.
  • #96 Ask the audience. One big one.
  • #97 Ask the audience. One big one.
  • #98 Ask the audience. One big one.
  • #99 Ask the audience. One big one.
  • #100 Ask the audience. One big one.
  • #101 Ask the audience. One big one.
  • #102 Ask the audience. One big one.
  • #103 Ask the audience. One big one.
  • #104 Ask the audience. One big one.
  • #105 Isolate an algorithmic, functional piece. More suited to functional style, rather than encapsulated OO/ Entity style
  • #106 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #107 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #108 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #109 Some say XXX This is what we are going to discuss! Understand a man by walking in his shoes
  • #110 TALK TO MUNIB!
  • #111 TALK TO MUNIB!