Testing in the 21st CenturyAs Unicorns
Alex SotoRed Hat Engineer@alexsotob
@alexsotob2
Alex Soto
Red Hat Engineer
www.lordofthejars.com
@alexsotob
Who Am I?
@alexsotob3
https://www.manning.com/books/testing-java-microservices
S O F T WA R E I S E AT I N G T H E W O R L D
@alexsotob5
@alexsotob6
@alexsotob7
“With great power, there must also come—great responsibility.”
—SPIDERMAN (STAN LEE)
@alexsotob9
@alexsotob10
@alexsotob11
@alexsotob12
Testing
@alexsotob13
Testing Evolution to micro services world
Manual Tests
After Code Automatic
Test
Test First TDD and BDD
Service Virtualization
and CDC
Testing in Production
@alexsotob14
Micro Services architecture
@alexsotob15
Service Virtualization
@alexsotob16
@Mock EmailService email;
Mockito.when(email.receiveBodyMessagesWithSubject("My Subject”)) .thenReturn("This is My Message")
// Test calls
Mockito.verify(email, Mockito.times(1)) .receiveBodyMessagesWithSubject(Matchers.anyString());
@ClassRule public static HoverflyRule hoverflyRule = HoverflyRule.inSimulationMode(SimulationSource.dsl( service("api.flight.com") .get("/api/bookings/1") .willReturn(success("{\"bookingId\":\"1\"\}", "application/json")) ));
// Test calls
hoverfly.verify( service(matches("*.flight.*")) .get("/api/bookings") .anyQueryParams());
Record Method Expectation
Verify Method Called
Record Service Expectation
Verify Service Called
@alexsotob17
Contract Tests
@alexsotob18
Consumer
request
response Stub Server
expectations
Provider
request
response
Result
Define Consumer Expectations Verify Expectations On Provider
@alexsotob19
We are on Production
@alexsotob20
Shit! We break Production Environment
@alexsotob21
Blue-Green Deployments
Starts with a “git commit and git push”
Blue/Green Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
BUILDSCM
Blue/Green Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
BUILDSCM
Blue/Green Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
BUILDSCM
Blue/Green Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
BUILDSCM
Blue/Green Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
BUILDSCM
Blue/Green Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Blue/Green Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
@alexsotob29
Canary Release
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
Canary Deployment
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
@alexsotob @AndyGeeDe40
Dark Launches
Dark Launches
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
INTERNAL USERS
Dark Launches
DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS
SCM
@alexsotob43
@alexsotob44
@alexsotob45
Business Logic
Centralized Configuration
Distributed Tracing
Service Discovery
Load Balancing
Circuit Breaking
@alexsotob46
NETFLIX Ribbon
Config Server
Java Microservices Platform circa 2016
@alexsotob47
Istio
Java Microservices Platform circa 2018
@alexsotob49
Let’s Wind Down
@alexsotob50
Tests are a Team
@alexsotob51
Secure Your Steps
@alexsotob52
Automate Everything
“Change is the essential process of all of existence.”
—SPOCK