This directory contains integration tests for the Python Durable Execution SDK examples. Tests can run in two modes using pytest fixtures.
Tests run against the in-memory DurableFunctionTestRunner:
- ✅ Fast execution (seconds)
- ✅ No AWS credentials needed
- ✅ Perfect for development
- ✅ Validates local runner behavior
# Run all example tests locally (default)
hatch run test:examples
# Run with explicit mode flag
pytest --runner-mode=local -m example examples/test/
# Run specific test
pytest --runner-mode=local -k test_hello_world examples/test/Tests run against actual AWS Lambda functions using DurableFunctionCloudTestRunner:
- ✅ Validates cloud deployment
- ✅ Tests real Lambda execution
- ✅ Verifies end-to-end behavior
⚠️ Requires deployed functions
# Deploy function first
hatch run examples:deploy "hello world" --function-name HelloWorld-Test
# Set environment variables for cloud testing
export AWS_REGION=us-west-2
export LAMBDA_ENDPOINT=https://lambda.us-west-2.amazonaws.com
export QUALIFIED_FUNCTION_NAME="HelloWorld-Test:\$LATEST"
export LAMBDA_FUNCTION_TEST_NAME="hello world"
# Run tests
pytest --runner-mode=cloud -k test_hello_world examples/test/
# Or using hatch
hatch run test:examples-integration -k test_hello_worldUse the durable_runner pytest fixture with the @pytest.mark.durable_execution marker:
import pytest
from aws_durable_execution_sdk_python.execution import InvocationStatus
from examples.src import my_example
@pytest.mark.example
@pytest.mark.durable_execution(
handler=my_example.handler,
lambda_function_name="my example",
)
def test_my_example(durable_runner):
"""Test my example in both local and cloud modes."""
with durable_runner:
result = durable_runner.run(input={"test": "data"}, timeout=10)
# Assertions work in both modes
assert result.status == InvocationStatus.SUCCEEDED
assert result.result == "expected output"
# Optional mode-specific validations
if durable_runner.mode == "cloud":
# Cloud-specific assertions
passAWS_REGION- AWS region for Lambda invocation (default: us-west-2)LAMBDA_ENDPOINT- Optional Lambda endpoint URL for testingQUALIFIED_FUNCTION_NAME- Deployed Lambda function ARN or qualified name (required for cloud mode)LAMBDA_FUNCTION_TEST_NAME- Lambda function name to match with test'slambda_function_namemarker (required for cloud mode)
--runner-mode- Test mode:local(default) orcloud
-m example- Run only example tests-k test_name- Run tests matching pattern
Tests automatically run in CI/CD after deployment:
deploy-examples.ymldeploys functions- Integration tests run against deployed functions
- Results reported in GitHub Actions
See .github/workflows/deploy-examples.yml for details.
Problem: TimeoutError: Execution did not complete within 60s
Solution: Increase timeout in test:
result = runner.run(input="test", timeout=120) # Increase to 120sProblem: ModuleNotFoundError: No module named 'aws_durable_execution_sdk_python_testing'
Solution: Install dependencies:
hatch run test:examples # Installs dependencies automatically