Skip to content

Commit 17d9435

Browse files
authored
Merge pull request #692 from hjgraca/feature/e2etests
chore: Add e2e tests
2 parents 57ab34e + 37bfb36 commit 17d9435

File tree

14 files changed

+183
-217
lines changed

14 files changed

+183
-217
lines changed

.github/workflows/e2e-infra-deploy.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

.github/workflows/e2e-infra-destroy.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/e2e-tests.yml

Lines changed: 130 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@ permissions:
2121
contents: read
2222

2323
jobs:
24-
25-
deploy-core-stack:
26-
runs-on: aws-powertools_ubuntu-latest_8-core
27-
permissions:
28-
id-token: write
29-
contents: read
24+
deploy-stack:
25+
runs-on: ubuntu-latest
3026
steps:
3127
- name: Checkout code
3228
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
3329

3430
- name: Configure AWS credentials
35-
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
31+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
3632
with:
3733
role-to-assume: ${{ secrets.E2E_DEPLOY_ROLE }}
3834
aws-region: us-east-1
@@ -42,23 +38,77 @@ jobs:
4238
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
4339
with:
4440
dotnet-version: '8.x'
45-
46-
- name: Setup Node.js
47-
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
48-
with:
49-
node-version: "20.10.0"
50-
41+
5142
- name: Install CDK
5243
run: npm install -g aws-cdk
5344

45+
- name: Install AWS Lambda .NET CLI Tools
46+
run: dotnet tool install -g Amazon.Lambda.Tools
47+
5448
- name: Deploy Core Stack
5549
run: |
5650
cd libraries/tests/e2e/infra
5751
cdk deploy --require-approval never
5852
53+
# deploy-aot-stack:
54+
# runs-on: ubuntu-latest
55+
# strategy:
56+
# fail-fast: false
57+
# matrix:
58+
# architecture: [ x86_64, arm64 ]
59+
# steps:
60+
# - name: Checkout code
61+
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
62+
#
63+
# - name: Configure AWS credentials
64+
# uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
65+
# with:
66+
# role-to-assume: ${{ secrets.E2E_DEPLOY_ROLE }}
67+
# aws-region: us-east-1
68+
#
69+
# - name: Set up .NET
70+
# uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
71+
# with:
72+
# dotnet-version: '8.x'
73+
#
74+
# - name: Install CDK
75+
# run: npm install -g aws-cdk
76+
#
77+
# - name: Install AWS Lambda .NET CLI Tools
78+
# run: dotnet tool install -g Amazon.Lambda.Tools
79+
#
80+
# - name: Set up QEMU
81+
# uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a
82+
# with:
83+
# platforms: ${{ matrix.architecture }}
84+
#
85+
# - name: Set up Docker Buildx
86+
# id: builder
87+
# uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
88+
# with:
89+
# install: true
90+
# driver: docker
91+
# platforms: linux/amd64,linux/arm64
92+
#
93+
# - name: Deploy AOT Stack
94+
# run: |
95+
# cd libraries/tests/e2e/infra-aot
96+
# cdk deploy -c architecture=${{ matrix.architecture }} --require-approval never
97+
98+
run-tests:
99+
runs-on: ubuntu-latest
100+
needs: deploy-stack
101+
steps:
59102
- name: Checkout code
60103
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
61104

105+
- name: Configure AWS credentials
106+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
107+
with:
108+
role-to-assume: ${{ secrets.E2E_DEPLOY_ROLE }}
109+
aws-region: us-east-1
110+
mask-aws-account-id: true
111+
62112
- name: Set up .NET
63113
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
64114
with:
@@ -69,28 +119,71 @@ jobs:
69119
cd libraries/tests/e2e/functions/core
70120
dotnet test
71121
72-
# run-tests:
73-
# runs-on: aws-powertools_ubuntu-latest_8-core
74-
# # needs: [deploy-core-stack, deploy-aot-stack]
75-
# # needs: [deploy-core-stack]
76-
# steps:
77-
# - name: Checkout code
78-
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
79-
80-
# - name: Set up .NET
81-
# uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3
82-
# with:
83-
# dotnet-version: '8.x'
84-
85-
# - name: Run Core Tests
86-
# run: |
87-
# cd libraries/tests/e2e/functions/core
88-
# dotnet test
89-
90-
# - name: Destroy Core Stack
91-
# if: always()
92-
# uses: ./.github/workflows/e2e-infra-destroy.yml
93-
94-
# destroy-core-stack:
122+
destroy-stack:
123+
runs-on: ubuntu-latest
124+
needs: run-tests
125+
if: always()
126+
steps:
127+
- name: Checkout code
128+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
129+
130+
- name: Configure AWS credentials
131+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
132+
with:
133+
role-to-assume: ${{ secrets.E2E_DEPLOY_ROLE }}
134+
aws-region: us-east-1
135+
mask-aws-account-id: true
136+
137+
- name: Install CDK
138+
run: npm install -g aws-cdk
139+
140+
- name: Install AWS Lambda .NET CLI Tools
141+
run: dotnet tool install -g Amazon.Lambda.Tools
142+
143+
- name: Destroy Core Stack
144+
run: |
145+
cd libraries/tests/e2e/infra
146+
cdk destroy --force
147+
148+
# destroy-aot-stack:
149+
# runs-on: ubuntu-latest
95150
# needs: run-tests
96-
# uses: ./.github/workflows/e2e-infra-destroy.yml
151+
# if: always()
152+
# strategy:
153+
# fail-fast: false
154+
# matrix:
155+
# architecture: [ x86_64, arm64 ]
156+
# steps:
157+
# - name: Checkout code
158+
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
159+
#
160+
# - name: Configure AWS credentials
161+
# uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
162+
# with:
163+
# role-to-assume: ${{ secrets.E2E_DEPLOY_ROLE }}
164+
# aws-region: us-east-1
165+
# mask-aws-account-id: true
166+
#
167+
# - name: Install CDK
168+
# run: npm install -g aws-cdk
169+
#
170+
# - name: Install AWS Lambda .NET CLI Tools
171+
# run: dotnet tool install -g Amazon.Lambda.Tools
172+
#
173+
# - name: Set up QEMU
174+
# uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a
175+
# with:
176+
# platforms: ${{ matrix.architecture }}
177+
#
178+
# - name: Set up Docker Buildx
179+
# id: builder
180+
# uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
181+
# with:
182+
# install: true
183+
# driver: docker
184+
# platforms: linux/amd64,linux/arm64
185+
#
186+
# - name: Destroy Core AOT Stack
187+
# run: |
188+
# cd libraries/tests/e2e/infra-aot
189+
# cdk destroy -c architecture=${{ matrix.architecture }} --force

libraries/tests/e2e/functions/core/logging/AOT-Function/src/AOT-Function/AOT-Function.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4"/>
2323
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.1" />
2424
</ItemGroup>
25-
<ItemGroup>
26-
<ProjectReference Include="..\..\..\..\..\..\..\..\src\AWS.Lambda.Powertools.Logging\AWS.Lambda.Powertools.Logging.csproj" />
27-
</ItemGroup>
2825
<ItemGroup>
2926
<Compile Include="..\..\..\Function\src\Function\TestHelper.cs">
3027
<Link>TestHelper.cs</Link>
3128
</Compile>
3229
</ItemGroup>
30+
<ItemGroup>
31+
<ProjectReference Include="..\..\..\..\..\..\..\..\src\AWS.Lambda.Powertools.Logging\AWS.Lambda.Powertools.Logging.csproj" />
32+
</ItemGroup>
3333
</Project>

libraries/tests/e2e/functions/core/logging/Function/test/Function.Tests/FunctionTest.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public FunctionTest(ITestOutputHelper testOutputHelper)
2525
[InlineData("E2ETestLambda_ARM_NET6_logging")]
2626
[InlineData("E2ETestLambda_X64_NET8_logging")]
2727
[InlineData("E2ETestLambda_ARM_NET8_logging")]
28-
[InlineData("E2ETestLambda_ARM_AOT_NET8_logging")]
28+
// [InlineData("E2ETestLambda_ARM_AOT_NET8_logging")]
2929
public async Task TestFunction(string functionName)
3030
{
3131
var request = new InvokeRequest
@@ -114,30 +114,6 @@ private void AssertEventLog(string functionName, bool isColdStart, string output
114114
Assert.True(headersElement.TryGetProperty("Cache-Control", out JsonElement cacheControlElement));
115115
Assert.Equal("max-age=0", cacheControlElement.GetString());
116116

117-
Assert.True(headersElement.TryGetProperty("CloudFront-Forwarded-Proto",
118-
out JsonElement cloudFrontForwardedProtoElement));
119-
Assert.Equal("https", cloudFrontForwardedProtoElement.GetString());
120-
121-
Assert.True(headersElement.TryGetProperty("CloudFront-Viewer-Country",
122-
out JsonElement cloudFrontViewerCountryElement));
123-
Assert.Equal("US", cloudFrontViewerCountryElement.GetString());
124-
125-
Assert.True(headersElement.TryGetProperty("Upgrade-Insecure-Requests",
126-
out JsonElement upgradeInsecureRequestsElement));
127-
Assert.Equal("1", upgradeInsecureRequestsElement.GetString());
128-
129-
Assert.True(headersElement.TryGetProperty("User-Agent", out JsonElement userAgentElement));
130-
Assert.Equal("Custom User Agent String", userAgentElement.GetString());
131-
132-
Assert.True(headersElement.TryGetProperty("X-Forwarded-For", out JsonElement xForwardedForElement));
133-
Assert.Equal("127.0.0.1, 127.0.0.2", xForwardedForElement.GetString());
134-
135-
Assert.True(headersElement.TryGetProperty("X-Forwarded-Port", out JsonElement xForwardedPortElement));
136-
Assert.Equal("443", xForwardedPortElement.GetString());
137-
138-
Assert.True(headersElement.TryGetProperty("X-Forwarded-Proto", out JsonElement xForwardedProtoElement));
139-
Assert.Equal("https", xForwardedProtoElement.GetString());
140-
141117
Assert.True(
142118
messageElement.TryGetProperty("QueryStringParameters", out JsonElement queryStringParametersElement));
143119
Assert.True(queryStringParametersElement.TryGetProperty("Foo", out JsonElement fooElement));

libraries/tests/e2e/functions/core/metrics/Function/src/Function/Function.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
using Amazon.Lambda.APIGatewayEvents;
22
using Amazon.Lambda.Core;
33
using AWS.Lambda.Powertools.Metrics;
4+
using Helpers;
45

56
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
67
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
78

8-
namespace Helpers;
9+
namespace Function;
910

1011
public class Function
1112
{

0 commit comments

Comments
 (0)