Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clients/client-cloudwatch-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"extract:docs": "api-extractor run --local",
"generate:client": "node ../../scripts/generate-clients/single-service --solo cloudwatch-logs"
"generate:client": "node ../../scripts/generate-clients/single-service --solo cloudwatch-logs",
"test:e2e": "yarn g:vitest run -c vitest.config.e2e.mts",
"test:e2e:watch": "yarn g:vitest watch -c vitest.config.e2e.mts"
},
"main": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts",
Expand Down
69 changes: 69 additions & 0 deletions clients/client-cloudwatch-logs/test/CloudWatchLogs.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { CloudWatchLogs } from "@aws-sdk/client-cloudwatch-logs";
import { GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
import { describe, expect, test as it } from "vitest";

describe(
CloudWatchLogs.name,
{
timeout: 120_000,
retry: 4,
},
() => {
const cwlDefault = new CloudWatchLogs({
region: "us-west-2",
});

it("should be able to use an event stream to tail logs", async () => {
const sts = new STS({ region: "us-west-2" });
const id: GetCallerIdentityCommandOutput = await sts.getCallerIdentity();
const accountId = id.Account;

for (const cwl of [cwlDefault]) {
const testLogGroupName = `/jsv3-e2e-${accountId}`;

let logGroups = await cwl.listLogGroups({
logGroupNamePattern: `^${testLogGroupName}`,
limit: 1,
});

if (!logGroups.logGroups?.length) {
await cwl.createLogGroup({
logGroupName: testLogGroupName,
});
logGroups = await cwl.listLogGroups({
logGroupNamePattern: `^${testLogGroupName}`,
limit: 1,
});
}

const groupArn = logGroups.logGroups?.[0]?.logGroupArn;

if (groupArn) {
const liveTail = await cwl.startLiveTail({
logGroupIdentifiers: [groupArn],
});

let pagesRead = 0;

for await (const page of liveTail.responseStream ?? []) {
pagesRead += 1;

if (pagesRead === 1) {
expect(page.sessionStart?.requestId).toBeTypeOf("string");
expect(page.sessionStart?.sessionId).toBeTypeOf("string");
expect(page.sessionStart?.logGroupIdentifiers).toEqual([groupArn]);
} else if (pagesRead === 2) {
expect(page.sessionUpdate?.sessionMetadata).toMatchObject({
sampled: expect.any(Boolean),
});
} else if (pagesRead > 2) {
break;
}
}

cwl.destroy();
}
}
});
}
);
10 changes: 10 additions & 0 deletions clients/client-cloudwatch-logs/vitest.config.e2e.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
exclude: ["**/*.browser.e2e.spec.ts"],
include: ["**/*.e2e.spec.ts"],
environment: "node",
},
mode: "development",
});
Loading