From b681e339fa37f2a26763458ee56b31af1d6a7ec5 Mon Sep 17 00:00:00 2001
From: Thomas Ieong
Date: Thu, 23 Feb 2023 21:16:14 +0100
Subject: services: Add rspamd-service-type.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 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
Change-Id: I7196643f087ffe9fc91aab231b69d5ed8dc9d198
Signed-off-by: Ludovic Courtès
---
gnu/tests/mail.scm | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 66 insertions(+), 1 deletion(-)
(limited to 'gnu/tests')
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
;;; Copyright © 2019 Christopher Baines
;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice
+;;; Copyright © 2023 Thomas Ieong
;;;
;;; 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))))
--
cgit v1.2.3