add "clickhouse is healthy" check
This commit is contained in:
parent
0b99b46256
commit
55a7f98f49
|
@ -9,14 +9,35 @@ const twoHourAgo = dateFns.format(
|
||||||
"yyyy-MM-dd hh:mm:ss"
|
"yyyy-MM-dd hh:mm:ss"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const now = dateFns.format(new Date(), "yyyy-MM-dd hh:mm:ss");
|
||||||
|
|
||||||
describe("Events", () => {
|
describe("Events", () => {
|
||||||
|
test.only("clickhouse is healthy", async () => {
|
||||||
|
const { data } = await (
|
||||||
|
await clickhouseClient.query({
|
||||||
|
query: `
|
||||||
|
SELECT
|
||||||
|
hostName() AS host,
|
||||||
|
uptime() AS uptime_seconds,
|
||||||
|
version() AS clickhouse_version,
|
||||||
|
'OK' AS status
|
||||||
|
FROM system.tables
|
||||||
|
LIMIT 1;
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
).json();
|
||||||
|
const [{ status }] = data as any;
|
||||||
|
assert.equal(status, "OK");
|
||||||
|
});
|
||||||
test("has inserted events", async () => {
|
test("has inserted events", async () => {
|
||||||
|
const query = knex("events")
|
||||||
|
.count("")
|
||||||
|
.whereBetween("created_at", [twoHourAgo, now])
|
||||||
|
.toString();
|
||||||
|
console.log(query);
|
||||||
const { data } = (await (
|
const { data } = (await (
|
||||||
await clickhouseClient.query({
|
await clickhouseClient.query({
|
||||||
query: knex("events")
|
query,
|
||||||
.count("")
|
|
||||||
.where("created_at", ">", twoHourAgo)
|
|
||||||
.toString(),
|
|
||||||
})
|
})
|
||||||
).json()) as any;
|
).json()) as any;
|
||||||
assert.notEqual(Number.parseInt(data[0]["count()"], 10), 0);
|
assert.notEqual(Number.parseInt(data[0]["count()"], 10), 0);
|
||||||
|
|
Loading…
Reference in New Issue