SlideShare a Scribd company logo
The utlimate
SERVERLESS
TESTING GUIDE
#WISSENTEILEN
THE PRACTICAL SKILLS YOU‘LL
NEED TO TEST SERVERLESS
by Lars Röwekamp
a.k.a @mobileLarson
ABOUT OPEN KNOWLEDGE
Software development and IT consulting
ABOUT ME
Who am i?
• CIO New Technologies
• Enterprise & Mobile
• Author, Speaker, Coach & Mentor
• Snowboard & MTB Enthusiast
• Traveller between the worlds
Lars Röwekamp (a.k.a. @mobileLarson)
LR
Testing
Serverless
Shouldn‘t be to
complicated!- famous last words -
Testing is about …
gaining confidence in your
code running as expected on
a specific target platform.
Testing is about …
minimizing the risk that
something unexpected will
happen in production.
„What does this mean in the
context of Serverless?"
„Run Code,
not Servers!“
#WISSENTEILEN
“Run your business code
highly-available
in the cloud in response
to events and scale
without any servers to
manage.“*
*(AWS Lambda product description)
#WISSENTEILEN
“Run your business code
highly distributed
and event driven in a non
transparent environment
with no single
point of control.“*
*(my personal interpretation)
Surviving Serverless Testing: The ultimate Guide
The Road to the Cloud ...
The Serverless Showcase
AWS Cloud
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
Store raw Image
1
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create ThumbnailStore raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
„What can go
wrong?“
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
What could possibly go wrong?
• internal programming /business logic errors
• abnormalities (e.g. unexpected or invalid calls)
• lost or duplicated events
• high latency / timeouts
• security attacks (e.g. DoS/DDoS)
• personalized SLAs / usage plans / unexpected peaks of workload
• customer location changes
• …
„Run Code, not Servers“, they said!
„It will be fun“, they said
What, how and where should we test to …
• gain confidence in our code
• minimize risk of failures in production
Testing, the traditional way
Testing, the serverless way
„The biggest complexity is not within
the function itself, but in how it interacts
with other functions and services
(a.k.a. cloud components).“
Testing, the serverless way
Remember goals of testing: „minimize risk“
• configuration risk
• technical workflow risk
• business logic risk
• integration risk
Testing, the serverless way
Remember goals of testing: „minimize risk“
• configuration risk
• technical workflow risk
• business logic risk
• integration risk
Testing, the serverless way
Unit Testing
… for Serverless Functions
„Make sure that your business logic is
working as expected.“
• business logic errors
• coding errors
• …
Unit Testing
… for Serverless Functions
• seperation of logic and infrastructure
• mock dependencies
• jUnit, testNG, Mockito
• Jasmin, MochaJS, JEST
Integration Testing
… for Cloud Components
„Make sure that the integration of your
serverless function with all the other
cloud components works as expected.“
• wrong DynamoDB query
• unexpected response format
• ….
Integration Testing
… for Cloud Components
• dev/test components in the cloud*
• mock/fake cloud components**
• S3rver
• dynamodb-local
• kinesalite
• node-lambda
• fake-sns
• elasticmq* could become kind of expensive
** potential problem of self fulfilling prophecy
End-to-End Testing
… for User-Stories
„Make sure that chains of serverless
functions and cloud components work as
expected - inside the target environment.“
• wrong IAM permissions
• timeouts not set correctly
• not enough memory allocated
End-to-End Testing
… for User-Stories
• cloud test stages*
• local cloud emulation**
• SAM local (AWS)
• LocalStack (localstack.org)
• Serverless Offline (Serverless Framework)* could become kind of expensive
** emulate only part of the real world restrictions
Best Practices
#1 seperate business logic from infrastructure inside your functions
Testing Best Practices
AWS CloudOn-Premise
handler
logic
unit test candidate
e
i
u
integration test candidate
end-to-end test candidate
u
Infrastructure Business Logic
Infrastructure Business Logic
Business Logic Tests
#2 mock cloud infrastructure components of your functions
Testing Best Practices
AWS CloudOn-Premise
handler
logic
unit test candidate
e
i
u
integration test candidate
end-to-end test candidate
u
um
Infrastructure
AWS agnostic logger (log4j2)
fake infrastructure component (Context)
mock infrastructure component (Context)
#3 use local environment for functional testing (e.g. SAM local)
Testing Best Practices
AWS CloudOn-Premise
handler
logic
unit test candidate
e
i
u
integration test candidate
end-to-end test candidate
uvia SAM local
via SAM local
SAM
yaml
TEST
u
u
Surviving Serverless Testing: The ultimate Guide
$ sam local invoke "Greetings" -e event-greeting.json --env-vars env.json
function name payload for function
$ sam local invoke "Greetings" -e event-greeting.json --env-vars env.json
function name payload for function
#WISSENTEILEN
#4 use local environment for trigger integration testing
Testing Best Practices
AWS CloudOn-Premise
handler
logic
unit test candidate
e
i
u
integration test candidate
end-to-end test candidate
uvia SAM local
via SAM local
SAM
yaml
TEST
u
u
i
i
$ sam local start-api –p 8080
$ sam local start-api –p 8080
$ sam local start-api –p 8080
#WISSENTEILEN
#5 use local „cloud“ components for basic integration testing
Testing Best Practices
AWS CloudOn-Premise
handler
logic
unit test candidate
e
i
u
integration test candidate
end-to-end test candidate
u
via DynamoDB local
via FakeS3 via SAM local
via SAM local
SAM
yaml
TEST
u
u
i
i
i
i
WARNING: local cloud
components can only proof
functional correctness but
not infrastructural
correctness like DLQs,
timeouts, throttling, SLAs, …
$ sam local generate-event [SERVICE] [OPTION]
Simulate Component Event to trigger Lambda
$ sam local genarte-event [SERVICE] [OPTION]
Simulate Component Event to trigger Lambda
Simulate Component triggered by Lambda
$ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
$ java –jar DynamoDBLocal.-jar
Simulate Component triggered by Lambda
$ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
Simulate Component triggered by Lambda
$ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
#WISSENTEILEN
#6 use temporary integration cloud for partial integration testing
Testing Best Practices
AWS CloudOn-Premise
handler
logic
unit test candidate
e
i
u
integration test candidate
end-to-end test candidate
uvia SAM local
via SAM local
SAM
yaml
TEST
u
u
via DynamoDB local
via FakeS3
i
i
Temorary Intregration #Dev1
ii
INT
i
i
#WISSENTEILEN
#7 use permanent integration cloud for end-to-end testing
Testing Best Practices
AWS CloudOn-Premise
handler
logic
unit test candidate
e
i
u
integration test candidate
end-to-end test candidate
uvia SAM local
via SAM local
SAM
yaml
TEST
u
u
via DynamoDB local
via FakeS3
i
i
Permament IntregrationINT
e
e
e
e
i
i
„Are we
done?“
#WISSENTEILEN
Testing in Production
Remember goals of testing: „gain confidence“
• outages of cloud & cloud components
• outages of 3rd party apps you depend on
• bugs / problems related to scale
Testing in Production
Robust monitoring and error reporting
• logging
• tracing
• metrics
• alerting
Anticipation of disruption
and automated recovery!
Testing in Production
Chaos Engineering
• Inject small doses of failure into your system!
seperate business logic from infrastructure inside your functions
mock cloud infrastructure components of your functions
use local environment for functional testing (e.g. SAM local)
use local environment for trigger integration testing
use local „cloud“ components for basic integration testing
use temporary integration cloud for partial integration testing
use permanent integration cloud for end-to-end testing
REMEBER: Testing does not end in production!
Testing Summary
unit test
e
i
u
integration test
end-to-end test
e
i
i
i
u
u
i
Testing does not end
in production!

More Related Content

PDF
Lessons Learned from building a serverless API
PDF
Debunking serverless myths
PDF
How to build a social network on serverless
PDF
How serverless changes the cost paradigm
PDF
Stop calling everything serverless!
PDF
Implementing Infrastructure as Code ConfigMgtCamp 2017
PDF
Serverless is more FinDev than DevOps
PDF
The Journey from Monolith to Microservices: a Guided Adventure
Lessons Learned from building a serverless API
Debunking serverless myths
How to build a social network on serverless
How serverless changes the cost paradigm
Stop calling everything serverless!
Implementing Infrastructure as Code ConfigMgtCamp 2017
Serverless is more FinDev than DevOps
The Journey from Monolith to Microservices: a Guided Adventure

What's hot (18)

PDF
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
PDF
Gojko's 5 rules for super responsive Serverless applications
PPTX
Firebase vs MongoDB Stitch vs AWS Amplify vs Azure Mobile Apps
PDF
How to build a social network on Serverless (AWS Community Summit)
PDF
Writing less code with Serverless on AWS at AWS User Group Nairobi
PDF
Writing less code with Serverless on AWS at OOP 2022
PDF
20180111 we bde-bs - serverless url shortener
PDF
Adopting Java for the Serverless world at Serverless Meetup New York and Boston
PDF
Design and Develop Serverless Applications as Set-Pieces
PDF
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
PDF
Whizlabs webinar - Deploying Portfolio Site with AWS Serverless
PDF
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
PDF
How to build observability into a serverless application
PDF
Making Sense of Serverless Computing
PDF
Chris Munns, DevOps @ Amazon: Microservices, 2 Pizza Teams, & 50 Million Depl...
PDF
Microservices the Good Bad and the Ugly
PDF
Serverless architectures
PDF
Adopting Java for the Serverless world at Serverless Meetup Singapore
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
Gojko's 5 rules for super responsive Serverless applications
Firebase vs MongoDB Stitch vs AWS Amplify vs Azure Mobile Apps
How to build a social network on Serverless (AWS Community Summit)
Writing less code with Serverless on AWS at AWS User Group Nairobi
Writing less code with Serverless on AWS at OOP 2022
20180111 we bde-bs - serverless url shortener
Adopting Java for the Serverless world at Serverless Meetup New York and Boston
Design and Develop Serverless Applications as Set-Pieces
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
Whizlabs webinar - Deploying Portfolio Site with AWS Serverless
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
How to build observability into a serverless application
Making Sense of Serverless Computing
Chris Munns, DevOps @ Amazon: Microservices, 2 Pizza Teams, & 50 Million Depl...
Microservices the Good Bad and the Ugly
Serverless architectures
Adopting Java for the Serverless world at Serverless Meetup Singapore
Ad

Similar to Surviving Serverless Testing: The ultimate Guide (20)

PDF
AWS Lambda from the Trenches
PDF
Serverless in production, an experience report (linuxing in london)
PDF
Serverless in production, an experience report (JeffConf)
PDF
Serverless in production (O'Reilly Software Architecture)
PDF
DevOps with Serverless
PDF
Serverless in production, an experience report (Going Serverless)
PDF
Serverless in production, an experience report (London DevOps)
PPTX
Serverless without Code (Lambda)
PDF
Deploying large-scale, serverless and asynchronous systems - without integrat...
PDF
Ci/CD for AWS Lambda Projects - JLM CTO Club
PDF
Serverless in production, an experience report (FullStack 2018)
PPTX
From Monolithic to Modern Apps: Best Practices
PDF
Serverless in production, an experience report (LNUG)
PDF
Serverless in Production, an experience report (AWS UG South Wales)
PDF
Serverless in Production, an experience report (cloudXchange)
PDF
Serverless in production, an experience report (IWOMM)
PDF
Serverless best practices plus design principles 20m version
PDF
Serverless in production, an experience report (CoDe-Conf)
PDF
CI/CD for AWS Lambda Projects - IsraelCloud Meetup
PDF
Serverless in production, an experience report
AWS Lambda from the Trenches
Serverless in production, an experience report (linuxing in london)
Serverless in production, an experience report (JeffConf)
Serverless in production (O'Reilly Software Architecture)
DevOps with Serverless
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (London DevOps)
Serverless without Code (Lambda)
Deploying large-scale, serverless and asynchronous systems - without integrat...
Ci/CD for AWS Lambda Projects - JLM CTO Club
Serverless in production, an experience report (FullStack 2018)
From Monolithic to Modern Apps: Best Practices
Serverless in production, an experience report (LNUG)
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (cloudXchange)
Serverless in production, an experience report (IWOMM)
Serverless best practices plus design principles 20m version
Serverless in production, an experience report (CoDe-Conf)
CI/CD for AWS Lambda Projects - IsraelCloud Meetup
Serverless in production, an experience report
Ad

More from OPEN KNOWLEDGE GmbH (20)

PPTX
Warum der Computer "Nein" sagt - Mehr Nachvollziehbarkeit dank Explainable AI
PDF
Machine Learning? Ja gerne! Aber was und wie? Eine Kurzanleitung für den erfo...
PDF
From Zero to still Zero: Die schönsten Fehler auf dem Weg in die Cloud
PDF
Der Spagat zwischen BIAS und FAIRNESS (2024)
PDF
FEHLENDE DATEN? (K)EIN PROBLEM!: Die Kunst der Data Imputation
PPTX
Nie wieder Log-Files!
PDF
Cloud-native and Enterprise Java? Hold my beer!
PPTX
From Zero to still Zero: The most beautiful mistakes going into the cloud.
PDF
API Expand Contract
PDF
Ready for the Future: Jakarta EE in Zeiten von Cloud Native & Co
PDF
Shared Data in verteilten Architekturen
PDF
Machine Learning mit TensorFlow.js
PDF
KI und Architektur
PDF
It's not Rocket Science: Neuronale Netze
PDF
Shared Data in verteilten Systemen
PDF
Business-Mehrwert durch KI
PDF
Mehr Sicherheit durch Automatisierung
PDF
API-Design, Microarchitecture und Testing
PDF
Supersonic Java für die Cloud: Quarkus
PDF
Hilfe, ich will meinen Monolithen zurück!
Warum der Computer "Nein" sagt - Mehr Nachvollziehbarkeit dank Explainable AI
Machine Learning? Ja gerne! Aber was und wie? Eine Kurzanleitung für den erfo...
From Zero to still Zero: Die schönsten Fehler auf dem Weg in die Cloud
Der Spagat zwischen BIAS und FAIRNESS (2024)
FEHLENDE DATEN? (K)EIN PROBLEM!: Die Kunst der Data Imputation
Nie wieder Log-Files!
Cloud-native and Enterprise Java? Hold my beer!
From Zero to still Zero: The most beautiful mistakes going into the cloud.
API Expand Contract
Ready for the Future: Jakarta EE in Zeiten von Cloud Native & Co
Shared Data in verteilten Architekturen
Machine Learning mit TensorFlow.js
KI und Architektur
It's not Rocket Science: Neuronale Netze
Shared Data in verteilten Systemen
Business-Mehrwert durch KI
Mehr Sicherheit durch Automatisierung
API-Design, Microarchitecture und Testing
Supersonic Java für die Cloud: Quarkus
Hilfe, ich will meinen Monolithen zurück!

Recently uploaded (20)

PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPT
Introduction Database Management System for Course Database
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Online Work Permit System for Fast Permit Processing
PDF
AI in Product Development-omnex systems
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
top salesforce developer skills in 2025.pdf
ManageIQ - Sprint 268 Review - Slide Deck
How to Choose the Right IT Partner for Your Business in Malaysia
Introduction Database Management System for Course Database
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
CHAPTER 2 - PM Management and IT Context
ISO 45001 Occupational Health and Safety Management System
Design an Analysis of Algorithms I-SECS-1021-03
Softaken Excel to vCard Converter Software.pdf
L1 - Introduction to python Backend.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Navsoft: AI-Powered Business Solutions & Custom Software Development
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
VVF-Customer-Presentation2025-Ver1.9.pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
Online Work Permit System for Fast Permit Processing
AI in Product Development-omnex systems
Upgrade and Innovation Strategies for SAP ERP Customers
Odoo POS Development Services by CandidRoot Solutions
top salesforce developer skills in 2025.pdf

Surviving Serverless Testing: The ultimate Guide

  • 1. The utlimate SERVERLESS TESTING GUIDE #WISSENTEILEN THE PRACTICAL SKILLS YOU‘LL NEED TO TEST SERVERLESS by Lars Röwekamp a.k.a @mobileLarson
  • 2. ABOUT OPEN KNOWLEDGE Software development and IT consulting
  • 3. ABOUT ME Who am i? • CIO New Technologies • Enterprise & Mobile • Author, Speaker, Coach & Mentor • Snowboard & MTB Enthusiast • Traveller between the worlds Lars Röwekamp (a.k.a. @mobileLarson) LR
  • 5. Shouldn‘t be to complicated!- famous last words -
  • 6. Testing is about … gaining confidence in your code running as expected on a specific target platform.
  • 7. Testing is about … minimizing the risk that something unexpected will happen in production.
  • 8. „What does this mean in the context of Serverless?"
  • 10. #WISSENTEILEN “Run your business code highly-available in the cloud in response to events and scale without any servers to manage.“* *(AWS Lambda product description)
  • 11. #WISSENTEILEN “Run your business code highly distributed and event driven in a non transparent environment with no single point of control.“* *(my personal interpretation)
  • 13. The Road to the Cloud ... The Serverless Showcase
  • 14. AWS Cloud Use-Case: Upload Image upload image with additional information
  • 15. AWS Cloud Store raw Image 1 Use-Case: Upload Image upload image with additional information
  • 16. AWS Cloud Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 17. AWS Cloud AWS Step Functions workflow: Store Image Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 18. AWS Cloud AWS Step Functions workflow: Store Image Create ThumbnailStore raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 19. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 20. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 21. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 22. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 23. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 25. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 26. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 27. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 28. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 29. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 30. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 31. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 32. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 33. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 34. AWS Cloud AWS Step Functions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 35. What could possibly go wrong? • internal programming /business logic errors • abnormalities (e.g. unexpected or invalid calls) • lost or duplicated events • high latency / timeouts • security attacks (e.g. DoS/DDoS) • personalized SLAs / usage plans / unexpected peaks of workload • customer location changes • …
  • 36. „Run Code, not Servers“, they said! „It will be fun“, they said
  • 37. What, how and where should we test to … • gain confidence in our code • minimize risk of failures in production
  • 39. Testing, the serverless way „The biggest complexity is not within the function itself, but in how it interacts with other functions and services (a.k.a. cloud components).“
  • 40. Testing, the serverless way Remember goals of testing: „minimize risk“ • configuration risk • technical workflow risk • business logic risk • integration risk
  • 41. Testing, the serverless way Remember goals of testing: „minimize risk“ • configuration risk • technical workflow risk • business logic risk • integration risk
  • 43. Unit Testing … for Serverless Functions „Make sure that your business logic is working as expected.“ • business logic errors • coding errors • …
  • 44. Unit Testing … for Serverless Functions • seperation of logic and infrastructure • mock dependencies • jUnit, testNG, Mockito • Jasmin, MochaJS, JEST
  • 45. Integration Testing … for Cloud Components „Make sure that the integration of your serverless function with all the other cloud components works as expected.“ • wrong DynamoDB query • unexpected response format • ….
  • 46. Integration Testing … for Cloud Components • dev/test components in the cloud* • mock/fake cloud components** • S3rver • dynamodb-local • kinesalite • node-lambda • fake-sns • elasticmq* could become kind of expensive ** potential problem of self fulfilling prophecy
  • 47. End-to-End Testing … for User-Stories „Make sure that chains of serverless functions and cloud components work as expected - inside the target environment.“ • wrong IAM permissions • timeouts not set correctly • not enough memory allocated
  • 48. End-to-End Testing … for User-Stories • cloud test stages* • local cloud emulation** • SAM local (AWS) • LocalStack (localstack.org) • Serverless Offline (Serverless Framework)* could become kind of expensive ** emulate only part of the real world restrictions
  • 50. #1 seperate business logic from infrastructure inside your functions Testing Best Practices AWS CloudOn-Premise handler logic unit test candidate e i u integration test candidate end-to-end test candidate u
  • 54. #2 mock cloud infrastructure components of your functions Testing Best Practices AWS CloudOn-Premise handler logic unit test candidate e i u integration test candidate end-to-end test candidate u um
  • 59. #3 use local environment for functional testing (e.g. SAM local) Testing Best Practices AWS CloudOn-Premise handler logic unit test candidate e i u integration test candidate end-to-end test candidate uvia SAM local via SAM local SAM yaml TEST u u
  • 61. $ sam local invoke "Greetings" -e event-greeting.json --env-vars env.json function name payload for function
  • 62. $ sam local invoke "Greetings" -e event-greeting.json --env-vars env.json function name payload for function
  • 63. #WISSENTEILEN #4 use local environment for trigger integration testing Testing Best Practices AWS CloudOn-Premise handler logic unit test candidate e i u integration test candidate end-to-end test candidate uvia SAM local via SAM local SAM yaml TEST u u i i
  • 64. $ sam local start-api –p 8080
  • 65. $ sam local start-api –p 8080
  • 66. $ sam local start-api –p 8080
  • 67. #WISSENTEILEN #5 use local „cloud“ components for basic integration testing Testing Best Practices AWS CloudOn-Premise handler logic unit test candidate e i u integration test candidate end-to-end test candidate u via DynamoDB local via FakeS3 via SAM local via SAM local SAM yaml TEST u u i i i i WARNING: local cloud components can only proof functional correctness but not infrastructural correctness like DLQs, timeouts, throttling, SLAs, …
  • 68. $ sam local generate-event [SERVICE] [OPTION] Simulate Component Event to trigger Lambda
  • 69. $ sam local genarte-event [SERVICE] [OPTION] Simulate Component Event to trigger Lambda
  • 70. Simulate Component triggered by Lambda $ aws –endpoint-url=http://localhost:8000 dynamodb list-tables $ java –jar DynamoDBLocal.-jar
  • 71. Simulate Component triggered by Lambda $ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
  • 72. Simulate Component triggered by Lambda $ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
  • 73. #WISSENTEILEN #6 use temporary integration cloud for partial integration testing Testing Best Practices AWS CloudOn-Premise handler logic unit test candidate e i u integration test candidate end-to-end test candidate uvia SAM local via SAM local SAM yaml TEST u u via DynamoDB local via FakeS3 i i Temorary Intregration #Dev1 ii INT i i
  • 74. #WISSENTEILEN #7 use permanent integration cloud for end-to-end testing Testing Best Practices AWS CloudOn-Premise handler logic unit test candidate e i u integration test candidate end-to-end test candidate uvia SAM local via SAM local SAM yaml TEST u u via DynamoDB local via FakeS3 i i Permament IntregrationINT e e e e i i
  • 77. Testing in Production Remember goals of testing: „gain confidence“ • outages of cloud & cloud components • outages of 3rd party apps you depend on • bugs / problems related to scale
  • 78. Testing in Production Robust monitoring and error reporting • logging • tracing • metrics • alerting Anticipation of disruption and automated recovery!
  • 79. Testing in Production Chaos Engineering • Inject small doses of failure into your system!
  • 80. seperate business logic from infrastructure inside your functions mock cloud infrastructure components of your functions use local environment for functional testing (e.g. SAM local) use local environment for trigger integration testing use local „cloud“ components for basic integration testing use temporary integration cloud for partial integration testing use permanent integration cloud for end-to-end testing REMEBER: Testing does not end in production! Testing Summary unit test e i u integration test end-to-end test e i i i u u i
  • 81. Testing does not end in production!