Speaker: Takumi Abe @ AWS Community Day Hong Kong 2025
Summary by Amazon Nova
https://www.youtube.com/watch?v=bLP3IlSSv7o
Summary by Amazon Nova
Phase 1: Requirements:
Architecture Overview:
Batch processing workflow using AWS Lambda and Step Functions.
Three states in a straight line.
Unit tests for each Lambda function, but manual testing for Step Functions workflow.
Testing Goals:
Automate Step Functions workflow testing.
Ensure input and output values match expected values.
Integrate tests into CI/CD pipeline using GitHub Actions.
Avoid deploying to a real AWS environment for testing.
Phase 2: Plan:
Tools and Technologies:
Step Functions Local: For running and testing Step Functions locally.
GitHub Actions: For CI/CD workflow automation.
Localstack or similar: To simulate AWS Lambda locally.
GitHub Actions Workflow:
Set up workflow to run tests on push or pull requests.
Use Step Functions Local Docker image for local testing environment.
Use Localstack for Lambda simulation.
Import Step Functions definition and run workflow locally.
Verify input and output values of each state.
Steps in the Workflow:
[ 1 ] Start Containers:
Pull and start Step Functions Local Docker image.
Set up Localstack for Lambda simulation.
[ 2 ] Import Step Functions Definition:
Import state machine definition into local environment.
[ 3 ] Run Workflow:
Trigger Step Functions workflow using local endpoint.
[ 4 ] Validate Results:
Check input and output values against expected values.
[ 5 ] Report Results:
Generate a report or status indicating test success or failure.
How to Test Serverless Architecture?
Introduction:
Serverless architecture offers significant benefits, enabling quick delivery of value to customers.
The focus here is on testing from a testing perspective, rather than system performance or cost.
Why Do We Need Testing?
Testing helps us understand, predict, and control system behavior.
It allows us to identify and quantify system risks.
Writing tests helps us better understand requirements.
Testing ensures reproducibility and explainability of results.
The primary goal of testing is to reduce unknown risks.
Types of Tests:
Unit Tests: Test individual components or functions in isolation.
Integration Tests: Test the interaction between combined components.
Logic Tests: Verify the correctness of business logic.
Workflow Tests: Test the end-to-end flow of a process or workflow.
API Tests: Test the functionality and reliability of APIs.
Recommendation:
It is important to be aware of different test types and their purposes and goals.
Understanding these test types will help in designing effective testing strategies for serverless architectures.
Separate Processing for Easier Testing:
Key Points:
Easy-to-Test Units: Units that are easy to test are also easy to understand.
System Clarity: When a system is designed with separate, testable units, it naturally shows what it does, when it does it, and why it does it.
Avoiding Complexity: If something is hard to test, it likely means there is too much responsibility and logic concentrated in one place.
Example Comparison:
Less Architecture: A single Lambda function handles both getting data from other servers and processing/storing it in DynamoDB.
Right Architecture: Separate Lambda functions for each operation (getting data and processing/storing data).
Benefits of Separation:
Easier to test each part individually.
When an error occurs, it is easier to pinpoint the exact location of the problem.
Reduces the time from error occurrence to error identification and fix.
General Principle:
Dividing Methods: The same principle of dividing methods applies across different programming languages (e.g., Python, Ruby, Go).
Small Units: Identify what you consider to be small, testable units and apply this division principle accordingly.
Testing Perspective in System Design:
Identifying Weak Points: From a testing perspective, it is easy to identify weak points, such as too much responsibility in one place.
Reducing Error Detection Time: High testability helps reduce the time from error occurrence to error detection and fix, similar to reducing the development cycle.
Quick Delivery: High testability contributes to quicker system delivery.
Key Points to Consider When Building Serverless Architecture from a Testing Perspective:
Separate Processing: Easier to test units are easier to understand. Separating processes helps identify weak points and reduces error detection time.
Avoiding Complexity: Concentrated responsibility and logic in one place make testing difficult. Separate processes to simplify testing and troubleshooting.
High Testability: Contributes to quicker system delivery and reduced development cycles.
Final Goal:
The ultimate goal for engineers is to deliver value to users.
Always keep user value in mind to ensure successful outcomes.
Encouraged discussion and collaboration to share insights and improve testing practices.
Top comments (0)