Skip to content

chore: add e2e lambda lifecycle test and workflow#627

Open
ava-silver wants to merge 1 commit into
ava.silver/chore/add-e2e-cdk-lambda-fixturefrom
ava.silver/chore/add-e2e-lambda-lifecycle-test-and-workflow
Open

chore: add e2e lambda lifecycle test and workflow#627
ava-silver wants to merge 1 commit into
ava.silver/chore/add-e2e-cdk-lambda-fixturefrom
ava.silver/chore/add-e2e-lambda-lifecycle-test-and-workflow

Conversation

@ava-silver

@ava-silver ava-silver commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the end-to-end instrumentation lifecycle test for the DatadogLambda construct on AWS Lambda, plus its config, README, and CI workflow. lambda.test.ts drives one CDK stack -- the same physical function throughout -- through the full contract:

  1. APPLY -- deploy the bare workload, then redeploy with the construct, instrumenting the function in place; assert config present (pinned Datadog Node + extension layers, redirected handler, DD_* env, identifying tags).
  2. TRIGGER -- lambda invoke, then poll the Datadog API until spans and logs carrying the run identity (service/env/version/run id) appear.
  3. RE-APPLY -- cdk diff --fail; assert no diff.
  4. REMOVE -- cdk destroy; assert the function no longer exists.

e2e.config.ts and versions.ts hold the repo-specific bits: pinned versions, expected layer ARNs, the env/tag contract, and AWS retry patterns. Generic polling and verification come from the shared helpers.

Infrastructure

The "tool under test" is the construct itself (src/), bundled into the CDK app -- not a published package -- so a failure blames the construct. Each run deploys one CloudFormation stack holding a single Lambda; the E2E_INSTRUMENT flag toggles whether the app applies the construct.

flowchart LR
  src["DatadogLambda construct<br/>(src/, under test)"]
  app["CDK app<br/>(esbuild bundle)"]
  ddAcct["Public DD layer account"]
  fn["Workload Lambda"]

  src -->|bundled into| app
  app -->|deploy: bare, then APPLY w/ construct| fn
  ddAcct -->|Node + Extension layers| fn
Loading

The Datadog API key is passed inline to the construct at deploy and surfaces as DD_API_KEY on the function; CI mints it so the workload ships to the org the suite queries. Teardown always runs cdk destroy; the cross-repo sweeper reclaims anything leaked by cancelled CI.

The app is bundled to a single CJS file with esbuild (the repo's TS toolchain is incompatible with ts-node) and run with plain node.

Motivation

Gives the construct a real instrumentation lifecycle test against live AWS + Datadog, so a regression in layer pinning, handler redirect, env wiring, or telemetry flow fails CI.

Testing Guidelines

.github/workflows/e2e.yml runs the suite behind path filters. AWS creds come from OIDC, Datadog creds from dd-sts -- no long-lived secrets, and a missing credential fails loudly rather than skipping green.

Ran the full suite end-to-end locally against the serverless sandbox -- all phases plus teardown pass.

Additional Notes

  • Layer/extension versions and the runtime are pinned (overridable via env) so failures blame the construct, not an upstream bump.
  • package.json / yarn.lock / .projen/* churn is projen-generated from the .projenrc.js edit (adds vitest, the Datadog API client, and the test:e2e task).

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ava-silver
ava-silver marked this pull request as ready for review June 26, 2026 21:54
@ava-silver
ava-silver requested review from a team as code owners June 26, 2026 21:54
@ava-silver
ava-silver requested a review from TalUsvyatsky June 26, 2026 21:54
@ava-silver
ava-silver force-pushed the ava.silver/chore/add-e2e-lambda-lifecycle-test-and-workflow branch from 6c6b703 to 6f54462 Compare June 29, 2026 17:34
@ava-silver
ava-silver force-pushed the ava.silver/chore/add-e2e-cdk-lambda-fixture branch from f0c6f88 to 95acad5 Compare June 29, 2026 17:34
@datadog-datadog-prod-us1-2

Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

e2e | lambda-e2e   View in Datadog   GitHub Actions

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6f54462 | Docs | Datadog PR Page | Give us feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants