Message ID | 4e1df2f011f5766d48c44d7231e562a889239e7a.camel@telenet.be |
---|---|
State | Accepted |
Headers | show |
Series | [bug#45905] IPFS service definition | expand |
Context | Check | Description |
---|---|---|
cbaines/comparison | success | View comparision |
cbaines/git branch | success | View Git branch |
cbaines/applying patch | fail | View Laminar job |
cbaines/issue | success | View issue |
Hi Maxime, Maxime Devos <maximedevos@telenet.be> 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’.
Hi Maxime, Maxime Devos <maximedevos@telenet.be> 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’.
From 732c018b9d24f0f36700c6f8715e989ee3d94663 Mon Sep 17 00:00:00 2001 From: Maxime Devos <maximedevos@telenet.be> Date: Sun, 28 Mar 2021 17:01:49 +0200 Subject: [PATCH 3/3] gnu: tests: Test basic funtionality of the IPFS service. It is tested whether the IPFS service listens at the gateway and API ports and whether it is possible to upload and download a bytevector. 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? * gnu/tests/networking.scm (%ipfs-os): New variable. (run-ipfs-test): New procedure. (%test-ipfs): New system test. --- gnu/tests/networking.scm | 81 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 022663aa67..f886eac881 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2017, 2020 Marius Bakke <marius@gnu.org> ;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com> ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> ;;; ;;; This file is part of GNU Guix. ;;; @@ -34,7 +35,8 @@ #:use-module (gnu packages networking) #:use-module (gnu services shepherd) #:use-module (ice-9 match) - #:export (%test-inetd %test-openvswitch %test-dhcpd %test-tor %test-iptables)) + #:export (%test-inetd %test-openvswitch %test-dhcpd %test-tor %test-iptables + %test-ipfs)) (define %inetd-os ;; Operating system with 2 inetd services. @@ -563,3 +565,80 @@ COMMIT (name "iptables") (description "Test a running iptables daemon.") (value (run-iptables-test)))) + + +;;; +;;; IPFS service +;;; + +(define %ipfs-os + (simple-operating-system + (service ipfs-service-type))) + +(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") + + ;; Test the IPFS service. + + (test-assert "ipfs is alive" (ipfs-is-alive?)) + + (test-assert "ipfs is listening on the gateway" + (let ((default-port 8082)) + (wait-for-tcp-port default-port marionette))) + + (test-assert "ipfs is listening on the API endpoint" + (let ((default-port 5001)) + (wait-for-tcp-port default-port marionette))) + + (define test-bv (string->utf8 "hello ipfs!")) + (test-equal "can upload and download a file to/from ipfs" + test-bv + (read-contents (add-data test-bv))) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + (gexp->derivation "ipfs-test" test)) + +(define %test-ipfs + (system-test + (name "ipfs") + (description "Test a running IPFS daemon configuration.") + (value (run-ipfs-test)))) -- 2.31.0