diff options
author | Thomas Ieong <th.ieong@free.fr> | 2023-02-23 21:16:14 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2023-12-14 23:12:24 +0100 |
commit | b681e339fa37f2a26763458ee56b31af1d6a7ec5 (patch) | |
tree | 731cd4646426e2b33ee6a2ea866f77a465b16759 /gnu/tests/mail.scm | |
parent | 7ce0c79e7abd1822060760d4f1cb0bd6c00b5d19 (diff) | |
download | guix-b681e339fa37f2a26763458ee56b31af1d6a7ec5.tar.gz |
services: Add rspamd-service-type.
* gnu/services/mail.scm (rspamd-service-type): New variable. * gnu/tests/mail.scm (%test-rspamd): New variable. * doc/guix.texi: Document it. Co-authored-by: Saku Laesvuori <saku@laesvuori.fi> Change-Id: I7196643f087ffe9fc91aab231b69d5ed8dc9d198 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/tests/mail.scm')
-rw-r--r-- | gnu/tests/mail.scm | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/gnu/tests/mail.scm b/gnu/tests/mail.scm index dcb8f08ea8..176e7c1d07 100644 --- a/gnu/tests/mail.scm +++ b/gnu/tests/mail.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org> ;;; Copyright © 2019 Christopher Baines <mail@cbaines.net> ;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr> +;;; Copyright © 2023 Thomas Ieong <th.ieong@free.fr> ;;; ;;; This file is part of GNU Guix. ;;; @@ -40,7 +41,8 @@ #:export (%test-opensmtpd %test-exim %test-dovecot - %test-getmail)) + %test-getmail + %test-rspamd)) (define %opensmtpd-os (simple-operating-system @@ -579,3 +581,66 @@ Subject: Hello Nice to meet you!") (name "getmail") (description "Connect to a running Getmail server.") (value (run-getmail-test)))) + +(define %rspamd-os + (simple-operating-system + (service rspamd-service-type))) + +(define (run-rspamd-test) + "Return a test of an OS running Rspamd service." + + (define vm + (virtual-machine + (marionette-operating-system + %rspamd-os + #:imported-modules '((gnu services herd))))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-64) + (gnu build marionette)) + + (define marionette + (make-marionette '(#$vm))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "rspamd") + + (test-assert "service is running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'rspamd)) + marionette)) + + (test-assert "rspamd socket ready" + (wait-for-unix-socket + "/var/lib/rspamd/rspamd.sock" + marionette)) + + (test-assert "rspamd log file" + (wait-for-file "/var/log/rspamd/rspamd.log" marionette)) + + ;; Check that we can access the web ui + + (test-equal "http-get" + 200 + (marionette-eval + '(begin + (use-modules (web client) + (web response)) + ;; HEAD returns 500 internal server error, so use GET even though + ;; only the headers are relevant + (response-code (http-get "http://localhost:11334"))) + marionette)) + + (test-end)))) + + (gexp->derivation "rspamd-test" test)) + +(define %test-rspamd + (system-test + (name "rspamd") + (description "Basic rspamd service test.") + (value (run-rspamd-test)))) |