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"
|
||||
);
|
||||
|
||||
const now = dateFns.format(new Date(), "yyyy-MM-dd hh:mm:ss");
|
||||
|
||||
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 () => {
|
||||
const query = knex("events")
|
||||
.count("")
|
||||
.whereBetween("created_at", [twoHourAgo, now])
|
||||
.toString();
|
||||
console.log(query);
|
||||
const { data } = (await (
|
||||
await clickhouseClient.query({
|
||||
query: knex("events")
|
||||
.count("")
|
||||
.where("created_at", ">", twoHourAgo)
|
||||
.toString(),
|
||||
query,
|
||||
})
|
||||
).json()) as any;
|
||||
assert.notEqual(Number.parseInt(data[0]["count()"], 10), 0);
|
||||
|
|
Loading…
Reference in New Issue