Skip to content

Commit b30175a

Browse files
authored
JavaScript (v3): Integration test fixes (#6814)
* JavaScript (v3): CloudWatch Events - Make integ test cleanup more robust. * JavaScript (v3): DynamoDb - Fix bad scenario options for partiql examples. * JavaScript (v3): SES - Mark tests for sequential runs instead of concurrent.
1 parent 029c29b commit b30175a

File tree

4 files changed

+61
-19
lines changed

4 files changed

+61
-19
lines changed

javascriptv3/example_code/cloudwatch-events/tests/cloudwatch-events.integration.test.js

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,21 @@ const createLogGroup = async (logGroupName) => {
3939
* @param {string} ruleName - The name of the rule.
4040
*/
4141
const deleteRule = async (ruleName) => {
42-
const cweClient = new CloudWatchEventsClient({});
43-
const command = new DeleteRuleCommand({
44-
Name: ruleName,
45-
});
46-
await cweClient.send(command);
42+
try {
43+
const cweClient = new CloudWatchEventsClient({});
44+
const command = new DeleteRuleCommand({
45+
Name: ruleName,
46+
});
47+
await cweClient.send(command);
48+
} catch (caught) {
49+
if (caught instanceof Error) {
50+
console.error(
51+
`Failed to delete rule: ${ruleName}. ${caught.name}: ${caught.message}`,
52+
);
53+
} else {
54+
throw caught;
55+
}
56+
}
4757
};
4858

4959
/**
@@ -52,28 +62,48 @@ const deleteRule = async (ruleName) => {
5262
* @param {string[]} targetIds - The IDs of the targets to remove.
5363
*/
5464
const removeTargets = async (ruleName, targetIds) => {
55-
const cweClient = new CloudWatchEventsClient({});
56-
const command = new RemoveTargetsCommand({
57-
Rule: ruleName,
58-
Ids: targetIds,
59-
});
60-
await cweClient.send(command);
65+
try {
66+
const cweClient = new CloudWatchEventsClient({});
67+
const command = new RemoveTargetsCommand({
68+
Rule: ruleName,
69+
Ids: targetIds,
70+
});
71+
await cweClient.send(command);
72+
} catch (caught) {
73+
if (caught instanceof Error) {
74+
console.error(
75+
`Failed to remove targets: ${targetIds} from rule: ${ruleName}. ${caught.name}: ${caught.message}`,
76+
);
77+
} else {
78+
throw caught;
79+
}
80+
}
6181
};
6282

6383
/**
6484
* Delete a log group.
6585
* @param {string} logGroupName - The name of the log group.
6686
*/
6787
const deleteLogGroup = async (logGroupName) => {
68-
const cwlClient = new CloudWatchLogsClient({});
69-
const command = new DeleteLogGroupCommand({
70-
logGroupName: logGroupName,
71-
});
72-
await cwlClient.send(command);
88+
try {
89+
const cwlClient = new CloudWatchLogsClient({});
90+
const command = new DeleteLogGroupCommand({
91+
logGroupName: logGroupName,
92+
});
93+
await cwlClient.send(command);
94+
} catch (caught) {
95+
if (caught instanceof Error) {
96+
console.error(
97+
`Failed to delete log group: ${logGroupName}. ${caught.name}: ${caught.message}`,
98+
);
99+
} else {
100+
throw caught;
101+
}
102+
}
73103
};
74104

75105
describe("CloudWatch Events integration test", () => {
76-
const logGroupName = "test-log-group";
106+
const logGroupName = "cloudwatch-events-test-log-group";
77107
const ruleName = "test-rule";
78108
const rulePattern = JSON.stringify({
79109
source: ["my.app"],

javascriptv3/example_code/dynamodb/scenarios/partiql-batch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const main = async (confirmAll = false) => {
3535
"deleteTable",
3636
`A table named ${tableName} already exists. If you choose not to delete
3737
this table, the scenario cannot continue. Delete it?`,
38-
{ confirmAll },
38+
{ type: "confirm", confirmAll },
3939
);
4040
const deleteTable = await input.handle({});
4141
if (deleteTable) {

javascriptv3/example_code/dynamodb/scenarios/partiql-single.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const main = async (confirmAll = false) => {
3535
"deleteTable",
3636
`A table named ${tableName} already exists. If you choose not to delete
3737
this table, the scenario cannot continue. Delete it?`,
38-
{ confirmAll },
38+
{ type: "confirm", confirmAll },
3939
);
4040
const deleteTable = await input.handle({});
4141
if (deleteTable) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
import { defineConfig } from "vitest/config";
4+
5+
export default defineConfig({
6+
test: {
7+
testTimeout: 3600000, // 1 hour timeout
8+
sequence: {
9+
concurrent: false, // Run tests sequentially
10+
},
11+
},
12+
});

0 commit comments

Comments
 (0)