Skip to content

Commit d4f4130

Browse files
authored
Run AWS Lambda tests locally (#3988)
Test Sentry AWS Lambda integration locally instead of creating actual Lambda function in AWS: - Create a local AWS Lambda environment using AWS SAM and AWS CDK. (Docker based) - Start a local Sentry server that accepts envelopes. - Run the tests in the local AWS Lambda environment configured with a DSN that tells the SDK to send data to the local Sentry server. - Read the captured envelopes from the local Sentry server to assert their correctness. - Update CI configuration, so AWS tests are now handled the same as test suite matrices of other integrations. There is also a follow-up PR that removes obsolete code handling AWS authentication data: #4076 (This PR will also fix the one failing test) Fixes #2795
1 parent a97c53c commit d4f4130

File tree

34 files changed

+1021
-1685
lines changed

34 files changed

+1021
-1685
lines changed

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
Thank you for contributing to `sentry-python`! Please add tests to validate your changes, and lint your code using `tox -e linters`.
66

7-
Running the test suite on your PR might require maintainer approval. The AWS Lambda tests additionally require a maintainer to add a special label, and they will fail until this label is added.
7+
Running the test suite on your PR might require maintainer approval.

Diff for: .github/workflows/scripts/trigger_tests_on_label.py

-72
This file was deleted.

Diff for: .github/workflows/test-integrations-aws.yml

-126
This file was deleted.

Diff for: .github/workflows/test-integrations-cloud.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ jobs:
3535
# ubuntu-20.04 is the last version that supported python3.6
3636
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
3737
os: [ubuntu-20.04]
38+
services:
39+
docker:
40+
image: docker:dind # Required for Docker network management
41+
options: --privileged # Required for Docker-in-Docker operations
3842
steps:
3943
- uses: actions/[email protected]
4044
- uses: actions/setup-python@v5
@@ -47,6 +51,10 @@ jobs:
4751
- name: Erase coverage
4852
run: |
4953
coverage erase
54+
- name: Test aws_lambda latest
55+
run: |
56+
set -x # print commands that are executed
57+
./scripts/runtox.sh "py${{ matrix.python-version }}-aws_lambda-latest"
5058
- name: Test boto3 latest
5159
run: |
5260
set -x # print commands that are executed
@@ -97,12 +105,16 @@ jobs:
97105
strategy:
98106
fail-fast: false
99107
matrix:
100-
python-version: ["3.6","3.7","3.9","3.11","3.12","3.13"]
108+
python-version: ["3.6","3.7","3.8","3.9","3.11","3.12","3.13"]
101109
# python3.6 reached EOL and is no longer being supported on
102110
# new versions of hosted runners on Github Actions
103111
# ubuntu-20.04 is the last version that supported python3.6
104112
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
105113
os: [ubuntu-20.04]
114+
services:
115+
docker:
116+
image: docker:dind # Required for Docker network management
117+
options: --privileged # Required for Docker-in-Docker operations
106118
steps:
107119
- uses: actions/[email protected]
108120
- uses: actions/setup-python@v5
@@ -115,6 +127,10 @@ jobs:
115127
- name: Erase coverage
116128
run: |
117129
coverage erase
130+
- name: Test aws_lambda pinned
131+
run: |
132+
set -x # print commands that are executed
133+
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-aws_lambda"
118134
- name: Test boto3 pinned
119135
run: |
120136
set -x # print commands that are executed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ relay
2828
pip-wheel-metadata
2929
.mypy_cache
3030
.vscode/
31+
32+
# for running AWS Lambda tests using AWS SAM
33+
sam.template.yaml

Diff for: requirements-testing.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ socksio
1414
httpcore[http2]
1515
setuptools
1616
Brotli
17+
docker

Diff for: scripts/aws-cleanup.sh

-18
This file was deleted.

Diff for: scripts/aws-delete-lambda-layer-versions.sh renamed to scripts/aws/aws-delete-lambda-layer-versions.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
#
33
# Deletes all versions of the layer specified in LAYER_NAME in one region.
4+
# Use with caution!
45
#
56

67
set -euo pipefail

Diff for: scripts/aws-deploy-local-layer.sh renamed to scripts/aws/aws-deploy-local-layer.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env bash
22
#
3-
# Builds and deploys the Sentry AWS Lambda layer (including the Sentry SDK and the Sentry Lambda Extension)
3+
# Builds and deploys the `SentryPythonServerlessSDK-local-dev` AWS Lambda layer (containing the Sentry SDK)
44
#
55
# The currently checked out version of the SDK in your local directory is used.
6-
# The latest version of the Lambda Extension is fetched from the Sentry Release Registry.
76
#
87

98
set -euo pipefail

Diff for: scripts/aws_lambda_functions/README.md

-4
This file was deleted.

Diff for: scripts/aws_lambda_functions/sentryPythonDeleteTestFunctions/README.md

-13
This file was deleted.

Diff for: scripts/aws_lambda_functions/sentryPythonDeleteTestFunctions/lambda_function.py

-55
This file was deleted.

0 commit comments

Comments
 (0)