From patchwork Thu Jun 26 12:06:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Evgeny Pisemsky X-Patchwork-Id: 43226 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5B5D927BC49; Thu, 26 Jun 2025 13:07:29 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C603527BC4A for ; Thu, 26 Jun 2025 13:07:28 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uUlNi-0005b5-9h; Thu, 26 Jun 2025 08:07:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uUlNf-0005aM-49 for guix-patches@gnu.org; Thu, 26 Jun 2025 08:07:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uUlNe-0002mY-Mv for guix-patches@gnu.org; Thu, 26 Jun 2025 08:07:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=0TY3hNRoE3XU/12htxs1aJ8dcgYx3Egvt7GU5r3qVSQ=; b=tLNIWNeaQbYHPLT3RK2cW9QyLvxM2v6aIzkZJo4Fs0zPzKIeCMkONGLP/RM+HXxSH7eUhR117eqDA09sG2qNccPJ9NqLiQtGtgtF+ksy/oQl0QxZkAldMSn84lbhTvnK7V9pSx4yYGEGcipEGWWSqJc8cLAsQaHNPtQ4rqF7tG1CUW4stAvxy3BlW0zVmJOkluy69hFmgCUJPU2yY2c6ko+7UF7n9CBLHZiLpW7ccsoXvlIwO78wfB6JocoMbgYI8PSbPC5EhAsuS75InqV9q3b3hHTecpAK5Zb5gm0XOvTtP/1jAT90+AG21q53puY8o4O3bOeotzDKGGdwNO8itQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uUlNe-0000cE-5y for guix-patches@gnu.org; Thu, 26 Jun 2025 08:07:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78906] [PATCH] services: mosquitto: Add test suite. Resent-From: Evgeny Pisemsky Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 26 Jun 2025 12:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 78906 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78906@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17509396202357 (code B ref -1); Thu, 26 Jun 2025 12:07:01 +0000 Received: (at submit) by debbugs.gnu.org; 26 Jun 2025 12:07:00 +0000 Received: from localhost ([127.0.0.1]:48848 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uUlNc-0000bw-9n for submit@debbugs.gnu.org; Thu, 26 Jun 2025 08:07:00 -0400 Received: from lists.gnu.org ([2001:470:142::17]:36344) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uUlNX-0000bf-Vq for submit@debbugs.gnu.org; Thu, 26 Jun 2025 08:06:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uUlNS-0005ZG-AH for guix-patches@gnu.org; Thu, 26 Jun 2025 08:06:50 -0400 Received: from pisemsky.site ([103.54.19.55]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uUlNO-0002kg-Se for guix-patches@gnu.org; Thu, 26 Jun 2025 08:06:49 -0400 Received: from laptop ( [212.233.85.28]) by pisemsky.site (OpenSMTPD) with ESMTPSA id a6e43af2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Thu, 26 Jun 2025 12:06:27 +0000 (UTC) From: Evgeny Pisemsky Date: Thu, 26 Jun 2025 15:06:14 +0300 Message-ID: X-Mailer: git-send-email 2.50.0 MIME-Version: 1.0 Received-SPF: pass client-ip=103.54.19.55; envelope-from=mail@pisemsky.site; helo=pisemsky.site X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/tests/messaging.scm (%test-mosquitto): New variable. Change-Id: Ia84291576b9417ce678df3e0ed18caa6ce27b759 --- gnu/tests/messaging.scm | 79 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) base-commit: f126116b7af714a8ec1fc2307668199ec118f0bd 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 ;;; Copyright © 2018 Efraim Flashner ;;; Copyright © 2025 Maxim Cournoyer +;;; Copyright © 2025 Evgeny Pisemsky ;;; ;;; 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))))