diff options
| author | Timotej Lazar <timotej.lazar@araneo.si> | 2022-07-15 07:56:06 +0200 |
|---|---|---|
| committer | Christopher Baines <mail@cbaines.net> | 2022-07-15 09:38:42 +0100 |
| commit | 6a2a8ca1f5560c37cdf20cbbac972db64a9dbac9 (patch) | |
| tree | 68c86db44b73e9d7ab36705e7f0190c06ad7e3d7 /gnu/tests | |
| parent | 9238ba58748d99970674e098c9b1b0ed8ca66c14 (diff) | |
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 <mail@cbaines.net>
Diffstat (limited to 'gnu/tests')
| -rw-r--r-- | gnu/tests/guix.scm | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/gnu/tests/guix.scm b/gnu/tests/guix.scm index a4c3e35e5d4..ad0980a10ca 100644 --- a/gnu/tests/guix.scm +++ b/gnu/tests/guix.scm | |||
| @@ -222,14 +222,23 @@ host all all ::1/128 trust")))))) | |||
| 222 | ((pid) (number? pid)))))) | 222 | ((pid) (number? pid)))))) |
| 223 | marionette)) | 223 | marionette)) |
| 224 | 224 | ||
| 225 | ;; The service starts immediately but replies with status 500 until | ||
| 226 | ;; initialization is complete, so keep trying for a while. | ||
| 227 | (define (try-http-get attempts) | ||
| 228 | (let ((status | ||
| 229 | (let-values (((response text) | ||
| 230 | (http-get #$(simple-format | ||
| 231 | #f "http://localhost:~A/healthcheck" | ||
| 232 | forwarded-port)))) | ||
| 233 | (response-code response)))) | ||
| 234 | (if (or (= status 200) (<= attempts 1)) | ||
| 235 | status | ||
| 236 | (begin (sleep 5) | ||
| 237 | (try-http-get (- attempts 1)))))) | ||
| 238 | |||
| 225 | (test-equal "http-get" | 239 | (test-equal "http-get" |
| 226 | 200 | 240 | 200 |
| 227 | (let-values | 241 | (try-http-get 12)) |
| 228 | (((response text) | ||
| 229 | (http-get #$(simple-format | ||
| 230 | #f "http://localhost:~A/healthcheck" forwarded-port) | ||
| 231 | #:decode-body? #t))) | ||
| 232 | (response-code response))) | ||
| 233 | 242 | ||
| 234 | (test-end)))) | 243 | (test-end)))) |
| 235 | 244 | ||
