Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
🧪 fix tests
Thibault Le Ouay3a5054ecff1a
diff --git a/.dockerignore b/.dockerignoreindex 2e390aa99..4f1d395d2 100644--- a/.dockerignore+++ b/.dockerignore@@ -4,4 +4,5 @@**/README.md**/.next**/.git-node_modules\ No newline at end of file+node_modules+openstatus.db\ No newline at end of filediff --git a/apps/server/fly.toml b/apps/server/fly.tomlindex 3e54ecda6..084e461d0 100644--- a/apps/server/fly.toml+++ b/apps/server/fly.toml@@ -14,8 +14,8 @@ primary_region = "ams"internal_port = 3000force_https = trueauto_stop_machines = false- auto_start_machines = true- min_machines_running = 2+ auto_start_machines = false+ min_machines_running = 12processes = ["app"][http_service.concurrency]type = "requests"diff --git a/apps/server/src/checker/checker.test.ts b/apps/server/src/checker/checker.test.tsindex 0c79296a3..a8cf93e97 100644--- a/apps/server/src/checker/checker.test.ts+++ b/apps/server/src/checker/checker.test.ts@@ -11,11 +11,13 @@ mock.module("./ping.ts", () => {test("should call upsertMonitorStatus when we can fetch", async () => {const fn = mock(() => {});- mock.module("./alerting.ts", () => {+ mock.module("./monitor-handler.ts", () => {return {- upsertMonitorStatus: fn,+ handleMonitorFailed: mock(() => {}),+ handleMonitorRecovered: fn,};});+await checkerRetryPolicy({workspaceId: "1",monitorId: "1",@@ -31,9 +33,10 @@ test("should call upsertMonitorStatus when we can fetch", async () => {test("should call upsertMonitorStatus when status error", async () => {const fn = mock(() => {});- mock.module("./alerting.ts", () => {+ mock.module("./monitor-handler.ts", () => {return {- upsertMonitorStatus: fn,+ handleMonitorFailed: fn,+ handleMonitorRecovered: mock(() => {}),};});try {@@ -55,9 +58,9 @@ test("should call upsertMonitorStatus when status error", async () => {test("What should we do when redirect ", async () => {const fn = mock(() => {});- mock.module("./alerting.ts", () => {+ mock.module("./monitor-handler.ts", () => {return {- upsertMonitorStatus: fn,+ handleMonitorFailed: fn,};});try {@@ -79,17 +82,15 @@ test("What should we do when redirect ", async () => {test("When 404 we should trigger alerting ", async () => {const fn = mock(() => {});const fn1 = mock(() => {});- const fn2 = mock(() => {});- mock.module("./alerting.ts", () => {+ mock.module("./ping.ts", () => {return {- upsertMonitorStatus: fn,- triggerAlerting: fn1,+ publishPing: fn,};});- mock.module("./ping.ts", () => {+ mock.module("./monitor-handler.ts", () => {return {- publishPing: fn2,+ handleMonitorFailed: fn1,};});try {@@ -107,24 +108,20 @@ test("When 404 we should trigger alerting ", async () => {}expect(fn).toHaveBeenCalledTimes(1);expect(fn1).toHaveBeenCalledTimes(1);- expect(fn2).toHaveBeenCalledTimes(1);});test("When error 404 we should not trigger alerting ", async () => {const fn = mock(() => {});const fn1 = mock(() => {});- const fn2 = mock(() => {});- mock.module("./alerting.ts", () => {+ mock.module("./ping.ts", () => {return {- upsertMonitorStatus: fn,- triggerAlerting: fn1,+ publishPing: fn,};});-- mock.module("./ping.ts", () => {+ mock.module("./monitor-handler.ts", () => {return {- publishPing: fn2,+ handleMonitorFailed: fn1,};});try {@@ -140,7 +137,6 @@ test("When error 404 we should not trigger alerting ", async () => {} catch (e) {expect(e).toBeInstanceOf(Error);}- expect(fn).toHaveBeenCalledTimes(0);+ expect(fn).toHaveBeenCalledTimes(1);expect(fn1).toHaveBeenCalledTimes(0);- expect(fn2).toHaveBeenCalledTimes(1);});diff --git a/apps/server/src/checker/checker.ts b/apps/server/src/checker/checker.tsindex 92e623722..9cc40df12 100644--- a/apps/server/src/checker/checker.ts+++ b/apps/server/src/checker/checker.ts@@ -75,7 +75,7 @@ const run = async (data: Payload, retry: number) => {message: undefined,});if (data?.status === "error") {- handleMonitorRecovered(data, res);+ await handleMonitorRecovered(data, res);}} else {if (retry < 2) {@@ -94,8 +94,8 @@ const run = async (data: Payload, retry: number) => {statusCode: res?.status,message,});- if (data?.status === "active") {- handleMonitorFailed(data, res, message);+ if (data.status === "active") {+ await handleMonitorFailed(data, res, message);}}}