Compare commits
No commits in common. "96a7606ee255f232db5dd733160cf67268906bf5" and "4b6be4f4e8af07c7a3c60675f360df8cb96542a6" have entirely different histories.
96a7606ee2
...
4b6be4f4e8
84
.drone.yml
84
.drone.yml
|
@ -1,33 +1,3 @@
|
||||||
kind: secret
|
|
||||||
name: POSTGRES_PASSWORD
|
|
||||||
get:
|
|
||||||
path: secrets
|
|
||||||
name: POSTGRES_PASSWORD
|
|
||||||
---
|
|
||||||
kind: secret
|
|
||||||
name: CLICKHOUSE_PASSWORD
|
|
||||||
get:
|
|
||||||
path: secrets
|
|
||||||
name: CLICKHOUSE_PASSWORD
|
|
||||||
---
|
|
||||||
kind: secret
|
|
||||||
name: SMTP_HOST
|
|
||||||
get:
|
|
||||||
path: secrets
|
|
||||||
name: SMTP_HOST
|
|
||||||
---
|
|
||||||
kind: secret
|
|
||||||
name: SMTP_USERNAME
|
|
||||||
get:
|
|
||||||
path: secrets
|
|
||||||
name: SMTP_USERNAME
|
|
||||||
---
|
|
||||||
kind: secret
|
|
||||||
name: SMTP_PASSWORD
|
|
||||||
get:
|
|
||||||
path: secrets
|
|
||||||
name: SMTP_PASSWORD
|
|
||||||
---
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: healthcheck
|
name: healthcheck
|
||||||
|
@ -36,60 +6,8 @@ trigger:
|
||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
services:
|
|
||||||
- name: kubectl-proxy-postgres
|
|
||||||
image: bitnami/kubectl
|
|
||||||
network_mode: host
|
|
||||||
environment:
|
|
||||||
KUBE_CONFIG:
|
|
||||||
from_secret: KUBE_CONFIG
|
|
||||||
commands:
|
|
||||||
- echo "$$KUBE_CONFIG" | base64 -d > /.kube/config
|
|
||||||
- kubectl -n databases port-forward pod/postgres-0 5432:5432
|
|
||||||
- name: kubectl-proxy-clickhouse
|
|
||||||
image: bitnami/kubectl
|
|
||||||
network_mode: host
|
|
||||||
environment:
|
|
||||||
KUBE_CONFIG:
|
|
||||||
from_secret: KUBE_CONFIG
|
|
||||||
commands:
|
|
||||||
- echo "$$KUBE_CONFIG" | base64 -d > /.kube/config
|
|
||||||
- kubectl -n databases port-forward pod/clickhouse-0 8123:8123
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: install
|
|
||||||
image: node:20.10.0
|
|
||||||
commands:
|
|
||||||
- npm install
|
|
||||||
- name: build
|
|
||||||
image: node:20.10.0
|
|
||||||
commands:
|
|
||||||
- npm run build
|
|
||||||
- name: test
|
- name: test
|
||||||
network_mode: host
|
|
||||||
image: node:20.10.0
|
image: node:20.10.0
|
||||||
commands:
|
commands:
|
||||||
- npm run test
|
- echo test
|
||||||
environment:
|
|
||||||
POSTGRES_HOST: localhost
|
|
||||||
POSTGRES_DATABASE: nocodelytics_production
|
|
||||||
POSTGRES_PASSWORD:
|
|
||||||
from_secret: POSTGRES_PASSWORD
|
|
||||||
CLICKHOUSE_HOST: http://localhost:8123
|
|
||||||
CLICKHOUSE_DATABASE: nocodelytics_production
|
|
||||||
CLICKHOUSE_PASSWORD:
|
|
||||||
from_secret: CLICKHOUSE_PASSWORD
|
|
||||||
- name: notify
|
|
||||||
image: drillster/drone-email
|
|
||||||
settings:
|
|
||||||
host:
|
|
||||||
from_secret: SMTP_HOST
|
|
||||||
port: 587
|
|
||||||
username:
|
|
||||||
from_secret: SMTP_USERNAME
|
|
||||||
password:
|
|
||||||
from_secret: SMTP_PASSWORD
|
|
||||||
from: no-reply@nocodelytics.com
|
|
||||||
recipients: [florian@nocodelytics.com]
|
|
||||||
when:
|
|
||||||
status: [failure]
|
|
||||||
|
|
|
@ -4,40 +4,19 @@ import { sum } from "lodash";
|
||||||
import * as dateFns from "date-fns";
|
import * as dateFns from "date-fns";
|
||||||
import { clickhouseClient, knex } from "./databases";
|
import { clickhouseClient, knex } from "./databases";
|
||||||
|
|
||||||
const twoHourAgo = dateFns.format(
|
const oneHourAgo = dateFns.format(
|
||||||
dateFns.subHours(new Date(), 2),
|
dateFns.subHours(new Date(), 1),
|
||||||
"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("clickhouse is healthy", async () => {
|
test.skip("has inserted events", 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 (
|
const { data } = (await (
|
||||||
await clickhouseClient.query({
|
await clickhouseClient.query({
|
||||||
query,
|
query: knex("events")
|
||||||
|
.count("")
|
||||||
|
.where("created_at", ">", oneHourAgo)
|
||||||
|
.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);
|
||||||
|
@ -47,7 +26,7 @@ describe("Events", () => {
|
||||||
await clickhouseClient.query({
|
await clickhouseClient.query({
|
||||||
query: knex("events")
|
query: knex("events")
|
||||||
.count()
|
.count()
|
||||||
.where("created_at", ">", twoHourAgo)
|
.where("created_at", ">", oneHourAgo)
|
||||||
.groupBy("geo_ip_country")
|
.groupBy("geo_ip_country")
|
||||||
.toString(),
|
.toString(),
|
||||||
format: "JSON",
|
format: "JSON",
|
||||||
|
|
Loading…
Reference in New Issue