From 5d8c2c00d60196c46a32b68c618ccbe2b3aa48f4 Mon Sep 17 00:00:00 2001 From: Simon South Date: Mon, 1 Mar 2021 10:13:29 -0500 Subject: tests: Add Transmission Daemon system test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/tests/file-sharing.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. Signed-off-by: Ludovic Courtès --- gnu/tests/file-sharing.scm | 271 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 gnu/tests/file-sharing.scm (limited to 'gnu/tests') diff --git a/gnu/tests/file-sharing.scm b/gnu/tests/file-sharing.scm new file mode 100644 index 0000000000..9a8ee6a593 --- /dev/null +++ b/gnu/tests/file-sharing.scm @@ -0,0 +1,271 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Simon South +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +;;; +;;; The Transmission Daemon service. +;;; + +(define-module (gnu tests file-sharing) + #:use-module (gnu packages bittorrent) + #:use-module (gnu services) + #:use-module (gnu services file-sharing) + #:use-module (gnu services networking) + #:use-module (gnu system vm) + #:use-module (gnu tests) + #:use-module (guix gexp) + #:export (%test-transmission-daemon)) + +(define %transmission-daemon-user "transmission") +(define %transmission-daemon-group "transmission") + +(define %transmission-daemon-config-dir "/var/lib/transmission-daemon") +(define %transmission-daemon-watch-dir + (string-append %transmission-daemon-config-dir "/watch")) +(define %transmission-daemon-incomplete-dir + (string-append %transmission-daemon-config-dir "/incomplete")) + +(define %transmission-daemon-settings-file + (string-append %transmission-daemon-config-dir "/settings.json")) + +(define %transmission-daemon-peer-port 51000) ; default is 51413 + +(define %transmission-daemon-rpc-port 9999) ; default is 9091 +(define %transmission-daemon-rpc-username "test-username") +(define %transmission-daemon-rpc-password "test-password") + +(define %transmission-daemon-test-configuration + (transmission-daemon-configuration + (incomplete-dir-enabled? #t) + (incomplete-dir %transmission-daemon-incomplete-dir) + + (watch-dir-enabled? #t) + (watch-dir %transmission-daemon-watch-dir) + + (peer-port-random-on-start? #f) + (peer-port %transmission-daemon-peer-port) + + (rpc-enabled? #t) + (rpc-port %transmission-daemon-rpc-port) + (rpc-whitelist-enabled? #f) + (rpc-authentication-required? #t) + (rpc-username %transmission-daemon-rpc-username) + (rpc-password (transmission-password-hash %transmission-daemon-rpc-password + "yEK0q3.X")))) + +(define (run-transmission-daemon-test) + (define os + (marionette-operating-system + (simple-operating-system + (service dhcp-client-service-type) + (service transmission-daemon-service-type + %transmission-daemon-test-configuration)) + #:imported-modules '((gnu services herd) + (json parser)) + #:requirements '(transmission-daemon))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-64)) + + (define marionette + (make-marionette + (list #$(virtual-machine + (operating-system os) + (port-forwardings + `((9091 . ,%transmission-daemon-rpc-port))))))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "transmission-daemon") + + ;; Make sure the "transmission" user and group have been created. + (test-assert "\"transmission\" user exists" + (marionette-eval + '(begin + (getpwnam #$%transmission-daemon-user) + #t) + marionette)) + (test-assert "\"transmission\" group exists" + (marionette-eval + '(begin + (getgrnam #$%transmission-daemon-group) + #t) + marionette)) + + ;; Make sure Transmission Daemon's configuration directory has been + ;; created with the correct ownership and permissions. + (test-assert "configuration directory exists" + (marionette-eval + '(eq? (stat:type (stat #$%transmission-daemon-config-dir)) + 'directory) + marionette)) + (test-assert "configuration directory has correct ownership" + (marionette-eval + '(let ((config-dir (stat #$%transmission-daemon-config-dir)) + (transmission-user (getpwnam #$%transmission-daemon-user))) + (and (eqv? (stat:uid config-dir) + (passwd:uid transmission-user)) + (eqv? (stat:gid config-dir) + (passwd:gid transmission-user)))) + marionette)) + (test-assert "configuration directory has expected permissions" + (marionette-eval + '(eqv? (stat:perms (stat #$%transmission-daemon-config-dir)) + #o750) + marionette)) + + ;; Make sure the incomplete-downloads and watch directories have been + ;; created with the correct ownership and permissions. + (test-assert "incomplete-downloads directory exists" + (marionette-eval + '(eq? (stat:type (stat #$%transmission-daemon-incomplete-dir)) + 'directory) + marionette)) + (test-assert "incomplete-downloads directory has correct ownership" + (marionette-eval + '(let ((incomplete-dir + (stat #$%transmission-daemon-incomplete-dir)) + (transmission-user + (getpwnam #$%transmission-daemon-user))) + (and (eqv? (stat:uid incomplete-dir) + (passwd:uid transmission-user)) + (eqv? (stat:gid incomplete-dir) + (passwd:gid transmission-user)))) + marionette)) + (test-assert + "incomplete-downloads directory has expected permissions" + (marionette-eval + '(eqv? (stat:perms (stat #$%transmission-daemon-incomplete-dir)) + #o750) + marionette)) + + (test-assert "watch directory exists" + (marionette-eval + '(eq? (stat:type (stat #$%transmission-daemon-watch-dir)) + 'directory) + marionette)) + (test-assert "watch directory has correct ownership" + (marionette-eval + '(let ((watch-dir (stat #$%transmission-daemon-watch-dir)) + (transmission-user (getpwnam #$%transmission-daemon-user))) + (and (eqv? (stat:uid watch-dir) + (passwd:uid transmission-user)) + (eqv? (stat:gid watch-dir) + (passwd:gid transmission-user)))) + marionette)) + (test-assert "watch directory has expected permissions" + (marionette-eval + '(eqv? (stat:perms (stat #$%transmission-daemon-watch-dir)) + #o770) + marionette)) + + ;; Make sure the settings file has been created and appears valid. + (test-assert "settings file exists" + (marionette-eval + '(file-exists? #$%transmission-daemon-settings-file) + marionette)) + (test-assert "settings file is valid JSON" + (marionette-eval + '(begin + (use-modules (json parser)) + (with-input-from-file #$%transmission-daemon-settings-file + (lambda () + (json->scm))) + #t) + marionette)) + (test-assert "settings file contains a non-empty JSON object" + (marionette-eval + '(begin + (use-modules (json parser) + (srfi srfi-1)) + (let ((settings (with-input-from-file + #$%transmission-daemon-settings-file + (lambda () + (json->scm))))) + (and (list? settings) + (not (null? settings)) + (every pair? settings)))) + marionette)) + + ;; Make sure Transmission Daemon is running. + (test-assert "transmission-daemon is running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (live-service-running + (find (lambda (live-service) + (memq 'transmission-daemon + (live-service-provision live-service))) + (current-services)))) + marionette)) + + ;; Make sure the daemon is listening for peer connections. + (test-assert "transmission-daemon is listening for peers" + (wait-for-tcp-port #$%transmission-daemon-peer-port marionette)) + + ;; Make sure the daemon is listening for RPC-client connections. + (test-assert "transmission-daemon is listening for RPC clients" + (wait-for-tcp-port #$%transmission-daemon-rpc-port marionette)) + + ;; Make sure the RPC-authentication settings are honored. + (test-assert "transmission-daemon requires RPC authentication" + (let ((transmission-remote + (string-append #+transmission "/bin/transmission-remote"))) + (with-error-to-port (%make-void-port "w") + (lambda () + (not (zero? (system* transmission-remote + "--session-info"))))))) + (test-assert "transmission-daemon rejects incorrect RPC credentials" + (let ((transmission-remote + (string-append #+transmission "/bin/transmission-remote")) + (wrong-auth-string + (string-append #$%transmission-daemon-rpc-username + ":" + "wrong-" + #$%transmission-daemon-rpc-password))) + (with-error-to-port (%make-void-port "w") + (lambda () + (not (zero? (system* transmission-remote + "--auth" wrong-auth-string + "--session-info"))))))) + (test-assert "transmission-daemon accepts correct RPC credentials" + (let ((transmission-remote + (string-append #+transmission "/bin/transmission-remote")) + (auth-string + (string-append #$%transmission-daemon-rpc-username + ":" + #$%transmission-daemon-rpc-password))) + (with-output-to-port (%make-void-port "w") + (lambda () + (zero? (system* transmission-remote + "--auth" auth-string + "--session-info")))))) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "transmission-daemon-test" test)) + +(define %test-transmission-daemon + (system-test + (name "transmission-daemon") + (description "Test a running Transmission Daemon service.") + (value (run-transmission-daemon-test)))) -- cgit v1.2.3 From 81f65a3a2c5f4d1a5e8d74a4525181d8ae7d5408 Mon Sep 17 00:00:00 2001 From: Pierre Langlois Date: Fri, 2 Apr 2021 11:11:10 +0100 Subject: tests: libvirt: Catch issues with incorrect /var and /etc in package. * gnu/tests/virtualization.scm (run-libvirt-test): Chdir to "/tmp" before running test. Add "connect" test. --- gnu/tests/virtualization.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gnu/tests') diff --git a/gnu/tests/virtualization.scm b/gnu/tests/virtualization.scm index e95787ee19..9f9d3a5e26 100644 --- a/gnu/tests/virtualization.scm +++ b/gnu/tests/virtualization.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2017 Christopher Baines ;;; Copyright © 2020 Ludovic Courtès ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2021 Pierre Langlois ;;; ;;; This file is part of GNU Guix. ;;; @@ -92,10 +93,20 @@ 0 (marionette-eval `(begin + (chdir "/tmp") (system* ,(string-append #$libvirt "/bin/virsh") "-c" "qemu:///system" "version")) marionette)) + (test-eq "connect" + 0 + (marionette-eval + `(begin + (chdir "/tmp") + (system* ,(string-append #$libvirt "/bin/virsh") + "-c" "qemu:///system" "connect")) + marionette)) + (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) -- cgit v1.2.3 From eda4bb4f16f74436b0caf1c584888c89b3c4c69b Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 10 Nov 2018 10:04:00 +0000 Subject: services: Add Laminar. * gnu/services/ci.scm: New file. * gnu/tests/ci.scm: New file. * doc/guix.texi (Laminar): Document the Laminar service. --- doc/guix.texi | 64 ++++++++++++++++++++++++-- gnu/services/ci.scm | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ gnu/tests/ci.scm | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 316 insertions(+), 3 deletions(-) create mode 100644 gnu/services/ci.scm create mode 100644 gnu/tests/ci.scm (limited to 'gnu/tests') diff --git a/doc/guix.texi b/doc/guix.texi index d1a15cb28b..edd91d8dd0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -38,7 +38,7 @@ Copyright @copyright{} 2016, 2017 Nikita Gillmann@* Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Jan Nieuwenhuizen@* Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Julien Lepiller@* Copyright @copyright{} 2016 Alex ter Weele@* -Copyright @copyright{} 2016, 2017, 2018, 2019 Christopher Baines@* +Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Christopher Baines@* Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@* Copyright @copyright{} 2017, 2018, 2020, 2021 Mathieu Othacehe@* Copyright @copyright{} 2017 Federico Beffa@* @@ -342,7 +342,7 @@ Services * DNS Services:: DNS daemons. * VPN Services:: VPN daemons. * Network File System:: NFS related services. -* Continuous Integration:: The Cuirass service. +* Continuous Integration:: Cuirass and Laminar services. * Power Management Services:: Extending battery life. * Audio Services:: The MPD. * Virtualization Services:: Virtualization services. @@ -14820,7 +14820,7 @@ declaration. * DNS Services:: DNS daemons. * VPN Services:: VPN daemons. * Network File System:: NFS related services. -* Continuous Integration:: The Cuirass service. +* Continuous Integration:: Cuirass and Laminar services. * Power Management Services:: Extending battery life. * Audio Services:: The MPD. * Virtualization Services:: Virtualization services. @@ -27329,6 +27329,64 @@ the store items being published. @end table @end deftp +@subsubheading Laminar + +@uref{https://laminar.ohwg.net/, Laminar} is a lightweight and modular +Continuous Integration service. It doesn't have a configuration web UI +instead uses version-controllable configuration files and scripts. + +Laminar encourages the use of existing tools such as bash and cron +instead of reinventing them. + +@defvr {Scheme Procedure} laminar-service-type +The type of the Laminar service. Its value must be a +@code{laminar-configuration} object, as described below. + +All configuration values have defaults, a minimal configuration to get +Laminar running is shown below. By default, the web interface is +available on port 8080. + +@lisp +(service laminar-service-type) +@end lisp +@end defvr + +@deftp {Data Type} laminar-configuration +Data type representing the configuration of Laminar. + +@table @asis +@item @code{laminar} (default: @code{laminar}) +The Laminar package to use. + +@item @code{home-directory} (default: @code{"/var/lib/laminar"}) +The directory for job configurations and run directories. + +@item @code{bind-http} (default: @code{"*:8080"}) +The interface/port or unix socket on which laminard should listen for +incoming connections to the web frontend. + +@item @code{bind-rpc} (default: @code{"unix-abstract:laminar"}) +The interface/port or unix socket on which laminard should listen for +incoming commands such as build triggers. + +@item @code{title} (default: @code{"Laminar"}) +The page title to show in the web frontend. + +@item @code{keep-rundirs} (default: @code{0}) +Set to an integer defining how many rundirs to keep per job. The +lowest-numbered ones will be deleted. The default is 0, meaning all run +dirs will be immediately deleted. + +@item @code{archive-url} (default: @code{#f}) +The web frontend served by laminard will use this URL to form links to +artefacts archived jobs. + +@item @code{base-url} (default: @code{#f}) +Base URL to use for links to laminar itself. + +@end table +@end deftp + @node Power Management Services @subsection Power Management Services diff --git a/gnu/services/ci.scm b/gnu/services/ci.scm new file mode 100644 index 0000000000..0b18521e76 --- /dev/null +++ b/gnu/services/ci.scm @@ -0,0 +1,127 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2018, 2019, 2020, 2021 Christopher Baines +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu services ci) + #:use-module (guix gexp) + #:use-module (guix records) + #:use-module (gnu packages admin) + #:use-module (gnu packages ci) + #:use-module (gnu services) + #:use-module (gnu services base) + #:use-module (gnu services shepherd) + #:use-module (gnu services admin) + #:use-module (gnu system shadow) + #:use-module (ice-9 match) + #:export (laminar-configuration + laminar-configuration? + laminar-configuration-home-directory + laminar-configuration-bind-http + laminar-configuration-bind-rpc + laminar-configuration-title + laminar-configuration-keep-rundirs + laminar-configuration-archive-url + laminar-configuration-base-url + + laminar-service-type)) + +;;;; Commentary: +;;; +;;; This module implements a service that to run instances of Laminar, a +;;; continuous integration tool. +;;; +;;;; Code: + +(define-record-type* + laminar-configuration make-laminar-configuration + laminar-configuration? + (laminar laminars-configuration-laminar + (default laminar)) + (home-directory laminar-configuration-home-directory + (default "/var/lib/laminar")) + (bind-http laminar-configuration-bind-http + (default "*:8080")) + (bind-rpc laminar-configuration-bind-rpc + (default "unix-abstract:laminar")) + (title laminar-configuration-title + (default "Laminar")) + (keep-rundirs laminar-keep-rundirs + (default 0)) + (archive-url laminar-archive-url + (default #f)) + (base-url laminar-base-url + (default #f))) + +(define laminar-shepherd-service + (match-lambda + (($ laminar home-directory + bind-http bind-rpc + title keep-rundirs archive-url + base-url) + (list (shepherd-service + (documentation "Run Laminar.") + (provision '(laminar)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append laminar "/sbin/laminard")) + #:environment-variables + `(,(string-append "LAMINAR_HOME=" + #$home-directory) + ,(string-append "LAMINAR_BIND_HTTP=" + #$bind-http) + ,(string-append "LAMINAR_TITLE=" + #$title) + ,(string-append "LAMINAR_KEEP_RUNDIRS=" + #$(number->string + keep-rundirs)) + ,@(if #$archive-url + (list + (string-append "LAMINAR_ARCHIVE_URL=" + #$archive-url)) + '()) + ,@(if #$base-url + (list + (string-append "LAMINAR_BASE_URL=" + #$base-url)) + '())) + #:user "laminar" + #:group "laminar")) + (stop #~(make-kill-destructor))))))) + +(define (laminar-account config) + "Return the user accounts and user groups for CONFIG." + (list (user-group + (name "laminar") + (system? #t)) + (user-account + (name "laminar") + (group "laminar") + (system? #t) + (comment "Laminar privilege separation user") + (home-directory (laminar-configuration-home-directory config)) + (shell #~(string-append #$shadow "/sbin/nologin"))))) + +(define laminar-service-type + (service-type + (name 'laminar) + (extensions + (list + (service-extension shepherd-root-service-type laminar-shepherd-service) + (service-extension account-service-type laminar-account))) + (default-value (laminar-configuration)) + (description + "Run the Laminar continuous integration service."))) diff --git a/gnu/tests/ci.scm b/gnu/tests/ci.scm new file mode 100644 index 0000000000..a8b39fcd01 --- /dev/null +++ b/gnu/tests/ci.scm @@ -0,0 +1,128 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Ludovic Courtès +;;; Copyright © 2017, 2018, 2019, 2020, 2021 Christopher Baines +;;; Copyright © 2017, 2018 Clément Lassieur +;;; Copyright © 2018 Pierre-Antoine Rouby +;;; Copyright © 2018 Marius Bakke +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu tests ci) + #:use-module (gnu tests) + #:use-module (gnu system) + #:use-module (gnu system file-systems) + #:use-module (gnu system shadow) + #:use-module (gnu system vm) + #:use-module (gnu services) + #:use-module (gnu services ci) + #:use-module (gnu services web) + #:use-module (gnu services networking) + #:use-module (guix gexp) + #:use-module (guix store) + #:export (%test-laminar)) + + +(define %laminar-os + ;; Operating system under test. + (simple-operating-system + (service dhcp-client-service-type) + (service laminar-service-type))) + +(define* (run-laminar-test #:optional (http-port 8080)) + "Run tests in %LAMINAR-OS, which has laminar running and listening on +HTTP-PORT." + (define os + (marionette-operating-system + %laminar-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm + (virtual-machine + (operating-system os) + (port-forwardings `((,http-port . 8080))))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-11) (srfi srfi-64) + (ice-9 match) + (gnu build marionette) + (web uri) + (web client) + (web response)) + + (define marionette + ;; Forward the guest's HTTP-PORT, where laminar is listening, to + ;; port 8080 in the host. + (make-marionette (list #$vm))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "laminar") + + (test-assert "service running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'laminar)) + marionette)) + + (define* (retry-on-error f #:key times delay) + (let loop ((attempt 1)) + (match (catch + #t + (lambda () + (cons #t + (f))) + (lambda args + (cons #f + args))) + ((#t . return-value) + return-value) + ((#f . error-args) + (if (>= attempt times) + error-args + (begin + (sleep delay) + (loop (+ 1 attempt)))))))) + + (test-equal "http-get" + 200 + (retry-on-error + (lambda () + (let-values (((response text) + (http-get #$(format + #f + "http://localhost:~A/" + http-port) + ;; TODO: Why does decoding fail? + #:decode-body? #f))) + (response-code response))) + #:times 10 + #:delay 5)) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "laminar-test" test)) + +(define %test-laminar + (system-test + (name "laminar") + (description "Connect to a running Laminar server.") + (value (run-laminar-test)))) -- cgit v1.2.3 From 173a631da0324d8a837ef4355a5e1a9673def837 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Fri, 9 Apr 2021 19:47:28 +0200 Subject: tests: nfs: Fix typo in description. * gnu/tests/nfs.scm (%test-nfs-root-fs)[description]: Fix typo. --- gnu/tests/nfs.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/tests') diff --git a/gnu/tests/nfs.scm b/gnu/tests/nfs.scm index 5d04af38fb..9b2b785176 100644 --- a/gnu/tests/nfs.scm +++ b/gnu/tests/nfs.scm @@ -410,5 +410,5 @@ directories can be mounted.") (system-test (name "nfs-root-fs") (description "Test that an NFS server can be started and the exported -directory can be used as root filesystem.") +directory can be used as root file system.") (value (run-nfs-root-fs-test)))) -- cgit v1.2.3 From e1a465209925c43871ce581c2752ae620fbedd3a Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Mon, 12 Apr 2021 14:09:24 +0200 Subject: tests: docker: Increase VM building memory size to 1024MiB. This fixes the following error when running the "docker-system" test: In ice-9/ftw.scm: 553:30 1 (_ #) In unknown file: 0 (readdir #) ERROR: In procedure readdir: In procedure readdir: Cannot allocate memory * gnu/tests/docker.scm (%test-docker-system): Bump image building VM memory size to 1024 MiB. --- gnu/tests/docker.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gnu/tests') diff --git a/gnu/tests/docker.scm b/gnu/tests/docker.scm index cbb856b016..92611b0a8d 100644 --- a/gnu/tests/docker.scm +++ b/gnu/tests/docker.scm @@ -303,5 +303,6 @@ docker-image} inside Docker.") (inherit (simple-operating-system)) ;; Use locales for a single libc to ;; reduce space requirements. - (locale-libcs (list glibc)))) + (locale-libcs (list glibc))) + #:memory-size 1024) run-docker-system-test))))) -- cgit v1.2.3 From 68c9e0a56e008f19427bd213cf5b24bdd8fe5922 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Sun, 28 Mar 2021 17:01:49 +0200 Subject: gnu: tests: Test basic funtionality of the IPFS service. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Signed-off-by: Ludovic Courtès --- gnu/tests/networking.scm | 92 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) (limited to 'gnu/tests') 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)))) -- cgit v1.2.3 From c311147bd16aa0e5746d9cbf31502f5fd61e470c Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 12 Apr 2021 21:41:41 +0100 Subject: services: postgresql: Change service default socket directory. Fixes . PostgreSQL running with a different socket directory to the default one in the package itself breaks some services, this commit restores the previous behaviour where PostgreSQL by default will run with a socket directory that matches the default used by PostgreSQL packaged for Guix. Switching to a different default value can happen, but only alongside changing the PostgreSQL package. * gnu/services/databases.scm ()[socket-directory]: Change default to #false. * doc/guix.texi (Database Services): Update documentation, and specify a different value for disabling connections via sockets. * gnu/tests/guix.scm (%guix-data-service-os): Use default PostgreSQL behaviour. * gnu/tests/monitoring.scm (%zabbix-os): Likewise. * gnu/tests/web.scm (patchwork-os): Likewise. Signed-off-by: Leo Famulari --- doc/guix.texi | 9 ++++++--- gnu/services/databases.scm | 2 +- gnu/tests/guix.scm | 5 +---- gnu/tests/monitoring.scm | 7 +------ gnu/tests/web.scm | 7 +------ 5 files changed, 10 insertions(+), 20 deletions(-) (limited to 'gnu/tests') diff --git a/doc/guix.texi b/doc/guix.texi index 456dfb264d..1069a5d296 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -19830,12 +19830,15 @@ configuration. @item @code{ident-file} (default: @code{%default-postgres-ident}) Filename or G-expression for the user name mapping configuration. -@item @code{socket-directory} (default: @code{"/var/run/postgresql"}) +@item @code{socket-directory} (default: @code{#false}) Specifies the directory of the Unix-domain socket(s) on which PostgreSQL -is to listen for connections from client applications. If set to -@code{#false} PostgreSQL does not listen on any Unix-domain sockets, in +is to listen for connections from client applications. If set to +@code{""} PostgreSQL does not listen on any Unix-domain sockets, in which case only TCP/IP sockets can be used to connect to the server. +By default, the @code{#false} value means the PostgreSQL default value +will be used, which is currently @samp{/tmp}. + @item @code{extra-config} (default: @code{'()}) List of additional keys and values to include in the PostgreSQL config file. Each entry in the list should be a list where the first element diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index a841e7a50e..6ef3f3383c 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -115,7 +115,7 @@ host all all ::1/128 md5")) (ident-file postgresql-config-file-ident-file (default %default-postgres-ident)) (socket-directory postgresql-config-file-socket-directory - (default "/var/run/postgresql")) + (default #false)) (extra-config postgresql-config-file-extra-config (default '()))) diff --git a/gnu/tests/guix.scm b/gnu/tests/guix.scm index 219b8b482f..af7d8f0b21 100644 --- a/gnu/tests/guix.scm +++ b/gnu/tests/guix.scm @@ -164,10 +164,7 @@ " local all all trust host all all 127.0.0.1/32 trust -host all all ::1/128 trust")) - ;; XXX: Remove when postgresql default socket directory is - ;; changed to /var/run/postgresql. - (socket-directory #f))))) +host all all ::1/128 trust")))))) (service guix-data-service-type (guix-data-service-configuration (host "0.0.0.0"))) diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm index be69e1c259..8630f5818c 100644 --- a/gnu/tests/monitoring.scm +++ b/gnu/tests/monitoring.scm @@ -309,12 +309,7 @@ zabbix||{} (service dhcp-client-service-type) (service postgresql-service-type (postgresql-configuration - (postgresql postgresql) - ;; XXX: Remove when postgresql default socket directory is - ;; changed to /var/run/postgresql. - (config-file - (postgresql-config-file - (socket-directory #f))))) + (postgresql postgresql))) (service zabbix-front-end-service-type (zabbix-front-end-configuration (db-password "zabbix"))) diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm index cc0e79c8b2..7f4518acd2 100644 --- a/gnu/tests/web.scm +++ b/gnu/tests/web.scm @@ -569,12 +569,7 @@ HTTP-PORT." (listen '("8080")))))) (service postgresql-service-type (postgresql-configuration - (postgresql postgresql-10) - ;; XXX: Remove when postgresql default socket directory is - ;; changed to /var/run/postgresql. - (config-file - (postgresql-config-file - (socket-directory #f))))) + (postgresql postgresql-10))) (service patchwork-service-type (patchwork-configuration (patchwork patchwork) -- cgit v1.2.3 From 822eacc6bb0878323e6687d4460a7c53066545e1 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 13 Apr 2021 09:57:56 +0200 Subject: tests: halt: Fix it. This fixes: . The OCR prompt detection is failing, so remove it altogether. It looks like the test doesn't need the prompt detection delay to work properly. * gnu/tests/base.scm (run-halt-test): Remove failing OCR detection. --- gnu/tests/base.scm | 4 ---- 1 file changed, 4 deletions(-) (limited to 'gnu/tests') diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index e5f9b87b1d..9429a10b75 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -555,10 +555,6 @@ functionality tests.") (start-service 'term-tty1)) marionette) (marionette-type "root\n" marionette) - (wait-for-screen-text marionette - (lambda (text) - (string-contains text "root@komputilo")) - #:ocrad ocrad) ;; Start tmux and wait for it to be ready. (marionette-type "tmux new-session 'echo 1 > /ready; bash'\n" -- cgit v1.2.3 From c51ffa784e06f1541ee4e6a2378122e51f390e54 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 13 Apr 2021 19:26:39 +0200 Subject: tests: postgresql: Fix it. This is a follow-up of c311147bd16aa0e5746d9cbf31502f5fd61e470c. * gnu/tests/databases.scm (run-postgresql-test): Use "/tmp" as database host. --- gnu/tests/databases.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/tests') diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index 4bfe4ee282..c8d11e10c0 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -233,7 +233,7 @@ (let* ((port (open-pipe* OPEN_READ #$(file-append postgresql "/bin/psql") - "-tAh" "/var/run/postgresql" + "-tAh" "/tmp" "-c" "SELECT 1 FROM pg_database WHERE datname='root'")) (output (get-string-all port))) -- cgit v1.2.3