Skip to content

Commit c741030

Browse files
authored
test(aws-serverless): Split npm & layer tests (#20442)
This PR splits the aws-serverless test app into two, aws-serverless, which tests the npm package directly, and aws-serverless-layer, which tests using the layer. This allowed to make the test app easier to understand and follow and make the dependency graph clearer as well. I choose to run the layer in different node versions and the npm stuff only in node 20, IMHO that should be good enough, I don't think we need to also run the npm stuff in all the node versions, so we can reduce the number of test apps a bit.
1 parent f97076d commit c741030

16 files changed

Lines changed: 388 additions & 109 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ jobs:
935935
matrix.test-application)
936936
uses: oven-sh/setup-bun@v2
937937
- name: Set up AWS SAM
938-
if: matrix.test-application == 'aws-serverless'
938+
if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer'
939939
uses: aws-actions/setup-sam@v2
940940
with:
941941
use-installer: true
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "aws-serverless-layer",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "commonjs",
6+
"scripts": {
7+
"test": "playwright test",
8+
"clean": "npx rimraf node_modules pnpm-lock.yaml",
9+
"test:pull-sam-image": "./pull-sam-image.sh",
10+
"test:build": "pnpm test:pull-sam-image && pnpm install && npx rimraf node_modules/@sentry/aws-serverless/nodejs",
11+
"test:assert": "pnpm test"
12+
},
13+
"//": "We just need the @sentry/aws-serverless layer zip file, not the NPM package",
14+
"devDependencies": {
15+
"@aws-sdk/client-lambda": "^3.863.0",
16+
"@playwright/test": "~1.56.0",
17+
"@sentry-internal/test-utils": "link:../../../test-utils",
18+
"@sentry/aws-serverless": "link:../../../../packages/aws-serverless/build/aws/dist-serverless/",
19+
"aws-cdk-lib": "^2.210.0",
20+
"constructs": "^10.4.2",
21+
"glob": "^11.0.3",
22+
"rimraf": "^5.0.10"
23+
},
24+
"volta": {
25+
"extends": "../../package.json"
26+
},
27+
"//": "We need to override this here again to ensure this is not overwritten by the test runner",
28+
"pnpm": {
29+
"overrides": {
30+
"@sentry/aws-serverless": "link:../../../../packages/aws-serverless/build/aws/dist-serverless/"
31+
}
32+
},
33+
"sentryTest": {
34+
"variants": [
35+
{
36+
"build-command": "NODE_VERSION=22 pnpm test:build",
37+
"assert-command": "NODE_VERSION=22 pnpm test:assert",
38+
"label": "aws-serverless-layer (Node 22)"
39+
},
40+
{
41+
"build-command": "NODE_VERSION=18 pnpm test:build",
42+
"assert-command": "NODE_VERSION=18 pnpm test:assert",
43+
"label": "aws-serverless-layer (Node 18)"
44+
}
45+
]
46+
}
47+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
export default getPlaywrightConfig(undefined, {
4+
timeout: 60 * 1000 * 3, // 3 minutes
5+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# Pull the Lambda Node docker image for SAM local. NODE_VERSION should be the major only (e.g. 20).
4+
# Defaults to 20 to match the repo's Volta Node major (see root package.json "volta.node").
5+
6+
set -e
7+
8+
NODE_VERSION="${NODE_VERSION:-20}"
9+
10+
echo "Pulling Lambda Node $NODE_VERSION docker image..."
11+
docker pull "public.ecr.aws/lambda/nodejs:${NODE_VERSION}"
12+
13+
echo "Successfully pulled Lambda Node $NODE_VERSION docker image"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SAM CLI expects this file in the project root; without it, `sam local start-lambda` logs
2+
# OSError / missing file errors when run from the e2e temp directory.
3+
# These values are placeholders — this app only uses `sam local`, not deploy.
4+
version = 0.1
5+
6+
[default.deploy.parameters]
7+
stack_name = "sentry-e2e-aws-serverless-layer-local"
8+
region = "us-east-1"
9+
confirm_changeset = false
10+
capabilities = "CAPABILITY_IAM"

dev-packages/e2e-tests/test-applications/aws-serverless/src/lambda-functions-layer/Error/index.js renamed to dev-packages/e2e-tests/test-applications/aws-serverless-layer/src/lambda-functions-layer/Error/index.js

File renamed without changes.

dev-packages/e2e-tests/test-applications/aws-serverless/src/lambda-functions-layer/ErrorEsm/index.mjs renamed to dev-packages/e2e-tests/test-applications/aws-serverless-layer/src/lambda-functions-layer/ErrorEsm/index.mjs

File renamed without changes.

dev-packages/e2e-tests/test-applications/aws-serverless/src/lambda-functions-layer/Streaming/index.mjs renamed to dev-packages/e2e-tests/test-applications/aws-serverless-layer/src/lambda-functions-layer/Streaming/index.mjs

File renamed without changes.

dev-packages/e2e-tests/test-applications/aws-serverless/src/lambda-functions-layer/TracingCjs/index.js renamed to dev-packages/e2e-tests/test-applications/aws-serverless-layer/src/lambda-functions-layer/TracingCjs/index.js

File renamed without changes.

dev-packages/e2e-tests/test-applications/aws-serverless/src/lambda-functions-layer/TracingEsm/index.mjs renamed to dev-packages/e2e-tests/test-applications/aws-serverless-layer/src/lambda-functions-layer/TracingEsm/index.mjs

File renamed without changes.

0 commit comments

Comments
 (0)