Skip to content

Commit 178aea9

Browse files
authored
test: add more randomness to bucketNames (#5332)
1 parent bc7bd43 commit 178aea9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/middleware-sdk-s3/src/region-redirect-middleware.e2e.spec.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ describe("S3 Global Client Test", () => {
1515
let callerID = null as unknown as GetCallerIdentityCommandOutput;
1616
let bucketNames = [] as string[];
1717

18+
// random element limited to 2 letters to avoid concurrent IO, and
19+
// to limit bucket count to 676 if there is failure to delete them.
20+
const alphabet = "abcdefghijklmnopqrstuvwxyz";
21+
const randId = alphabet[(Math.random() * alphabet.length) | 0] + alphabet[(Math.random() * alphabet.length) | 0];
22+
1823
beforeAll(async () => {
19-
jest.setTimeout(500000);
24+
jest.setTimeout(60000);
2025
callerID = await stsClient.getCallerIdentity({});
21-
bucketNames = regionConfigs.map((config) => `${callerID.Account}-redirect-${config.region}`);
26+
bucketNames = regionConfigs.map((config) => `${callerID.Account}-${randId}-redirect-${config.region}`);
2227
await Promise.all(bucketNames.map((bucketName, index) => deleteBucket(s3Clients[index], bucketName)));
2328
await Promise.all(bucketNames.map((bucketName, index) => s3Clients[index].createBucket({ Bucket: bucketName })));
2429
});
@@ -35,7 +40,7 @@ describe("S3 Global Client Test", () => {
3540
await s3Client.putObject({ Bucket: bucketName, Key: objKey, Body: testValue });
3641
}
3742
}
38-
}, 50000);
43+
}, 60000);
3944

4045
it("Should be able to get objects following region redirect", async () => {
4146
// Fetch and assert objects
@@ -47,7 +52,7 @@ describe("S3 Global Client Test", () => {
4752
expect(data).toEqual(testValue);
4853
}
4954
}
50-
}, 50000);
55+
}, 60000);
5156

5257
it("Should delete objects following region redirect", async () => {
5358
for (const bucketName of bucketNames) {
@@ -56,7 +61,7 @@ describe("S3 Global Client Test", () => {
5661
await s3Client.deleteObject({ Bucket: bucketName, Key: objKey });
5762
}
5863
}
59-
}, 50000);
64+
}, 60000);
6065
});
6166

6267
async function deleteBucket(s3: S3, bucketName: string) {

0 commit comments

Comments
 (0)