GNU bug report logs - #56563
[PATCH] gnu: tests: Fix guix-data-service test.

Previous Next

Package: guix-patches;

Reported by: Timotej Lazar <timotej.lazar <at> araneo.si>

Date: Thu, 14 Jul 2022 19:23:02 UTC

Severity: normal

Tags: patch

Done: Christopher Baines <mail <at> cbaines.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 56563 in the body.
You can then email your comments to 56563 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#56563; Package guix-patches. (Thu, 14 Jul 2022 19:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Timotej Lazar <timotej.lazar <at> araneo.si>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 14 Jul 2022 19:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Timotej Lazar <timotej.lazar <at> araneo.si>
To: guix-patches <at> gnu.org
Cc: Timotej Lazar <timotej.lazar <at> araneo.si>
Subject: [PATCH] gnu: tests: Fix guix-data-service test.
Date: Thu, 14 Jul 2022 21:21:38 +0200
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





Information forwarded to guix-patches <at> gnu.org:
bug#56563; Package guix-patches. (Thu, 14 Jul 2022 21:27:02 GMT) Full text and rfc822 format available.

Message #8 received at 56563 <at> debbugs.gnu.org (full text, mbox):

From: Munyoki Kilyungi <me <at> bonfacemunyoki.com>
To: Timotej Lazar <timotej.lazar <at> araneo.si>
Cc: 56563 <at> debbugs.gnu.org
Subject: Re: [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test.
Date: Fri, 15 Jul 2022 00:26:16 +0300
[Message part 1 (text/plain, inline)]
Timotej Lazar <timotej.lazar <at> 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))
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#56563; Package guix-patches. (Fri, 15 Jul 2022 05:53:01 GMT) Full text and rfc822 format available.

Message #11 received at 56563 <at> debbugs.gnu.org (full text, mbox):

From: Timotej Lazar <timotej.lazar <at> araneo.si>
To: Munyoki Kilyungi <me <at> bonfacemunyoki.com>
Cc: 56563 <at> debbugs.gnu.org
Subject: Re: [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test.
Date: Fri, 15 Jul 2022 07:52:33 +0200
Munyoki Kilyungi <me <at> bonfacemunyoki.com> [2022-07-15 00:26:16+0300]:
> Timotej Lazar <timotej.lazar <at> 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!




Information forwarded to guix-patches <at> gnu.org:
bug#56563; Package guix-patches. (Fri, 15 Jul 2022 05:57:01 GMT) Full text and rfc822 format available.

Message #14 received at 56563 <at> debbugs.gnu.org (full text, mbox):

From: Timotej Lazar <timotej.lazar <at> araneo.si>
To: 56563 <at> debbugs.gnu.org
Cc: Timotej Lazar <timotej.lazar <at> araneo.si>
Subject: [PATCH v2] gnu: tests: Fix guix-data-service test.
Date: Fri, 15 Jul 2022 07:56:06 +0200
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





Information forwarded to guix-patches <at> gnu.org:
bug#56563; Package guix-patches. (Fri, 15 Jul 2022 08:36:01 GMT) Full text and rfc822 format available.

Message #17 received at 56563 <at> debbugs.gnu.org (full text, mbox):

From: Munyoki Kilyungi <me <at> bonfacemunyoki.com>
To: Timotej Lazar <timotej.lazar <at> araneo.si>
Cc: 56563 <at> debbugs.gnu.org
Subject: Re: [bug#56563] [PATCH] gnu: tests: Fix guix-data-service test.
Date: Fri, 15 Jul 2022 11:35:30 +0300
[Message part 1 (text/plain, inline)]
Timotej Lazar <timotej.lazar <at> araneo.si> anaandika:

> Munyoki Kilyungi <me <at> bonfacemunyoki.com> [2022-07-15 00:26:16+0300]:
>> Timotej Lazar <timotej.lazar <at> 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))
[signature.asc (application/pgp-signature, inline)]

Reply sent to Christopher Baines <mail <at> cbaines.net>:
You have taken responsibility. (Fri, 15 Jul 2022 09:08:02 GMT) Full text and rfc822 format available.

Notification sent to Timotej Lazar <timotej.lazar <at> araneo.si>:
bug acknowledged by developer. (Fri, 15 Jul 2022 09:08:02 GMT) Full text and rfc822 format available.

Message #22 received at 56563-done <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: Timotej Lazar <timotej.lazar <at> araneo.si>
Cc: 56563-done <at> debbugs.gnu.org
Subject: Re: [bug#56563] [PATCH v2] gnu: tests: Fix guix-data-service test.
Date: Fri, 15 Jul 2022 10:06:20 +0100
[Message part 1 (text/plain, inline)]
Timotej Lazar <timotej.lazar <at> 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
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 12 Aug 2022 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 310 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.