diff options
| author | wrobell <wrobell@riseup.net> | 2026-06-16 20:17:41 +0100 |
|---|---|---|
| committer | Nguyễn Gia Phong <cnx@loang.net> | 2026-07-26 15:23:19 +0900 |
| commit | ce8df300216b308720903e6da9e01d246143b47f (patch) | |
| tree | 6184790b895796fd3621bf753daddc4471449ee3 /gnu/tests | |
| parent | 47b41dced835020f803dc56f52e949c94d2f7061 (diff) | |
services: Add epmd-service-type.
Add Erlang Port Mapper Daemon (epmd) service.
Run the service on localhost by default.
* gnu/services/high-availability.scm (<epmd-configuration>): New record.
(epmd-service-type): New variable.
* gnu/tests/high-availability.scm (run-epmd-test): New procedure.
(%epmd-os, %tests-epmd): New variables.
* doc/gnu.texi (High Availability Services): Document it.
Merges: https://codeberg.org/guix/guix/pulls/9607
References: https://www.rabbitmq.com/blog/2024/12/18/epmd-public-exposure
References: https://erlef.org/blog/eef/epmd-public-exposure
Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
Diffstat (limited to 'gnu/tests')
| -rw-r--r-- | gnu/tests/high-availability.scm | 81 |
1 files changed, 80 insertions, 1 deletions
diff --git a/gnu/tests/high-availability.scm b/gnu/tests/high-availability.scm index 6eb13d1a068..faa657bfc3c 100644 --- a/gnu/tests/high-availability.scm +++ b/gnu/tests/high-availability.scm | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | (define-module (gnu tests high-availability) | 20 | (define-module (gnu tests high-availability) |
| 21 | #:use-module (gnu tests) | 21 | #:use-module (gnu tests) |
| 22 | #:use-module (gnu packages erlang) | ||
| 22 | #:use-module (gnu packages high-availability) | 23 | #:use-module (gnu packages high-availability) |
| 23 | #:use-module (gnu system) | 24 | #:use-module (gnu system) |
| 24 | #:use-module (gnu system file-systems) | 25 | #:use-module (gnu system file-systems) |
| @@ -29,7 +30,85 @@ | |||
| 29 | #:use-module (gnu services networking) | 30 | #:use-module (gnu services networking) |
| 30 | #:use-module (guix gexp) | 31 | #:use-module (guix gexp) |
| 31 | #:use-module (guix store) | 32 | #:use-module (guix store) |
| 32 | #:export (%test-rabbitmq)) | 33 | #:export (%test-epmd |
| 34 | %test-rabbitmq)) | ||
| 35 | |||
| 36 | ;;; | ||
| 37 | ;;; Erlang Port Mapper Daemon (epmd) service. | ||
| 38 | ;;; | ||
| 39 | (define %epmd-os | ||
| 40 | (simple-operating-system | ||
| 41 | (service epmd-service-type | ||
| 42 | (epmd-configuration (port 14369))))) | ||
| 43 | |||
| 44 | (define* (run-epmd-test #:key (epmd-port 14369)) | ||
| 45 | "Run tests in %EPMD-OS, forwarding PORT." | ||
| 46 | (define os | ||
| 47 | (marionette-operating-system | ||
| 48 | %epmd-os | ||
| 49 | #:imported-modules '((gnu services herd) | ||
| 50 | (guix combinators)))) | ||
| 51 | |||
| 52 | (define forwarded-port 14369) | ||
| 53 | |||
| 54 | (define vm | ||
| 55 | (virtual-machine | ||
| 56 | (operating-system os) | ||
| 57 | (memory-size 512) | ||
| 58 | (port-forwardings `((,epmd-port . ,forwarded-port))))) | ||
| 59 | |||
| 60 | (define test | ||
| 61 | (with-imported-modules '((gnu build marionette)) | ||
| 62 | #~(begin | ||
| 63 | (use-modules (srfi srfi-64) | ||
| 64 | (gnu build marionette) | ||
| 65 | (ice-9 rdelim)) | ||
| 66 | |||
| 67 | (define marionette | ||
| 68 | (make-marionette (list #$vm))) | ||
| 69 | |||
| 70 | (mkdir #$output) | ||
| 71 | (chdir #$output) | ||
| 72 | |||
| 73 | (test-runner-current (system-test-runner #$output)) | ||
| 74 | (test-begin "epmd") | ||
| 75 | |||
| 76 | ;; Wait for epmd to be up and running. | ||
| 77 | (test-assert "service running" | ||
| 78 | (marionette-eval | ||
| 79 | '(begin | ||
| 80 | (use-modules (gnu services herd)) | ||
| 81 | (match (start-service 'epmd) | ||
| 82 | (#f #f) | ||
| 83 | (('service response-parts ...) | ||
| 84 | (match (assq-ref response-parts 'running) | ||
| 85 | ((#t) #t) | ||
| 86 | ((pid) pid))))) | ||
| 87 | marionette)) | ||
| 88 | |||
| 89 | (test-assert "epmd port ready" | ||
| 90 | (wait-for-tcp-port #$forwarded-port marionette)) | ||
| 91 | |||
| 92 | (test-assert "epmd connection is successful" | ||
| 93 | (marionette-eval | ||
| 94 | '(begin | ||
| 95 | (use-modules (guix build utils)) | ||
| 96 | |||
| 97 | (current-output-port (open-file "/dev/console" "w0")) | ||
| 98 | (invoke #$(file-append erlang "/bin/epmd") | ||
| 99 | "-port" | ||
| 100 | "14369" | ||
| 101 | "-names")) | ||
| 102 | marionette)) | ||
| 103 | (test-end)))) | ||
| 104 | |||
| 105 | (gexp->derivation "epmd-test" test)) | ||
| 106 | |||
| 107 | (define %test-epmd | ||
| 108 | (system-test | ||
| 109 | (name "epmd") | ||
| 110 | (description "Connect to a running epmd service.") | ||
| 111 | (value (run-epmd-test)))) | ||
| 33 | 112 | ||
| 34 | (define %rabbitmq-config-file | 113 | (define %rabbitmq-config-file |
| 35 | (plain-file "rabbitmq.conf" " | 114 | (plain-file "rabbitmq.conf" " |
