summaryrefslogtreecommitdiff
path: root/gnu/tests
diff options
context:
space:
mode:
authorGiacomo Leidi <therewasa@fishinthecalculator.me>2026-01-10 17:23:44 +0100
committerGiacomo Leidi <therewasa@fishinthecalculator.me>2026-03-09 23:17:24 +0100
commit520785e315eddbe47199ac557e88e60eca3ae97c (patch)
tree5af120ab54fdc523729e13cde06d13f197358710 /gnu/tests
parent1a109f379835315c0a4ea23b1ff52d0e77d7fede (diff)
gnu: Add soju-service-type.
* gnu/services/messaging.scm (%default-soju-shepherd-requirement): New variable. (soju-ssl-certificate): New configuration record. (soju-database): New configuration record. (soju-configuration): New configuration record. (serialize-soju-configuration,soju-activation,soju-accounts, soju-shepherd-services): New procedures. (soju-service-type): New service. (serialize-ngircd-configuration): Reformat. (pounce-configuration): Reformat. * doc/guix.texi: Document the new soju service. * gnu/tests/messaging.scm: Test the new soju service. Change-Id: I6223ecac1aaaab76bd75461851ffe4cec0678118
Diffstat (limited to 'gnu/tests')
-rw-r--r--gnu/tests/messaging.scm112
1 files changed, 111 insertions, 1 deletions
diff --git a/gnu/tests/messaging.scm b/gnu/tests/messaging.scm
index 83ccca88918..559dc81a747 100644
--- a/gnu/tests/messaging.scm
+++ b/gnu/tests/messaging.scm
@@ -4,6 +4,7 @@
4;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il> 4;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
5;;; Copyright © 2025 Maxim Cournoyer <maxim@guixotic.coop> 5;;; Copyright © 2025 Maxim Cournoyer <maxim@guixotic.coop>
6;;; Copyright © 2025 Evgeny Pisemsky <mail@pisemsky.site> 6;;; Copyright © 2025 Evgeny Pisemsky <mail@pisemsky.site>
7;;; Copyright © 2026 Giacomo Leidi <therewasa@fishinthecalculator.me>
7;;; 8;;;
8;;; This file is part of GNU Guix. 9;;; This file is part of GNU Guix.
9;;; 10;;;
@@ -44,7 +45,8 @@
44 %test-ngircd 45 %test-ngircd
45 %test-pounce 46 %test-pounce
46 %test-quassel 47 %test-quassel
47 %test-mosquitto)) 48 %test-mosquitto
49 %test-soju))
48 50
49(define (run-xmpp-test name xmpp-service pid-file create-account) 51(define (run-xmpp-test name xmpp-service pid-file create-account)
50 "Run a test of an OS running XMPP-SERVICE, which writes its PID to PID-FILE." 52 "Run a test of an OS running XMPP-SERVICE, which writes its PID to PID-FILE."
@@ -669,3 +671,111 @@ OPENSSL:localhost:7000,verify=0 &")
669 (name "mosquitto") 671 (name "mosquitto")
670 (description "Test a running Mosquitto MQTT broker.") 672 (description "Test a running Mosquitto MQTT broker.")
671 (value (run-mosquitto-test)))) 673 (value (run-mosquitto-test))))
674
675
676;;;
677;;; soju.
678;;;
679
680(define %soju-os
681 (operating-system
682 (inherit %simple-os)
683 (packages (cons* soju %base-packages))
684 (services
685 (cons*
686 (service dhcpcd-service-type)
687 (service soju-service-type
688 (soju-configuration
689 (debug? #t)
690 (listen '("irc://localhost" "unix+admin:///var/lib/soju/soju.sock"))
691 (title "soju IRC bouncer")
692 (extra-content
693 (list (plain-file "soju.conf" "hostname test.example.org")))))
694 %base-services))))
695
696(define (run-soju-test)
697 (define vm
698 (virtual-machine
699 (operating-system
700 (marionette-operating-system
701 %soju-os
702 #:imported-modules (source-module-closure
703 '((gnu services herd)))))))
704
705 (define test
706 (with-imported-modules '((gnu build marionette))
707 #~(begin
708 (use-modules (srfi srfi-64)
709 (gnu build marionette))
710
711 (define marionette
712 (make-marionette (list #$vm)))
713
714 (test-runner-current (system-test-runner #$output))
715 (test-begin "soju")
716
717 (marionette-eval
718 '(begin
719 (use-modules (gnu services herd))
720 (wait-for-service 'user-processes))
721 marionette)
722
723 (test-equal "soju configuration file is well formed"
724 "listen irc://localhost
725listen unix+admin:///var/lib/soju/soju.sock
726title \"soju IRC bouncer\"
727db sqlite3 /var/lib/soju/soju.db
728hostname test.example.org
729"
730 (marionette-eval
731 '(begin
732 (use-modules (ice-9 popen)
733 (ice-9 rdelim)
734 (ice-9 textual-ports))
735 (let* ((port (open-input-pipe "herd configuration soju"))
736 (soju.conf (string-trim-both (read-line port))))
737 (close-pipe port)
738 (call-with-input-file soju.conf get-string-all)))
739 marionette))
740
741 (test-assert "soju service runs"
742 (marionette-eval
743 '(begin
744 (use-modules (gnu services herd))
745 (wait-for-service 'soju))
746 marionette))
747
748 (test-assert "soju listens on TCP port 6667"
749 (wait-for-tcp-port 6667 marionette))
750
751 (test-equal "sojuctl can create a user"
752 "fishinthecalculator (admin): 0 networks"
753 (marionette-eval
754 '(begin
755 (use-modules (ice-9 popen)
756 (ice-9 rdelim))
757 (system (string-join
758 '("sojuctl" "-config" "$(herd configuration soju)"
759 "user" "create" "-admin"
760 "-username" "fishinthecalculator"
761 "-password" "1234")
762 " "))
763 (let* ((port (open-input-pipe (string-join
764 '("sojuctl" "-config"
765 "$(herd configuration soju)"
766 "user" "status")
767 " ")))
768 (msg (read-line port)))
769 (close-pipe port)
770 msg))
771 marionette))
772
773 (test-end))))
774
775 (gexp->derivation "soju-test" test))
776
777(define %test-soju
778 (system-test
779 (name "soju")
780 (description "Run a soju IRC bouncer.")
781 (value (run-soju-test))))