Skip to content

Commit 0178624

Browse files
authored
test(middleware-sdk-s3): increase randomness of e2e test (#7463)
1 parent 4960a92 commit 0178624

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

packages/middleware-sdk-s3/src/s3-expires-middleware.e2e.spec.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@ describe("S3 Expires e2e test", () => {
1818
let callerID = null as unknown as GetCallerIdentityCommandOutput;
1919
let Bucket: string;
2020

21-
// random element limited to 2 letters to avoid concurrent IO, and
22-
// to limit bucket count to 676 if there is failure to delete them.
23-
const alphabet = "abcdefghijklmnopqrstuvwxyz";
24-
const randId = alphabet[(Math.random() * alphabet.length) | 0] + alphabet[(Math.random() * alphabet.length) | 0];
21+
const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
22+
const char = () => alphabet[(Math.random() * alphabet.length) | 0];
23+
const randId = char() + char() + char() + char() + (Date.now() % 1000);
2524

2625
beforeAll(async () => {
2726
callerID = await stsClient.getCallerIdentity({});
28-
Bucket = `${callerID.Account}-${randId}-s3-expires`;
29-
await s3.createBucket({
30-
Bucket,
31-
});
27+
Bucket = `${callerID.Account}-s3-expires-${randId}`;
28+
29+
await s3
30+
.createBucket({
31+
Bucket,
32+
})
33+
.catch((e) => {
34+
if (e.name === "BucketAlreadyOwnedByYou") {
35+
return;
36+
}
37+
throw e;
38+
});
3239
});
3340

3441
afterAll(async () => {

0 commit comments

Comments
 (0)