aboutsummaryrefslogtreecommitdiff
path: root/gnu/tests
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/tests')
-rw-r--r--gnu/tests/base.scm69
-rw-r--r--gnu/tests/install.scm1
-rw-r--r--gnu/tests/monitoring.scm71
3 files changed, 114 insertions, 27 deletions
diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
index db904d7f10..fd758f6586 100644
--- a/gnu/tests/base.scm
+++ b/gnu/tests/base.scm
@@ -74,7 +74,8 @@
#:key
initialization
root-password
- desktop?)
+ desktop?
+ extra-tests)
"Return a derivation called NAME that tests basic features of the OS started
using COMMAND, a gexp that evaluates to a list of strings. Compare some
properties of running system to what's declared in OS, an <operating-system>.
@@ -85,7 +86,12 @@ inserted before the first test. This is used to introduce an extra
initialization step, such as entering a LUKS passphrase.
When ROOT-PASSWORD is true, enter it as the root password when logging in.
-Otherwise assume that there is no password for root."
+Otherwise assume that there is no password for root.
+
+When EXTRA-TESTS is true, it must be a one-argument procedure that is
+passed a gexp denoting the marionette. It must then return a gexp that is
+inserted after the last test. This is meant as a way of extending the basic
+tests that are defined within this procedure."
(define special-files
(service-value
(fold-services (operating-system-services os)
@@ -170,29 +176,6 @@ grep --version
info --version")
marionette)))
- (test-assert "/etc/profile.d is sourced"
- (zero? (marionette-eval '(system "
-. /etc/profile
-set -e -x
-test -f /etc/profile.d/test_profile_d.sh
-test \"$PROFILE_D_OK\" = yes")
- marionette)))
-
- (test-assert "/etc/bashrc.d is sourced"
- (zero? (marionette-eval
- '(system* "bash"
- ;; Ensure Bash runs interactively.
- "--init-file"
- #$(plain-file "test_bashrc_d.sh"
- "\
-. /etc/bashrc
-set -e -x
-test -f /etc/bashrc.d/bash_completion.sh
-test -f /etc/bashrc.d/aliases.sh
-test -f /etc/bashrc.d/test_bashrc_d.sh
-test \"$BASHRC_D_OK\" = yes"))
- marionette)))
-
(test-equal "special files"
'#$special-files
(marionette-eval
@@ -582,6 +565,9 @@ test \"$BASHRC_D_OK\" = yes"))
(compose string-trim-right get-string-all)))
marionette))
+ #$(and extra-tests
+ (extra-tests #~marionette))
+
(test-end))))
(gexp->derivation name test))
@@ -626,7 +612,38 @@ functionality tests, using the given KERNEL.")
;; 'system-qemu-image/shared-store-script'.
(run-basic-test (virtualized-operating-system os '())
#~(list #$vm)
- name)))))
+ name
+ ;; Add extra tests for the etc-profile-d-service-type
+ ;; and etc-bashrc-d-service-type services defined above.
+ ;; Those tests cannot directly be part of the
+ ;; run-basic-test procedure that is used in many other
+ ;; locations.
+ #:extra-tests
+ (lambda (marionette)
+ #~(begin
+ (test-assert "/etc/profile.d is sourced"
+ (zero?
+ (marionette-eval '(system "
+. /etc/profile
+set -e -x
+test -f /etc/profile.d/test_profile_d.sh
+test \"$PROFILE_D_OK\" = yes")
+ #$marionette)))
+
+ (test-assert "/etc/bashrc.d is sourced"
+ (zero?
+ (marionette-eval
+ '(system* "bash"
+ "-i" ;run interactively
+ #$(plain-file "test_bashrc_d.sh"
+ "\
+. /etc/bashrc
+set -e -x
+test -f /etc/bashrc.d/bash_completion.sh
+test -f /etc/bashrc.d/aliases.sh
+test -f /etc/bashrc.d/test_bashrc_d.sh
+test \"$BASHRC_D_OK\" = yes"))
+ #$marionette))))))))))
(define %test-basic-os
(test-basic-os))
diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm
index 8293296339..7ef0cae73b 100644
--- a/gnu/tests/install.scm
+++ b/gnu/tests/install.scm
@@ -2001,7 +2001,6 @@ build (current-guix) and then store a couple of full system images.")
(list (service gnome-desktop-service-type)
(service xfce-desktop-service-type)
(service mate-desktop-service-type)
- (service enlightenment-desktop-service-type)
(set-xorg-configuration
(xorg-configuration
(keyboard-layout keyboard-layout)))
diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm
index 85362ef733..49dce06c79 100644
--- a/gnu/tests/monitoring.scm
+++ b/gnu/tests/monitoring.scm
@@ -33,6 +33,7 @@
#:use-module (guix gexp)
#:export (%test-prometheus
%test-prometheus-node-exporter
+ %test-alertmanager
%test-zabbix))
@@ -175,6 +176,76 @@
;;;
+;;; Alertmanager
+;;;
+
+(define* (run-alertmanager-test name test-os)
+ "Run tests in %TEST-OS, which has Alertmanager running."
+ (define os
+ (marionette-operating-system
+ test-os
+ #:imported-modules '((gnu services herd))))
+
+ (define vm
+ (virtual-machine
+ (operating-system os)
+ (port-forwardings '((8080 . 9093)))))
+
+ (define test
+ (with-imported-modules '((gnu build marionette))
+ #~(begin
+ (use-modules (srfi srfi-11)
+ (srfi srfi-64)
+ (gnu build marionette)
+ (web client)
+ (web response))
+
+ (define marionette
+ (make-marionette (list #$vm)))
+
+ (mkdir #$output)
+ (chdir #$output)
+
+ (test-begin #$name)
+
+ (test-assert "alertmanager running"
+ (marionette-eval
+ '(begin
+ (use-modules (gnu services herd))
+ (match (start-service 'alertmanager)
+ (#f #f)
+ (('service response-parts ...)
+ (match (assq-ref response-parts 'running)
+ ((pid) (number? pid))))))
+ marionette))
+
+ (test-equal "alertmanager healthy"
+ 200
+ (begin
+ (wait-for-tcp-port 9090 marionette)
+ (let-values (((response text)
+ (http-get "http://localhost:8080/-/healthy")))
+ (response-code response))))
+
+ (test-end)
+ (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+ (gexp->derivation (string-append name "-test") test))
+
+(define %alertmanager-test-os
+ (simple-operating-system
+ (service dhcp-client-service-type)
+ (service alertmanager-service-type)))
+
+(define %test-alertmanager
+ (system-test
+ (name "alertmanager")
+ (description "Connect to a running Alertmanager service.")
+ (value (run-alertmanager-test name
+ %alertmanager-test-os))))
+
+
+;;;
;;; Zabbix
;;;