diff --git a/test/backend-test/monitors/test-grpc.js b/test/backend-test/monitors/test-grpc.js index 24edfb81..def83904 100644 --- a/test/backend-test/monitors/test-grpc.js +++ b/test/backend-test/monitors/test-grpc.js @@ -82,7 +82,7 @@ async function createTestGrpcServer(port, methodHandlers) { describe("GrpcKeywordMonitorType", { skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64"), }, () => { - test("gRPC keyword found in response", async () => { + test("check() sets status to UP when keyword is found in response", async () => { const port = 50051; const server = await createTestGrpcServer(port, { Echo: (call, callback) => { @@ -118,7 +118,7 @@ describe("GrpcKeywordMonitorType", { } }); - test("gRPC keyword not found in response", async () => { + test("check() rejects when keyword is not found in response", async () => { const port = 50052; const server = await createTestGrpcServer(port, { Echo: (call, callback) => { @@ -158,7 +158,7 @@ describe("GrpcKeywordMonitorType", { } }); - test("gRPC inverted keyword - keyword present (should fail)", async () => { + test("check() rejects when inverted keyword is present in response", async () => { const port = 50053; const server = await createTestGrpcServer(port, { Echo: (call, callback) => { @@ -198,7 +198,7 @@ describe("GrpcKeywordMonitorType", { } }); - test("gRPC inverted keyword - keyword not present (should pass)", async () => { + test("check() sets status to UP when inverted keyword is not present in response", async () => { const port = 50054; const server = await createTestGrpcServer(port, { Echo: (call, callback) => { @@ -234,7 +234,7 @@ describe("GrpcKeywordMonitorType", { } }); - test("gRPC connection failure", async () => { + test("check() rejects when gRPC server is unreachable", async () => { const grpcMonitor = new GrpcKeywordMonitorType(); const monitor = { grpcUrl: "localhost:50099", @@ -262,7 +262,7 @@ describe("GrpcKeywordMonitorType", { ); }); - test("gRPC response truncation for long messages", async () => { + test("check() truncates long response messages in error output", async () => { const port = 50055; const longMessage = "A".repeat(100) + " with SUCCESS keyword"; diff --git a/test/backend-test/monitors/test-mqtt.js b/test/backend-test/monitors/test-mqtt.js index dbcf56a8..a361e868 100644 --- a/test/backend-test/monitors/test-mqtt.js +++ b/test/backend-test/monitors/test-mqtt.js @@ -58,91 +58,91 @@ describe("MqttMonitorType", { concurrency: 4, skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64") }, () => { - test("valid keywords (type=default)", async () => { + test("check() sets status to UP when keyword is found in message (type=default)", async () => { const heartbeat = await testMqtt("KEYWORD", null, "-> KEYWORD <-"); assert.strictEqual(heartbeat.status, UP); assert.strictEqual(heartbeat.msg, "Topic: test; Message: -> KEYWORD <-"); }); - test("valid nested topic", async () => { + test("check() sets status to UP when keyword is found in nested topic", async () => { const heartbeat = await testMqtt("KEYWORD", null, "-> KEYWORD <-", "a/b/c", "a/b/c"); assert.strictEqual(heartbeat.status, UP); assert.strictEqual(heartbeat.msg, "Topic: a/b/c; Message: -> KEYWORD <-"); }); - test("valid nested topic (with special chars)", async () => { + test("check() sets status to UP when keyword is found in nested topic with special characters", async () => { const heartbeat = await testMqtt("KEYWORD", null, "-> KEYWORD <-", "a/'/$/./*/%", "a/'/$/./*/%"); assert.strictEqual(heartbeat.status, UP); assert.strictEqual(heartbeat.msg, "Topic: a/'/$/./*/%; Message: -> KEYWORD <-"); }); - test("valid wildcard topic (with #)", async () => { + test("check() sets status to UP when keyword is found using # wildcard", async () => { const heartbeat = await testMqtt("KEYWORD", null, "-> KEYWORD <-", "a/#", "a/b/c"); assert.strictEqual(heartbeat.status, UP); assert.strictEqual(heartbeat.msg, "Topic: a/b/c; Message: -> KEYWORD <-"); }); - test("valid wildcard topic (with +)", async () => { + test("check() sets status to UP when keyword is found using + wildcard", async () => { const heartbeat = await testMqtt("KEYWORD", null, "-> KEYWORD <-", "a/+/c", "a/b/c"); assert.strictEqual(heartbeat.status, UP); assert.strictEqual(heartbeat.msg, "Topic: a/b/c; Message: -> KEYWORD <-"); }); - test("valid wildcard topic (with + and #)", async () => { + test("check() sets status to UP when keyword is found using + and # wildcards", async () => { const heartbeat = await testMqtt("KEYWORD", null, "-> KEYWORD <-", "a/+/c/#", "a/b/c/d/e"); assert.strictEqual(heartbeat.status, UP); assert.strictEqual(heartbeat.msg, "Topic: a/b/c/d/e; Message: -> KEYWORD <-"); }); - test("invalid topic", async () => { + test("check() rejects with timeout when topic does not match", async () => { await assert.rejects( testMqtt("keyword will not be checked anyway", null, "message", "x/y/z", "a/b/c"), new Error("Timeout, Message not received"), ); }); - test("invalid wildcard topic (with #)", async () => { + test("check() rejects with timeout when # wildcard is not last character", async () => { await assert.rejects( testMqtt("", null, "# should be last character", "#/c", "a/b/c"), new Error("Timeout, Message not received"), ); }); - test("invalid wildcard topic (with +)", async () => { + test("check() rejects with timeout when + wildcard topic does not match", async () => { await assert.rejects( testMqtt("", null, "message", "x/+/z", "a/b/c"), new Error("Timeout, Message not received"), ); }); - test("valid keywords (type=keyword)", async () => { + test("check() sets status to UP when keyword is found in message (type=keyword)", async () => { const heartbeat = await testMqtt("KEYWORD", "keyword", "-> KEYWORD <-"); assert.strictEqual(heartbeat.status, UP); assert.strictEqual(heartbeat.msg, "Topic: test; Message: -> KEYWORD <-"); }); - test("invalid keywords (type=default)", async () => { + test("check() rejects when keyword is not found in message (type=default)", async () => { await assert.rejects( testMqtt("NOT_PRESENT", null, "-> KEYWORD <-"), new Error("Message Mismatch - Topic: test; Message: -> KEYWORD <-"), ); }); - test("invalid keyword (type=keyword)", async () => { + test("check() rejects when keyword is not found in message (type=keyword)", async () => { await assert.rejects( testMqtt("NOT_PRESENT", "keyword", "-> KEYWORD <-"), new Error("Message Mismatch - Topic: test; Message: -> KEYWORD <-"), ); }); - test("valid json-query", async () => { + test("check() sets status to UP when json-query finds expected value", async () => { // works because the monitors' jsonPath is hard-coded to "firstProp" const heartbeat = await testMqtt("present", "json-query", "{\"firstProp\":\"present\"}"); assert.strictEqual(heartbeat.status, UP); assert.strictEqual(heartbeat.msg, "Message received, expected value is found"); }); - test("invalid (because query fails) json-query", async () => { + test("check() rejects when json-query path returns undefined", async () => { // works because the monitors' jsonPath is hard-coded to "firstProp" await assert.rejects( testMqtt("[not_relevant]", "json-query", "{}"), @@ -150,7 +150,7 @@ describe("MqttMonitorType", { ); }); - test("invalid (because successMessage fails) json-query", async () => { + test("check() rejects when json-query value does not match expected value", async () => { // works because the monitors' jsonPath is hard-coded to "firstProp" await assert.rejects( testMqtt("[wrong_success_messsage]", "json-query", "{\"firstProp\":\"present\"}"), diff --git a/test/backend-test/monitors/test-mssql.js b/test/backend-test/monitors/test-mssql.js index 091f01ac..f265bcdf 100644 --- a/test/backend-test/monitors/test-mssql.js +++ b/test/backend-test/monitors/test-mssql.js @@ -26,7 +26,7 @@ describe( (process.platform !== "linux" || process.arch !== "x64"), }, () => { - test("MSSQL is running", async () => { + test("check() sets status to UP when MSSQL server is reachable", async () => { let mssqlContainer; try { @@ -69,7 +69,7 @@ describe( } }); - test("MSSQL with custom query returning single value", async () => { + test("check() sets status to UP when custom query returns single value", async () => { const mssqlContainer = await createAndStartMSSQLContainer(); const mssqlMonitor = new MssqlMonitorType(); @@ -97,7 +97,7 @@ describe( } }); - test("MSSQL with custom query and condition that passes", async () => { + test("check() sets status to UP when custom query result meets condition", async () => { const mssqlContainer = await createAndStartMSSQLContainer(); const mssqlMonitor = new MssqlMonitorType(); @@ -133,7 +133,7 @@ describe( } }); - test("MSSQL with custom query and condition that fails", async () => { + test("check() rejects when custom query result does not meet condition", async () => { const mssqlContainer = await createAndStartMSSQLContainer(); const mssqlMonitor = new MssqlMonitorType(); @@ -174,7 +174,7 @@ describe( } }); - test("MSSQL query returns no results", async () => { + test("check() rejects when query returns no results", async () => { const mssqlContainer = await createAndStartMSSQLContainer(); const mssqlMonitor = new MssqlMonitorType(); @@ -207,7 +207,7 @@ describe( } }); - test("MSSQL query returns multiple rows", async () => { + test("check() rejects when query returns multiple rows", async () => { const mssqlContainer = await createAndStartMSSQLContainer(); const mssqlMonitor = new MssqlMonitorType(); @@ -240,7 +240,7 @@ describe( } }); - test("MSSQL query returns multiple columns", async () => { + test("check() rejects when query returns multiple columns", async () => { const mssqlContainer = await createAndStartMSSQLContainer(); const mssqlMonitor = new MssqlMonitorType(); @@ -273,7 +273,7 @@ describe( } }); - test("MSSQL is not running", async () => { + test("check() rejects when MSSQL server is not reachable", async () => { const mssqlMonitor = new MssqlMonitorType(); const monitor = { databaseConnectionString: diff --git a/test/backend-test/monitors/test-postgres.js b/test/backend-test/monitors/test-postgres.js index 505e0fc9..098c862a 100644 --- a/test/backend-test/monitors/test-postgres.js +++ b/test/backend-test/monitors/test-postgres.js @@ -12,7 +12,7 @@ describe( (process.platform !== "linux" || process.arch !== "x64"), }, () => { - test("Postgres is running", async () => { + test("check() sets status to UP when Postgres server is reachable", async () => { // The default timeout of 30 seconds might not be enough for the container to start const postgresContainer = await new PostgreSqlContainer( "postgres:latest" @@ -37,7 +37,7 @@ describe( } }); - test("Postgres is not running", async () => { + test("check() rejects when Postgres server is not reachable", async () => { const postgresMonitor = new PostgresMonitorType(); const monitor = { databaseConnectionString: "http://localhost:15432", diff --git a/test/backend-test/monitors/test-rabbitmq.js b/test/backend-test/monitors/test-rabbitmq.js index 88a04afa..63d358df 100644 --- a/test/backend-test/monitors/test-rabbitmq.js +++ b/test/backend-test/monitors/test-rabbitmq.js @@ -7,7 +7,7 @@ const { UP, PENDING } = require("../../../src/util"); describe("RabbitMQ Single Node", { skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64"), }, () => { - test("RabbitMQ is running", async () => { + test("check() sets status to UP when RabbitMQ server is reachable", async () => { // The default timeout of 30 seconds might not be enough for the container to start const rabbitMQContainer = await new RabbitMQContainer().withStartupTimeout(60000).start(); const rabbitMQMonitor = new RabbitMqMonitorType(); @@ -33,7 +33,7 @@ describe("RabbitMQ Single Node", { } }); - test("RabbitMQ is not running", async () => { + test("check() rejects when RabbitMQ server is not reachable", async () => { const rabbitMQMonitor = new RabbitMqMonitorType(); const monitor = { rabbitmqNodes: JSON.stringify([ "http://localhost:15672" ]), diff --git a/test/backend-test/monitors/test-tcp.js b/test/backend-test/monitors/test-tcp.js index 71f0f2f8..76d093ff 100644 --- a/test/backend-test/monitors/test-tcp.js +++ b/test/backend-test/monitors/test-tcp.js @@ -4,17 +4,7 @@ const { TCPMonitorType } = require("../../../server/monitor-types/tcp"); const { UP, PENDING } = require("../../../src/util"); const net = require("net"); -/** - * Test suite for TCP Monitor functionality - * This test suite checks the behavior of the TCPMonitorType class - * under different network connection scenarios. - */ describe("TCP Monitor", () => { - /** - * Creates a TCP server on a specified port - * @param {number} port - The port number to listen on - * @returns {Promise} A promise that resolves with the created server - */ async function createTCPServer(port) { return new Promise((resolve, reject) => { const server = net.createServer(); @@ -29,11 +19,7 @@ describe("TCP Monitor", () => { }); } - /** - * Test case to verify TCP monitor works when a server is running - * Checks that the monitor correctly identifies an active TCP server - */ - test("TCP server is running", async () => { + test("check() sets status to UP when TCP server is reachable", async () => { const port = 12345; const server = await createTCPServer(port); @@ -59,11 +45,7 @@ describe("TCP Monitor", () => { } }); - /** - * Test case to verify TCP monitor handles non-running servers - * Checks that the monitor correctly identifies an inactive TCP server - */ - test("TCP server is not running", async () => { + test("check() rejects with connection failed when TCP server is not running", async () => { const tcpMonitor = new TCPMonitorType(); const monitor = { @@ -83,11 +65,7 @@ describe("TCP Monitor", () => { ); }); - /** - * Test case to verify TCP monitor handles servers with expired or invalid TLS certificates - * Checks that the monitor correctly identifies TLS certificate issues - */ - test("TCP server with expired or invalid TLS certificate", async t => { + test("check() rejects when TLS certificate is expired or invalid", async () => { const tcpMonitor = new TCPMonitorType(); const monitor = { @@ -114,7 +92,7 @@ describe("TCP Monitor", () => { ); }); - test("TCP server with valid TLS certificate (SSL)", async t => { + test("check() sets status to UP when TLS certificate is valid (SSL)", async () => { const tcpMonitor = new TCPMonitorType(); const monitor = { @@ -137,7 +115,7 @@ describe("TCP Monitor", () => { assert.strictEqual(heartbeat.status, UP); }); - test("TCP server with valid TLS certificate (STARTTLS)", async t => { + test("check() sets status to UP when TLS certificate is valid (STARTTLS)", async () => { const tcpMonitor = new TCPMonitorType(); const monitor = { @@ -160,7 +138,7 @@ describe("TCP Monitor", () => { assert.strictEqual(heartbeat.status, UP); }); - test("TCP server with valid but name mismatching TLS certificate (STARTTLS)", async t => { + test("check() rejects when TLS certificate hostname does not match (STARTTLS)", async () => { const tcpMonitor = new TCPMonitorType(); const monitor = { @@ -185,7 +163,7 @@ describe("TCP Monitor", () => { regex ); }); - test("XMPP server with valid certificate (STARTTLS)", async t => { + test("check() sets status to UP for XMPP server with valid certificate (STARTTLS)", async () => { const tcpMonitor = new TCPMonitorType(); const monitor = { diff --git a/test/backend-test/monitors/test-websocket.js b/test/backend-test/monitors/test-websocket.js index 545cad46..d2923f1e 100644 --- a/test/backend-test/monitors/test-websocket.js +++ b/test/backend-test/monitors/test-websocket.js @@ -22,9 +22,9 @@ function nonCompliantWS(port = 8080) { return new Promise((resolve) => srv.listen(port, () => resolve(srv))); } -describe("Websocket Test", { +describe("WebSocket Monitor", { }, () => { - test("Non WS Server", {}, async () => { + test("check() rejects with unexpected server response when connecting to non-WebSocket server", {}, async () => { const websocketMonitor = new WebSocketMonitorType(); const monitor = { @@ -44,7 +44,7 @@ describe("Websocket Test", { ); }); - test("Secure WS", async () => { + test("check() sets status to UP when connecting to secure WebSocket server", async () => { const websocketMonitor = new WebSocketMonitorType(); const monitor = { @@ -68,7 +68,7 @@ describe("Websocket Test", { assert.deepStrictEqual(heartbeat, expected); }); - test("Insecure WS", async (t) => { + test("check() sets status to UP when connecting to insecure WebSocket server", async (t) => { t.after(() => wss.close()); const websocketMonitor = new WebSocketMonitorType(); const wss = new WebSocketServer({ port: 8080 }); @@ -94,7 +94,7 @@ describe("Websocket Test", { assert.deepStrictEqual(heartbeat, expected); }); - test("Non compliant WS Server wrong status code", async () => { + test("check() rejects when status code does not match expected value", async () => { const websocketMonitor = new WebSocketMonitorType(); const monitor = { @@ -115,7 +115,7 @@ describe("Websocket Test", { ); }); - test("Secure WS Server no status code", async () => { + test("check() rejects when expected status code is empty", async () => { const websocketMonitor = new WebSocketMonitorType(); const monitor = { @@ -136,7 +136,7 @@ describe("Websocket Test", { ); }); - test("Non compliant WS server without IgnoreSecWebsocket", async (t) => { + test("check() rejects when Sec-WebSocket-Accept header is invalid", async (t) => { t.after(() => wss.close()); const websocketMonitor = new WebSocketMonitorType(); const wss = await nonCompliantWS(); @@ -159,7 +159,7 @@ describe("Websocket Test", { ); }); - test("Non compliant WS server with IgnoreSecWebsocket", async (t) => { + test("check() sets status to UP when ignoring invalid Sec-WebSocket-Accept header", async (t) => { t.after(() => wss.close()); const websocketMonitor = new WebSocketMonitorType(); const wss = await nonCompliantWS(); @@ -185,7 +185,7 @@ describe("Websocket Test", { assert.deepStrictEqual(heartbeat, expected); }); - test("Compliant WS server with IgnoreSecWebsocket", async () => { + test("check() sets status to UP for compliant WebSocket server when ignoring Sec-WebSocket-Accept", async () => { const websocketMonitor = new WebSocketMonitorType(); const monitor = { @@ -209,7 +209,7 @@ describe("Websocket Test", { assert.deepStrictEqual(heartbeat, expected); }); - test("Non WS server with IgnoreSecWebsocket", async () => { + test("check() rejects non-WebSocket server even when ignoring Sec-WebSocket-Accept", async () => { const websocketMonitor = new WebSocketMonitorType(); const monitor = { @@ -230,7 +230,7 @@ describe("Websocket Test", { ); }); - test("Secure WS no subprotocol support", async () => { + test("check() rejects when server does not support requested subprotocol", async () => { const websocketMonitor = new WebSocketMonitorType(); const monitor = { @@ -252,7 +252,7 @@ describe("Websocket Test", { ); }); - test("Multiple subprotocols invalid input", async () => { + test("check() rejects when multiple subprotocols contain invalid characters", async () => { const websocketMonitor = new WebSocketMonitorType(); const monitor = { @@ -274,7 +274,7 @@ describe("Websocket Test", { ); }); - test("Insecure WS subprotocol multiple spaces", async (t) => { + test("check() sets status to UP when subprotocol with multiple spaces is accepted", async (t) => { t.after(() => wss.close()); const websocketMonitor = new WebSocketMonitorType(); const wss = new WebSocketServer({ port: 8080, @@ -305,7 +305,7 @@ describe("Websocket Test", { assert.deepStrictEqual(heartbeat, expected); }); - test("Insecure WS supports one subprotocol", async (t) => { + test("check() sets status to UP when server supports requested subprotocol", async (t) => { t.after(() => wss.close()); const websocketMonitor = new WebSocketMonitorType(); const wss = new WebSocketServer({ port: 8080, diff --git a/test/backend-test/test-migration.js b/test/backend-test/test-migration.js index 87e5ff9d..19b00dad 100644 --- a/test/backend-test/test-migration.js +++ b/test/backend-test/test-migration.js @@ -3,7 +3,7 @@ const fs = require("fs"); const path = require("path"); const { GenericContainer, Wait } = require("testcontainers"); -describe("Database Migration - Optimize Important Indexes", () => { +describe("Database Migration", () => { test("SQLite: All migrations run successfully", async () => { const testDbPath = path.join(__dirname, "../../data/test-migration.db"); const testDbDir = path.dirname(testDbPath);