Skip to content

Commit 84ba3d8

Browse files
authored
JavaScript (v3): Integration test fixes. (#6853)
* JavaScript (v3): DynamoDB - Fix hanging test in partiql-batch. * JavaScript (v3): IAM - Adjust timings in iam basics to prevent timeouts. * JavaScript (v3): SES - Fix integration test issues. Several issues were found in the SES integration tests: - Actual emails were being sent (to a bogus email address) instead of throwing the expected errors. - There was no waiter checking for S3 object deletion, allowing for a bucket deletion to fail. - An SES quota had been hit, preventing further tests from running. The first two issues were addressed, which should prevent the third from happening again. * Revert "Weathertop: Pause JSV3 runs (#6851)" This reverts commit b3925e3. Integration tests were paused in order to debug some failures that were causing the AWS account to be polluted with resources. The tests are cleaned up in a previous commit and this turns the tests back on.
1 parent 198402e commit 84ba3d8

File tree

9 files changed

+50
-56
lines changed

9 files changed

+50
-56
lines changed

javascriptv3/Dockerfile

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
# syntax=docker/dockerfile:1
22
FROM node:20
33

4-
CMD exit 0
4+
# Update image
5+
RUN apt-get update && \
6+
apt-get upgrade -y && \
7+
apt-get clean && \
8+
rm -rf /var/lib/apt/lists/*
59

6-
# # Update image
7-
# RUN apt-get update && \
8-
# apt-get upgrade -y && \
9-
# apt-get clean && \
10-
# rm -rf /var/lib/apt/lists/*
10+
# Copy source code
11+
COPY ./javascriptv3 /javascriptv3
1112

12-
# # Copy source code
13-
# COPY ./javascriptv3 /javascriptv3
13+
# Set non-root user
14+
RUN useradd -m automation && \
15+
chown -R automation:automation /javascriptv3
16+
USER automation:automation
1417

15-
# # Set non-root user
16-
# RUN useradd -m automation && \
17-
# chown -R automation:automation /javascriptv3
18-
# USER automation:automation
18+
# Copy resources
19+
COPY --chown=automation:automation ./resources /resources
20+
COPY --chown=automation:automation ./python/example_code/glue/flight_etl_job_script.py /python/example_code/glue/flight_etl_job_script.py
21+
COPY --chown=automation:automation ./workflows /workflows
1922

20-
# # Copy resources
21-
# COPY --chown=automation:automation ./resources /resources
22-
# COPY --chown=automation:automation ./python/example_code/glue/flight_etl_job_script.py /python/example_code/glue/flight_etl_job_script.py
23-
# COPY --chown=automation:automation ./workflows /workflows
24-
25-
# # Set default command
26-
# # `npm i` needs to be run in the container. Otherwise it causes a dependency issue: https://github.com/evanw/esbuild/issues/1646#issuecomment-1238080595
27-
# CMD npm i --prefix /javascriptv3 && npm run --prefix /javascriptv3 integration-test
23+
# Set default command
24+
# `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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const main = async (confirmAll = false) => {
3737
this table, the scenario cannot continue. Delete it?`,
3838
{ type: "confirm", confirmAll },
3939
);
40-
const deleteTable = await input.handle({});
40+
const deleteTable = await input.handle({}, { confirmAll });
4141
if (deleteTable) {
4242
await client.send(new DeleteTableCommand({ tableName }));
4343
} else {

javascriptv3/example_code/iam/scenarios/basic.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import { ScenarioInput } from "@aws-doc-sdk-examples/lib/scenario/index.js";
2525

2626
// Set the parameters.
2727
const iamClient = new IAMClient({});
28-
const userName = "test_name";
29-
const policyName = "test_policy";
30-
const roleName = "test_role";
28+
const userName = "iam_basic_test_username";
29+
const policyName = "iam_basic_test_policy";
30+
const roleName = "iam_basic_test_role";
3131

3232
/**
3333
* Create a new IAM user. If the user already exists, give
@@ -213,7 +213,7 @@ export const main = async (confirmAll = false) => {
213213
// List the S3 buckets again.
214214
// Retry the list buckets operation until it succeeds. AccessDenied might
215215
// be thrown while the role policy is still stabilizing.
216-
await retry({ intervalInMs: 2000, maxRetries: 60 }, () =>
216+
await retry({ intervalInMs: 2000, maxRetries: 120 }, () =>
217217
listBuckets(s3Client),
218218
);
219219

javascriptv3/example_code/iam/vite.config.js

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

44
import { defineConfig } from "vitest/config";
55

6-
const TEST_TIMEOUT_IN_MINUTES = 5;
6+
const TEST_TIMEOUT_IN_MINUTES = 30;
77
const MS_IN_SECOND = 1000;
88
const SECONDS_IN_MINUTE = 60;
99

javascriptv3/example_code/s3/libs/s3Utils.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
PutObjectLegalHoldCommand,
1212
GetObjectRetentionCommand,
1313
DeleteObjectCommand,
14+
waitUntilObjectNotExists,
1415
} from "@aws-sdk/client-s3";
1516
import { client as s3Client } from "../client.js";
1617

@@ -31,16 +32,23 @@ export function deleteBucket(bucketName) {
3132
}
3233

3334
export async function emptyBucket(bucketName) {
34-
const listObjectsCommand = new ListObjectsCommand({ Bucket: bucketName });
35-
const listObjectsResult = await s3Client.send(listObjectsCommand);
35+
const listObjectsResult = await s3Client.send(
36+
new ListObjectsCommand({ Bucket: bucketName }),
37+
);
3638
const objects = listObjectsResult.Contents;
3739
const objectIdentifiers = objects.map((o) => ({ Key: o.Key }));
38-
const deleteObjectsCommand = new DeleteObjectsCommand({
39-
Bucket: bucketName,
40-
Delete: { Objects: objectIdentifiers },
41-
});
42-
43-
return s3Client.send(deleteObjectsCommand);
40+
await s3Client.send(
41+
new DeleteObjectsCommand({
42+
Bucket: bucketName,
43+
Delete: { Objects: objectIdentifiers },
44+
}),
45+
);
46+
for (const objId of objectIdentifiers) {
47+
await waitUntilObjectNotExists(
48+
{ client: s3Client },
49+
{ Bucket: bucketName, Key: objId.Key },
50+
);
51+
}
4452
}
4553

4654
export function putBucketPolicyAllowPuts(bucketName, sid) {

javascriptv3/example_code/ses/tests/create-receipt-rule.integration.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
import { describe, beforeAll, afterAll, it, expect } from "vitest";
3+
import { describe, beforeAll, afterAll, it } from "vitest";
44

55
import {
66
RULE_SET_NAME,
@@ -40,7 +40,6 @@ describe("ses_createreceiptrule", () => {
4040
});
4141

4242
it("should create a receipt rule", async () => {
43-
const result = await run();
44-
expect(result.$metadata.httpStatusCode).toBe(200);
43+
await run();
4544
});
4645
});

javascriptv3/example_code/ses/tests/send-bulk-templated-email.integration.test.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import { describe, beforeAll, afterAll, it, expect } from "vitest";
44

5-
import {
6-
createIdentity,
7-
createTemplate,
8-
deleteIdentity,
9-
deleteTemplate,
10-
} from "../src/libs/sesUtils";
11-
import { run, TEMPLATE_NAME, USERS } from "../src/ses_sendbulktemplatedemail";
5+
import { createTemplate, deleteTemplate } from "../src/libs/sesUtils";
6+
import { run, TEMPLATE_NAME } from "../src/ses_sendbulktemplatedemail";
127
import { MessageRejected } from "@aws-sdk/client-ses";
138

149
describe("ses_sendbulktemplatedemail", () => {
1510
beforeAll(async () => {
1611
try {
17-
await Promise.all(USERS.map((user) => createIdentity(user.emailAddress)));
1812
await createTemplate(TEMPLATE_NAME);
1913
} catch (e) {
2014
console.error(e);
@@ -23,7 +17,6 @@ describe("ses_sendbulktemplatedemail", () => {
2317

2418
afterAll(async () => {
2519
try {
26-
await Promise.all(USERS.map((user) => deleteIdentity(user.emailAddress)));
2720
await deleteTemplate(TEMPLATE_NAME);
2821
} catch (e) {
2922
console.error(e);

javascriptv3/example_code/ses/tests/send-templated-email.integration.test.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import { describe, beforeAll, afterAll, it, expect } from "vitest";
44

5-
import {
6-
createIdentity,
7-
createTemplate,
8-
deleteIdentity,
9-
deleteTemplate,
10-
} from "../src/libs/sesUtils";
11-
import { run, TEMPLATE_NAME, USER } from "../src/ses_sendtemplatedemail";
5+
import { createTemplate, deleteTemplate } from "../src/libs/sesUtils";
6+
import { run, TEMPLATE_NAME } from "../src/ses_sendtemplatedemail";
127
import { MessageRejected } from "@aws-sdk/client-ses";
138

149
describe("ses_sendbulktemplatedemail", () => {
1510
beforeAll(async () => {
1611
try {
17-
await createIdentity(USER.emailAddress);
1812
await createTemplate(TEMPLATE_NAME);
1913
} catch (e) {
2014
console.error(e);
@@ -23,7 +17,6 @@ describe("ses_sendbulktemplatedemail", () => {
2317

2418
afterAll(async () => {
2519
try {
26-
await deleteIdentity(USER.emailAddress);
2720
await deleteTemplate(TEMPLATE_NAME);
2821
} catch (e) {
2922
console.error(e);

javascriptv3/example_code/ses/vite.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import { defineConfig } from "vitest/config";
44

5+
const timeout = 3600000; // 1 hour timeout
6+
57
export default defineConfig({
68
test: {
7-
testTimeout: 3600000, // 1 hour timeout
9+
testTimeout: timeout,
10+
hookTimeout: timeout,
811
sequence: {
912
concurrent: false, // Run tests sequentially
1013
},

0 commit comments

Comments
 (0)