From 6a2a8ca1f5560c37cdf20cbbac972db64a9dbac9 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 15 Jul 2022 07:56:06 +0200 Subject: gnu: tests: Fix guix-data-service test. Since revision 32, guix-data-service starts immediately but returns an HTTP error code until initialization is complete. Adjust the test accordingly, and remove the increased startup time limit. * gnu/services/guix.scm (guix-data-service): Use default #:pid-file-timeout. * gnu/tests/guix.scm (guix-data-service): Retry the http-get test several times to give the service time to initialize. Signed-off-by: Christopher Baines --- gnu/tests/guix.scm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'gnu/tests') diff --git a/gnu/tests/guix.scm b/gnu/tests/guix.scm index a4c3e35e5d..ad0980a10c 100644 --- a/gnu/tests/guix.scm +++ b/gnu/tests/guix.scm @@ -222,14 +222,23 @@ host all all ::1/128 trust")))))) ((pid) (number? pid)))))) marionette)) + ;; The service starts immediately but replies with status 500 until + ;; initialization is complete, so keep trying for a while. + (define (try-http-get attempts) + (let ((status + (let-values (((response text) + (http-get #$(simple-format + #f "http://localhost:~A/healthcheck" + forwarded-port)))) + (response-code response)))) + (if (or (= status 200) (<= attempts 1)) + status + (begin (sleep 5) + (try-http-get (- attempts 1)))))) + (test-equal "http-get" 200 - (let-values - (((response text) - (http-get #$(simple-format - #f "http://localhost:~A/healthcheck" forwarded-port) - #:decode-body? #t))) - (response-code response))) + (try-http-get 12)) (test-end)))) -- cgit v1.2.3