From bfb35abf16bb4aa52b143dd1eb31ddef16898b37 Mon Sep 17 00:00:00 2001 From: wrobell Date: Sun, 14 Jun 2026 17:57:57 +0100 Subject: services: Update rabbitmq service Update RabbitMQ default configuration to use localhost interface by default and avoid listening on public interfaces. Change the default configuration file to set inter-node communication listener to localhost network interface (see also https://www.rabbitmq.com/docs/networking#distribution). This requires setting RabbitMQ node name to `rabbit@localhost`, so introduce `node-name` RabbitMQ configuration field with such default value. Path to the RabbitMQ environment configuration file was hardcoded. Remove the hardcoding and allow to create such file with env-config-file RabbitMQ configuration field. Add new RabbitMQ service tests to check RabbitMQ broker startup and status after the service is started. * gnu/services/high-availability.scm () [, ]: New fields. (rabbitmq-shepherd-service): Use them. (%default-rabbitmq-config-file): Update. * gnu/tests/high-availability.scm (run-rabbitmq-test): Add new tests. * doc/gnu.texi (High Availability Services): Document new fields and provide information about local interfaces. Merges: guix/guix!9360 Signed-off-by: Sharlatan Hellseher --- gnu/tests/high-availability.scm | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'gnu/tests') diff --git a/gnu/tests/high-availability.scm b/gnu/tests/high-availability.scm index 591e5f5bc23..6eb13d1a068 100644 --- a/gnu/tests/high-availability.scm +++ b/gnu/tests/high-availability.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Christopher Baines -;;; Copyright © 2025 Artur Wroblewski +;;; Copyright © 2025-2026 Artur Wroblewski ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,6 +19,7 @@ (define-module (gnu tests high-availability) #:use-module (gnu tests) + #:use-module (gnu packages high-availability) #:use-module (gnu system) #:use-module (gnu system file-systems) #:use-module (gnu system shadow) @@ -34,12 +35,15 @@ (plain-file "rabbitmq.conf" " listeners.tcp.1 = 127.0.0.1:15672 listeners.tcp.2 = ::1:15672 + +distribution.listener.interface = 127.0.0.1 ")) (define %rabbitmq-os (simple-operating-system (service rabbitmq-service-type - (rabbitmq-configuration (config-file %rabbitmq-config-file))))) + (rabbitmq-configuration (node-name "rabbit@komputilo") + (config-file %rabbitmq-config-file))))) (define* (run-rabbitmq-test #:key (rabbitmq-port 15672)) "Run tests in %RABBITMQ-OS, forwarding PORT." @@ -94,6 +98,29 @@ listeners.tcp.2 = ::1:15672 '(file-exists? "/var/log/rabbitmq/rabbit@komputilo.log") marionette)) + (test-assert "RabbitMQ await startup command is successful" + (marionette-eval + '(begin + (use-modules (guix build utils)) + + (current-output-port (open-file "/dev/console" "w0")) + (invoke #$(file-append rabbitmq "/sbin/rabbitmqctl") + "await_startup" + "-n" + "rabbit@komputilo")) + marionette)) + + (test-assert "RabbitMQ status command is successful" + (marionette-eval + '(begin + (use-modules (guix build utils)) + + (current-output-port (open-file "/dev/console" "w0")) + (invoke #$(file-append rabbitmq "/sbin/rabbitmqctl") + "status" + "-n" + "rabbit@komputilo")) + marionette)) (test-end)))) (gexp->derivation "rabbitmq-test" test)) -- cgit v1.2.3