Deploy Microservices with Confidence
@alexsotob
@alexsotob2
Alex Soto
Red Hat Engineer
www.lordofthejars.com
@alexsotob
Who Am I?
@alexsotob3
https://www.manning.com/books/testing-java-microservices
@alexsotob4
Questions
@alexsotob5
Any resemblance to reality is pure coincidence
@alexsotob @AndyGeeDe6
Micro Services architecture
@alexsotob7
Villains Database Application
Villains Crimes
Give Me Crimes of GruGive Me Information of Gru
@alexsotob8
Villains Database Application
Consumer Producer
GET /crimes/Gru
[{
"name": "Moon",
"villain": "Gru",
"wiki": "/wiki/Moon"
}]
GET /villains/Gru
"name": “Gru”,
"areaOfInfluence": "World"
"crimes": [{
"name": "Moon",
"wiki": "/wiki/Moon"
}]
@alexsotob @AndyGeeDe9
Let’s Go to Production
@alexsotob10
Destroying
Production Deployment
@alexsotob @AndyGeeDe11
Shit! We break Production Environment
@alexsotob12
@alexsotob13
Unit Tests and Mock
@alexsotob
Advantages Disadvantages
Unit Tests (and Mocks)
14
Cheap
No setup of environment
Fast
Mocks
Reliable
All local, no flaky
Not Trustworthy
How you understand the system
Targeted
You know where it failed
@alexsotob15
Integration Tests
@alexsotob
Advantages Disadvantages
Integration Tests
16
Trustworthy
They are real
Not Reliable
May fail for any external reason
Slow
Boot service and dependencies
Become e2e
You easily end up with e2e tests
@alexsotob17
Manual Tests
@alexsotob18
Contract Tests
@alexsotob19
Ownership of the Contracts
@alexsotob
> Provider Contracts
provider centric, consumers adapts all or nothing
> Consumer Contracts
individual consumer’s needs
> Consumer-driven Contracts
representation of a provider's obligations to all its consumers
Ownership
Different Approaches
20
@alexsotob21
Consumer Side
Stub Server
Consumer
Test
Expectations
GET /crimes/Gru
[{"name":...]}
Sharing
Provider Side
Sharing
Test
Provider
GET /crimes/Gru
[{"name":...]}
@alexsotob23
Contract Tests Testing Frameworks
Consumer Driven Contracts
@alexsotob24
> Pact Foundation
Pact specification v3
> Integration with several languages
JVM, Ruby, Python, Go, .Net, Swift, JS
> Pact Broker
Sharing contracts, API documentation, Overview of services
> Arquillian Algeron
Arquillian ecosystem + Pact, Publishers/Retrievers, JBoss Forge
@alexsotob25
Building
With Certainty
@alexsotob26
Deploy with Certainty
@alexsotob
> Execute Build
Publish contracts as artefact version
> Run Head Provider Contract Tests
Check contract compatibility against version contract
> Run Prod Provider Contract Tests
Check contract compatibility against version contract
> Release Consumer
Tag contract with environment name
Deploying Consumer
Steps on CI (Commit Stage)
27
@alexsotob
> Execute Build
Run as usual
> Run Provider Contract Tests
Check contract compatibility against latest contract
> Run Prod Provider Contract Tests
Check contract compatibility against environment contract
> Release Provider
Deploying Provider
Steps on CI (Commit Stage)
28
@alexsotob29
Automate Everything
Enjoy your Vacations
@alexsotob30
Let’s Wind Down
@alexsotob
Conclusions
31
> End To End Tests
Late feedback
Expensive change
Difficult to orchestrate
> Consumer Driven Contracts
Fail fast
Independent deployments
Improve communication
More Info
https://github.com/arquillian-testing-microservices/
https://www.manning.com/books/testing-java-microservices
@alexsotob

Deploy With Confidence