Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ package-lock.json
/.idea/

.gitlab/build-*.yaml

# Local datadog-lambda-js tarballs produced for container integration tests
integration_tests/container/*/datadog-lambda-js-local.tgz
6 changes: 5 additions & 1 deletion .gitlab/input_files/build.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ unit test ({{ $runtime.name }}):

integration test ({{ $runtime.name }}):
stage: test
tags: ["arch:amd64"]
# `docker-in-docker:<arch>` routes the job to a runner with a live Docker
# daemon (vs. plain `arch:amd64` which only has the docker CLI). Required by
# the container-image integration tests, which build & push ECR images for
# the `container-{cjs,esm}_node*` functions.
tags: ["docker-in-docker:amd64"]
image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION}
needs:
- build layer ({{ $runtime.name }})
Expand Down
1 change: 0 additions & 1 deletion .gitlab/scripts/publish_npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ if [ -d "./dist" ]; then
rm -rf ./dist
fi
yarn build
cp ./dist/handler.cjs ./dist/handler.js
npm publish
11 changes: 11 additions & 0 deletions integration_tests/container/cjs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG NODE_VERSION=22
FROM public.ecr.aws/lambda/nodejs:${NODE_VERSION}

COPY package.json handler.js ${LAMBDA_TASK_ROOT}/
COPY datadog-lambda-js-local.tgz /tmp/datadog-lambda-js-local.tgz
RUN cd ${LAMBDA_TASK_ROOT} \
&& npm install --omit=dev \
&& npm install --no-save /tmp/datadog-lambda-js-local.tgz \
&& rm /tmp/datadog-lambda-js-local.tgz

CMD ["node_modules/datadog-lambda-js/dist/handler.handler"]
3 changes: 3 additions & 0 deletions integration_tests/container/cjs/handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.handle = (event) => {
return { message: "hello, dog!" };
};
8 changes: 8 additions & 0 deletions integration_tests/container/cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "container-cjs-test",
"version": "1.0.0",
"private": true,
"dependencies": {
"dd-trace": "5.105.0"
}
}
11 changes: 11 additions & 0 deletions integration_tests/container/esm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG NODE_VERSION=22
FROM public.ecr.aws/lambda/nodejs:${NODE_VERSION}

COPY package.json handler.mjs ${LAMBDA_TASK_ROOT}/
COPY datadog-lambda-js-local.tgz /tmp/datadog-lambda-js-local.tgz
RUN cd ${LAMBDA_TASK_ROOT} \
&& npm install --omit=dev \
&& npm install --no-save /tmp/datadog-lambda-js-local.tgz \
&& rm /tmp/datadog-lambda-js-local.tgz

CMD ["node_modules/datadog-lambda-js/dist/handler.handler"]
8 changes: 8 additions & 0 deletions integration_tests/container/esm/handler.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { promisify } from "util";

// Verify top-level await works in the container-image ESM path
await promisify(setTimeout)(50);

export function handle(event) {
return { message: "hello, dog!" };
}
9 changes: 9 additions & 0 deletions integration_tests/container/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "container-esm-test",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"dd-trace": "5.105.0"
}
}
36 changes: 36 additions & 0 deletions integration_tests/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ provider:
iam:
# IAM permissions require that all functions are deployed with this role
role: "arn:aws:iam::425362996713:role/serverless-integration-test-lambda-role"
# Container image builds for the npm-redirect tests. Each Node major is built
# from public.ecr.aws/lambda/nodejs:${NODE_MAJOR} so the AWS-stock RIC for
# that runtime is exercised against `dist/handler.handler`.
ecr:
images:
datadog-lambda-js-cjs:
path: ./container/cjs
platform: linux/amd64
buildArgs:
NODE_VERSION: ${env:NODE_MAJOR}
datadog-lambda-js-esm:
path: ./container/esm
platform: linux/amd64
buildArgs:
NODE_VERSION: ${env:NODE_MAJOR}

layers:
node:
Expand Down Expand Up @@ -81,6 +96,27 @@ functions:
environment:
DD_FLUSH_TO_LOG: true

# container-cjs — npm-installed datadog-lambda-js, CJS user handler,
# invoked through AWS-stock RIC via `dist/handler.handler`.
container-cjs_node:
name: integration-tests-js-${sls:stage}-container-cjs_${env:RUNTIME}
image:
name: datadog-lambda-js-cjs
environment:
DD_FLUSH_TO_LOG: true
DD_LAMBDA_HANDLER: handler.handle

# container-esm — npm-installed datadog-lambda-js, ESM user handler,
# invoked through AWS-stock RIC via `dist/handler.handler`. Guards against
# ERR_REQUIRE_ESM if `dist/handler.js` ever returns to the published tarball.
container-esm_node:
name: integration-tests-js-${sls:stage}-container-esm_${env:RUNTIME}
image:
name: datadog-lambda-js-esm
environment:
DD_FLUSH_TO_LOG: true
DD_LAMBDA_HANDLER: handler.handle

# status-code-500s
status-code-500s_node:
name: integration-tests-js-${sls:stage}-status-code-500s_${env:RUNTIME}
Expand Down
Loading
Loading