mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-04 20:24:04 +00:00
c01494ec33
Some checks failed
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20, ARM64) (push) Has been cancelled
Auto Test / auto-test (20, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20, windows-latest) (push) Has been cancelled
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / check-linters (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
json-yaml-validate / json-yaml-validate (push) Has been cancelled
Co-authored-by: Frank Elsinga <frank@elsinga.de>
53 lines
1.9 KiB
JavaScript
53 lines
1.9 KiB
JavaScript
const { describe, test } = require("node:test");
|
|
const assert = require("node:assert");
|
|
const { RabbitMQContainer } = require("@testcontainers/rabbitmq");
|
|
const { RabbitMqMonitorType } = require("../../server/monitor-types/rabbitmq");
|
|
const { UP, DOWN, PENDING } = require("../../src/util");
|
|
|
|
describe("RabbitMQ Single Node", {
|
|
skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64"),
|
|
}, () => {
|
|
test("RabbitMQ is running", 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();
|
|
const connectionString = `http://${rabbitMQContainer.getHost()}:${rabbitMQContainer.getMappedPort(15672)}`;
|
|
|
|
const monitor = {
|
|
rabbitmqNodes: JSON.stringify([ connectionString ]),
|
|
rabbitmqUsername: "guest",
|
|
rabbitmqPassword: "guest",
|
|
};
|
|
|
|
const heartbeat = {
|
|
msg: "",
|
|
status: PENDING,
|
|
};
|
|
|
|
try {
|
|
await rabbitMQMonitor.check(monitor, heartbeat, {});
|
|
assert.strictEqual(heartbeat.status, UP);
|
|
assert.strictEqual(heartbeat.msg, "OK");
|
|
} finally {
|
|
rabbitMQContainer.stop();
|
|
}
|
|
});
|
|
|
|
test("RabbitMQ is not running", async () => {
|
|
const rabbitMQMonitor = new RabbitMqMonitorType();
|
|
const monitor = {
|
|
rabbitmqNodes: JSON.stringify([ "http://localhost:15672" ]),
|
|
rabbitmqUsername: "rabbitmqUser",
|
|
rabbitmqPassword: "rabbitmqPass",
|
|
};
|
|
|
|
const heartbeat = {
|
|
msg: "",
|
|
status: PENDING,
|
|
};
|
|
|
|
await rabbitMQMonitor.check(monitor, heartbeat, {});
|
|
assert.strictEqual(heartbeat.status, DOWN);
|
|
});
|
|
|
|
});
|