Skip to content

Commit 14d281c

Browse files
committed
clean up code
1 parent 5bc76bc commit 14d281c

File tree

4 files changed

+14
-36
lines changed

4 files changed

+14
-36
lines changed

.gitlab/templates/pipeline.yaml.tpl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,8 @@ publish integration layer (arm64):
349349
- echo "Publishing layer with suffix - ${PIPELINE_LAYER_SUFFIX}"
350350
script:
351351
- .gitlab/scripts/publish_layers.sh
352-
# Get the layer ARN we just published and save it as an artifact
353352
- LAYER_ARN=$(aws lambda list-layer-versions --layer-name "Datadog-Extension-ARM-${CI_COMMIT_SHORT_SHA}" --query 'LayerVersions[0].LayerVersionArn' --output text --region us-east-1)
354353
- echo "Published layer ARN - ${LAYER_ARN}"
355-
- echo "${LAYER_ARN}" > integration_layer_arn.txt
356-
artifacts:
357-
paths:
358-
- integration_layer_arn.txt
359-
expire_in: 1 hour
360354
{{ end }}
361355

362356
# Integration Tests - Deploy CDK stacks with commit hash prefix
@@ -368,8 +362,6 @@ integration-deploy:
368362
- when: on_success
369363
needs:
370364
- publish integration layer (arm64)
371-
dependencies:
372-
- publish integration layer (arm64)
373365
variables:
374366
IDENTIFIER: ${CI_COMMIT_SHORT_SHA}
375367
AWS_DEFAULT_REGION: us-east-1
@@ -383,7 +375,7 @@ integration-deploy:
383375
{{ end }}
384376
script:
385377
- echo "Deploying CDK stacks with identifier ${IDENTIFIER}..."
386-
- export EXTENSION_LAYER_ARN=$(cat ../integration_layer_arn.txt)
378+
- export EXTENSION_LAYER_ARN=$(aws lambda list-layer-versions --layer-name "Datadog-Extension-ARM-${CI_COMMIT_SHORT_SHA}" --query 'LayerVersions[0].LayerVersionArn' --output text --region us-east-1)
387379
- echo "Using integration test layer - ${EXTENSION_LAYER_ARN}"
388380
- export CDK_DEFAULT_ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
389381
- export CDK_DEFAULT_REGION=us-east-1

integration-tests/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ For simplicity, integraiton tests are setup to only test against ARM runtimes.
3636
First, publish your extension layer.
3737

3838
```bash
39-
./scripts/publish_local.sh
39+
./scripts/local_publish.sh
4040
```
4141

4242
This will create and publish `Datadog-Extension-ARM-<your name>`.
@@ -46,7 +46,7 @@ This will create and publish `Datadog-Extension-ARM-<your name>`.
4646
Deploy the CDK stacks that create Lambda functions for testing.
4747

4848
```bash
49-
./scripts/deploy.sh <stack name>
49+
./scripts/local_deploy.sh <stack name>
5050
```
5151

5252
This will create `integ-<your name>-<stack name>`. The stacks will use the lambda extension created in the previous step.
@@ -56,8 +56,15 @@ This will create `integ-<your name>-<stack name>`. The stacks will use the lambd
5656
Run Jest tests that invoke Lambda functions and verify Datadog telemetry:
5757

5858
```bash
59+
# All tests
5960
npm test
61+
62+
# Single test
63+
npm test -- <my test file>
6064
```
61-
**Note**: Tests wait 10 minutes after Lambda invocation to allow telemetry to appear in Datadog.
65+
66+
67+
68+
**Note**: Tests wait for a few minutes after Lambda invocation to allow telemetry to appear in Datadog.
6269

6370

integration-tests/bin/app.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
11
#!/usr/bin/env node
22
import 'source-map-support/register';
33
import * as cdk from 'aws-cdk-lib';
4-
import * as os from 'os';
54
import { BaseNodeStack } from '../lib/stacks/base-node-stack';
65
import { BasePythonStack } from '../lib/stacks/base-python-stack';
6+
import { getIdentifier } from '../tests/utils/config';
77

88
const app = new cdk.App();
99

10-
// Get configuration from context or environment variables
1110
const env = {
1211
account: process.env.CDK_DEFAULT_ACCOUNT || process.env.AWS_ACCOUNT_ID,
1312
region: process.env.CDK_DEFAULT_REGION || process.env.AWS_REGION || 'us-east-1',
1413
};
1514

16-
// Get identifier from environment variable, or derive from username, or default
17-
function getIdentifier(): string {
18-
if (process.env.IDENTIFIER) {
19-
return process.env.IDENTIFIER;
20-
}
21-
22-
if (process.env.SUFFIX) {
23-
return process.env.SUFFIX;
24-
}
25-
26-
try {
27-
const username = os.userInfo().username;
28-
const firstName = username.split('.')[0];
29-
if (firstName && firstName.length > 0) {
30-
return firstName;
31-
}
32-
} catch (error) {
33-
}
34-
35-
return 'integration';
36-
}
37-
3815
const identifier = getIdentifier();
3916

4017
new BaseNodeStack(app, `integ-${identifier}-base-node`, {

integration-tests/tests/utils/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export function getIdentifier(): string {
44
if (process.env.IDENTIFIER) {
55
return process.env.IDENTIFIER;
66
}
7+
78
try {
89
const username = os.userInfo().username;
910
const firstName = username.split('.')[0];
@@ -13,5 +14,6 @@ export function getIdentifier(): string {
1314
} catch (error) {
1415
console.error('Error getting identifier:', error);
1516
}
17+
1618
return 'integration';
1719
}

0 commit comments

Comments
 (0)