mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
Compare commits
3 commits
21a2d3c681
...
7961ebb43b
Author | SHA1 | Date | |
---|---|---|---|
|
7961ebb43b | ||
|
685043e55b | ||
|
0ba3773031 |
5 changed files with 70 additions and 6 deletions
17
package-lock.json
generated
17
package-lock.json
generated
|
@ -93,6 +93,7 @@
|
|||
"@playwright/test": "~1.39.0",
|
||||
"@popperjs/core": "~2.10.2",
|
||||
"@testcontainers/hivemq": "^10.13.1",
|
||||
"@testcontainers/rabbitmq": "^10.13.2",
|
||||
"@types/bootstrap": "~5.1.9",
|
||||
"@types/node": "^20.8.6",
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
||||
|
@ -4172,6 +4173,15 @@
|
|||
"testcontainers": "^10.13.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@testcontainers/rabbitmq": {
|
||||
"version": "10.13.2",
|
||||
"resolved": "https://registry.npmjs.org/@testcontainers/rabbitmq/-/rabbitmq-10.13.2.tgz",
|
||||
"integrity": "sha512-npBKBnq3c6hETmxGZ/gVMke9cc1J/pcftNW9S3WidL48hxFBIPjYNM9FdTfWuoNER/8kuf4xJ8yCuJEYGH3ZAg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"testcontainers": "^10.13.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tootallnate/once": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
|
||||
|
@ -15925,11 +15935,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/testcontainers": {
|
||||
"version": "10.13.1",
|
||||
"resolved": "https://registry.npmjs.org/testcontainers/-/testcontainers-10.13.1.tgz",
|
||||
"integrity": "sha512-JBbOhxmygj/ouH/47GnoVNt+c55Telh/45IjVxEbDoswsLchVmJiuKiw/eF6lE5i7LN+/99xsrSCttI3YRtirg==",
|
||||
"version": "10.13.2",
|
||||
"resolved": "https://registry.npmjs.org/testcontainers/-/testcontainers-10.13.2.tgz",
|
||||
"integrity": "sha512-LfEll+AG/1Ks3n4+IA5lpyBHLiYh/hSfI4+ERa6urwfQscbDU+M2iW1qPQrHQi+xJXQRYy4whyK1IEHdmxWa3Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@balena/dockerignore": "^1.0.2",
|
||||
"@types/dockerode": "^3.3.29",
|
||||
|
|
|
@ -155,6 +155,7 @@
|
|||
"@playwright/test": "~1.39.0",
|
||||
"@popperjs/core": "~2.10.2",
|
||||
"@testcontainers/hivemq": "^10.13.1",
|
||||
"@testcontainers/rabbitmq": "^10.13.2",
|
||||
"@types/bootstrap": "~5.1.9",
|
||||
"@types/node": "^20.8.6",
|
||||
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
||||
|
|
|
@ -1058,6 +1058,7 @@
|
|||
"rabbitmqNodesInvalid": "Please use a complete URL for RabbitMQ nodes.",
|
||||
"RabbitMQ Username": "RabbitMQ Username",
|
||||
"RabbitMQ Password": "RabbitMQ Password",
|
||||
"RabbitMQ (using Management Plugin)": "RabbitMQ (using Management Plugin)",
|
||||
"SendGrid API Key": "SendGrid API Key",
|
||||
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas"
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
MQTT
|
||||
</option>
|
||||
<option value="rabbitmq">
|
||||
RabbitMQ (using Management Plugin)
|
||||
{{ $t("RabbitMQ (using Management Plugin)") }}
|
||||
</option>
|
||||
<option value="kafka-producer">
|
||||
Kafka Producer
|
||||
|
@ -1789,7 +1789,7 @@ message HealthCheckResponse {
|
|||
toast.error(this.$t("rabbitmqNodesRequired"));
|
||||
return false;
|
||||
}
|
||||
if (!this.monitor.rabbitmqNodes.every(node => node.startsWith("http://" || node.startsWith("https://")))) {
|
||||
if (!this.monitor.rabbitmqNodes.every(node => node.startsWith("http://") || node.startsWith("https://"))) {
|
||||
toast.error(this.$t("rabbitmqNodesInvalid"));
|
||||
return false;
|
||||
}
|
||||
|
|
53
test/backend-test/test-rabbitmq.js
Normal file
53
test/backend-test/test-rabbitmq.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
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);
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in a new issue