Skip to content

Commit 9d76f62

Browse files
committed
update
1 parent a4aca4c commit 9d76f62

3 files changed

Lines changed: 28 additions & 59 deletions

File tree

integration-tests/README.md

Lines changed: 26 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,91 +4,60 @@ This directory contains integration tests for the Datadog Lambda Extension.
44

55
The general flow is:
66
1. Deploy test setup using CDK.
7-
2. Invoke lambda function.
8-
3. Call Datadog to get telemetry data.
9-
4. Check telemtry data based on test requirements.
7+
2. Invoke lambda functions.
8+
3. Wait ~10 minutes for data to propagate to Datadog.
9+
3. Call Datadog to get telemetry data and check the data based on test requirements.
1010

1111
For simplicity, integraiton tests are setup to only test against ARM runtimes.
1212

13-
### Local Development
13+
## Guidelines
1414

15-
1. **Datadog API Keys**: Set environment variables
15+
### Naming
16+
* An `identifier` is used to differentiate the different stacks. For local development, the identifier is automatically set using the command `whoami` and parses the user's first name. For gitlab pipelines, the identifier is the git commit short sha.
17+
* Stacks should be named `integ-<identifier>-<stack name>`
18+
* Lambda functions should be named `<stack-id>-<function name>`
19+
20+
### Stacks
21+
* Stacks automatically get deployed as part of the gitlab integration pipeline. Stack should be setup to not retain resources. A helper function `createLogGroup` exists with `removalPolicy: cdk.RemovalPolicy.DESTROY`.
22+
23+
24+
## Local Development
25+
26+
### Prerequisites Set env variables
27+
**Datadog API Keys**: Set environment variables
1628
```bash
1729
export DD_API_KEY="your-datadog-api-key"
1830
export DD_APP_KEY="your-datadog-app-key"
19-
```
20-
21-
2. **AWS Secrets Manager**: You need a secret ARN for the Datadog API key that Lambda functions will use
22-
```bash
2331
export DATADOG_API_SECRET_ARN="arn:aws:secretsmanager:us-east-1:ACCOUNT_ID:secret:YOUR_SECRET"
2432
```
2533

26-
## Local Testing Workflow
27-
2834
### 1. Build and Deploy Extension Layer
2935

30-
First, publish your extension layer with a unique suffix:
36+
First, publish your extension layer.
3137

3238
```bash
33-
cd /path/to/datadog-lambda-extension
34-
35-
# Example: scripts/publish_bottlecap_sandbox.sh <suffix>
36-
TODO
39+
./scripts/publish_local.sh
3740
```
3841

42+
This will create and publish `Datadog-Extension-ARM-<your name>`.
43+
3944
### 2. Deploy Test Stacks
4045

41-
Deploy the CDK stacks that create Lambda functions for testing:
46+
Deploy the CDK stacks that create Lambda functions for testing.
4247

4348
```bash
44-
cd integration-tests
45-
./scripts/deploy.sh ExampleTestStack yourname
49+
./scripts/deploy.sh base-node
4650
```
4751

52+
This will create `integ-<your name>-baes-node`. The stacks will use the lambda extension created in the previous step.
53+
4854
### 3. Run Integration Tests
4955

5056
Run Jest tests that invoke Lambda functions and verify Datadog telemetry:
5157

5258
```bash
53-
export SUFFIX="yourname"
54-
export DD_API_KEY="your-datadog-api-key"
55-
export DD_APP_KEY="your-datadog-app-key"
56-
57-
# Run tests
5859
npm test
5960
```
60-
61-
**Note**: Tests wait 10 minutes after Lambda invocation to allow telemetry to appear in Datadog. The total test timeout is ~11.6 minutes per test.
62-
63-
64-
## GitLab CI/CD Pipeline
65-
66-
The integration tests run automatically on merge requests:
67-
68-
### Pipeline Stages
69-
70-
1. **`publish integration layer (arm64)`**
71-
- Publishes an arm64 extension layer with suffix: `${CI_COMMIT_SHORT_SHA}`
72-
- Layer name: `Datadog-Extension-<commit-hash>`
73-
- Saves layer ARN as artifact
74-
75-
2. **`integration-deploy`**
76-
- Deploys all CDK stacks with suffix: `${CI_COMMIT_SHORT_SHA}`
77-
- Uses the layer ARN from previous step
78-
- Sets `SUFFIX=${CI_COMMIT_SHORT_SHA}`
79-
80-
3. **`integration-test`**
81-
- Runs Jest test suite
82-
- Uses `SUFFIX=${CI_COMMIT_SHORT_SHA}` to find deployed functions
83-
- DD_API_KEY and DD_APP_KEY retrieved from AWS SSM Parameter Store
84-
- Generates JUnit XML and HTML reports
85-
86-
4. **`integration-cleanup-stacks`**
87-
- Destroys all stacks with the commit hash suffix
88-
- Runs even if tests fail (`when: always`)
89-
90-
5. **`integration-cleanup-layers`**
91-
- Deletes all layer versions with the commit hash suffix
92-
- Runs even if tests fail (`when: always`)
61+
**Note**: Tests wait 10 minutes after Lambda invocation to allow telemetry to appear in Datadog.
9362

9463

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class BasePythonStack extends cdk.Stack {
1111
const pythonFunction = new lambda.Function(this, pythonFunctionName, {
1212
runtime: lambda.Runtime.PYTHON_3_12,
1313
architecture: lambda.Architecture.ARM_64,
14-
handler: '/opt/python/lib/python3.12/site-packages/datadog_lambda/handler.handler',
14+
handler: 'datadog_lambda.handler.handler',
1515
code: lambda.Code.fromAsset('./lambda/base-python'),
1616
functionName: pythonFunctionName,
1717
timeout: cdk.Duration.seconds(30),

integration-tests/scripts/local_deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fi
3030

3131
echo "Using extension layer: $EXTENSION_LAYER_ARN"
3232

33-
FULL_STACK_NAME="IntegrationTests-$IDENTIFIER-$STACK_NAME"
33+
FULL_STACK_NAME="integ-$IDENTIFIER-$STACK_NAME"
3434
echo "Deploying stack: $FULL_STACK_NAME"
3535

3636
# Build and deploy

0 commit comments

Comments
 (0)