Subject: Re: bug#45905: [PATCH] IPFS service definition

From: Ludovic Courtès <[email-masked]>
Date: Mon, 29 Mar 2021 16:07:26 +0200

Hi Maxime,

Maxime Devos <[email-masked]> skribis:

> TODO: this test isn't run for some reason:
>
> $ make && make check-system TESTS="ipfs"
>> [compilation bla bla]
>> Compiling Scheme modules...
>> Selected 1 system tests...
>> (end of output)
>
> ??? why isn't the IPFS test executed?

[...]

> +(define (run-ipfs-test)
> +  (define os
> +    (marionette-operating-system %ipfs-os
> +                                 #:imported-modules '((gnu services herd)
> +                                                      (guix ipfs))
> +                                 #:requirements '(ipfs)))
> +
> +  (define test
> +    (with-imported-modules '((gnu build marionette))
> +      #~(begin
> +          (use-modules (gnu build marionette)
> +                       (srfi srfi-64))
> +
> +          (define marionette
> +            (make-marionette (list #$(virtual-machine os))))
> +
> +          (define (ipfs-is-alive?)
> +            (marionette-eval
> +             '(begin
> +                (use-modules (gnu services herd)
> +                             (srfi srfi-1))
> +                (live-service-running
> +                 (find (lambda (live)
> +                         (memq 'ipfs
> +                               (live-service-provision live)))
> +                       (current-services))))
> +             marionette))
> +
> +          ;; The default API endpoint port 5001 is used,
> +          ;; so there is no need to parameterize %ipfs-base-url.
> +          ;; By running this within the VM instead of outside the VM
> +          ;; this system test does not have to forward any ports. 
> +          (define (add-data data)
> +            (marionette-eval
> +             `((@ (guix ipfs) add-contents) ,data)))
> +          (define (read-contents object)
> +            (marionette-eval
> +             `((@ (guix ipfs) read-contents) ,object)))
> +
> +          (test-begin "ipfs")

[...]

> +  (gexp->derivation "ipfs-test" test))

You need to add:

  (mkdir #$output)
  (chdir #$output)

right before (test-begin "ipfs").

Failing to do that, you create “ipfs-test.drv” as a zero-output
derivation—i.e., a derivation that doesn’t produce any output.  Since it
produces nothing, the daemon doesn’t bother running its code.

Nitpick: please avoid ‘@’.  Instead, explicitly do:

  (marionette-eval '(use-modules (ipfs)) marionette)

Alternatively, you can arrange to set up port forwarding for the VM and
use the (ipfs) module from the host rather than from the guest.  This is
what (gnu tests ssh) does, for example.

As it stands, the test fails because you need to:

  (define test
    (with-extensions (list guile-json)
      …))

so that Guile-JSON is available, and probably also:

  (with-imported-modules '((ipfs))
    …)

The rest LGTM.

HTH!

Ludo’.