Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 5 additions & 2 deletions .claude/skills/release-lambda-layer/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ Reference: https://datadoghq.atlassian.net/wiki/spaces/SLS/pages/3375925277
1. Create a branch for the version bump.
2. Run `yarn upgrade dd-trace` (or `yarn upgrade dd-trace@^a.b.c` for a
specific version) to pick up the latest tracer.
3. If dd-trace changed, refresh integration test snapshots:
`BUILD_LAYERS=true UPDATE_SNAPSHOTS=true DD_API_KEY=<key from 1Password> aws-vault exec sso-serverless-sandbox-account-admin -- ./scripts/run_integration_tests.sh`
3. If dd-trace changed, refresh the integration test snapshots. The local
RIE-based docker suite is the behavioral gate:
`UPDATE_SNAPSHOTS=true ./integration_tests_local/run.sh`
Rely on the end-to-end test suites for coverage that requires real AWS
Lambda resources.
4. Bump `package.json` version to `X.Y.0`:
- Minor version bumps on every release, and **must match the layer
version**.
Expand Down
23 changes: 0 additions & 23 deletions .gitlab/input_files/build.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,6 @@ npm package test ({{ $runtime.name }}):
script:
- ./scripts/test_npm_package.sh datadog-lambda-js-*.tgz

integration test ({{ $runtime.name }}):
stage: test
# `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 }})
dependencies:
- build layer ({{ $runtime.name }})
cache: &{{ $runtime.name }}-cache
variables:
CI_ENABLE_CONTAINER_IMAGE_BUILDS: "true"
before_script:
- EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source .gitlab/scripts/get_secrets.sh
- (cd integration_tests && yarn install)
script:
- RUNTIME_PARAM={{ $runtime.node_major_version }} ./scripts/run_integration_tests.sh

{{ range $environment := (ds "environments").environments }}
{{ $dotenv := print $runtime.name "_" $environment.name ".env" }}

Expand All @@ -146,7 +125,6 @@ sign layer ({{ $runtime.name }}):
- lint ({{ $runtime.name }})
- unit test ({{ $runtime.name }})
- npm package test ({{ $runtime.name }})
- integration test ({{ $runtime.name }})
dependencies:
- build layer ({{ $runtime.name }})
artifacts: # Re specify artifacts so the modified signed file is passed
Expand Down Expand Up @@ -182,7 +160,6 @@ publish layer {{ $environment.name }} ({{ $runtime.name }}):
- lint ({{ $runtime.name }})
- unit test ({{ $runtime.name }})
- npm package test ({{ $runtime.name }})
- integration test ({{ $runtime.name }})
{{ end }}
dependencies:
{{ if or (eq $environment.name "prod") }}
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: check-merge-conflict
files: \.py$
- id: trailing-whitespace
exclude: integration_tests/snapshots
exclude: integration_tests_local/snapshots
- repo: git@github.com:pre-commit/mirrors-prettier
rev: ""
hooks:
Expand All @@ -18,4 +18,4 @@ repos:
description: Checks for AWS or Datadog API keys
entry: .github/.git-hooks/detect-api-keys.py
language: python
exclude: ^(yarn.lock|integration_tests/|event_samples/|src/trace/trigger.spec.ts|src/trace/context.spec.ts|src/trace/trigger.ts)
exclude: ^(yarn.lock|integration_tests/|integration_tests_local/snapshots/|event_samples/|src/trace/trigger.spec.ts|src/trace/context.spec.ts|src/trace/trigger.ts)
16 changes: 5 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,13 @@ We love pull requests. For new features, consider opening an issue to discuss th
```bash
yarn test
```
1. Run the integration tests against your own AWS account and Datadog org (or ask a Datadog member to run):
1. Run the local docker-based integration tests (no AWS account needed — this is the
behavioral gate that runs per PR):
```bash
BUILD_LAYERS=true DD_API_KEY=<your Datadog api key> ./scripts/run_integration_tests.sh
./integration_tests_local/run.sh
Comment thread
joeyzhao2018 marked this conversation as resolved.
```
1. Update integration test snapshots if needed (Datadog employees only; requires AWS credentials and Docker):
```bash
BUILD_LAYERS=true UPDATE_SNAPSHOTS=true DD_API_KEY=<your Datadog api key> aws-vault exec sso-serverless-sandbox-account-admin -- ./scripts/run_integration_tests.sh
```
If ECR image push fails locally, update zip/layer handler snapshots only:
```bash
BUILD_LAYERS=true UPDATE_SNAPSHOTS=true SKIP_CONTAINER_TESTS=true DD_API_KEY=<your Datadog api key> aws-vault exec sso-serverless-sandbox-account-admin -- ./scripts/run_integration_tests.sh
```
The script uses Serverless `3.39.0` from `integration_tests/package.json` (not a globally installed CLI).
1. Rely on the end-to-end test suites for cases that require real AWS Lambda
resources. See `integration_tests/README.md`.
1. Push to your fork and [submit a pull request][pr].

[pr]: https://github.com/your-username/datadog-lambda-js/compare/DataDog:main..main.
Expand Down
25 changes: 25 additions & 0 deletions integration_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# integration_tests/

This directory now hosts only the **fixtures shared with the local docker-based
integration suite** (`integration_tests_local/`):

- `input_events/` — the nine event payloads the local RIE-based suite invokes
with,
- `parse-json.js` — JSON-log line parser used by `integration_tests_local/normalize.sh`,
- `container/` — the container-image fixtures (`cjs`, `esm`) built by the local suite.

## The real AWS Lambda resource-based suite was deprecated

The serverless-deployed suite that used to live here (`serverless.yml`,
`snapshots/`, per-handler files, `scripts/run_integration_tests.sh`) was removed.
The in-repo integration coverage now uses `integration_tests_local/`, a
docker/RIE-based suite that runs per PR without an AWS account. Its goldens are
strictly stronger for behavior: they preserve span `meta`/`metrics` keys, which
the deprecated suite's normalization stripped wholesale.

Cases that require real AWS Lambda resources are covered by the end-to-end test
suites.

Do not re-add serverless-deployed tests here. Add behavioral cases to the local
RIE-based suite, and rely on the end-to-end suites for real AWS Lambda resource
cases.
9 changes: 5 additions & 4 deletions integration_tests/container/cjs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ARG NODE_VERSION=22
FROM public.ecr.aws/lambda/nodejs:${NODE_VERSION}

# Overrides the dd-trace pin in package.json so this image tracks the same
# tracer line as the layer built for NODE_VERSION (v5 below Node 22, v6 above).
ARG DD_TRACE_VERSION=""
# Exact lockfile-resolved v6 pin, or the maintained v5 compatibility pin for
# Node 18/20. The runner always supplies it.
ARG DD_TRACE_VERSION

# handler.js is the default redirect-mode fixture (DD_LAMBDA_HANDLER=handler.handle).
# The remaining *.js files are the manual-wrap fixture handlers ported from the
Expand All @@ -12,7 +12,8 @@ ARG DD_TRACE_VERSION=""
COPY package.json *.js ${LAMBDA_TASK_ROOT}/
COPY datadog-lambda-js-local.tgz /tmp/datadog-lambda-js-local.tgz
RUN cd ${LAMBDA_TASK_ROOT} \
&& if [ -n "$DD_TRACE_VERSION" ]; then npm pkg set dependencies.dd-trace="$DD_TRACE_VERSION"; fi \
&& test -n "$DD_TRACE_VERSION" \
&& npm pkg set dependencies.dd-trace="$DD_TRACE_VERSION" \
&& npm install --omit=dev \
&& npm install --no-save /tmp/datadog-lambda-js-local.tgz \
&& rm /tmp/datadog-lambda-js-local.tgz
Expand Down
3 changes: 1 addition & 2 deletions integration_tests/container/cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"axios": "1.18.1",
"dd-trace": "6.15.0"
"axios": "1.18.1"
}
}
9 changes: 5 additions & 4 deletions integration_tests/container/esm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
ARG NODE_VERSION=22
FROM public.ecr.aws/lambda/nodejs:${NODE_VERSION}

# Overrides the dd-trace pin in package.json so this image tracks the same
# tracer line as the layer built for NODE_VERSION (v5 below Node 22, v6 above).
ARG DD_TRACE_VERSION=""
# Exact lockfile-resolved v6 pin, or the maintained v5 compatibility pin for
# Node 18/20. The runner always supplies it.
ARG DD_TRACE_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} \
&& if [ -n "$DD_TRACE_VERSION" ]; then npm pkg set dependencies.dd-trace="$DD_TRACE_VERSION"; fi \
&& test -n "$DD_TRACE_VERSION" \
&& npm pkg set dependencies.dd-trace="$DD_TRACE_VERSION" \
&& npm install --omit=dev \
&& npm install --no-save /tmp/datadog-lambda-js-local.tgz \
&& rm /tmp/datadog-lambda-js-local.tgz
Expand Down
4 changes: 1 addition & 3 deletions integration_tests/container/esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"dd-trace": "6.15.0"
}
"dependencies": {}
}
9 changes: 8 additions & 1 deletion integration_tests/container/layer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@
ARG NODE_VERSION=22
FROM public.ecr.aws/lambda/nodejs:${NODE_VERSION}

# Exact lockfile-resolved v6 pin, or the maintained v5 compatibility pin for
# Node 18/20. The runner always supplies it.
ARG DD_TRACE_VERSION

# Install dependencies BEFORE copying layer_pkg: npm prunes anything in
# node_modules that is not in deps.package.json, so copying the layer tree
# first would silently delete it.
COPY deps.package.json /opt/nodejs/package.json
# --omit=optional matches the release build's --ignore-optional: pprof/appsec
# natives are not exercised by these fixtures and skipping them keeps the
# build fast.
RUN cd /opt/nodejs && npm install --omit=dev --omit=optional --no-audit --no-fund
RUN cd /opt/nodejs \
&& test -n "$DD_TRACE_VERSION" \
&& npm pkg set dependencies.dd-trace="$DD_TRACE_VERSION" \
&& npm install --omit=dev --omit=optional --no-audit --no-fund
COPY layer_pkg /opt/nodejs/node_modules/datadog-lambda-js/

# handler.js (CJS) and esm.mjs (top-level await) are plain unwrapped user
Expand Down
8 changes: 0 additions & 8 deletions integration_tests/esm.mjs

This file was deleted.

20 changes: 0 additions & 20 deletions integration_tests/http-requests.js

This file was deleted.

18 changes: 0 additions & 18 deletions integration_tests/package.json

This file was deleted.

91 changes: 0 additions & 91 deletions integration_tests/process-input-traced.js

This file was deleted.

Loading
Loading