Skip to content

Commit 2cebb9f

Browse files
authored
JavaScript (v3): Integration test fix (#7165)
CDK Synth does not behave as we expected. It does not deploy assets. CDK deploy is required in order to upload assets. Removed SDK usage of CFN to create the stack and replaced it with a child process running CDK deploy.
1 parent a780f3e commit 2cebb9f

File tree

4 files changed

+22
-303
lines changed

4 files changed

+22
-303
lines changed

javascriptv3/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ COPY --chown=automation:automation ./workflows /workflows
2222

2323
# Set default command
2424
# `npm i` needs to be run in the container. Otherwise it causes a dependency issue: https://github.com/evanw/esbuild/issues/1646#issuecomment-1238080595
25-
CMD npm i --prefix /javascriptv3 && npm run --prefix /javascriptv3 integration-test
25+
# `aws-cdk` is required by some integration tests in order to deploy resources
26+
CMD npm i -g aws-cdk && npm i --prefix /javascriptv3 && npm run --prefix /javascriptv3 integration-test

javascriptv3/example_code/cross-services/wkflw-pools-triggers/cdk/lib/stack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class PoolsAndTriggersStack extends Stack {
1717

1818
constructor(scope: Construct, id: string, props?: StackProps) {
1919
super(scope, id, props);
20-
this.createFunction("AutoConfirmHandler");
20+
this.createFunction("autoConfirmHandler");
2121
this.poolsAndTriggersBase.outputs(this);
2222
}
2323

javascriptv3/example_code/cross-services/wkflw-pools-triggers/cdk/stack.yaml

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

javascriptv3/example_code/cross-services/wkflw-pools-triggers/tests/scenario-auto-confirm.integration.test.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
import { readFile } from "node:fs/promises";
43
import { dirname, join } from "node:path";
4+
import { spawn } from "node:child_process";
55

6-
import { describe, it, expect, beforeAll, afterAll } from "vitest";
6+
import { describe, it, beforeAll, afterAll } from "vitest";
77
import {
8-
Capability,
98
CloudFormationClient,
10-
CreateStackCommand,
119
DeleteStackCommand,
1210
DescribeStacksCommand,
1311
} from "@aws-sdk/client-cloudformation";
@@ -24,16 +22,24 @@ describe("Scenario - AutoConfirm", () => {
2422
const stackName = "PoolsAndTriggersStack";
2523

2624
beforeAll(async () => {
27-
const path = join(__dirname, "../cdk/stack.yaml");
28-
const stack = await readFile(path, { encoding: "utf8" });
25+
const cdkDeploy = spawn("cdk", ["deploy", "--require-approval", "never"], {
26+
cwd: `${__dirname}/../cdk`,
27+
});
28+
29+
cdkDeploy.stderr.on("data", (d) => {
30+
console.error(d);
31+
});
32+
33+
await new Promise((resolve, reject) => {
34+
cdkDeploy.on("exit", (code) => {
35+
if (code === 0) {
36+
resolve();
37+
} else {
38+
reject();
39+
}
40+
});
41+
});
2942

30-
await cloudformationClient.send(
31-
new CreateStackCommand({
32-
StackName: stackName,
33-
TemplateBody: stack,
34-
Capabilities: [Capability.CAPABILITY_NAMED_IAM],
35-
}),
36-
);
3743
await retry(
3844
{ intervalInMs: 2000, maxRetries: 100, backoff: 5000 },
3945
async () => {

0 commit comments

Comments
 (0)