-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathnode_summary.test.ts
More file actions
86 lines (81 loc) · 2.95 KB
/
Copy pathnode_summary.test.ts
File metadata and controls
86 lines (81 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import type { ClickHouseClient } from "@clickhouse/client-common";
import { createSimpleTable } from "@test/fixtures/simple_table";
import { jsonValues } from "@test/fixtures/test_data";
import { createTestClient } from "@test/utils/client";
import { guid } from "@test/utils/guid";
import { TestEnv, isOnEnv } from "@test/utils/test_env";
import type Stream from "stream";
// FIXME: figure out if we can get non-flaky assertion with an SMT Cloud instance.
// It could be that it requires full quorum settings for non-flaky assertions.
// SharedMergeTree Cloud instance is auto by default (and cannot be modified).
describe.skipIf(!isOnEnv(TestEnv.LocalSingleNode, TestEnv.LocalCluster))(
"[Node.js] Summary header parsing",
() => {
let client: ClickHouseClient<Stream.Readable>;
let tableName: string;
beforeAll(async () => {
client = createTestClient();
tableName = `summary_test_${guid()}`;
await createSimpleTable(client, tableName);
});
afterAll(async () => {
await client.close();
});
it("should provide summary for insert/exec", async () => {
const { summary: insertSummary } = await client.insert({
table: tableName,
values: jsonValues,
format: "JSONEachRow",
});
expect(insertSummary).toEqual(
expect.objectContaining({
read_rows: expect.any(String),
read_bytes: expect.any(String),
written_rows: expect.any(String),
written_bytes: expect.any(String),
result_rows: expect.any(String),
result_bytes: expect.any(String),
elapsed_ns: expect.any(String),
}),
);
const { summary: execSummary } = await client.exec({
query: `INSERT INTO ${tableName}
SELECT *
FROM ${tableName}`,
});
expect(execSummary).toEqual(
expect.objectContaining({
read_rows: expect.any(String),
read_bytes: expect.any(String),
written_rows: expect.any(String),
written_bytes: expect.any(String),
result_rows: expect.any(String),
result_bytes: expect.any(String),
elapsed_ns: expect.any(String),
}),
);
});
it("should provide summary for command", async () => {
const { summary } = await client.command({
query: `INSERT INTO ${tableName}
VALUES (144, 'Hello', [2, 4]),
(255, 'World', [3, 5])`,
clickhouse_settings: {
wait_end_of_query: 1,
},
});
expect(summary).toEqual(
expect.objectContaining({
read_rows: expect.any(String),
read_bytes: expect.any(String),
written_rows: expect.any(String),
written_bytes: expect.any(String),
result_rows: expect.any(String),
result_bytes: expect.any(String),
elapsed_ns: expect.any(String),
}),
);
});
},
);