Skip to content

Commit

Permalink
JavaScript (v3): Integration test fix (#7165)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cpyle0819 authored Dec 19, 2024
1 parent a780f3e commit 2cebb9f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 303 deletions.
3 changes: 2 additions & 1 deletion javascriptv3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ COPY --chown=automation:automation ./workflows /workflows

# Set default command
# `npm i` needs to be run in the container. Otherwise it causes a dependency issue: https://github.com/evanw/esbuild/issues/1646#issuecomment-1238080595
CMD npm i --prefix /javascriptv3 && npm run --prefix /javascriptv3 integration-test
# `aws-cdk` is required by some integration tests in order to deploy resources
CMD npm i -g aws-cdk && npm i --prefix /javascriptv3 && npm run --prefix /javascriptv3 integration-test
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class PoolsAndTriggersStack extends Stack {

constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
this.createFunction("AutoConfirmHandler");
this.createFunction("autoConfirmHandler");
this.poolsAndTriggersBase.outputs(this);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { readFile } from "node:fs/promises";
import { dirname, join } from "node:path";
import { spawn } from "node:child_process";

import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { describe, it, beforeAll, afterAll } from "vitest";
import {
Capability,
CloudFormationClient,
CreateStackCommand,
DeleteStackCommand,
DescribeStacksCommand,
} from "@aws-sdk/client-cloudformation";
Expand All @@ -24,16 +22,24 @@ describe("Scenario - AutoConfirm", () => {
const stackName = "PoolsAndTriggersStack";

beforeAll(async () => {
const path = join(__dirname, "../cdk/stack.yaml");
const stack = await readFile(path, { encoding: "utf8" });
const cdkDeploy = spawn("cdk", ["deploy", "--require-approval", "never"], {
cwd: `${__dirname}/../cdk`,
});

cdkDeploy.stderr.on("data", (d) => {
console.error(d);
});

await new Promise((resolve, reject) => {
cdkDeploy.on("exit", (code) => {
if (code === 0) {
resolve();
} else {
reject();
}
});
});

await cloudformationClient.send(
new CreateStackCommand({
StackName: stackName,
TemplateBody: stack,
Capabilities: [Capability.CAPABILITY_NAMED_IAM],
}),
);
await retry(
{ intervalInMs: 2000, maxRetries: 100, backoff: 5000 },
async () => {
Expand Down

0 comments on commit 2cebb9f

Please sign in to comment.