Skip to content

refactor(integration-tests): consolidate lambda code and test structure#1102

Merged
jchrostek-dd merged 4 commits intomainfrom
john/update-tests
Mar 16, 2026
Merged

refactor(integration-tests): consolidate lambda code and test structure#1102
jchrostek-dd merged 4 commits intomainfrom
john/update-tests

Conversation

@jchrostek-dd
Copy link
Contributor

@jchrostek-dd jchrostek-dd commented Mar 16, 2026

Overview

  • Some refactoring to cleanup the integration test code, will make it easier for some future changes I plan on making (adding more comprehensive tests)
  • No change to actual extension code.

Summary

  • Rename base stack to on-demand for clearer naming
  • Create shared lambda handlers (default-*) used by on-demand, lmi, and snapstart stacks
  • Refactor tests to use describe.each pattern for iterating over runtimes
  • Add new test utilities (default.ts, invoke.ts) for cleaner test organization
  • Remove duplicate per-stack lambda code in favor of shared handlers

This refactoring consolidates ~20 duplicate lambda handler files into 4 shared handlers (one per runtime), making the test infrastructure easier to maintain and extend.

Test plan

  • Deployed on-demand stack to sandbox account
  • Ran on-demand.test.ts - all 40 tests passed
  • CI checks

🤖 Generated with Claude Code

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the integration-test harness by consolidating per-stack Lambda handlers into shared default-* handlers and restructuring test invocation/telemetry collection utilities, alongside renaming the “base” stack/tests to “on-demand”.

Changes:

  • Replaced per-stack Lambda handler directories with shared lambda/default-* handlers and updated CDK stacks to point at them.
  • Reworked test utilities to separate invocation (invoke.ts) from telemetry collection (default.ts) and updated tests to describe.each patterns.
  • Renamed the “base” stack/tests to “on-demand” and updated the CDK app entrypoint accordingly.

Reviewed changes

Copilot reviewed 42 out of 46 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
integration-tests/tests/utils/util.ts Removed legacy invoke+Datadog helper (superseded by new utilities).
integration-tests/tests/utils/lambda.ts Simplified Lambda utilities (publish version / snapstart readiness / cold start).
integration-tests/tests/utils/invoke.ts Added dedicated Lambda invoke helper.
integration-tests/tests/utils/default.ts Added shared invoke + Datadog telemetry collection orchestrator.
integration-tests/tests/utils/datadog.ts Added DatadogTelemetry and request-id based telemetry helper; tightened query signatures.
integration-tests/tests/snapstart.test.ts Refactored SnapStart tests to table-driven runtime iteration + new telemetry utilities.
integration-tests/tests/otlp.test.ts Refactored OTLP tests to new invocation/telemetry utilities.
integration-tests/tests/on-demand.test.ts Added new on-demand test suite (replaces deleted base tests).
integration-tests/tests/lmi.test.ts Refactored LMI tests to new invocation/telemetry utilities.
integration-tests/tests/base.test.ts Removed base test suite (replaced by on-demand).
integration-tests/package.json Updated dependencies (CDK + added AWS SDK clients/uuid).
integration-tests/lib/stacks/snapstart.ts Updated SnapStart stack to use shared handlers and new handler names.
integration-tests/lib/stacks/on-demand.ts Renamed/refactored base stack to on-demand and pointed at shared handlers.
integration-tests/lib/stacks/lmi.ts Updated LMI stack to use shared handlers and added env vars.
integration-tests/lambda/snapstart-python/requirements.txt Removed snapstart-specific Python handler assets.
integration-tests/lambda/snapstart-python/lambda_function.py Removed snapstart-specific Python handler implementation.
integration-tests/lambda/snapstart-java/src/main/java/example/SnapstartHandler.java Removed snapstart-specific Java handler implementation.
integration-tests/lambda/snapstart-java/pom.xml Removed snapstart-specific Java build config.
integration-tests/lambda/snapstart-java/.gitignore Removed snapstart-specific Java ignore rules.
integration-tests/lambda/snapstart-dotnet/Function.csproj Removed snapstart-specific .NET build config.
integration-tests/lambda/snapstart-dotnet/Function.cs Removed snapstart-specific .NET handler implementation.
integration-tests/lambda/snapstart-dotnet/.gitignore Removed snapstart-specific .NET ignore rules.
integration-tests/lambda/lmi-node/index.js Removed LMI-specific Node handler (replaced by shared default).
integration-tests/lambda/lmi-java/src/main/java/example/Handler.java Removed LMI-specific Java handler (replaced by shared default).
integration-tests/lambda/lmi-dotnet/Function.csproj Removed LMI-specific .NET build config (replaced by shared default).
integration-tests/lambda/lmi-dotnet/Function.cs Removed LMI-specific .NET handler (replaced by shared default).
integration-tests/lambda/default-python/requirements.txt Added shared Python handler packaging file.
integration-tests/lambda/default-python/lambda_function.py Updated shared Python handler behavior/response.
integration-tests/lambda/default-node/package.json Added shared Node handler package metadata.
integration-tests/lambda/default-node/index.js Added shared Node handler implementation.
integration-tests/lambda/default-java/src/main/java/example/Handler.java Added shared Java handler implementation.
integration-tests/lambda/default-java/pom.xml Updated shared Java build metadata and dependencies.
integration-tests/lambda/default-java/.gitignore Added shared Java ignore rules.
integration-tests/lambda/default-dotnet/Function.csproj Added shared .NET build config.
integration-tests/lambda/default-dotnet/Function.cs Added shared .NET handler implementation.
integration-tests/lambda/default-dotnet/.gitignore Adjusted shared .NET ignore rules.
integration-tests/lambda/base-python/lambda_function.py Removed base-specific Python handler.
integration-tests/lambda/base-node/package.json Removed base-specific Node package metadata.
integration-tests/lambda/base-node/index.js Removed base-specific Node handler.
integration-tests/lambda/base-java/src/main/java/example/Handler.java Removed base-specific Java handler.
integration-tests/lambda/base-java/pom.xml Removed base-specific Java build config.
integration-tests/lambda/base-java/.gitignore Removed base-specific Java ignore rules.
integration-tests/lambda/base-dotnet/Function.cs Removed base-specific .NET handler.
integration-tests/config.ts Added Datadog indexing wait constants (and migrated wait configuration here).
integration-tests/bin/app.ts Updated app to deploy OnDemand stack instead of Base.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +28 to +36
let responsePayload;
try {
responsePayload = JSON.parse(new TextDecoder().decode(response.Payload));
console.log(`Response payload: ${JSON.stringify(responsePayload)}`);
} catch (error: any) {
console.error('Failed to parse response payload:', error.message);
console.log('Raw payload:', new TextDecoder().decode(response.Payload));
throw error;
}
Comment on lines +10 to +13
export const ASYNC_DATADOG_INDEXING_WAIT_MS = 90 * 1000; // 90 seconds

// Extended wait time for tests that need more time (e.g., OTLP tests)
export const DATADOG_INDEXING_WAIT_5_MIN_MS = 5 * 60 * 1000; // 5 minutes
Comment on lines 38 to 42
DD_SERVICE: javaFunctionName,
AWS_LAMBDA_EXEC_WRAPPER: '/opt/datadog_wrapper',
DD_TRACE_ENABLED: 'true',
SLEEP_MS: '10000',
},
Comment on lines 41 to 46
DD_SERVICE: nodeFunctionName,
DD_TRACE_ENABLED: 'true',
DD_LAMBDA_HANDLER: 'index.handler',
RETURN_REQUEST_ID: 'true',
},
logGroup: createLogGroup(this, nodeFunctionName)
Comment on lines 72 to 74
const now = Date.now();
const fromTime = now - (2 * 60 * 60 * 1000); // 2 hours ago
const fromTime = now - (1 * 60 * 60 * 1000); // 1 hours ago
const toTime = now;
Comment on lines 5 to 8
export async function forceColdStart(functionName: string): Promise<void> {
setTimestampEnvVar(functionName)
await new Promise(resolve => setTimeout(resolve, 10000));
}
jchrostek-dd and others added 2 commits March 16, 2026 09:51
- Rename base stack to on-demand for clearer naming
- Create shared lambda handlers (default-*) used by on-demand, lmi, and snapstart stacks
- Refactor tests to use describe.each pattern for iterating over runtimes
- Add new test utilities (default.ts, invoke.ts) for cleaner test organization
- Remove duplicate per-stack lambda code in favor of shared handlers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove unused payload parsing in invoke.ts
- Implement SLEEP_MS support in default handlers for trace isolation testing
- Remove unused RETURN_REQUEST_ID env var from lmi.ts
- Fix missing await in forceColdStart causing race condition
- Fix grammar typo in datadog.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jchrostek-dd and others added 2 commits March 16, 2026 10:07
Update GitLab CI test suite name to match the stack rename.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes corrupted lockfile that had absolute local paths causing
npm ci to fail on Linux CI with fsevents platform error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jchrostek-dd jchrostek-dd merged commit 07e4bb5 into main Mar 16, 2026
50 checks passed
@jchrostek-dd jchrostek-dd deleted the john/update-tests branch March 16, 2026 16:19
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.

3 participants