From patchwork Tue Mar 30 13:37:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 28195 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 C3C1A27BC66; Tue, 30 Mar 2021 14:39: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=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,MISSING_HEADERS,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=no 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 2FC7027BC65 for ; Tue, 30 Mar 2021 14:39:24 +0100 (BST) Received: from localhost ([::1]:49748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lREaZ-0006tw-7X for patchwork@mira.cbaines.net; Tue, 30 Mar 2021 09:39:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lREaE-0006tc-GA for guix-patches@gnu.org; Tue, 30 Mar 2021 09:39:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39077) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lREaE-00034B-95 for guix-patches@gnu.org; Tue, 30 Mar 2021 09:39:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lREaE-0007xr-5l for guix-patches@gnu.org; Tue, 30 Mar 2021 09:39:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#45905] [PATCH v3] IPFS service definition Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 30 Mar 2021 13:39:02 +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 Cc: 45905@debbugs.gnu.org Received: via spool by 45905-submit@debbugs.gnu.org id=B45905.161711148630531 (code B ref 45905); Tue, 30 Mar 2021 13:39:02 +0000 Received: (at 45905) by debbugs.gnu.org; 30 Mar 2021 13:38:06 +0000 Received: from localhost ([127.0.0.1]:50623 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lREZC-0007vy-Fc for submit@debbugs.gnu.org; Tue, 30 Mar 2021 09:38:06 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:38664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lREZ8-0007vj-OX for 45905@debbugs.gnu.org; Tue, 30 Mar 2021 09:37:57 -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 mdds240090mfAB406ddsvx; Tue, 30 Mar 2021 15:37:52 +0200 Message-ID: <42e840c5a55968ecf8173e4eb84af7dc415f3a51.camel@telenet.be> From: Maxime Devos Date: Tue, 30 Mar 2021 15:37:46 +0200 In-Reply-To: References: 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=1617111472; bh=8VZqwgUYWq2jv/rb5OKkLsqwsGuudFxdaLCeR2FmwyM=; h=Subject:From:Cc:Date:In-Reply-To:References; b=PiQExAS7BoCTqmwaL0KC8t6uSMFHb9eB99va1abdOKYcV7oyhEflFlY/Iay5Kt2xs A9eVZl38ZRyGGSSyRQWg0yVpYe46KdUBKrWzJXO4kEU6g56Qy68FgqUZheV0ddHj+n Aq05H22FoWOUp4QVkgM/ZAGEcesqZCkkSgfhmeDRCCZrN5L1/nOIYq9TNZA8wCC3je mn+sMZY0Ig2V4/PFahPlje0Sd92Z/CN/XfBIioJ9V27GG+1dmWGrgLOz84BoqOpkXA Q/1lyFazI2YbBTQHvwd5QawbpWYy7yYCvJVgIsCJaDTErM8fKzpLrsFT8Wm93ccp+d 3zeD0/AikmPXA== 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 Hi Guix, Revised patch series is attached. Changes in v2: * let the shepherd service depend on (loopback) instead of (networking) * added a (broken) system test for the IPFS service Changes in v3: * added 'extensions' argument to 'marionette-operating-system'. * fixed the system test * tweaked the documentation formatting and removed a misleading comment on forwarding (port forwarding would be fine here, as the test is run in a container so there is no risk of port conflicts IIUC) Ludovic Courtès wrote: > Nitpick: please avoid ‘@’. Instead, explicitly do: > [...] I actually prefer '(@ (...) ...)' here, but whatever. It's changed in v3. > As it stands, the test fails because you need to: > (define test > (with-extensions (list guile-json) > …)) As the uploading and downloading is done in the guest, not the host, this needs to be done somewhat differently. That's what the patch ‘tests: Support package extensions in the backdoor REPL’ is for. Greetings, Maxime From b9134c60d9e662dd497caf0c1819e3e04a5e8b4e Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Sun, 28 Mar 2021 17:01:49 +0200 Subject: [PATCH 4/4] 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. * gnu/tests/networking.scm (%ipfs-os): New variable. (run-ipfs-test): New procedure. (%test-ipfs): New system test. --- gnu/tests/networking.scm | 92 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index 022663aa67..453e63f52d 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. ;;; @@ -29,12 +30,15 @@ #:use-module (guix gexp) #:use-module (guix store) #:use-module (guix monads) + #:use-module (guix modules) #:use-module (gnu packages bash) #:use-module (gnu packages linux) #:use-module (gnu packages networking) + #:use-module (gnu packages guile) #: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 +567,89 @@ 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 (source-module-closure + '((gnu services herd) + (guix ipfs))) + #:extensions (list guile-json-4) + #:requirements '(ipfs))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (rnrs bytevectors) + (srfi srfi-64) + (ice-9 binary-ports)) + + (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. + (define (add-data data) + (marionette-eval `(content-name (add-data ,data)) marionette)) + (define (read-contents object) + (marionette-eval + `(let* ((input (read-contents ,object)) + (all-input (get-bytevector-all input))) + (close-port input) + all-input) + marionette)) + + (marionette-eval '(use-modules (guix ipfs)) marionette) + (mkdir #$output) + (chdir #$output) + + (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.1