Skip to content

Commit 7ab7a0b

Browse files
committed
refactor
1 parent 2ed23e8 commit 7ab7a0b

File tree

13 files changed

+26
-404
lines changed

13 files changed

+26
-404
lines changed

integration-tests/README.md

Lines changed: 12 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,19 @@
22

33
This directory contains integration tests for the Datadog Lambda Extension.
44

5+
Each test suite has a cdk stack and an associated test file. Example, `base.ts` and `base.tests.ts`. Test suits are run in parallel in Gitlab CI/CD pipeline.
6+
57
The general flow is:
68
1. Deploy test setup using CDK.
79
2. Invoke lambda functions.
810
3. Wait for data to propagate to Datadog.
911
4. Call Datadog to get telemetry data and check the data based on test requirements.
1012

11-
For simplicity, integration tests are setup to only test against ARM runtimes.
12-
13-
## Supported Runtimes
13+
For simplicity, integration tests are set up to only test against ARM runtimes and 4 runtimes (Python, Node, Java, and Dotnet).
1414

15-
All test suites cover the following Lambda runtimes:
16-
- **Java 21** - Eclipse Temurin
17-
- **.NET 8** - Alpine
18-
- **Python 3.12/3.13** - Standard Python runtime
19-
- **Node.js 20** - Alpine
2015

2116
## Test Suites
2217

23-
Integration tests are organized into independent test suites that run in parallel in the GitLab CI/CD pipeline. Each suite has its own lifecycle (deploy → test → cleanup) and can be executed independently.
24-
2518
### Base Tests
2619

2720
The base test suite provides basic functionality tests across all supported Lambda runtimes. These tests verify core extension functionality without additional instrumentation.
@@ -55,10 +48,6 @@ The OTLP test suite verifies OpenTelemetry Protocol (OTLP) integration with the
5548

5649
## CI/CD Pipeline Structure
5750

58-
The GitLab CI/CD pipeline runs test suites independently in parallel, providing:
59-
- **Isolation**: One test suite failure doesn't block others
60-
- **Speed**: Test suites run simultaneously
61-
- **Efficiency**: Can retry individual test suites without redeploying all stacks
6251

6352
### Pipeline Flow
6453

@@ -70,26 +59,26 @@ publish layer → build lambdas ─────┤
7059

7160
### Test Suite Lifecycle
7261

73-
Each test suite (base, otlp) follows this lifecycle:
62+
Each test suite (base, otlp, etc.) follows this lifecycle:
7463

7564
1. **Deploy**: Deploys only the stacks for that suite
76-
- Pattern: `cdk deploy "integ-${IDENTIFIER}-${TEST_SUITE}-*"`
77-
- Example: `integ-abc123-base-*` deploys all base test stacks
65+
- Pattern: `cdk deploy "integ-${IDENTIFIER}-${TEST_SUITE}"`
66+
- Example: `integ-abc123-base` deploys all base test stacks
7867

7968
2. **Test**: Runs only the tests for that suite
8069
- Command: `jest tests/${TEST_SUITE}.test.ts`
8170
- Example: `jest tests/base.test.ts`
8271

8372
3. **Cleanup**: Removes only the stacks for that suite
8473
- Runs with `when: always` to ensure cleanup on failure
85-
- Pattern: Deletes all stacks matching `integ-${IDENTIFIER}-${TEST_SUITE}-*`
74+
- Pattern: Deletes all stacks matching `integ-${IDENTIFIER}-${TEST_SUITE}`
8675

8776
### Adding a New Test Suite
8877

8978
To add a new test suite to the parallel execution:
9079

9180
1. **Create test file**: `tests/<suite-name>.test.ts`
92-
2. **Create CDK stacks**: `lib/stacks/<suite-name>-<runtime>-stack.ts`
81+
2. **Create CDK stacks**: `lib/stacks/<suite-name>.ts`
9382
3. **Register stacks**: Add to `bin/app.ts`
9483
4. **Update pipeline**: Add suite name to `.gitlab/templates/pipeline.yaml.tpl`:
9584
```yaml
@@ -98,58 +87,6 @@ To add a new test suite to the parallel execution:
9887
- TEST_SUITE: [base, otlp, <suite-name>]
9988
```
10089
101-
### Running Test Suites Locally
102-
103-
Test individual suites using CDK patterns:
104-
105-
```bash
106-
# Deploy specific test suite
107-
export IDENTIFIER="john"
108-
npx cdk deploy "integ-${IDENTIFIER}-base-*" --require-approval never
109-
110-
# Run specific test suite
111-
jest tests/base.test.ts
112-
113-
# Cleanup specific test suite stacks
114-
aws cloudformation list-stacks \
115-
--query "StackSummaries[?starts_with(StackName, 'integ-${IDENTIFIER}-base-')].StackName" \
116-
--output text | xargs -n1 aws cloudformation delete-stack --stack-name
117-
```
118-
119-
## Building Lambda Functions
120-
121-
Lambda functions with compiled languages (Java, .NET) or external dependencies (Python, Node.js with packages) must be built before deployment. Build scripts use Docker for cross-platform compatibility and don't require local toolchains.
122-
123-
### Build Scripts
124-
125-
Runtime-specific build scripts are located in `scripts/`:
126-
127-
```bash
128-
# Build all Java Lambda functions
129-
./scripts/build-java.sh
130-
131-
# Build all .NET Lambda functions
132-
./scripts/build-dotnet.sh
133-
134-
# Build all Python Lambda functions
135-
./scripts/build-python.sh
136-
137-
# Build all Node.js Lambda functions
138-
./scripts/build-node.sh
139-
```
140-
141-
You can also build a specific function by providing its path:
142-
143-
```bash
144-
# Build a specific Java function
145-
./scripts/build-java.sh lambda/otlp-java
146-
147-
# Build a specific .NET function
148-
./scripts/build-dotnet.sh lambda/base-dotnet
149-
```
150-
151-
**Note:** The `local_deploy.sh` script automatically builds required Lambda functions based on the stack name, so manual building is optional for local development.
152-
15390
## Guidelines
15491
15592
### Naming
@@ -172,7 +109,7 @@ export DD_APP_KEY="your-datadog-app-key"
172109
export DATADOG_API_SECRET_ARN="arn:aws:secretsmanager:us-east-1:ACCOUNT_ID:secret:YOUR_SECRET"
173110
```
174111

175-
**Docker**: Required for building Lambda functions. [Install Docker](https://docs.docker.com/get-docker/)
112+
**Docker**: Required for building Lambda functions.
176113

177114
### Workflow
178115

@@ -201,19 +138,11 @@ This creates `integ-<your-name>-<stack-name>` and automatically:
201138

202139
**Examples:**
203140
```bash
204-
# Deploy base Java test
205-
./scripts/local_deploy.sh base-java-stack
141+
# Deploy base test stack
142+
./scripts/local_deploy.sh base
206143
207-
# Deploy OTLP Python test
208-
./scripts/local_deploy.sh otlp-python-stack
209144
```
210145

211-
**Available Stacks:**
212-
- `base-java-stack`, `otlp-java-stack`
213-
- `base-dotnet-stack`, `otlp-dotnet-stack`
214-
- `base-python-stack`, `otlp-python-stack`
215-
- `base-node-stack`, `otlp-node-stack`
216-
217146
#### 3. Run Integration Tests
218147

219148
Run Jest tests that invoke Lambda functions and verify Datadog telemetry:
@@ -223,27 +152,8 @@ Run Jest tests that invoke Lambda functions and verify Datadog telemetry:
223152
npm test
224153
225154
# Run specific test file
226-
npm test -- base-java.test.ts
155+
npm test -- base.test.ts
227156
228-
# Run specific test suite
229-
npm test -- --testNamePattern="OTLP"
230157
```
231158

232159
**Note**: Tests wait several minutes after Lambda invocation to allow telemetry to propagate to Datadog.
233-
234-
### Manual Building (Optional)
235-
236-
If you need to build Lambda functions manually without deploying:
237-
238-
```bash
239-
# Build all functions for a runtime
240-
./scripts/build-java.sh
241-
./scripts/build-dotnet.sh
242-
./scripts/build-python.sh
243-
./scripts/build-node.sh
244-
245-
# Build specific function
246-
./scripts/build-java.sh lambda/otlp-java
247-
```
248-
249-

integration-tests/bin/app.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22
import 'source-map-support/register';
33
import * as cdk from 'aws-cdk-lib';
4-
import {BaseStack} from '../lib/stacks/base-stack';
5-
import {OtlpStack} from '../lib/stacks/otlp-stack';
4+
import {Base} from '../lib/stacks/base';
5+
import {Otlp} from '../lib/stacks/otlp';
66
import {getIdentifier} from '../tests/utils/config';
77

88
const app = new cdk.App();
@@ -15,10 +15,10 @@ const env = {
1515
const identifier = getIdentifier();
1616

1717
const stacks = [
18-
new BaseStack(app, `integ-${identifier}-base`, {
18+
new Base(app, `integ-${identifier}-base`, {
1919
env,
2020
}),
21-
new OtlpStack(app, `integ-${identifier}-otlp`, {
21+
new Otlp(app, `integ-${identifier}-otlp`, {
2222
env,
2323
}),
2424
]

integration-tests/lib/stacks/base-dotnet-stack.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

integration-tests/lib/stacks/base-java-stack.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

integration-tests/lib/stacks/base-node-stack.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

integration-tests/lib/stacks/base-python-stack.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

integration-tests/lib/stacks/base-stack.ts renamed to integration-tests/lib/stacks/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
getDotnet8Layer
1313
} from '../util';
1414

15-
export class BaseStack extends cdk.Stack {
15+
export class Base extends cdk.Stack {
1616
constructor(scope: Construct, id: string, props: cdk.StackProps) {
1717
super(scope, id, props);
1818

0 commit comments

Comments
 (0)