Skip to content

Commit 4602a78

Browse files
committed
test: create log group if none exists
1 parent 6cad22b commit 4602a78

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

clients/client-cloudwatch-logs/test/CloudWatchLogs.e2e.spec.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CloudWatchLogs } from "@aws-sdk/client-cloudwatch-logs";
2+
import { GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
23
import { AwsJson1_1Protocol, AwsSmithyRpcV2CborProtocol } from "@aws-sdk/core/protocols";
3-
import type { IncomingMessage } from "node:http";
44
import { describe, expect, test as it } from "vitest";
55

66
describe(
@@ -34,12 +34,29 @@ describe(
3434
});
3535

3636
it("should be able to use an event stream to tail logs", async () => {
37+
const sts = new STS({ region: "us-west-2" });
38+
const id: GetCallerIdentityCommandOutput = await sts.getCallerIdentity();
39+
const accountId = id.Account;
40+
3741
for (const cwl of [cwlDefault, cwlCustom]) {
38-
const logGroups = await cwl.listLogGroups({
42+
const testLogGroupName = `/jsv3-e2e-${accountId}`;
43+
44+
let logGroups = await cwl.listLogGroups({
45+
logGroupNamePattern: `^${testLogGroupName}`,
3946
limit: 1,
4047
});
4148

42-
const groupArn = logGroups.logGroups?.[0].logGroupArn;
49+
if (!logGroups.logGroups?.length) {
50+
await cwl.createLogGroup({
51+
logGroupName: testLogGroupName,
52+
});
53+
logGroups = await cwl.listLogGroups({
54+
logGroupNamePattern: `^${testLogGroupName}`,
55+
limit: 1,
56+
});
57+
}
58+
59+
const groupArn = logGroups.logGroups?.[0]?.logGroupArn;
4360

4461
if (groupArn) {
4562
const liveTail = await cwl.startLiveTail({
@@ -69,5 +86,8 @@ describe(
6986
}
7087
});
7188
},
72-
120_000
89+
{
90+
timeout: 120_000,
91+
retry: 4,
92+
}
7393
);

0 commit comments

Comments
 (0)