Skip to content

Commit 5f06d15

Browse files
committed
Add function invocation and durable execution history testing
- Invoke deployed functions with test payload - List durable executions and get execution history - Test job runs in parallel for each deployed function - Cleanup depends on both deploy and test jobs
1 parent ba0d2a3 commit 5f06d15

File tree

2 files changed

+90
-6
lines changed

2 files changed

+90
-6
lines changed

.github/workflows/deploy-examples.yml

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,13 @@ jobs:
9595
echo "EOF" >> $GITHUB_OUTPUT
9696
echo "Function name map: $FUNCTION_NAME_MAP"
9797
98-
cleanup:
99-
needs: [deploy]
98+
test:
99+
needs: deploy
100100
runs-on: ubuntu-latest
101-
if: always()
101+
strategy:
102+
matrix:
103+
example: ${{ fromJson(needs.deploy.outputs.function-name-map) }}
104+
fail-fast: false
102105

103106
steps:
104107
- uses: actions/checkout@v4
@@ -123,6 +126,83 @@ jobs:
123126
role-session-name: pythonTestingLibraryGitHubIntegrationTest
124127
aws-region: ${{ env.AWS_REGION }}
125128

129+
- name: Invoke Lambda function
130+
env:
131+
LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT }}
132+
FUNCTION_NAME: ${{ matrix.example }}
133+
run: |
134+
echo "Testing function: $FUNCTION_NAME"
135+
aws lambda invoke \
136+
--function-name "$FUNCTION_NAME" \
137+
--cli-binary-format raw-in-base64-out \
138+
--payload '{"name": "World"}' \
139+
--region "${{ env.AWS_REGION }}" \
140+
--endpoint-url "$LAMBDA_ENDPOINT" \
141+
/tmp/response.json
142+
echo "Response:"
143+
cat /tmp/response.json
144+
145+
- name: Find Durable Execution
146+
env:
147+
LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT }}
148+
FUNCTION_NAME: ${{ matrix.example }}
149+
run: |
150+
echo "Listing durable executions for function: $FUNCTION_NAME"
151+
aws lambda list-durable-executions \
152+
--function-name "$FUNCTION_NAME" \
153+
--region "${{ env.AWS_REGION }}" \
154+
--endpoint-url "$LAMBDA_ENDPOINT" \
155+
--cli-binary-format raw-in-base64-out \
156+
--status-filter SUCCEEDED \
157+
> /tmp/executions.json
158+
echo "Durable Executions:"
159+
cat /tmp/executions.json
160+
161+
# Extract the first execution ARN for history retrieval
162+
EXECUTION_ARN=$(jq -r '.DurableExecutions[0].DurableExecutionArn // empty' /tmp/executions.json)
163+
echo "EXECUTION_ARN=$EXECUTION_ARN" >> $GITHUB_ENV
164+
165+
- name: Get Durable Execution History
166+
if: env.EXECUTION_ARN != ''
167+
env:
168+
LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT }}
169+
run: |
170+
echo "Getting execution history for: $EXECUTION_ARN"
171+
aws lambda get-durable-execution-history \
172+
--durable-execution-arn "$EXECUTION_ARN" \
173+
--region "${{ env.AWS_REGION }}" \
174+
--endpoint-url "$LAMBDA_ENDPOINT" \
175+
--cli-binary-format raw-in-base64-out \
176+
> /tmp/history.json
177+
echo "Execution History:"
178+
cat /tmp/history.json
179+
180+
cleanup:
181+
needs: [deploy, test]
182+
runs-on: ubuntu-latest
183+
if: always()
184+
185+
steps:
186+
- uses: actions/checkout@v4
187+
188+
- name: Setup SSH Agent
189+
uses: webfactory/ssh-agent@v0.9.0
190+
with:
191+
ssh-private-key: ${{ secrets.SDK_KEY }}
192+
193+
- name: Setup Python
194+
uses: actions/setup-python@v4
195+
with:
196+
python-version: '3.13'
197+
198+
- name: Configure AWS credentials
199+
if: github.event_name != 'workflow_dispatch' || github.actor != 'nektos/act'
200+
uses: aws-actions/configure-aws-credentials@v4
201+
with:
202+
role-to-assume: "${{ secrets.ACTIONS_INTEGRATION_ROLE_NAME }}"
203+
role-session-name: pythonTestingLibraryGitHubIntegrationTest
204+
aws-region: ${{ env.AWS_REGION }}
205+
126206
- name: Install Hatch
127207
run: pip install hatch
128208

examples/src/hello_world.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from typing import Any
22

3+
from aws_durable_execution_sdk_python.context import DurableContext
4+
from aws_durable_execution_sdk_python.execution import durable_handler
35

4-
def handler(_event: Any, _context: Any) -> str:
5-
"""Simple hello world function."""
6-
return "Hello World!"
6+
7+
@durable_handler
8+
def handler(_event: Any, _context: DurableContext) -> str:
9+
"""Simple hello world durable function."""
10+
return "Hello World!"

0 commit comments

Comments
 (0)