|
1 | 1 | import { CloudWatchLogs } from "@aws-sdk/client-cloudwatch-logs"; |
| 2 | +import { GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts"; |
2 | 3 | import { AwsJson1_1Protocol, AwsSmithyRpcV2CborProtocol } from "@aws-sdk/core/protocols"; |
3 | | -import type { IncomingMessage } from "node:http"; |
4 | 4 | import { describe, expect, test as it } from "vitest"; |
5 | 5 |
|
6 | 6 | describe( |
@@ -34,12 +34,29 @@ describe( |
34 | 34 | }); |
35 | 35 |
|
36 | 36 | 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 | + |
37 | 41 | 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}`, |
39 | 46 | limit: 1, |
40 | 47 | }); |
41 | 48 |
|
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; |
43 | 60 |
|
44 | 61 | if (groupArn) { |
45 | 62 | const liveTail = await cwl.startLiveTail({ |
@@ -69,5 +86,8 @@ describe( |
69 | 86 | } |
70 | 87 | }); |
71 | 88 | }, |
72 | | - 120_000 |
| 89 | + { |
| 90 | + timeout: 120_000, |
| 91 | + retry: 4, |
| 92 | + } |
73 | 93 | ); |
0 commit comments