chore: add e2e lambda instrumentation test suite#706
Draft
ava-silver wants to merge 6 commits into
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #706 +/- ##
=======================================
Coverage 77.69% 77.69%
=======================================
Files 12 12
Lines 1112 1112
Branches 350 350
=======================================
Hits 864 864
Misses 118 118
Partials 130 130 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What does this PR do?
Adds a full-lifecycle end-to-end test suite for the AWS Lambda instrumentation this plugin performs. It deploys a real, ephemeral Lambda with the plugin enabled, verifies the deployed config and the telemetry it ships to Datadog, proves re-deploy is idempotent, then tears the stack down and verifies a clean end-state.
Conforms to the shared contract in
serverless-ci/e2e/spec.mdand mirrors thedatadog-cireference suite (e2e/cloud-run.test.ts+e2e/helpers/*).Full lifecycle (
e2e/lambda.test.ts):For this tool the plugin runs as part of
sls deploy, so provisioning the uninstrumented workload and APPLY are the same step. REMOVE deletes the whole CloudFormation stack, so the clean end-state is the function (and all its DD config) being absent -- asserted explicitly.Config (
helpers/lambda-verifier.ts): asserts the pinned Datadog Node layer + extension layer (versions read fromsrc/layers.json, so drift blames the plugin), the redirected handler with the original preserved inDD_LAMBDA_HANDLER, the requiredDD_*env vars, and theservice/env/version/dd_sls_plugintags. Identity (run-id service name, env, version) is asserted, not mere presence.Telemetry (
helpers/lambda-telemetry-checker.ts): polls spans + logs (15s × 20) filtered by the unique service name; matched records must carry the full identity (service + env + version), asserting identity, not existence.Idempotent: re-deploy must produce a byte-for-byte identical instrumentation snapshot -- no double-wrap, no duplicate layers.
Motivation
The plugin had no end-to-end coverage of the instrumentation it actually performs against a live AWS account and a live Datadog org. Unit tests verify the generated config; this suite verifies that a real deploy produces a working, instrumented function that ships correctly-tagged telemetry, and that removal leaves nothing behind.
Testing Guidelines
Ran the full suite locally end-to-end against the serverless sandbox account (us-east-1):
Config verified on the real deployed function; spans (identity service + e2e + 1.0.0) and logs (service + e2e) found in Datadog; idempotent re-apply; clean removal with no leaked CloudFormation stacks.
See
e2e/README.mdfor full local-run + auth prerequisites.Additional Notes
Auth (CI) -- no static Datadog keys live in this repo:
aws-actions/configure-aws-credentials, assumingvars.AWS_ROLE_ARN_E2E(scoped to this repo, e2e sandbox account).DataDog/dd-sts-actionunder theserverless-plugin-datadog-e2epolicy, exported to the suite asDATADOG_API_KEY/DATADOG_APP_KEY.Fail-loud, skip-quiet: the suite fails loudly on any auth or telemetry failure. It only no-ops via the
SKIP_LAMBDA_TESTSflag / thedorny/paths-filtergate when no relevant files changed (src/**,e2e/**, the workflow file).Resource hygiene: every run uses a unique name
one-e2e-slsplugin-lambda-<runid>and stampsone_e2e_created:<unix-ts>atomically at creation (helpers/naming.ts) on the stack and every resource, so the cross-repo sweeper can age it out. In-test teardown runs inafterAllregardless of outcome.Pinned + bounded: pinned artifacts (Node layer + extension via
layers.json,serverless@3, one canonical runtime nodejs20.x), bounded retries on transient cloud errors (helpers/exec.ts), telemetry polled on a budget. TS helpers are runner-agnostic (node:assert, no vitest imports).Packaging: standalone npm project under
e2e/(isolated from the plugin Yarn Berry setup).setup.shbuilds the plugin and installs it into the workload fixture from a packed tarball -- afile:link would recurse, since the repo root contains the fixture.Required repo settings: variables
AWS_ROLE_ARN_E2E(OIDC deploy role),AWS_REGION_E2E(defaultus-east-1), optionallyDD_SITE_E2E. The OIDC role and the dd-sts policy backing it are cataloged inserverless-ci/e2e/iam-infra.md.Types of changes
Check all that apply