From patchwork Sun Mar 28 16:36:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 28159 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E837327BC63; Sun, 28 Mar 2021 17:37:26 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D1AFB27BC64 for ; Sun, 28 Mar 2021 17:37:22 +0100 (BST) Received: from localhost ([::1]:36316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQYPi-00030F-1j for patchwork@mira.cbaines.net; Sun, 28 Mar 2021 12:37:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQYPN-0002zq-Vq for guix-patches@gnu.org; Sun, 28 Mar 2021 12:37:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35354) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lQYPN-0003YB-Os for guix-patches@gnu.org; Sun, 28 Mar 2021 12:37:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lQYPN-00019V-Ks for guix-patches@gnu.org; Sun, 28 Mar 2021 12:37:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#45905] [PATCH] IPFS service definition Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 28 Mar 2021 16:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45905 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: 45905@debbugs.gnu.org Received: via spool by 45905-submit@debbugs.gnu.org id=B45905.16169493954382 (code B ref 45905); Sun, 28 Mar 2021 16:37:01 +0000 Received: (at 45905) by debbugs.gnu.org; 28 Mar 2021 16:36:35 +0000 Received: from localhost ([127.0.0.1]:46897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lQYOo-00018U-Pr for submit@debbugs.gnu.org; Sun, 28 Mar 2021 12:36:35 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:43000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lQYOl-00018J-Jz for 45905@debbugs.gnu.org; Sun, 28 Mar 2021 12:36:25 -0400 Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by albert.telenet-ops.be with bizsmtp id lscM2400G0mfAB406scMxl; Sun, 28 Mar 2021 18:36:22 +0200 Message-ID: <4e1df2f011f5766d48c44d7231e562a889239e7a.camel@telenet.be> From: Maxime Devos Date: Sun, 28 Mar 2021 18:36:13 +0200 In-Reply-To: <871rc6koew.fsf@gnu.org> References: <874kh3w1j6.fsf@gnu.org> <36af87b3ec48ed159cc237dcac93320817c74f58.camel@telenet.be> <871rc6koew.fsf@gnu.org> User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1616949382; bh=aK98yxaD7fKTwRBZCOcsh/Ir94vsR/UFt1lz5C7MpM4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Zb9DfX+xlPVqyfPCjKHGcRUGVyFZpFBEYt/HzZ2ZYxv8nS2MGfSAPJnFV3tYx3TnQ iG4M7QwwrCsxlyHXuvkSjgFcy1hcoqLFMYBlc4/VLm33/JSx/2CJ+piIMMJDD7chdm EV8x5FA8/fZU9mFZPkHg3oaOdOGZvLi1rslcRsMaEt7qWXt0Jl7z0ctr5cDyy2pd+8 NoY2U6RwYY+pZ6loizAWyrg+H9/H81empiSikIN8maS0XXUH10ixP8704UiatwZJaN ivthXydeHs5wLNnyEFZnW+r0f2pJEKQ89ZPpVYebJB60CBLpCxTLoO8GG2IfNebXma cQ4sRg7vdE1Jw== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches On Tue, 2021-03-23 at 14:08 +0100, Ludovic Courtès wrote: > [...] > Yes, I think so. We “just” need to package ‘fs-repo-migrations’ first. > > Perhaps it’d be okay, as a first step, to provide an IPFS service that > doesn’t handle migrations automatically. > > [...] Punt for later. > > > The patch LGTM. However, we usually commit services along with a system > > > test under (gnu tests …). The manual has info on how to run individual > > > system tests: > > > > > > https://guix.gnu.org/manual/en/html_node/Running-the-Test-Suite.html > > > > > > Could you write a test that ensures that basic functionality works? It > > > could be as simple as waiting for the service to be up, then invoking > > > ‘ipfs add’ and ‘ipfs get’. WDYT? > > > > [...] I have attached a revised patch series testing such basic functionality. However, I tested the functionality with the HTTP interface instead of with the command line, as the CLI tools assume the IPFS daemon is run as the same user as the CLI tools. (IIRC there is an implementation of the CLI tools somewhere that uses the API endpoint instead of reading/writing to ~/.ipfs, but I don't recall where.) I have a problem: I can't run the test I wrote. $ make && make check-system TESTS="ipfs" > [compilation bla bla] > Compiling Scheme modules... > Selected 1 system tests... > (end of output) For some reason, the test I wrote seems to be ignored. (Also available from my public git repo: ) Greetings, Maxime. From 732c018b9d24f0f36700c6f8715e989ee3d94663 Mon Sep 17 00:00:00 2001 From: Maxime Devos 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 ;;; Copyright © 2018 Chris Marusich ;;; Copyright © 2018 Arun Isaac +;;; Copyright © 2021 Maxime Devos ;;; ;;; 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