Skip to content

Commit 6a4e3d7

Browse files
committed
address e2e review
1 parent 5b06df3 commit 6a4e3d7

7 files changed

Lines changed: 34 additions & 32 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ on:
2020

2121
jobs:
2222
lambda-e2e:
23-
# Skip on forks: OIDC federation only exists on the canonical repo.
24-
if: github.repository == 'DataDog/datadog-cdk-constructs'
23+
# Fork pull requests cannot use the canonical repository's OIDC identities.
24+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
2525
runs-on: ubuntu-latest
2626
permissions:
2727
id-token: write

.projen/tasks.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ npmScripts.addDeletionOverride("scripts.compat");
284284
projenTasks.addDeletionOverride("scripts.test:compile");
285285
// Replaces the removed `scripts` project option (dropped in projen 0.100/0.101).
286286
project.addTask("check-formatting", {
287-
exec: "prettier --check src/**/*.ts integration_tests/**/*.ts examples/**/*.ts e2e/*.ts e2e/app/**/*.ts e2e/helpers/e2e.config.ts e2e/helpers/versions.ts",
287+
exec: "prettier --check src/**/*.ts integration_tests/**/*.ts examples/**/*.ts e2e/*.ts e2e/app/**/*.ts e2e/helpers/e2e.config.ts",
288288
});
289289
project.addTask("test:e2e", {
290-
exec: "vitest run --config e2e/vitest.config.ts e2e",
290+
exec: "tsc --noEmit -p e2e/tsconfig.json && vitest run --config e2e/vitest.config.ts e2e",
291291
});
292292
project.addTask("create-release", {
293293
exec: "bash scripts/create_release.sh",

e2e/helpers/e2e.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { type ExpectedLayers, type LambdaVerifierConfig } from "./lambda-verifier";
1010
import { type E2ENaming, RUN_ID_TAG_KEY } from "./naming";
11-
import { E2E_EXTENSION_LAYER_VERSION, E2E_NODE_LAYER_VERSION } from "./versions";
11+
import { E2E_EXTENSION_LAYER_VERSION, E2E_NODE_LAYER_VERSION } from "../app/versions";
1212

1313
// Repo-local config feeding the shared e2e helpers. This file is NOT synced -- it holds
1414
// everything specific to datadog-cdk-constructs that the shared, parameterized helpers

e2e/helpers/versions.ts

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

e2e/lambda.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
import { readdir, readFile, rm } from "node:fs/promises";
1010
import path from "node:path";
1111
import { afterAll, beforeAll, describe, expect, it } from "vitest";
12-
import { ENV_NAME, ENV_VERSION, NAMING, RETRY_PATTERNS, expectedLayerArns, verifierConfig } from "./helpers/e2e.config";
12+
import { ENV_NAME, ENV_VERSION, NAMING, RETRY_PATTERNS, expectedLayerArns } from "./helpers/e2e.config";
1313
import { execPromise, execPromiseWithRetries, type ExecResult } from "./helpers/exec";
1414
import { checkTelemetryFlowing } from "./helpers/lambda-telemetry-checker";
15-
import { verifyUninstrumented } from "./helpers/lambda-verifier";
1615
import { freshnessTimestamp, namePrefix, newRunId } from "./helpers/naming";
17-
import { verifyCdkInstrumented } from "./verifier";
16+
import { verifyCdkClean, verifyCdkInstrumented } from "./verifier";
1817

1918
const DEPLOY_TIMEOUT_MS = 900_000;
2019
const LIFECYCLE_TIMEOUT_MS = 1_800_000;
@@ -221,7 +220,7 @@ describe("cdk lambda e2e", () => {
221220
removed = true;
222221
});
223222

224-
await runPhase("verifying cleanup", () => verifyUninstrumented(verifierConfig(site, runId), serviceName, region));
223+
await runPhase("verifying cleanup", () => verifyCdkClean(serviceName, region, site, runId));
225224
},
226225
LIFECYCLE_TIMEOUT_MS,
227226
);

e2e/verifier.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
import assert from "node:assert/strict";
1010

11+
import { E2E_RUNTIME } from "./app/versions";
1112
import { functionName, verifierConfig } from "./helpers/e2e.config";
1213
import { execPromise } from "./helpers/exec";
13-
import { verifyInstrumented } from "./helpers/lambda-verifier";
14+
import { verifyInstrumented, verifyUninstrumented } from "./helpers/lambda-verifier";
1415
import { FRESHNESS_TAG_KEY, RUN_ID_TAG_KEY } from "./helpers/naming";
15-
import { E2E_RUNTIME } from "./helpers/versions";
1616

1717
interface LambdaConfiguration {
1818
FunctionArn: string;
@@ -23,6 +23,10 @@ interface TagsResponse {
2323
Tags?: Record<string, string>;
2424
}
2525

26+
interface LogGroupsResponse {
27+
logGroups?: Array<{ logGroupName?: string }>;
28+
}
29+
2630
const awsJson = async <T>(command: string): Promise<T> => {
2731
const result = await execPromise(command);
2832
assert.equal(result.exitCode, 0, result.stderr || result.stdout);
@@ -51,3 +55,21 @@ export const verifyCdkInstrumented = async (
5155
assert.equal(tags[FRESHNESS_TAG_KEY], createdTs, `${FRESHNESS_TAG_KEY} tag has the wrong timestamp`);
5256
assert.equal(tags[RUN_ID_TAG_KEY], runId, `${RUN_ID_TAG_KEY} tag has the wrong run id`);
5357
};
58+
59+
export const verifyCdkClean = async (
60+
serviceName: string,
61+
region: string,
62+
site: string,
63+
runId: string,
64+
): Promise<void> => {
65+
await verifyUninstrumented(verifierConfig(site, runId), serviceName, region);
66+
67+
const logGroupName = `/aws/lambda/${functionName(serviceName)}`;
68+
const { logGroups = [] } = await awsJson<LogGroupsResponse>(
69+
`aws logs describe-log-groups --log-group-name-prefix "${logGroupName}" --region "${region}" --output json`,
70+
);
71+
assert.ok(
72+
!logGroups.some((group) => group.logGroupName === logGroupName),
73+
`log group ${logGroupName} still exists after remove`,
74+
);
75+
};

0 commit comments

Comments
 (0)