Skip to content

Commit ff9e0b7

Browse files
authored
[.NET] Add Performance Testing Workflow for Lambda Layer (#393)
**Issue description:** Added a workflow to automatically performance test and gather the results for the unreleased .NET Lambda Layer. **The GitHub workflow does the following:** 1. Deploy and setup the .NET Lambda sample application instrumented with the Application Signals Lambda Layer on the AppSignals e2e testing aws account. 2. Record the start time of the test and run the specified amount (default: 20) Lambda cold start iterations on the sample application 3. Record the end time of the test 4. Query CW Logs Insights for the aggregated performance testing metrics with the following query: ``` fields @timestamp, @message, @initDuration | filter @message like "REPORT RequestId" | stats count(@initDuration) as Sample_Count, avg(@initDuration) as Average_Init_Duration, min(@initDuration) as Min_Init_Duration, max(@initDuration) as Max_Init_Duration, pct(@initDuration, 50) as P50_Init_Duration, pct(@initDuration, 90) as P90_Init_Duration, pct(@initDuration, 99) as P99_Init_Duration' ``` 5. Parse and flatten the result from the query call and save it in a file. 6. Clean and destroy the deployed lambda resources upon completion, cancellation, or failure. **Testing** Testing was done on a personal aws dev account with the exact IAM permissions as the e2e testing aws account. Example of a successful job: https://github.com/liustve/aws-application-signals-test-framework/actions/runs/14389946356
1 parent 7c9f852 commit ff9e0b7

File tree

3 files changed

+115
-2
lines changed

3 files changed

+115
-2
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
4+
name: DotNet Lambda Layer Performance Test
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
test_runs:
9+
description: 'Number of test runs to perform'
10+
required: true
11+
default: 20
12+
type: number
13+
14+
dotnet-version:
15+
description: 'dotnet version to use'
16+
required: true
17+
default: '8.0.x'
18+
type: string
19+
20+
jobs:
21+
dotnet-lambda-layer-performance-test:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
id-token: write
25+
contents: read
26+
27+
env:
28+
NUM_TEST_RUNS: ${{ github.event.inputs.test_runs }}
29+
30+
steps:
31+
- name: Configure AWS Credentials
32+
uses: aws-actions/configure-aws-credentials@v4
33+
with:
34+
role-to-assume: arn:aws:iam::${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }}:role/${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }}
35+
aws-region: us-east-1
36+
37+
- name: Checkout aws-otel-dotnet-instrumentation
38+
uses: actions/checkout@v4
39+
with:
40+
repository: aws-observability/aws-otel-dotnet-instrumentation
41+
path: aws-otel-dotnet-instrumentation
42+
43+
- name: Setup .NET
44+
uses: actions/setup-dotnet@v4
45+
with:
46+
dotnet-version: ${{ github.event.inputs.dotnet-version }}
47+
48+
- name: Setup AWS Lambda Tools
49+
run: dotnet tool install -g Amazon.Lambda.Tools
50+
51+
- name: Setup Terraform
52+
uses: hashicorp/setup-terraform@v2
53+
54+
- name: Build and Deploy .NET Sample App and Lambda Layer
55+
run: |
56+
cd aws-otel-dotnet-instrumentation/sample-applications/lambda-test-apps/SimpleLambdaFunction/
57+
./build-and-deploy.sh
58+
59+
- name: Checkout current repository
60+
uses: actions/checkout@v4
61+
with:
62+
path: current-repo
63+
64+
- name: Run Cold Start Iterations for Base Lambda + Lambda Layer
65+
run: |
66+
cd current-repo
67+
chmod +x lambda-layer-perf-test/lambda-layer-run.sh
68+
./lambda-layer-perf-test/lambda-layer-run.sh false SimpleLambdaFunction
69+
70+
- name: Remove Application Signals Lambda Layer
71+
run: |
72+
echo "Removing Lambda layer..."
73+
74+
OUTPUT=$(aws lambda update-function-configuration \
75+
--function-name SimpleLambdaFunction \
76+
--layers [])
77+
78+
echo "Lambda configuration:"
79+
echo "$OUTPUT"
80+
81+
LAYERS=$(echo "$OUTPUT" | jq -r '.Layers | length')
82+
83+
if [ "$LAYERS" -ne 0 ]; then
84+
echo "::error::Found $LAYERS layer(s) still attached to the function"
85+
echo "::error::Layer details:"
86+
echo "$OUTPUT" | jq -r '.Layers'
87+
exit 1
88+
else
89+
echo "✅ Layers successfully removed"
90+
fi
91+
92+
- name: Run Cold Start Iterations for Base Lambda
93+
run: |
94+
cd current-repo
95+
chmod +x lambda-layer-perf-test/lambda-layer-run.sh
96+
./lambda-layer-perf-test/lambda-layer-run.sh true SimpleLambdaFunction
97+
98+
- name: Upload test results
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: dotnet-performance-test-results
102+
path: |
103+
no_layer_results.txt
104+
layer_results.txt
105+
retention-days: 90
106+
107+
- name: Cleanup Terraform Resources
108+
if: success() || failure() || cancelled()
109+
run: |
110+
cd aws-otel-dotnet-instrumentation/sample-applications/lambda-test-apps/SimpleLambdaFunction/terraform/lambda
111+
echo "Starting Terraform cleanup..."
112+
terraform init
113+
terraform destroy -auto-approve

.github/workflows/node-lambda-layer-perf-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
- name: Upload test results
105105
uses: actions/upload-artifact@v4
106106
with:
107-
name: performance-test-results
107+
name: js-performance-test-results
108108
path: |
109109
no_layer_results.txt
110110
layer_results.txt

.github/workflows/python-lambda-layer-perf-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
- name: Upload test results
9696
uses: actions/upload-artifact@v4
9797
with:
98-
name: performance-test-results
98+
name: python-performance-test-results
9999
path: |
100100
no_layer_results.txt
101101
layer_results.txt

0 commit comments

Comments
 (0)