Subject: Re: [bug#76081] [PATCH v10 3/7] tests: oci-container: Set explicit timeouts.

From: Maxim Cournoyer <[email-masked]>
Date: Thu, 15 May 2025 16:21:58 +0900

Hi,

Giacomo Leidi <[email-masked]> writes:

> * gnu/tests/docker.scm: Simplify %test-oci-container test case and add
> explicit timeouts to tests outcomes.

[...]

>            (test-assert "docker-guile running"
>              (marionette-eval
>               '(begin
>                  (use-modules (gnu services herd))
> -                (match (start-service 'docker-guile)
> -                  (#f #f)
> -                  (('service response-parts ...)
> -                   (match (assq-ref response-parts 'running)
> -                     ((pid) pid)))))
> +                (wait-for-service 'docker-guile #:timeout 120)
> +                #t)

You can drop the trailing '#t'.

>               marionette))
>  
> -          (test-equal "passing host environment variables and volumes"
> -            '("value" "hello")
> -            (marionette-eval
> -             `(begin
> -                (use-modules (ice-9 popen)
> -                             (ice-9 rdelim))
> -
> -                (define slurp
> -                  (lambda args
> -                    (let* ((port (apply open-pipe* OPEN_READ args))
> -                           (output (let ((line (read-line port)))
> -                                     (if (eof-object? line)
> -                                         ""
> -                                         line)))
> -                           (status (close-pipe port)))
> -                      output)))
> -                (let* ((response1 (slurp
> -                                   ,(string-append #$docker-cli "/bin/docker")
> -                                   "exec" "docker-guile"
> -                                   "/bin/guile" "-c" "(display (getenv \"VARIABLE\"))"))
> -                       (response2 (slurp
> -                                   ,(string-append #$docker-cli "/bin/docker")
> -                                   "exec" "docker-guile"
> -                                   "/bin/guile" "-c" "(begin (use-modules (ice-9 popen) (ice-9 rdelim))
> +          (test-assert "passing host environment variables and volumes"
> +            (begin
> +              (define (run-test)
> +                (marionette-eval
> +                 `(begin
> +                    (use-modules (ice-9 popen)
> +                                 (ice-9 rdelim))
> +
> +                    (define slurp
> +                      (lambda args
> +                        (let* ((port (apply open-pipe* OPEN_READ args))
> +                               (output (let ((line (read-line port)))
> +                                         (if (eof-object? line)
> +                                             ""
> +                                             line)))
> +                               (status (close-pipe port)))
> +                          output)))
> +                    (let* ((response1 (slurp
> +                                       ,(string-append #$docker-cli "/bin/docker")
> +                                       "exec" "docker-guile"
> +                                       "/bin/guile" "-c" "(display (getenv \"VARIABLE\"))"))
> +                           (response2 (slurp
> +                                       ,(string-append #$docker-cli "/bin/docker")
> +                                       "exec" "docker-guile"
> +                                       "/bin/guile" "-c" "(begin (use-modules (ice-9 popen) (ice-9 rdelim))

Please mind the 80 columns maximum width :-).

>  (display (call-with-input-file \"/shared.txt\" read-line)))")))
> -                  (list response1 response2)))
> -             marionette))
> +                      (list response1 response2)))
> +                 marionette))
> +              ;; Allow services to come up on slower machines

Please use complete punctuation for standalone comments.

> +              (let loop ((attempts 0))
> +                (if (= attempts 60)
> +                    (error "Service didn't come up after more than 60 seconds")

I'm curious as to why this is necessary, given in the previous test we
wait for the docker-guile service to be ready?

-- 
Thanks,
Maxim