Microservices Pain: Testing
-
Upload
david-dawson -
Category
Software
-
view
723 -
download
1
Transcript of Microservices Pain: Testing
Microservices
&
Pain
David Dawson
CEO GoMicro.Services
London Microservices User Group
Founder & Lead
[email protected]
@davidthecoder
What are Microservices?
Isolation!
AspirationEvolutionAbility to change
Isolation
Aspiration
Dan North
Bounded/ Centred Community
Microservice Architecture?
What is Architecture?
ArchitecturevsDesign
Limitless OptionsFor Design
Only a few Architectures
What is Architecture?
Not the solution!
An approach to solving the problem.
Tools to engage the world
Sounds familiar.
ArchitectureIs Philosophy
h
MicroservicesPhilosophy
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
All done?
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
What Pains You?
Testing?
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Testing Microservices
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Testing Microservices
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Testing
Aspiration & Network Isolation
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
A brief history of
Testing
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
The SwampOf Manual Testing
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
xUnit, ClassicalTDD
circa 1989..
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
AkaStateistTDD
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
What does this look like?
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Code UnderTestDep(Stub?)Dep(Stub?)
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Code UnderTestDep(Stub?)Dep(Stub?)
invoke
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Code UnderTestDep(Stub?)Dep(Stub?)
assertcorrectresponse
invoke
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Code UnderTestDep(Stub?)Dep(Stub?)
assertcorrectresponse
invoke
algorithmic
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Circa 2008-10(ish)
London Schoolof TDD
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
AkaMockistTDD
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
What does this look like?
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Code UnderTestDep(Mock)Dep(Mock)
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Code UnderTestDep(Mock)Dep(Mock)
invoke
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Code UnderTestDep(Mock)Dep(Mock)
assertcorrectinteraction
invoke
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Code UnderTestDep(Mock)Dep(Mock)
assertcorrectinteraction
invoke
communication
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Microservices?
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
MicroserviceDesign?
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Entity OrientedMicroservices
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
1 * GET /awesome
2 * POST /hello
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
1 * GET /awesome
2 * POST /hello
Start up Mock Dependencies
Start service under test
Exercise Service
Exercise Service
Verify Mock Interactions
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
1 * GET /awesome
2 * POST /hello
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Client Libraries, then Mock
Pro
Simple, In Process
Con
Doesn't exercise the fullStack
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Protocol Replay
Pro
Simple, In Process
Con
Schema DriftNot Really a Mock
https://github.com/ozeias/go-vcr
https://relishapp.com/vcr/vcr/docs
http://freeside.co/betamax/
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Mock Processes
Pro
Full Stack
Con
Schema DriftHard to OrchestrateThe Network Hates You
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Remote Control
Set Expectations
Verify Expectations
Making Mock (/ Stub)Processes
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Orchestrating
Docker Compose
docker-compose.yml
rabbitmq: image: rabbitmq:3.5.4-managementservice-under-test: build: . links: - rabbitmqtest-with-deps: image: simplicityitself/test-with-deps links: - rabbitmq volumes: - ./test-results:/app/test-results/
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Orchestrating
Docker Compose
docker-compose.yml
rabbitmq: image: rabbitmq:3.5.4-managementservice-under-test: build: . links: - rabbitmqtest-with-deps: image: simplicityitself/test-with-deps links: - rabbitmq volumes: - ./test-results:/app/test-results/
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Orchestrating
Docker Compose
docker-compose.yml
rabbitmq: image: rabbitmq:3.5.4-managementservice-under-test: build: . links: - rabbitmqtest-with-deps: image: simplicityitself/test-with-deps links: - rabbitmq volumes: - ./test-results:/app/test-results/
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Orchestrating
Docker Compose
docker-compose.yml
rabbitmq: image: rabbitmq:3.5.4-managementservice-under-test: build: . links: - rabbitmqtest-with-deps: image: simplicityitself/test-with-deps links: - rabbitmq volumes: - ./test-results:/app/test-results/
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Orchestrating
Docker Compose
> docker-compose run test-with-deps
> docker-compose stop
> ls test-results/ xunit.xml
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
MicroserviceDesign?
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Flow OrientedMicroservices
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Events
Ask the audience.
One big one.
Order Placed
Events
Ask the audience.
One big one.
Order Placed
Payment Taken
Events
Ask the audience.
One big one.
Order Placed
Payment Taken
Email Sent
Events
Ask the audience.
One big one.
Order Stream
Notification Stream
Payment Stream
Events
Ask the audience.
One big one.
Order Stream
Events
Ask the audience.
One big one.
Order Stream
Events
Ask the audience.
One big one.
Order Stream
Events
Ask the audience.
One big one.
Order Stream
Events
Ask the audience.
One big one.
Order Stream
Events
Ask the audience.
One big one.
Order Stream
Events
An Entity
Ask the audience.
One big one.
Order Stream
Events
OrderService
Ask the audience.
One big one.
Order Stream
Events
OrderService
FraudService
Ask the audience.
One big one.
Order Stream
Events
OrderService
FraudService
Fulfillment
Ask the audience.
One big one.
Order Stream
Notification Stream
Payment Stream
Events
Ask the audience.
One big one.
Order Stream
Notification Stream
Payment Stream
Ask the audience.
One big one.
Order Stream
Notification Stream
Payment Stream
Ask the audience.
One big one.
Order Stream
Notification Stream
Payment Stream
Ask the audience.
One big one.
Order Stream
Notification Stream
Payment Stream
Ask the audience.
One big one.
Ask the audience.
One big one.
Order Placed
Payment Taken
Email Sent
Email Sent
Ask the audience.
One big one.
Dependencies
Ask the audience.
One big one.
Dependencies
Order Placed
Payment Taken
Email Sent
Email Sent
Ask the audience.
One big one.
Dependencies
Order Placed Order Creation Service
Payment Taken Payment Processor
Email Sent Email Gateway
Email Sent Email Gateway
Ask the audience.
One big one.
Order Placed
Payment Taken
Email Sent
Email Sent
Testing
Order Placed
Ask the audience.
One big one.
Testing
Order Placed
Payment Taken
Email Sent
Email Sent
A TEST
Ask the audience.
One big one.
Testing!
Order Placed
Email Sent
A TEST
Mock Payment Service?Ask the audience.
One big one.
Order Stream
Notification Stream
Payment Stream
Ask the audience.
One big one.
Testing!
Order Placed
Payment Taken
Email Sent
Email Sent
A TEST
Ask the audience.
One big one.
Testing!
Order Placed
Payment Taken
Email Sent
Email Sent
Isolate an algorithmic, functional piece.
More suited to functional style, rather than encapsulated OO/ Entity style
Set initial event chain state
Run service
Assert event chain end state
Event based test
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Event Store
Event Chains (Graph DB is good)
Best for testing system state mutation (commands)
Event based testYou'll need...
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Classical & Mockist
For Microservices
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
Algorithmic & Interaction
For Microservices
Some say XXX
This is what we are going to discuss!
Understand a man by walking in his shoes
David Dawson
@davidthecoder
Thanks
TALK TO MUNIB!