aboutsummaryrefslogtreecommitdiff
path: root/graph.js
diff options
context:
space:
mode:
Diffstat (limited to 'graph.js')
0 files changed, 0 insertions, 0 deletions
s;s available). (let ((guest-port 9)) (virtual-machine (operating-system os) (port-forwardings `((,forwarded-port . ,guest-port)))))) ;; The test duration is inconsistent, at times a test may complete under ;; 2 minutes and at times it may take up to 5 minutes. (define test-timeout (* 60 5)) (define test (with-imported-modules '((gnu build marionette)) #~(begin (use-modules (gnu build marionette) (srfi srfi-64)) (let ((marionette (make-marionette (list #$vm))) (pid-file #$(vnstat-configuration-pid-file vnstat-config))) (test-runner-current (system-test-runner #$output)) (test-begin "vnstat") (test-assert "service is running" (marionette-eval '(begin (use-modules (gnu services herd)) (start-service 'vnstatd)) marionette)) (test-assert "vnstatd ready" (wait-for-file pid-file marionette)) ;; Pump garbage into the 'discard' inetd service within the vm. (let* ((socat #$(file-append socat "/bin/socat")) (dest-addr #$(format #f "TCP4:localhost:~d" forwarded-port)) (args `("socat" "-u" "/dev/zero" ,dest-addr)) ;; XXX: Guile bug (22/03/2023, Guile 3.0.9) ;; Fixed in main: <https://issues.guix.gnu.org/61073> ;; FIXME: re-add #:output (%make-void-port "w") below on ;; next Guile release. (garbage-pump-pid (spawn socat args))) (test-group-with-cleanup "Logging" ;; To aid debugging, this test returns #t on success ;; and either #f or 'timed-out otherwise. (test-eq "vnstatd is logging" #t (marionette-eval '(begin (use-modules (ice-9 popen) (ice-9 match) (sxml simple) (sxml xpath)) (define selector (let ((xpath '(vnstat interface traffic total))) (compose (node-pos 1) (sxpath xpath)))) (let loop ((i 0)) (let* ((vnstat #$(file-append vnstat "/bin/vnstat")) (query-cmd (format #f "~a --xml" vnstat)) (proc (compose selector xml->sxml)) (result (call-with-port (open-input-pipe query-cmd) proc))) (match result ;; Counter still warming up. ((('total ('rx "0") ('tx "0"))) (sleep 1) (if (< i #$test-timeout) (loop (+ i 1)) 'timed-out)) ;; Count of bytes on iface was non-zero. ((('total ('rx rx) ('tx tx))) #t) ;; Unknown data encountered, perhaps the ;; data format changed? (_ #f))))) marionette)) ;; Cleanup: shutdown garbage pump. (kill garbage-pump-pid SIGTERM))) (test-end))))) (gexp->derivation "vnstat-test" test)) (define %test-vnstat (system-test (name "vnstat") (description "Basic tests for vnstat service.") (value (run-vnstat-test))))