unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test.
@ 2022-07-14 19:21 Timotej Lazar
  2022-07-14 21:26 ` Munyoki Kilyungi
  2022-07-15  5:56 ` [bug#56563] [PATCH v2] " Timotej Lazar
  0 siblings, 2 replies; 6+ messages in thread
From: Timotej Lazar @ 2022-07-14 19:21 UTC (permalink / raw)
  To: 56563; +Cc: Timotej Lazar

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.
---
 gnu/services/guix.scm |  2 --
 gnu/tests/guix.scm    | 19 +++++++++++++------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/gnu/services/guix.scm b/gnu/services/guix.scm
index 338e027245..dac1e5841a 100644
--- a/gnu/services/guix.scm
+++ b/gnu/services/guix.scm
@@ -652,8 +652,6 @@ (define (guix-data-service-shepherd-services config)
                 #:user #$user
                 #:group #$group
                 #:pid-file "/var/run/guix-data-service/pid"
-                ;; Allow time for migrations to run
-                #:pid-file-timeout 120
                 #:environment-variables
                 `(,(string-append
                     "GUIX_LOCPATH=" #$glibc-utf8-locales "/lib/locale")
diff --git a/gnu/tests/guix.scm b/gnu/tests/guix.scm
index a4c3e35e5d..ce62f74b60 100644
--- a/gnu/tests/guix.scm
+++ b/gnu/tests/guix.scm
@@ -222,14 +222,21 @@ (define marionette
                      ((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 10) (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 10))
 
           (test-end))))
 
-- 
2.36.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test.
  2022-07-14 19:21 [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test Timotej Lazar
@ 2022-07-14 21:26 ` Munyoki Kilyungi
  2022-07-15  5:52   ` Timotej Lazar
  2022-07-15  5:56 ` [bug#56563] [PATCH v2] " Timotej Lazar
  1 sibling, 1 reply; 6+ messages in thread
From: Munyoki Kilyungi @ 2022-07-14 21:26 UTC (permalink / raw)
  To: Timotej Lazar; +Cc: 56563

[-- Attachment #1: Type: text/plain, Size: 1542 bytes --]

Timotej Lazar <timotej.lazar@araneo.si> anaandika:

[...]
> +          ;; The service starts immediately but replies with status 500 until
> +          ;; initialization is complete, so keep trying for a while.
> +          (define* (try-http-get attempts)

Minor nitpick.  This function definition does not
take any optional or key-word arguments AFAICT, so
it should be a "define" instead :)

> +            (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 10) (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 10))
>  
>            (test-end))))


-- 
(Life is like a pencil that will surely run out,
    but will leave the beautiful writing of life.)
(D4F09EB110177E03C28E2FE1F5BBAE1E0392253F
    (hkp://keys.gnupg.net))

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 865 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test.
  2022-07-14 21:26 ` Munyoki Kilyungi
@ 2022-07-15  5:52   ` Timotej Lazar
  2022-07-15  8:35     ` Munyoki Kilyungi
  0 siblings, 1 reply; 6+ messages in thread
From: Timotej Lazar @ 2022-07-15  5:52 UTC (permalink / raw)
  To: Munyoki Kilyungi; +Cc: 56563

Munyoki Kilyungi <me@bonfacemunyoki.com> [2022-07-15 00:26:16+0300]:
> Timotej Lazar <timotej.lazar@araneo.si> anaandika:
>> +          (define* (try-http-get attempts)
>
> Minor nitpick.  This function definition does not
> take any optional or key-word arguments AFAICT, so
> it should be a "define" instead :)

It used to but then I changed my mind. :) Nice catch, I’ll send an
update. Thanks!




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#56563] [PATCH v2] gnu: tests: Fix guix-data-service test.
  2022-07-14 19:21 [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test Timotej Lazar
  2022-07-14 21:26 ` Munyoki Kilyungi
@ 2022-07-15  5:56 ` Timotej Lazar
  2022-07-15  9:06   ` bug#56563: " Christopher Baines
  1 sibling, 1 reply; 6+ messages in thread
From: Timotej Lazar @ 2022-07-15  5:56 UTC (permalink / raw)
  To: 56563; +Cc: Timotej Lazar

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.
---
 gnu/services/guix.scm |  2 --
 gnu/tests/guix.scm    | 19 +++++++++++++------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/gnu/services/guix.scm b/gnu/services/guix.scm
index 338e027245..dac1e5841a 100644
--- a/gnu/services/guix.scm
+++ b/gnu/services/guix.scm
@@ -652,8 +652,6 @@ (define (guix-data-service-shepherd-services config)
                 #:user #$user
                 #:group #$group
                 #:pid-file "/var/run/guix-data-service/pid"
-                ;; Allow time for migrations to run
-                #:pid-file-timeout 120
                 #:environment-variables
                 `(,(string-append
                     "GUIX_LOCPATH=" #$glibc-utf8-locales "/lib/locale")
diff --git a/gnu/tests/guix.scm b/gnu/tests/guix.scm
index a4c3e35e5d..02221f4364 100644
--- a/gnu/tests/guix.scm
+++ b/gnu/tests/guix.scm
@@ -222,14 +222,21 @@ (define marionette
                      ((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 10) (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 10))
 
           (test-end))))
 
-- 
2.36.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test.
  2022-07-15  5:52   ` Timotej Lazar
@ 2022-07-15  8:35     ` Munyoki Kilyungi
  0 siblings, 0 replies; 6+ messages in thread
From: Munyoki Kilyungi @ 2022-07-15  8:35 UTC (permalink / raw)
  To: Timotej Lazar; +Cc: 56563

[-- Attachment #1: Type: text/plain, Size: 673 bytes --]

Timotej Lazar <timotej.lazar@araneo.si> anaandika:

> Munyoki Kilyungi <me@bonfacemunyoki.com> [2022-07-15 00:26:16+0300]:
>> Timotej Lazar <timotej.lazar@araneo.si> anaandika:
>>> +          (define* (try-http-get attempts)
>>
>> Minor nitpick.  This function definition does not
>> take any optional or key-word arguments AFAICT, so
>> it should be a "define" instead :)
>
> It used to but then I changed my mind. :) Nice catch, I’ll send an
> update. Thanks!

Cool \m/\m/.

-- 
(Life is like a pencil that will surely run out,
    but will leave the beautiful writing of life.)
(D4F09EB110177E03C28E2FE1F5BBAE1E0392253F
    (hkp://keys.gnupg.net))

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 865 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#56563: [PATCH v2] gnu: tests: Fix guix-data-service test.
  2022-07-15  5:56 ` [bug#56563] [PATCH v2] " Timotej Lazar
@ 2022-07-15  9:06   ` Christopher Baines
  0 siblings, 0 replies; 6+ messages in thread
From: Christopher Baines @ 2022-07-15  9:06 UTC (permalink / raw)
  To: Timotej Lazar; +Cc: 56563-done

[-- Attachment #1: Type: text/plain, Size: 833 bytes --]


Timotej Lazar <timotej.lazar@araneo.si> writes:

> 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.
> ---
>  gnu/services/guix.scm |  2 --
>  gnu/tests/guix.scm    | 19 +++++++++++++------
>  2 files changed, 13 insertions(+), 8 deletions(-)
>

Thanks Timotej, I've pushed this as
a15b769c2f81034884ef0ae7fa8c1cea8df45c56.

I've also updated the data service so that it responds with a 503 for
the healthcheck when starting up, rather than a 500, as that's a bit
nicer.

Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-15  9:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-14 19:21 [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test Timotej Lazar
2022-07-14 21:26 ` Munyoki Kilyungi
2022-07-15  5:52   ` Timotej Lazar
2022-07-15  8:35     ` Munyoki Kilyungi
2022-07-15  5:56 ` [bug#56563] [PATCH v2] " Timotej Lazar
2022-07-15  9:06   ` bug#56563: " Christopher Baines

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).