GNU bug report logs

#78906 [PATCH] services: mosquitto: Add test suite.

PackageSource(s)Maintainer(s)
guix-patches PTS Buildd Popcon
Reply or subscribe to this bug. View this bug as an mbox, status mbox, or maintainer mbox

Report forwarded to guix-patches@gnu.org:
bug#78906; Package guix-patches. (Thu, 26 Jun 2025 12:07:02 GMT) (full text, mbox, link).


Acknowledgement sent to Evgeny Pisemsky <mail@pisemsky.site>:
New bug report received and forwarded. Copy sent to guix-patches@gnu.org. (Thu, 26 Jun 2025 12:07:02 GMT) (full text, mbox, link).


Message #5 received at submit@debbugs.gnu.org (full text, mbox, reply):

From: Evgeny Pisemsky <mail@pisemsky.site>
To: guix-patches@gnu.org
Subject: [PATCH] services: mosquitto: Add test suite.
Date: Thu, 26 Jun 2025 15:06:14 +0300
* gnu/tests/messaging.scm (%test-mosquitto): New variable.

Change-Id: Ia84291576b9417ce678df3e0ed18caa6ce27b759
---
 gnu/tests/messaging.scm | 79 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 78 insertions(+), 1 deletion(-)

diff --git a/gnu/tests/messaging.scm b/gnu/tests/messaging.scm
index 8df67433a7..43fbdee468 100644
--- a/gnu/tests/messaging.scm
+++ b/gnu/tests/messaging.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2017-2018, 2021-2022 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2025 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2025 Evgeny Pisemsky <mail@pisemsky.site>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -42,7 +43,8 @@ (define-module (gnu tests messaging)
             %test-bitlbee
             %test-ngircd
             %test-pounce
-            %test-quassel))
+            %test-quassel
+            %test-mosquitto))
 
 (define (run-xmpp-test name xmpp-service pid-file create-account)
   "Run a test of an OS running XMPP-SERVICE, which writes its PID to PID-FILE."
@@ -592,3 +594,78 @@ (define %test-quassel
    (name "quassel")
    (description "Connect to a quassel IRC server.")
    (value (run-quassel-test))))
+
+
+;;;
+;;; Mosquitto.
+;;;
+
+(define (run-mosquitto-test)
+  (define os
+    (marionette-operating-system
+     (simple-operating-system (service dhcpcd-service-type)
+                              (service mosquitto-service-type))
+     #:imported-modules (source-module-closure
+                         '((gnu services herd)))))
+
+  (define vm
+    (virtual-machine
+     (operating-system os)))
+
+  (define test
+    (with-imported-modules '((gnu build marionette))
+      #~(begin
+          (use-modules (srfi srfi-64)
+                       (gnu build marionette))
+
+          (define marionette
+            (make-marionette (list #$vm)))
+
+          (test-runner-current (system-test-runner #$output))
+          (test-begin "mosquitto")
+
+          (test-assert "service runs"
+            (marionette-eval
+             '(begin
+                (use-modules (gnu services herd))
+                (wait-for-service 'mosquitto))
+             marionette))
+
+          (test-assert "service listens on TCP port 1883"
+            (wait-for-tcp-port 1883 marionette))
+
+          (test-equal "service receives a message"
+            0
+            (marionette-eval
+             '(system* #$(file-append mosquitto "/bin/mosquitto_pub")
+                       "-t" "test-topic"
+                       "-m" "Hello, mosquitto!"
+                       "-r")
+             marionette))
+
+          (test-equal "service returns a message"
+            "Hello, mosquitto!"
+            (marionette-eval
+             '(begin
+                (use-modules (ice-9 popen)
+                             (ice-9 rdelim))
+                (let* ((port (open-pipe* OPEN_READ
+                                         #$(file-append
+                                            mosquitto
+                                            "/bin/mosquitto_sub")
+                                         "-t" "test-topic"
+                                         "-C" "1"))
+                       (msg (read-line port)))
+                  (close-pipe port)
+                  msg))
+             marionette))
+
+          (test-end))))
+
+  (gexp->derivation "mosquitto-test" test))
+
+(define %test-mosquitto
+  (system-test
+   (name "mosquitto")
+   (description "Test a running Mosquitto MQTT broker.")
+   (value (run-mosquitto-test))))

base-commit: f126116b7af714a8ec1fc2307668199ec118f0bd
-- 
2.50.0





bug closed, send any further explanations to 78906@debbugs.gnu.org and Evgeny Pisemsky <mail@pisemsky.site> Request was from Evgeny Pisemsky <mail@pisemsky.site> to control@debbugs.gnu.org. (Sun, 27 Jul 2025 16:03:02 GMT) (full text, mbox, link).


bug archived. Request was from Debbugs Internal Request <help-debbugs@gnu.org> to internal_control@debbugs.gnu.org. (Mon, 25 Aug 2025 11:24:06 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Tue Sep 9 03:37:33 2025; Machine Name: wallace-server

GNU bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.