diff options
Diffstat (limited to 'gnu/tests')
-rw-r--r-- | gnu/tests/monitoring.scm | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm index 4e3966fed1..e8055f4dd4 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)) @@ -178,6 +179,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 ;;; |