SlideShare une entreprise Scribd logo
1  sur  102
Télécharger pour lire hors ligne
Serverless microservices
Matt Fellows
@matthewfellows
smarter
Test , not harder
2
The new uService
The New Microservice
3
The New Microservice > After
API
External
Events
API
Outside World
Microservice
Interface
API
Master Data
API
Inside bounded context
Event Emitters
API
Materialised view /
cache
Events and
Processing
Data
Event Handlers
Processing
Offline Processing
4
Provisioning
Amazon ML
The New Microservice > After > Example Team 1 Bounded Context
Place Order API
External
Events
Order Status API
Outside World
Internal Events
Microservice
Interface
Data, Events and
Processing
Suggestions API
Publish Event
to external
subscribers
Insights /
Predictions
Customer /
Other Event
Orders
Push API
Inside bounded context
CRM
Materialised view of
customer
Provisioning Event
External
Events
… API
5
Provisioning
The New Microservice > After > Example Team 1 Bounded Context
External
Events
Outside World
Internal Events
Microservice
Interface
Data, Events and
Processing
Publish Event
to external
subscribers
Insights /
Predictions
Place Order API
Customer /
Other Event
Orders
Inside bounded context
Materialised view of
customer
Provisioning Event
CRM
Marketing
Automation
Customer
Support
6
The New Microservice > After > IoT ExampleThe New Microservice > After > Example 2 > IoT Architecture
API Gateway
Sensor A
Sensor B
Sensor C
IoT Rule A
IoT Rule B
IoT Rule C
AWS IoT Core
Sensor Data A
Sensor Data C
Processed Events
Sensor A
Vendor
Device API
Real-time events
Sensor Data B
Analytics
Device Ingest Process Store
8
Testing The New Microservice
How do we test these?
9
Testing The New Microservice > Test Pyramid
https://martinfowler.com/bliki/TestPyramid.html
Testing The New Microservice > Test Pyramid
Mama-mia!
11
Testing The New Microservice > Test Pyramid > Ideal Software Testing Pyramid
https://watirmelon.blog/testing-pyramids/
Don’t forget people - the
ones doing the testing!
Let me make this a bit
clearer for you...
12
Testing The New Microservice > Test Pyramid > Software Testing Trophy
https://kentcdodds.com/blog/write-tests
13
Testing The New Microservice > Test Pyramid > Testing Funnel?
https://medium.com/@copyconstruct/testing-microservices-the-sane-way-9bb31d158c16
14
Testing The New Microservice > Test Pyramid > Round Earth Heuristic
https://www.satisfice.com/blog/archives/4947
Today’s focus
Architecture > Microservices
1. Testability
2. Reduce need for UI / end-to-end testing
3. Observability
Testability
17
Structure
Testability
18
Testability > Lambda Pattern > Ports and Adaptors > Example
Order
Provisioning
Orders CRM
Orders
Testability > Lambda Anti-pattern > Example
MQ Handler
WebSocket
handler
Azure Function
Handler
Google Cloud Fn
Handler
Lambda
Handler
Service
Repository
Port
Adapter
Business Logic Domain Model Collaborators
Testability > Lambda Pattern > Ports and Adaptors
...
Test Harness
Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
Summary
● Separate protocol handling from
business logic
● Business logic shouldn’t change with
introduction of a new protocol
● Enables testability - Port, Adapter and
Business Logic are independently
testable
Testability > Lambda Pattern > Ports and Adaptors > Summary
WHAT WE ARE KNOWN FORTestability > Modularisation
Adapted from https://martinfowler.com/articles/microservice-testing
Adapters
Services
Domain
Repositories
Collaborators
External
Service
Test
modularity
30
How do you test locally?
Testability
WHAT WE ARE KNOWN FOR
31
Options
Testability > Testing Locally
● Use real services
● Stub services (e.g. Localstack)
● Stub SDK (e.g. Moto)
● Local Unit, Integration +
Component tests
32
Testability > Testing Locally
WHAT WE ARE KNOWN FOR
33
Options
● Feature arms race
● Trustworthy?
● Integrated = slower / harder
● All cloud providers?
● Point at the real services
● Stub services (e.g. Localstack)
● Stub SDK (e.g. Moto)
● Local Unit, Integration +
Component tests
Testability > Testing Locally
Challenges
34
Local Integration Test
Testability > Testing Locally
WHAT WE ARE KNOWN FORTestability > Testing Locally
Show me
where?
Adapters
Domain
Repositories
Collaborators
mock
Services
Testability > Testing Locally > Integration Test > Order Service
Look ma, no AWS
Code
Testability > Testing Locally > Integration Test > Order Service
Dependencies
injected
Testability > Testing Locally > Integration Test > Order Service
Look ma, no AWS
Code
Testability > Testing Locally > Integration Test > Order Service
Setup dependencies as
simple interface fakes
Testability > Testing Locally > Integration Test > Order Service
Run the unit under
test
Testability > Testing Locally > Integration Test > Order Service
Assert
42
Local Component Test
Testability > Testing Locally
WHAT WE ARE KNOWN FORTestability > Testing Locally > Component Test > Order Provisioning Service
Show me
where?
Adapters
Services
Domain
Repositories
Collaborators
mock
In-memory database
Testability > Testing Locally > Component Test > Order Provisioning Service
Component test of
handler
Setup dependencies,
inputs and expected
output
Testability > Testing Locally > Component Test > Order Provisioning Service
Testability > Testing Locally > Component Test > Order Provisioning Service
Invoke handler with
kinesis-shaped input
Testability > Testing Locally > Component Test > Order Provisioning Service
Assert the handler
response
Reduce # of e2e tests
Challenges
Integration
● More “white space” - integrations
● Async
○ who is my consumer?
○ delay in feedback
● Third Parties
50
Contract tests
Integration > Contract Tests
Problems with
automated e2e
tests
Integration > Contract Tests > Contracts
● Slow
● Easy to break
● Hard to fix
● Scales badly across teams
● Lots of set up  maintenance
● $$ potentially costly
Integration > Contract Tests > Contracts
Mocks to the rescue?
Integration > Contract Tests > Contracts
Mocks to the rescue?
WHAT WE ARE KNOWN FOR
54
Mocks
Solved problems New problems
● Hard to keep both sides in
sync
● Fast feedback
● Few dependencies
● No dedicated environment
● Reliable
● Easy to debug
Integration > Contract Tests > Contracts
55
Contract
{
“id”: 1234,
“items”:[
...
],
}
Consumer
Provider
Integration > Contract Tests > Contracts
Order API
GET /orders/1234
56
Provisioning
Amazon ML
Integration > Contract Tests > Contracts
Place Order API
External
Events
Order Status API
Outside World
Internal Events
Microservice
Interface
Data, Events and
Processing
Suggestions API
Publish Event
to external
subscribers
Insights /
Predictions
Customer /
Other Event
Orders
Push API
Inside bounded context
CRM
Materialised view of
customer
Provisioning Event
External
Events
… API
57
Provisioning
Amazon ML
Integration > Contract Tests > Contracts Everywhere!
Place Order API
External
Events
Order Status API
Outside World
Internal Events
Microservice
Interface
Data, Events and
Processing
Suggestions API
Publish Event
to external
subscribers
Insights /
Predictions
Customer /
Other Event
Orders
Push API
Inside bounded context
CRM
Materialised view of
customer
Provisioning Event
External
Events
… API
Contract
Contract
Contract
Contract
Contract
Contract
Contract
Contract
Integration > Contract Tests > Contracts
Integration > Contract Tests > Contracts
Mock
Integration > Contract Tests > Contracts
Mock
GET /orders/1234
Integration > Contract Tests > Contracts
Mock
{
“id”: 1234,
“items”:[
...
],
}
GET /orders/1234
Integration > Contract Tests > Contracts
Mock
Integration > Contract Tests > Contracts
Mock
GET /orders/1234
Integration > Contract Tests > Contracts
Mock
{
“id”: 1234,
“items”:[
...
],
}
GET /orders/1234
Integration > Contract Tests > Contracts
Mock ✔
WHAT WE ARE KNOWN FORTestability > Modularisation > Consumer Test
Adapted from https://martinfowler.com/articles/microservice-testing
Adapters
Services
Domain
Repositories
Collaborators
External
Service
Show me
where?
WHAT WE ARE KNOWN FORTestability > Modularisation > Provider Test
Adapted from https://martinfowler.com/articles/microservice-testing
Show me
where?
Adapters
Services
Domain
Repositories
Collaborators
mock
In-memory database
68
Integration > Contract Tests > Contracts
https://martinfowler.com/bliki/TestPyramid.html
Contract
Show me
where?
Bug turnaround -
minutes
Contracts tests
Integration > Contract Tests > Contracts
Know before you
commit
Contracts tests
Integration > Contract Tests > Contracts
Make changes with
speed and confidence
Contracts tests
Integration > Contract Tests > Contracts
Deploy independently
Contracts tests
Integration > Contract Tests > Contracts
Better API design
(Consumer)
Contracts tests
Integration > Contract Tests > Contracts
74
● Open source
● Multiple languages
○ Javascript
○ Go
○ Python
○ JVM
○ .NET
○ + more
pact.io
● HTTP contracts
● Message contracts
● … protocol agnostic!
Integration > Contract Tests > Contracts
75
Contract
{
“id”: 1234,
“items”:[
...
],
}
Consumer
Provider
Integration > Contract Tests > Consumer Contract Test
Order API
GET /orders/1234
Integration > Contract Tests > Contracts > Fetch Order Example
Setup API Host
Integration > Contract Tests > Contracts > Fetch Order Example
Expectations on
Order API made clear
Integration > Contract Tests > Contracts > Fetch Order Example
Expectations on
Order API made clear
Integration > Contract Tests > Contracts > Fetch Order Example
Call the OrderService
+ Assert
Integration > Contract Tests > Contracts > Fetch Order Example
Test state setup
Integration > Contract Tests > Contracts > Fetch Order Example
Test state setup
● Contract tests are faster, easier to
maintain and more reliable than e2e
tests
● Works for both synchronous and async
communication
● Use contract tests to reduce your
end-to-end test reliance
● End-to-end tests closer represent the
user experience
● Contract testing doesn’t replace
functional testing!
Summary
Integration > Contract Tests
Observe the Platform
84
Push responsibility into Platform
Observability
85
Push responsibility into Platform
Observability
86
#1 Log all the things!
Observability
87
#2 Use Middleware
Observability
Handler
Observability > Approach #2 > Middleware
{
"Records": [
{
"EventVersion": "1.0",
"EventSubscriptionArn": "somearn",
"EventSource": "aws:sns",
"Sns": {
...
}
}
]
}
{
"Success": true
}
HandlerHandlerHandler
before after
Request Response
1st middleware
2nd middleware
3rd middleware
Observability > Approach #2 > Middleware
Observability > Approach #2 > Middleware
Observability > Approach #2 > Middleware
92
#3 Push responsibility into Platform
Observability
93
Observability > Approach #1 > IT Ops Automation
Decide
Alarm
Schedule
Notify Pagerduty
Act
Isolate instance from
ASG
Offsite backup
Ship logs to Splunk
Orient
Security Analysis
Application Anomaly /
Canary Detection
Log forwarder
Policy Violation
Observe
Flow Logs
CloudTrail
CloudWatch Logs
Application Event
Configured Rule
Event
subscription
94
Observability > Approach #1 > IT Ops Automation
Decide
Alarm
Act
Ship logs to Splunk
Orient
Log forwarder
Observe
CloudWatch Logs
Event
subscription
WHAT WE ARE KNOWN FOR
95
Examples
● Automatically subscribe log groups and forward to ___
● Allow dynamic DEBUG monitoring (runtime sampling)
● Enable platform tracing (e.g. X-ray, IOPipe, Dashbird)
● Automatically inject correlation IDs
● Anomaly detection
Observability > Approach #1 > IT Ops Automation
● Invest in platform
● Structured + semantic logging is crucial
● Middleware to simplify and template out
specific shaped functions
Summary
Observability > Summary
Wrap it up
Summary
98
Summary
Problems
● Microservices + architecture has evolved
● ...and so must the pyramid!
● More diverse integrations
● More glue, cloud-native code
We’re all digital plumbers!
● Use Ports + Adapters (Hexagonal
architecture) to increase modularity
● Enable better testability and test
modularity
● Mock SDK for local tests
● Component tests can help to reduce
need for e2e tests
There is no single test strategy that will
work for all cases!
Structure...
Summary > Structure
● Contract tests are faster and more
reliable than E2E tests
● Use them to reduce your E2E footprint
● Contract tests enable independent
deployment
● They are not functional tests
Never forget forget the end user!
Reduce E2E...
Summary > Reduce reliance on E2E
● Is the property of understanding a
system as illuminated by its outputs
● Allows us to ask questions
● Helps us discover and respond to
unknown, unknowns
It’s not monitoring, but there is significant
implementation overlap.
Observability...
Summary > Observability
Matt Fellows
@matthewfellows
Serverless microservices
smarter
Pact
@pact_up
@pactflow
slack.pact.io
Test , not harder

Contenu connexe

Tendances

Tendances (20)

Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
 
Cqrs api v2
Cqrs api v2Cqrs api v2
Cqrs api v2
 
gRPC Overview
gRPC OverviewgRPC Overview
gRPC Overview
 
Armeriaworkshop2019 openchat julie
Armeriaworkshop2019 openchat julieArmeriaworkshop2019 openchat julie
Armeriaworkshop2019 openchat julie
 
JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
JFokus: Cubes, Hexagons, Triangles, and More: Understanding MicroservicesJFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
 
Monitoring Microservices
Monitoring MicroservicesMonitoring Microservices
Monitoring Microservices
 
Observability tips for HAProxy
Observability tips for HAProxyObservability tips for HAProxy
Observability tips for HAProxy
 
[오픈소스컨설팅]Atlassian Confluence User Guide_Full
[오픈소스컨설팅]Atlassian Confluence User Guide_Full[오픈소스컨설팅]Atlassian Confluence User Guide_Full
[오픈소스컨설팅]Atlassian Confluence User Guide_Full
 
Enforcing Your Organization's API Design Standards with SwaggerHub
Enforcing Your Organization's API Design Standards with SwaggerHubEnforcing Your Organization's API Design Standards with SwaggerHub
Enforcing Your Organization's API Design Standards with SwaggerHub
 
Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기
Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기
Jira + Confluence + Bitbucket으로 이슈 트래킹 걸음마 떼기
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
 
What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...
What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...
What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SRE
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
[법무법인 민후] 기기의 고유식별자 등을 이용한 정보처리의 법적 이슈
[법무법인 민후] 기기의 고유식별자 등을 이용한 정보처리의 법적 이슈[법무법인 민후] 기기의 고유식별자 등을 이용한 정보처리의 법적 이슈
[법무법인 민후] 기기의 고유식별자 등을 이용한 정보처리의 법적 이슈
 
Apigee Edge: Intro to Microgateway
Apigee Edge: Intro to MicrogatewayApigee Edge: Intro to Microgateway
Apigee Edge: Intro to Microgateway
 
오픈소스로 만드는 DB 모니터링 시스템 (w/graphite+grafana)
오픈소스로 만드는 DB 모니터링 시스템 (w/graphite+grafana)오픈소스로 만드는 DB 모니터링 시스템 (w/graphite+grafana)
오픈소스로 만드는 DB 모니터링 시스템 (w/graphite+grafana)
 
[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)
[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)
[MLOps KR 행사] MLOps 춘추 전국 시대 정리(210605)
 
Zabbix conference 2018v2
Zabbix conference 2018v2Zabbix conference 2018v2
Zabbix conference 2018v2
 
IT서비스관리 표준, ISO20000의 이해
IT서비스관리 표준, ISO20000의 이해IT서비스관리 표준, ISO20000의 이해
IT서비스관리 표준, ISO20000의 이해
 

Similaire à Serverless microservices: Test smarter, not harder

Testing strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorks
Testing strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorksTesting strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorks
Testing strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorks
Thoughtworks
 

Similaire à Serverless microservices: Test smarter, not harder (20)

Deploying large-scale, serverless and asynchronous systems - without integrat...
Deploying large-scale, serverless and asynchronous systems - without integrat...Deploying large-scale, serverless and asynchronous systems - without integrat...
Deploying large-scale, serverless and asynchronous systems - without integrat...
 
Trends and development practices in Serverless architectures
Trends and development practices in Serverless architecturesTrends and development practices in Serverless architectures
Trends and development practices in Serverless architectures
 
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
 
Contract testing | Евгений Кузьмин | CODEiD
Contract testing | Евгений Кузьмин | CODEiDContract testing | Евгений Кузьмин | CODEiD
Contract testing | Евгений Кузьмин | CODEiD
 
Acceptance Test Driven Development at StarWest 2014
Acceptance Test Driven Development at StarWest 2014Acceptance Test Driven Development at StarWest 2014
Acceptance Test Driven Development at StarWest 2014
 
SIPfoundry CoLab 2013 - Web Contact Center
SIPfoundry CoLab 2013 - Web Contact CenterSIPfoundry CoLab 2013 - Web Contact Center
SIPfoundry CoLab 2013 - Web Contact Center
 
Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...
Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...
Contract testing. Isolated testing of microservices with pact.io - Evgeniy Ku...
 
Complex architectures for authentication and authorization on AWS
Complex architectures for authentication and authorization on AWSComplex architectures for authentication and authorization on AWS
Complex architectures for authentication and authorization on AWS
 
Contract based testing
Contract based testingContract based testing
Contract based testing
 
Testing microservices
Testing microservicesTesting microservices
Testing microservices
 
Trusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy ModelTrusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy Model
 
Testing Microservices
Testing MicroservicesTesting Microservices
Testing Microservices
 
MSB Deep Dive
MSB Deep DiveMSB Deep Dive
MSB Deep Dive
 
Testing strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorks
Testing strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorksTesting strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorks
Testing strategies for micro services - Ketan Soni, Jesal Mistry, ThoughtWorks
 
Using Service Discovery and Service Proxy
Using Service Discovery and Service ProxyUsing Service Discovery and Service Proxy
Using Service Discovery and Service Proxy
 
Complex architectures for authentication and authorization on AWS
Complex architectures for authentication and authorization on AWSComplex architectures for authentication and authorization on AWS
Complex architectures for authentication and authorization on AWS
 
Delivering High Performance Ecommerce with Magento Commerce Cloud
Delivering High Performance Ecommerce with Magento Commerce CloudDelivering High Performance Ecommerce with Magento Commerce Cloud
Delivering High Performance Ecommerce with Magento Commerce Cloud
 
Advanced Controls access and user security for superusers con8824
Advanced Controls access and user security for superusers con8824Advanced Controls access and user security for superusers con8824
Advanced Controls access and user security for superusers con8824
 
the grinder testing certification
the grinder testing certificationthe grinder testing certification
the grinder testing certification
 
Grand tour of Azure API Management.pdf
Grand tour of Azure API Management.pdfGrand tour of Azure API Management.pdf
Grand tour of Azure API Management.pdf
 

Plus de DiUS

Plus de DiUS (20)

Lunch and Learn: You have the data, now what?
Lunch and Learn: You have the data, now what?Lunch and Learn: You have the data, now what?
Lunch and Learn: You have the data, now what?
 
How to build confidence in your release cycle
How to build confidence in your release cycleHow to build confidence in your release cycle
How to build confidence in your release cycle
 
Test Smart, not hard
Test Smart, not hardTest Smart, not hard
Test Smart, not hard
 
10 things-to-inspire-in-10-mins
10 things-to-inspire-in-10-mins10 things-to-inspire-in-10-mins
10 things-to-inspire-in-10-mins
 
The Diversity Dilemma - Supporting our Sisters in STEM
The Diversity Dilemma - Supporting our Sisters in STEMThe Diversity Dilemma - Supporting our Sisters in STEM
The Diversity Dilemma - Supporting our Sisters in STEM
 
GameDay - Achieving resilience through Chaos Engineering
GameDay - Achieving resilience through Chaos EngineeringGameDay - Achieving resilience through Chaos Engineering
GameDay - Achieving resilience through Chaos Engineering
 
The case for consumer-driven contracts
The case for consumer-driven contractsThe case for consumer-driven contracts
The case for consumer-driven contracts
 
Deploy with Confidence using Pact Go!
Deploy with Confidence using Pact Go!Deploy with Confidence using Pact Go!
Deploy with Confidence using Pact Go!
 
Crafting Quality Software
Crafting Quality SoftwareCrafting Quality Software
Crafting Quality Software
 
Metrics on the front, data in the back
Metrics on the front, data in the backMetrics on the front, data in the back
Metrics on the front, data in the back
 
Antifragility and testing for distributed systems failure
Antifragility and testing for distributed systems failureAntifragility and testing for distributed systems failure
Antifragility and testing for distributed systems failure
 
DIY IoT Backend
DIY IoT BackendDIY IoT Backend
DIY IoT Backend
 
How to Build Hardware Lean
How to Build Hardware LeanHow to Build Hardware Lean
How to Build Hardware Lean
 
Behaviour Change and Coaching: What we can learn from BJ Fogg
Behaviour Change and Coaching: What we can learn from BJ FoggBehaviour Change and Coaching: What we can learn from BJ Fogg
Behaviour Change and Coaching: What we can learn from BJ Fogg
 
Power in Agile Teams
Power in Agile Teams Power in Agile Teams
Power in Agile Teams
 
The Diversity Dilemma: Attracting and Retaining Talented Women in Technology-...
The Diversity Dilemma: Attracting and Retaining Talented Women in Technology-...The Diversity Dilemma: Attracting and Retaining Talented Women in Technology-...
The Diversity Dilemma: Attracting and Retaining Talented Women in Technology-...
 
Rise of the machines: Continuous Delivery at SEEK - YOW! Night Summary Slides
Rise of the machines: Continuous Delivery at SEEK - YOW! Night Summary SlidesRise of the machines: Continuous Delivery at SEEK - YOW! Night Summary Slides
Rise of the machines: Continuous Delivery at SEEK - YOW! Night Summary Slides
 
AWS Summit Melbourne 2014 | The Path to Business Agility for Vodafone: How Am...
AWS Summit Melbourne 2014 | The Path to Business Agility for Vodafone: How Am...AWS Summit Melbourne 2014 | The Path to Business Agility for Vodafone: How Am...
AWS Summit Melbourne 2014 | The Path to Business Agility for Vodafone: How Am...
 
Agile Australia 2014 | A light saber for your disruptive tool belt: the Busin...
Agile Australia 2014 | A light saber for your disruptive tool belt: the Busin...Agile Australia 2014 | A light saber for your disruptive tool belt: the Busin...
Agile Australia 2014 | A light saber for your disruptive tool belt: the Busin...
 
Agile Australia 2014 | UX: How to measure more than a gut feel by Amir Ansari
Agile Australia 2014 | UX: How to measure more than a gut feel by Amir AnsariAgile Australia 2014 | UX: How to measure more than a gut feel by Amir Ansari
Agile Australia 2014 | UX: How to measure more than a gut feel by Amir Ansari
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Serverless microservices: Test smarter, not harder

  • 2. 2 The new uService The New Microservice
  • 3. 3 The New Microservice > After API External Events API Outside World Microservice Interface API Master Data API Inside bounded context Event Emitters API Materialised view / cache Events and Processing Data Event Handlers Processing Offline Processing
  • 4. 4 Provisioning Amazon ML The New Microservice > After > Example Team 1 Bounded Context Place Order API External Events Order Status API Outside World Internal Events Microservice Interface Data, Events and Processing Suggestions API Publish Event to external subscribers Insights / Predictions Customer / Other Event Orders Push API Inside bounded context CRM Materialised view of customer Provisioning Event External Events … API
  • 5. 5 Provisioning The New Microservice > After > Example Team 1 Bounded Context External Events Outside World Internal Events Microservice Interface Data, Events and Processing Publish Event to external subscribers Insights / Predictions Place Order API Customer / Other Event Orders Inside bounded context Materialised view of customer Provisioning Event CRM Marketing Automation Customer Support
  • 6. 6 The New Microservice > After > IoT ExampleThe New Microservice > After > Example 2 > IoT Architecture API Gateway Sensor A Sensor B Sensor C IoT Rule A IoT Rule B IoT Rule C AWS IoT Core Sensor Data A Sensor Data C Processed Events Sensor A Vendor Device API Real-time events Sensor Data B Analytics Device Ingest Process Store
  • 7.
  • 8. 8 Testing The New Microservice How do we test these?
  • 9. 9 Testing The New Microservice > Test Pyramid https://martinfowler.com/bliki/TestPyramid.html
  • 10. Testing The New Microservice > Test Pyramid Mama-mia!
  • 11. 11 Testing The New Microservice > Test Pyramid > Ideal Software Testing Pyramid https://watirmelon.blog/testing-pyramids/ Don’t forget people - the ones doing the testing! Let me make this a bit clearer for you...
  • 12. 12 Testing The New Microservice > Test Pyramid > Software Testing Trophy https://kentcdodds.com/blog/write-tests
  • 13. 13 Testing The New Microservice > Test Pyramid > Testing Funnel? https://medium.com/@copyconstruct/testing-microservices-the-sane-way-9bb31d158c16
  • 14. 14 Testing The New Microservice > Test Pyramid > Round Earth Heuristic https://www.satisfice.com/blog/archives/4947
  • 15. Today’s focus Architecture > Microservices 1. Testability 2. Reduce need for UI / end-to-end testing 3. Observability
  • 18. 18 Testability > Lambda Pattern > Ports and Adaptors > Example Order Provisioning Orders CRM Orders
  • 19. Testability > Lambda Anti-pattern > Example
  • 20. MQ Handler WebSocket handler Azure Function Handler Google Cloud Fn Handler Lambda Handler Service Repository Port Adapter Business Logic Domain Model Collaborators Testability > Lambda Pattern > Ports and Adaptors ... Test Harness
  • 21. Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
  • 22. Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
  • 23. Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
  • 24. Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
  • 25. Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
  • 26. Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
  • 27. Testability > Lambda Pattern > Ports and Adaptors > Lambda Adapter
  • 28. Summary ● Separate protocol handling from business logic ● Business logic shouldn’t change with introduction of a new protocol ● Enables testability - Port, Adapter and Business Logic are independently testable Testability > Lambda Pattern > Ports and Adaptors > Summary
  • 29. WHAT WE ARE KNOWN FORTestability > Modularisation Adapted from https://martinfowler.com/articles/microservice-testing Adapters Services Domain Repositories Collaborators External Service Test modularity
  • 30. 30 How do you test locally? Testability
  • 31. WHAT WE ARE KNOWN FOR 31 Options Testability > Testing Locally ● Use real services ● Stub services (e.g. Localstack) ● Stub SDK (e.g. Moto) ● Local Unit, Integration + Component tests
  • 33. WHAT WE ARE KNOWN FOR 33 Options ● Feature arms race ● Trustworthy? ● Integrated = slower / harder ● All cloud providers? ● Point at the real services ● Stub services (e.g. Localstack) ● Stub SDK (e.g. Moto) ● Local Unit, Integration + Component tests Testability > Testing Locally Challenges
  • 35. WHAT WE ARE KNOWN FORTestability > Testing Locally Show me where? Adapters Domain Repositories Collaborators mock Services
  • 36. Testability > Testing Locally > Integration Test > Order Service Look ma, no AWS Code
  • 37. Testability > Testing Locally > Integration Test > Order Service Dependencies injected
  • 38. Testability > Testing Locally > Integration Test > Order Service Look ma, no AWS Code
  • 39. Testability > Testing Locally > Integration Test > Order Service Setup dependencies as simple interface fakes
  • 40. Testability > Testing Locally > Integration Test > Order Service Run the unit under test
  • 41. Testability > Testing Locally > Integration Test > Order Service Assert
  • 43. WHAT WE ARE KNOWN FORTestability > Testing Locally > Component Test > Order Provisioning Service Show me where? Adapters Services Domain Repositories Collaborators mock In-memory database
  • 44. Testability > Testing Locally > Component Test > Order Provisioning Service Component test of handler
  • 45. Setup dependencies, inputs and expected output Testability > Testing Locally > Component Test > Order Provisioning Service
  • 46. Testability > Testing Locally > Component Test > Order Provisioning Service Invoke handler with kinesis-shaped input
  • 47. Testability > Testing Locally > Component Test > Order Provisioning Service Assert the handler response
  • 48. Reduce # of e2e tests
  • 49. Challenges Integration ● More “white space” - integrations ● Async ○ who is my consumer? ○ delay in feedback ● Third Parties
  • 51. Problems with automated e2e tests Integration > Contract Tests > Contracts ● Slow ● Easy to break ● Hard to fix ● Scales badly across teams ● Lots of set up maintenance ● $$ potentially costly
  • 52. Integration > Contract Tests > Contracts Mocks to the rescue?
  • 53. Integration > Contract Tests > Contracts Mocks to the rescue?
  • 54. WHAT WE ARE KNOWN FOR 54 Mocks Solved problems New problems ● Hard to keep both sides in sync ● Fast feedback ● Few dependencies ● No dedicated environment ● Reliable ● Easy to debug Integration > Contract Tests > Contracts
  • 55. 55 Contract { “id”: 1234, “items”:[ ... ], } Consumer Provider Integration > Contract Tests > Contracts Order API GET /orders/1234
  • 56. 56 Provisioning Amazon ML Integration > Contract Tests > Contracts Place Order API External Events Order Status API Outside World Internal Events Microservice Interface Data, Events and Processing Suggestions API Publish Event to external subscribers Insights / Predictions Customer / Other Event Orders Push API Inside bounded context CRM Materialised view of customer Provisioning Event External Events … API
  • 57. 57 Provisioning Amazon ML Integration > Contract Tests > Contracts Everywhere! Place Order API External Events Order Status API Outside World Internal Events Microservice Interface Data, Events and Processing Suggestions API Publish Event to external subscribers Insights / Predictions Customer / Other Event Orders Push API Inside bounded context CRM Materialised view of customer Provisioning Event External Events … API Contract Contract Contract Contract Contract Contract Contract Contract
  • 58. Integration > Contract Tests > Contracts
  • 59. Integration > Contract Tests > Contracts Mock
  • 60. Integration > Contract Tests > Contracts Mock GET /orders/1234
  • 61. Integration > Contract Tests > Contracts Mock { “id”: 1234, “items”:[ ... ], } GET /orders/1234
  • 62. Integration > Contract Tests > Contracts Mock
  • 63. Integration > Contract Tests > Contracts Mock GET /orders/1234
  • 64. Integration > Contract Tests > Contracts Mock { “id”: 1234, “items”:[ ... ], } GET /orders/1234
  • 65. Integration > Contract Tests > Contracts Mock ✔
  • 66. WHAT WE ARE KNOWN FORTestability > Modularisation > Consumer Test Adapted from https://martinfowler.com/articles/microservice-testing Adapters Services Domain Repositories Collaborators External Service Show me where?
  • 67. WHAT WE ARE KNOWN FORTestability > Modularisation > Provider Test Adapted from https://martinfowler.com/articles/microservice-testing Show me where? Adapters Services Domain Repositories Collaborators mock In-memory database
  • 68. 68 Integration > Contract Tests > Contracts https://martinfowler.com/bliki/TestPyramid.html Contract Show me where?
  • 69. Bug turnaround - minutes Contracts tests Integration > Contract Tests > Contracts
  • 70. Know before you commit Contracts tests Integration > Contract Tests > Contracts
  • 71. Make changes with speed and confidence Contracts tests Integration > Contract Tests > Contracts
  • 72. Deploy independently Contracts tests Integration > Contract Tests > Contracts
  • 73. Better API design (Consumer) Contracts tests Integration > Contract Tests > Contracts
  • 74. 74 ● Open source ● Multiple languages ○ Javascript ○ Go ○ Python ○ JVM ○ .NET ○ + more pact.io ● HTTP contracts ● Message contracts ● … protocol agnostic! Integration > Contract Tests > Contracts
  • 75. 75 Contract { “id”: 1234, “items”:[ ... ], } Consumer Provider Integration > Contract Tests > Consumer Contract Test Order API GET /orders/1234
  • 76. Integration > Contract Tests > Contracts > Fetch Order Example Setup API Host
  • 77. Integration > Contract Tests > Contracts > Fetch Order Example Expectations on Order API made clear
  • 78. Integration > Contract Tests > Contracts > Fetch Order Example Expectations on Order API made clear
  • 79. Integration > Contract Tests > Contracts > Fetch Order Example Call the OrderService + Assert
  • 80. Integration > Contract Tests > Contracts > Fetch Order Example Test state setup
  • 81. Integration > Contract Tests > Contracts > Fetch Order Example Test state setup
  • 82. ● Contract tests are faster, easier to maintain and more reliable than e2e tests ● Works for both synchronous and async communication ● Use contract tests to reduce your end-to-end test reliance ● End-to-end tests closer represent the user experience ● Contract testing doesn’t replace functional testing! Summary Integration > Contract Tests
  • 84. 84 Push responsibility into Platform Observability
  • 85. 85 Push responsibility into Platform Observability
  • 86. 86 #1 Log all the things! Observability
  • 88. Handler Observability > Approach #2 > Middleware { "Records": [ { "EventVersion": "1.0", "EventSubscriptionArn": "somearn", "EventSource": "aws:sns", "Sns": { ... } } ] } { "Success": true } HandlerHandlerHandler before after Request Response 1st middleware 2nd middleware 3rd middleware
  • 89. Observability > Approach #2 > Middleware
  • 90. Observability > Approach #2 > Middleware
  • 91. Observability > Approach #2 > Middleware
  • 92. 92 #3 Push responsibility into Platform Observability
  • 93. 93 Observability > Approach #1 > IT Ops Automation Decide Alarm Schedule Notify Pagerduty Act Isolate instance from ASG Offsite backup Ship logs to Splunk Orient Security Analysis Application Anomaly / Canary Detection Log forwarder Policy Violation Observe Flow Logs CloudTrail CloudWatch Logs Application Event Configured Rule Event subscription
  • 94. 94 Observability > Approach #1 > IT Ops Automation Decide Alarm Act Ship logs to Splunk Orient Log forwarder Observe CloudWatch Logs Event subscription
  • 95. WHAT WE ARE KNOWN FOR 95 Examples ● Automatically subscribe log groups and forward to ___ ● Allow dynamic DEBUG monitoring (runtime sampling) ● Enable platform tracing (e.g. X-ray, IOPipe, Dashbird) ● Automatically inject correlation IDs ● Anomaly detection Observability > Approach #1 > IT Ops Automation
  • 96. ● Invest in platform ● Structured + semantic logging is crucial ● Middleware to simplify and template out specific shaped functions Summary Observability > Summary
  • 98. Summary 98 Summary Problems ● Microservices + architecture has evolved ● ...and so must the pyramid! ● More diverse integrations ● More glue, cloud-native code We’re all digital plumbers!
  • 99. ● Use Ports + Adapters (Hexagonal architecture) to increase modularity ● Enable better testability and test modularity ● Mock SDK for local tests ● Component tests can help to reduce need for e2e tests There is no single test strategy that will work for all cases! Structure... Summary > Structure
  • 100. ● Contract tests are faster and more reliable than E2E tests ● Use them to reduce your E2E footprint ● Contract tests enable independent deployment ● They are not functional tests Never forget forget the end user! Reduce E2E... Summary > Reduce reliance on E2E
  • 101. ● Is the property of understanding a system as illuminated by its outputs ● Allows us to ask questions ● Helps us discover and respond to unknown, unknowns It’s not monitoring, but there is significant implementation overlap. Observability... Summary > Observability