Skip to content

Commit 22ede5a

Browse files
authored
fix(e2e): clean up stale changesets (#3869)
1 parent 2fa297a commit 22ede5a

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

tests/e2e/delete-stale-changesets.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const { ListChangeSetsCommand, DeleteChangeSetCommand } = require("../../clients/client-cloudformation");
2+
3+
exports.deleteStaleChangesets = async (client, stackName) => {
4+
const changesets = await client.send(
5+
new ListChangeSetsCommand({
6+
StackName: stackName,
7+
})
8+
);
9+
10+
try {
11+
for (const changeset of changesets.Summaries) {
12+
if (
13+
changeset.Status === "FAILED" &&
14+
changeset.StatusReason ===
15+
`The submitted information didn't contain changes. Submit different information to create a change set.`
16+
) {
17+
console.log("Deleting stale changeset", changeset.ChangeSetId);
18+
await new Promise((r) => setTimeout(r, 200));
19+
await client.send(
20+
new DeleteChangeSetCommand({
21+
StackName: stackName,
22+
ChangeSetName: changeset.ChangeSetId,
23+
})
24+
);
25+
}
26+
}
27+
} catch(e) {
28+
// non-blocking throttling error, potentially.
29+
console.error(e);
30+
}
31+
};

tests/e2e/ensure-test-stack.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
waitUntilStackUpdateComplete,
88
waitUntilStackCreateComplete,
99
DescribeChangeSetCommand,
10+
DeleteChangeSetCommand,
1011
} = require("../../clients/client-cloudformation");
1112

1213
/**
@@ -51,6 +52,14 @@ exports.ensureTestStack = async (client, stackName, templateBody) => {
5152
})
5253
);
5354
if (Status === "FAILED" && StatusReason.includes("The submitted information didn't contain changes")) {
55+
await client
56+
.send(
57+
new DeleteChangeSetCommand({
58+
StackName: stackName,
59+
ChangeSetName: Id,
60+
})
61+
)
62+
.catch(() => {}); // ignored
5463
return;
5564
}
5665
throw e;

tests/e2e/get-integ-test-resources.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ const { STSClient, GetCallerIdentityCommand } = require("../../clients/client-st
44
const { CloudFormationClient, DescribeStackResourcesCommand } = require("../../clients/client-cloudformation");
55
const { S3ControlClient, ListMultiRegionAccessPointsCommand } = require("../../clients/client-s3-control");
66
const { ensureTestStack } = require("./ensure-test-stack");
7+
const { deleteStaleChangesets } = require("./delete-stale-changesets");
78

89
exports.getIntegTestResources = async () => {
910
const cloudformation = new CloudFormationClient({ logger: console });
1011
const region = await cloudformation.config.region();
1112
const stackName = "SdkReleaseV3IntegTestResourcesStack";
1213

14+
await deleteStaleChangesets(cloudformation, stackName);
1315
await ensureTestStack(
1416
cloudformation,
1517
stackName,

0 commit comments

Comments
 (0)