From dd2e6e31edff2d83c8820bb10e588c06495dc122 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 2 Oct 2020 18:51:28 +0100 Subject: tests: monitoring: Use (service postgresql-service-type). As I'm looking at removing the procedure, in favour of always using the service type. * gnu/tests/monitoring.scm (%zabbix-os): Use (service postgresql-service-type) rather than (postgresql-service). --- gnu/tests/monitoring.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/tests') diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm index d20b8ac59e..17b9edc3ac 100644 --- a/gnu/tests/monitoring.scm +++ b/gnu/tests/monitoring.scm @@ -307,7 +307,7 @@ zabbix||{} (let ((base-os (simple-operating-system (service dhcp-client-service-type) - (postgresql-service) + (service postgresql-service-type) (service zabbix-front-end-service-type (zabbix-front-end-configuration (db-password "zabbix"))) -- cgit v1.2.3 From bdcf4d88d58798eca7811c8b1fbd4638168d05c3 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 2 Oct 2020 19:15:44 +0100 Subject: services: databases: Don't specify a default postgresql version. Currently, if the postgresql package major version changes, this is going to break the service upon upgrade, because PostgreSQL will reject the data files from the differing major version of the service. Because it's important to either keep running a particular major version, or intentionally upgrade, I think the configuration would be better with no default. I think this is also going to be helpful when trying to assist users upgrading PostgreSQL. * gnu/services/databases.scm (): Remove default for postgresql. (postgresql-service-type): Remove the default value. * gnu/tests/databases.scm (%postgresql-os): Update accordingly. * gnu/tests/guix.scm (%guix-data-service-os): Update accordingly. * gnu/tests/monitoring.scm (%zabbix-os): Update accordingly. * gnu/tests/web.scm (patchwork-os): Update accordingly. * doc/guix.texi (PostgreSQL): Update accordingly. --- doc/guix.texi | 6 ++++-- gnu/services/databases.scm | 6 ++---- gnu/tests/databases.scm | 4 +++- gnu/tests/guix.scm | 1 + gnu/tests/monitoring.scm | 4 +++- gnu/tests/web.scm | 4 +++- 6 files changed, 16 insertions(+), 9 deletions(-) (limited to 'gnu/tests') diff --git a/doc/guix.texi b/doc/guix.texi index 582ab0fd2b..05111d4327 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -18457,7 +18457,9 @@ The following example describes a PostgreSQL service with the default configuration. @lisp -(service postgresql-service-type) +(service postgresql-service-type + (postgresql-configuration + (postgresql postgresql-10))) @end lisp If the services fails to start, it may be due to an incompatible @@ -18483,7 +18485,7 @@ Data type representing the configuration for the @code{postgresql-service-type}. @table @asis -@item @var{postgresql} (default: @code{postgresql}) +@item @var{postgresql} PostgreSQL package to use for the service. @item @var{port} (default: @code{5432}) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 7908a3e0f6..d7b4594b9e 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -147,8 +147,7 @@ host all all ::1/128 md5")) (define-record-type* postgresql-configuration make-postgresql-configuration postgresql-configuration? - (postgresql postgresql-configuration-postgresql ; - (default postgresql)) + (postgresql postgresql-configuration-postgresql) ; (port postgresql-configuration-port (default 5432)) (locale postgresql-configuration-locale @@ -279,8 +278,7 @@ host all all ::1/128 md5")) (service-extension account-service-type (const %postgresql-accounts)) (service-extension profile-service-type - (compose list postgresql-configuration-postgresql)))) - (default-value (postgresql-configuration)))) + (compose list postgresql-configuration-postgresql)))))) (define-deprecated (postgresql-service #:key (postgresql postgresql) (port 5432) diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index e0544bbcd2..d3045cc3f7 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -215,7 +215,9 @@ (define %postgresql-os (simple-operating-system - (service postgresql-service-type))) + (service postgresql-service-type + (postgresql-configuration + (postgresql postgresql-10))))) (define (run-postgresql-test) "Run tests in %POSTGRESQL-OS." diff --git a/gnu/tests/guix.scm b/gnu/tests/guix.scm index 20b67d55d3..af7d8f0b21 100644 --- a/gnu/tests/guix.scm +++ b/gnu/tests/guix.scm @@ -156,6 +156,7 @@ (service dhcp-client-service-type) (service postgresql-service-type (postgresql-configuration + (postgresql postgresql-10) (config-file (postgresql-config-file (hba-file diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm index 17b9edc3ac..7371b02fe1 100644 --- a/gnu/tests/monitoring.scm +++ b/gnu/tests/monitoring.scm @@ -307,7 +307,9 @@ zabbix||{} (let ((base-os (simple-operating-system (service dhcp-client-service-type) - (service postgresql-service-type) + (service postgresql-service-type + (postgresql-configuration + (postgresql postgresql-10))) (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 7513eab2e4..7f4518acd2 100644 --- a/gnu/tests/web.scm +++ b/gnu/tests/web.scm @@ -567,7 +567,9 @@ HTTP-PORT." (config (httpd-config-file (listen '("8080")))))) - (service postgresql-service-type) + (service postgresql-service-type + (postgresql-configuration + (postgresql postgresql-10))) (service patchwork-service-type (patchwork-configuration (patchwork patchwork) -- cgit v1.2.3 From 572c59a7a1ac94a1fda78fcd2cc37c3e335b297f Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Mon, 26 Oct 2020 16:32:37 +0100 Subject: tests: Fix nss-mdns test. * gnu/tests/base.scm (run-nss-mdns-test): Use full "avahi-browse" path. --- gnu/tests/base.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/tests') diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index 482310cc12..e5f9b87b1d 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -880,7 +880,7 @@ non-ASCII names from /tmp.") (test-equal "avahi-browse" 0 (marionette-eval - '(system* "avahi-browse" "-avt") + '(system* "/run/current-system/profile/bin/avahi-browse" "-avt") marionette)) (test-assert "getaddrinfo .local" -- cgit v1.2.3 From 1c6d98533153bc8e0e36236e7fbcf1eb5e178d26 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 23 Oct 2020 11:31:56 +0200 Subject: installer: Use UUIDs in the 'swap-devices' field. Note: This change requires an updated 'guix' package that contains Linux-swap support in (gnu build file-systems). * gnu/installer/parted.scm (user-partitions->configuration): Use UUIDs in the 'swap-devices' field. * gnu/installer/newt/final.scm (run-final-page)[wait-for-clients]: New procedure. Use it. * gnu/installer/tests.scm (choose-partitioning): Wait for 'starting-final-step' message and move configuration file dialog handling to... (conclude-installation): ... here. Send over PORT the reply corresponding to 'starting-final-step'. * gnu/tests/install.scm (gui-test-program): When ENCRYPTED? is false, invoke 'swaplabel' in the marionette. (installation-target-os-for-gui-tests): When ENCRYPTED? is false, except a fixed UUID. --- gnu/installer/newt/final.scm | 14 ++++++++++++++ gnu/installer/parted.scm | 7 ++++++- gnu/installer/tests.scm | 31 +++++++++++++++++++++++-------- gnu/tests/install.scm | 18 ++++++++++++++++-- 4 files changed, 59 insertions(+), 11 deletions(-) (limited to 'gnu/tests') diff --git a/gnu/installer/newt/final.scm b/gnu/installer/newt/final.scm index 89684c4d8a..5019a67429 100644 --- a/gnu/installer/newt/final.scm +++ b/gnu/installer/newt/final.scm @@ -29,6 +29,7 @@ #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:use-module (ice-9 match) + #:use-module ((ice-9 rdelim) #:select (read-line)) #:use-module (newt) #:export (run-final-page)) @@ -107,6 +108,19 @@ a specific step, or restart the installer.")) install-ok?)) (define (run-final-page result prev-steps) + (define (wait-for-clients) + (unless (null? (current-clients)) + (syslog "waiting with clients before starting final step~%") + (send-to-clients '(starting-final-step)) + (match (select (current-clients) '() '()) + (((port _ ...) _ _) + (read-line port))))) + + ;; Before generating the configuration file, give clients a chance to do + ;; things such as changing the swap partition label. + (wait-for-clients) + + (syslog "proceeding with final step~%") (let* ((configuration (format-configuration prev-steps result)) (user-partitions (result-step result 'partition)) (locale (result-step result 'locale)) diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm index fffd5abf3b..d799ee0e73 100644 --- a/gnu/installer/parted.scm +++ b/gnu/installer/parted.scm @@ -1327,7 +1327,12 @@ USER-PARTITIONS, or return nothing." ,@(initrd-configuration user-partitions) ,@(if (null? swap-devices) '() - `((swap-devices (list ,@swap-devices)))) + (let* ((uuids (map (lambda (file) + (uuid->string (read-partition-uuid file))) + swap-devices))) + `((swap-devices (list ,@(map (lambda (uuid) + `(uuid ,uuid)) + uuids)))))) ,@(if (null? encrypted-partitions) '() `((mapped-devices diff --git a/gnu/installer/tests.scm b/gnu/installer/tests.scm index 58bf0a2700..f318546a2f 100644 --- a/gnu/installer/tests.scm +++ b/gnu/installer/tests.scm @@ -286,8 +286,9 @@ instrumented for further testing." edit-configuration-file)) "Converse over PORT to choose the partitioning method. When ENCRYPTED? is true, choose full-disk encryption with PASSPHRASE as the LUKS passphrase. -This conversation goes past the final dialog box that shows the configuration -file, actually starting the installation process." +This conversation stops when the user partitions have been formatted, right +before the installer generates the configuration file and shows it in a dialog +box." (converse port ((list-selection (title "Partitioning method") (multiple-choices? #f) @@ -330,15 +331,29 @@ file, actually starting the installation process." #t) ((info (title "Preparing partitions") _ ...) (values)) ;nothing to return - ((file-dialog (title "Configuration file") - (text _) - (file ,configuration-file)) - (edit-configuration-file configuration-file)))) + ((starting-final-step) + ;; Do not return anything. The reply will be sent by + ;; 'conclude-installation' and in the meantime the installer just waits + ;; for us, giving us a chance to do things such as changing partition + ;; UUIDs before it generates the configuration file. + (values)))) (define (conclude-installation port) - "Conclude the installation by checking over PORT that we get the final -messages once the 'guix system init' process has completed." + "Conclude the installation by checking over PORT that we get the generated +configuration file, accepting it and starting the installation, and then +receiving the final messages once the 'guix system init' process has +completed." + ;; Assume the previous message received was 'starting-final-step'; here we + ;; send the reply to that message, which lets the installer continue. + (write #t port) + (newline port) + (force-output port) + (converse port + ((file-dialog (title "Configuration file") + (text _) + (file ,configuration-file)) + (edit-configuration-file configuration-file)) ((pause) ;"Press Enter to continue." #t) ((installation-complete) ;congratulations! diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index 86bd93966b..2d62a873ca 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -1211,6 +1211,16 @@ build (current-guix) and then store a couple of full system images.") #$marionette) (screenshot "installer-run.ppm") + (unless #$encrypted? + ;; At this point, user partitions are formatted and the installer is + ;; waiting for us to start the final step: generating the + ;; configuration file, etc. Set a fixed UUID on the swap partition + ;; that matches what 'installation-target-os-for-gui-tests' expects. + (marionette-eval* '(invoke #$(file-append util-linux "/sbin/swaplabel") + "-U" "11111111-2222-3333-4444-123456789abc" + "/dev/vda2") + #$marionette)) + (marionette-eval* '(conclude-installation installer-socket) #$marionette) @@ -1257,8 +1267,12 @@ build (current-guix) and then store a couple of full system images.") '("wheel" "audio" "video")))) %base-user-accounts)) ;; The installer does not create a swap device in guided mode with - ;; encryption support. - (swap-devices (if encrypted? '() '("/dev/vda2"))) + ;; encryption support. The installer produces a UUID for the partition; + ;; this "UUID" is explicitly set in 'gui-test-program' to the value shown + ;; below. + (swap-devices (if encrypted? + '() + (list (uuid "11111111-2222-3333-4444-123456789abc")))) (services (cons (service dhcp-client-service-type) (operating-system-user-services %minimal-os-on-vda))))) -- cgit v1.2.3 From a38d861e571c952f78ca588b50bdcc4adcb0c88c Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Wed, 21 Oct 2020 10:42:50 +0200 Subject: system: reconfigure: Use the disk-installer if provided. Fixes: . * gnu/build/bootloader.scm (write-file-on-device): Pass 'no-fail flag instead of 'no-create. Use a latin-1 transcoder. * guix/scripts/system/reconfigure.scm (install-bootloader-program): Add a "disk-installer" argument and use it as a fallback. (install-bootloader): Adapt accordingly. * gnu/tests/reconfigure.scm (run-install-bootloader-test): Ditto. --- gnu/build/bootloader.scm | 7 +++++-- gnu/tests/reconfigure.scm | 4 +++- guix/scripts/system/reconfigure.scm | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'gnu/tests') diff --git a/gnu/build/bootloader.scm b/gnu/build/bootloader.scm index 5ec839f902..3916930c89 100644 --- a/gnu/build/bootloader.scm +++ b/gnu/build/bootloader.scm @@ -38,10 +38,13 @@ (lambda (input) (let ((bv (get-bytevector-n input size))) (call-with-port + ;; Do not use "call-with-output-file" that would truncate the file. (open-file-output-port device - (file-options no-truncate no-create) + (file-options no-truncate no-fail) (buffer-mode block) - (native-transcoder)) + ;; Use the binary-friendly ISO-8859-1 + ;; encoding. + (make-transcoder (latin-1-codec))) (lambda (output) (seek output offset SEEK_SET) (put-bytevector output bv))))))) diff --git a/gnu/tests/reconfigure.scm b/gnu/tests/reconfigure.scm index 928a210a94..52beeef447 100644 --- a/gnu/tests/reconfigure.scm +++ b/gnu/tests/reconfigure.scm @@ -260,7 +260,9 @@ bootloader's configuration file." ;; test suite, the bootloader installer script is omitted. 'grub-install' ;; would attempt to write directly to the virtual disk if the ;; installation script were run. - (test (install-bootloader-program #f #f bootcfg bootcfg-file #f "/"))))) + (test + (install-bootloader-program #f #f #f bootcfg bootcfg-file #f "/"))))) + (define %test-switch-to-system (system-test diff --git a/guix/scripts/system/reconfigure.scm b/guix/scripts/system/reconfigure.scm index d89caf80fc..5581e12892 100644 --- a/guix/scripts/system/reconfigure.scm +++ b/guix/scripts/system/reconfigure.scm @@ -204,7 +204,8 @@ services as defined by OS." ;;; Bootloader configuration. ;;; -(define (install-bootloader-program installer bootloader-package bootcfg +(define (install-bootloader-program installer disk-installer + bootloader-package bootcfg bootcfg-file device target) "Return an executable store item that, upon being evaluated, will install BOOTCFG to BOOTCFG-FILE, a target file name, on DEVICE, a file system device, @@ -246,10 +247,17 @@ BOOTLOADER-PACKAGE." ;; a broken installation. (switch-symlinks new-gc-root #$bootcfg) (install-boot-config #$bootcfg #$bootcfg-file #$target) - (when #$installer + (when (or #$installer #$disk-installer) (catch #t (lambda () - (#$installer #$bootloader-package #$device #$target)) + ;; The bootloader might not support installation on a + ;; mounted directory using the BOOTLOADER-INSTALLER + ;; procedure. In that case, fallback to installing the + ;; bootloader directly on DEVICE using the + ;; BOOTLOADER-DISK-IMAGE-INSTALLER procedure. + (if #$installer + (#$installer #$bootloader-package #$device #$target) + (#$disk-installer #$bootloader-package 0 #$device))) (lambda args (delete-file new-gc-root) (match args @@ -272,11 +280,14 @@ additional configurations specified by MENU-ENTRIES can be selected." (let* ((bootloader (bootloader-configuration-bootloader configuration)) (installer (and run-installer? (bootloader-installer bootloader))) + (disk-installer (and run-installer? + (bootloader-disk-image-installer bootloader))) (package (bootloader-package bootloader)) (device (bootloader-configuration-target configuration)) (bootcfg-file (bootloader-configuration-file bootloader))) (eval #~(parameterize ((current-warning-port (%make-void-port "w"))) (primitive-load #$(install-bootloader-program installer + disk-installer package bootcfg bootcfg-file -- cgit v1.2.3 From a4e7749e91c5ed9b96117e3bcda8802e8744841e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 5 Nov 2020 16:09:17 +0100 Subject: services: Remove imports of (ice-9 …) modules. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/services/monitoring.scm (zabbix-server-activation): Remove (ice-9 rdelim) from the imported modules. (zabbix-agent-activation): Likewise. * gnu/tests/mail.scm (run-exim-test)[test]: Remove (ice-9 ftw) from the imported modules. --- gnu/services/monitoring.scm | 7 +++---- gnu/tests/mail.scm | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'gnu/tests') diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index 511f4fb2fe..da3d736ba6 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -279,11 +279,11 @@ configuration file.")) (define (zabbix-server-activation config) "Return the activation gexp for CONFIG." - (with-imported-modules '((guix build utils) - (ice-9 rdelim)) + (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils) (ice-9 rdelim)) + (let ((user (getpw #$(zabbix-server-configuration-user config)))) (for-each (lambda (file) (let ((directory (dirname file))) @@ -393,8 +393,7 @@ configuration file.")) (define (zabbix-agent-activation config) "Return the activation gexp for CONFIG." - (with-imported-modules '((guix build utils) - (ice-9 rdelim)) + (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils) (ice-9 rdelim)) diff --git a/gnu/tests/mail.scm b/gnu/tests/mail.scm index a50fb1dbca..eb8952b33a 100644 --- a/gnu/tests/mail.scm +++ b/gnu/tests/mail.scm @@ -205,8 +205,7 @@ acl_check_data: (port-forwardings '((1025 . 25))))) (define test - (with-imported-modules '((gnu build marionette) - (ice-9 ftw)) + (with-imported-modules '((gnu build marionette)) #~(begin (use-modules (rnrs base) (srfi srfi-64) -- cgit v1.2.3 From 3c69e81d85e337ccceb2248c497bd1732a63f7ec Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 6 Nov 2020 16:12:10 +0100 Subject: tests: docker-system: Increase VM memory. The test was failing with ENOSPC. * gnu/tests/docker.scm (run-docker-system-test)[vm]: Increase 'memory-size'. (%test-docker-system): Change 'locale-libcs' for the OS passed to 'system-docker-image'. --- gnu/tests/docker.scm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gnu/tests') diff --git a/gnu/tests/docker.scm b/gnu/tests/docker.scm index ea6c9a33fe..c70c3ddb9e 100644 --- a/gnu/tests/docker.scm +++ b/gnu/tests/docker.scm @@ -27,8 +27,9 @@ #:use-module (gnu services networking) #:use-module (gnu services docker) #:use-module (gnu services desktop) - #:use-module (gnu packages docker) + #:use-module ((gnu packages base) #:select (glibc)) #:use-module (gnu packages guile) + #:use-module (gnu packages docker) #:use-module (guix gexp) #:use-module (guix grafts) #:use-module (guix monads) @@ -206,7 +207,7 @@ inside %DOCKER-OS." ;; load' must be able to store the whole image into memory, hence the ;; huge memory requirements. We should avoid the volatile-root setup ;; instead. - (memory-size 3500) + (memory-size 4000) (port-forwardings '()))) (define test @@ -298,5 +299,9 @@ inside %DOCKER-OS." (description "Run a system image as produced by @command{guix system docker-image} inside Docker.") (value (with-monad %store-monad - (>>= (system-docker-image (simple-operating-system)) + (>>= (system-docker-image (operating-system + (inherit (simple-operating-system)) + ;; Use locales for a single libc to + ;; reduce space requirements. + (locale-libcs (list glibc)))) run-docker-system-test))))) -- cgit v1.2.3 From 9909eddbc55c6cac5acccab453993cd113aa38a1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 6 Nov 2020 23:12:12 +0100 Subject: tests: mpd: Remove race condition; use default MPD configuration. * gnu/tests/audio.scm (%mpd-os): Use the default 'mpd-configuration'. (run-mpd-test)[test]("mpd listening"): New test. ("mpc connect"): Use 'system*' and 'test-equal'. --- gnu/tests/audio.scm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'gnu/tests') diff --git a/gnu/tests/audio.scm b/gnu/tests/audio.scm index 8eadaf02e1..7bf7d4ef14 100644 --- a/gnu/tests/audio.scm +++ b/gnu/tests/audio.scm @@ -28,9 +28,7 @@ (define %mpd-os (simple-operating-system - (service mpd-service-type - (mpd-configuration - (user "root"))))) + (service mpd-service-type))) (define (run-mpd-test) "Run tests in %mpd-os, which has mpd running." @@ -62,9 +60,14 @@ (start-service 'mpd)) marionette)) - (test-assert "mpc connect" + (test-assert "mpd listening" + ;; Wait until mpd is actually listening before spawning 'mpc'. + (wait-for-tcp-port 6600 marionette)) + + (test-equal "mpc connect" + 0 (marionette-eval - '(zero? (system #$(file-append mpd-mpc "/bin/mpc"))) + '(system* #$(file-append mpd-mpc "/bin/mpc")) marionette)) (test-end) -- cgit v1.2.3 From de6b649f8031cc2fa45099a3c41d78c2e302fdf2 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 7 Nov 2020 12:07:41 +0100 Subject: tests: git-http: Avoid race condition. * gnu/tests/version-control.scm (run-git-http-test)[test]("fcgiwrap listens"): New test. --- gnu/tests/version-control.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gnu/tests') diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm index 230aa9edf9..d3cf19c913 100644 --- a/gnu/tests/version-control.scm +++ b/gnu/tests/version-control.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2018 Oleg Pykhalov -;;; Copyright © 2017, 2018 Ludovic Courtès +;;; Copyright © 2017, 2018, 2020 Ludovic Courtès ;;; Copyright © 2017, 2018 Clément Lassieur ;;; Copyright © 2018 Christopher Baines ;;; @@ -285,6 +285,10 @@ HTTP-PORT." '(file-exists? "/srv/git/test") marionette)) + (test-assert "fcgiwrap listens" + ;; Wait for fcgiwrap to be ready before cloning. + (wait-for-tcp-port 9000 marionette)) + ;; Make sure we can clone the repo from the host. (test-equal "clone" '#$README-contents -- cgit v1.2.3 From 7286c9b1879453ea4e0a08e91cc48706d8887f37 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 7 Nov 2020 12:48:24 +0100 Subject: tests: nfs-root-fs: Use the right store file name. * gnu/tests/nfs.scm (run-nfs-root-fs-test): Pass "nfs-root-fs-test" as the first argument to 'gexp->derivation'. --- 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 da729ddcc9..5d04af38fb 100644 --- a/gnu/tests/nfs.scm +++ b/gnu/tests/nfs.scm @@ -404,7 +404,7 @@ directories can be mounted.") (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) - (gexp->derivation "nfs-server-test" test)) + (gexp->derivation "nfs-root-fs-test" test)) (define %test-nfs-root-fs (system-test -- cgit v1.2.3 From a9a2fdaabcc78e7a54d9a6bcfa4ee3de308e9a90 Mon Sep 17 00:00:00 2001 From: Mikhail Tsykalov Date: Fri, 6 Nov 2020 12:47:38 +0300 Subject: mapped-devices: Add 'lvm-device-mapping'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/system/mapped-devices.scm (lvm-device-mapping, open-lvm-device, close-lvm-device): New variables. * gnu/tests/install.scm (%lvm-separate-home-os, %lvm-separate-home-os-source, %lvm-separate-home-installation-script, %test-lvm-separate-home-os): New variables. * gnu/system/linux-initrd.scm (raw-initrd): Add (srfi srfi-1) to initrd expression. Signed-off-by: Ludovic Courtès --- doc/guix.texi | 25 ++++++++++++- gnu/system/linux-initrd.scm | 1 + gnu/system/mapped-devices.scm | 25 ++++++++++++- gnu/tests/install.scm | 87 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+), 4 deletions(-) (limited to 'gnu/tests') diff --git a/doc/guix.texi b/doc/guix.texi index 13fb4b1531..22102972a3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13758,7 +13758,6 @@ Guix extends this notion by considering any device or set of devices that are @dfn{transformed} in some way to create a new device; for instance, RAID devices are obtained by @dfn{assembling} several other devices, such as hard disks or partitions, into a new one that behaves as one partition. -Other examples, not yet implemented, are LVM logical volumes. Mapped devices are declared using the @code{mapped-device} form, defined as follows; for examples, see below. @@ -13771,7 +13770,8 @@ the system boots up. @item source This is either a string specifying the name of the block device to be mapped, such as @code{"/dev/sda3"}, or a list of such strings when several devices -need to be assembled for creating a new one. +need to be assembled for creating a new one. In case of LVM this is a +string specifying name of the volume group to be mapped. @item target This string specifies the name of the resulting mapped device. For @@ -13780,6 +13780,9 @@ specifying @code{"my-partition"} leads to the creation of the @code{"/dev/mapper/my-partition"} device. For RAID devices of type @code{raid-device-mapping}, the full device name such as @code{"/dev/md0"} needs to be given. +LVM logical volumes of type @code{lvm-device-mapping} need to +be specified as @code{"VGNAME-LVNAME"}. + @item targets This list of strings specifies names of the resulting mapped devices in case there are several. The format is identical to @var{target}. @@ -13803,6 +13806,11 @@ module for the appropriate RAID level to be loaded, such as @code{raid456} for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10. @end defvr +@defvr {Scheme Variable} lvm-device-mapping +This defines LVM logical volume(s). Volume group is activated by +@command{vgchange} command from the package @code{lvm2}. +@end defvr + @cindex disk encryption @cindex LUKS The following example specifies a mapping from @file{/dev/sda3} to @@ -13860,6 +13868,19 @@ Note that the RAID level need not be given; it is chosen during the initial creation and formatting of the RAID device and is determined automatically later. +LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can +be declared as follows: + +@lisp +(mapped-device + (source "vg0") + (target (list "vg0-alpha" "vg0-beta")) + (type lvm-device-mapping)) +@end lisp + +Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can +then be used as the @code{device} of a @code{file-system} declaration +(@pxref{File Systems}). @node User Accounts @section User Accounts diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 3e2f1282cc..85e493fecb 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -217,6 +217,7 @@ upon error." (gnu system file-systems) ((guix build utils) #:hide (delete)) (guix build bournish) ;add the 'bournish' meta-command + (srfi srfi-1) ;for lvm-device-mapping (srfi srfi-26) ;; FIXME: The following modules are for diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 8b5aec983d..559c27bb28 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -36,7 +36,7 @@ #:autoload (gnu build linux-modules) (missing-modules) #:autoload (gnu packages cryptsetup) (cryptsetup-static) - #:autoload (gnu packages linux) (mdadm-static) + #:autoload (gnu packages linux) (mdadm-static lvm2-static) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) @@ -64,7 +64,8 @@ check-device-initrd-modules ;XXX: needs a better place luks-device-mapping - raid-device-mapping)) + raid-device-mapping + lvm-device-mapping)) ;;; Commentary: ;;; @@ -304,4 +305,24 @@ TARGET (e.g., \"/dev/md0\"), using 'mdadm'." (open open-raid-device) (close close-raid-device))) +(define (open-lvm-device source targets) + #~(and + (zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgchange" "--activate" "ay" #$source)) + ; /dev/mapper nodes are usually created by udev, but udev may be unavailable at the time we run this. So we create them here. + (zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgscan" "--mknodes")) + (every file-exists? (map (lambda (file) (string-append "/dev/mapper/" file)) + '#$targets)))) + + +(define (close-lvm-device source targets) + #~(zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgchange" "--activate" "n" #$source))) + +(define lvm-device-mapping + (mapped-device-kind + (open open-lvm-device) + (close close-lvm-device))) + ;;; mapped-devices.scm ends here diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index 2d62a873ca..71caa3a493 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -67,6 +67,7 @@ %test-btrfs-root-on-subvolume-os %test-jfs-root-os %test-f2fs-root-os + %test-lvm-separate-home-os %test-gui-installed-os %test-gui-installed-os-encrypted @@ -796,6 +797,92 @@ build (current-guix) and then store a couple of full system images.") (run-basic-test %encrypted-root-os command "encrypted-root-os" #:initialization enter-luks-passphrase))))) + +;;; +;;; Separate /home on LVM +;;; + +;; Since LVM support in guix currently doesn't allow root-on-LVM we use /home on LVM +(define-os-with-source (%lvm-separate-home-os %lvm-separate-home-os-source) + (use-modules (gnu) (gnu tests)) + + (operating-system + (host-name "separate-home-on-lvm") + (timezone "Europe/Paris") + (locale "en_US.utf8") + + (bootloader (bootloader-configuration + (bootloader grub-bootloader) + (target "/dev/vdb"))) + (kernel-arguments '("console=ttyS0")) + + (mapped-devices (list (mapped-device + (source "vg0") + (target "vg0-home") + (type lvm-device-mapping)))) + (file-systems (cons* (file-system + (device (file-system-label "root-fs")) + (mount-point "/") + (type "ext4")) + (file-system + (device "/dev/mapper/vg0-home") + (mount-point "/home") + (type "ext4") + (dependencies mapped-devices)) + %base-file-systems)) + (users %base-user-accounts) + (services (cons (service marionette-service-type + (marionette-configuration + (imported-modules '((gnu services herd) + (guix combinators))))) + %base-services)))) + +(define %lvm-separate-home-installation-script + "\ +. /etc/profile +set -e -x +guix --version + +export GUIX_BUILD_OPTIONS=--no-grafts +parted --script /dev/vdb mklabel gpt \\ + mkpart primary ext2 1M 3M \\ + mkpart primary ext2 3M 1.6G \\ + mkpart primary 1.6G 3.2G \\ + set 1 boot on \\ + set 1 bios_grub on +pvcreate /dev/vdb3 +vgcreate vg0 /dev/vdb3 +lvcreate -L 1.6G -n home vg0 +vgchange -ay +mkfs.ext4 -L root-fs /dev/vdb2 +mkfs.ext4 /dev/mapper/vg0-home +mount /dev/vdb2 /mnt +mkdir /mnt/home +mount /dev/mapper/vg0-home /mnt/home +df -h /mnt /mnt/home +herd start cow-store /mnt +mkdir /mnt/etc +cp /etc/target-config.scm /mnt/etc/config.scm +guix system init /mnt/etc/config.scm /mnt --no-substitutes +sync +reboot\n") + +(define %test-lvm-separate-home-os + (system-test + (name "lvm-separate-home-os") + (description + "Test functionality of an OS installed with a LVM /home partition") + (value + (mlet* %store-monad ((image (run-install %lvm-separate-home-os + %lvm-separate-home-os-source + #:script + %lvm-separate-home-installation-script + #:packages (list lvm2-static) + #:target-size (* 3200 MiB))) + (command (qemu-command/writable-image image))) + (run-basic-test %lvm-separate-home-os + `(,@command) "lvm-separate-home-os"))))) + ;;; ;;; Btrfs root file system. -- cgit v1.2.3 From 89b704a456ef1cdef855a6c483832a05e1117f24 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Fri, 27 Nov 2020 13:56:38 +0100 Subject: services: MySQL: Deprecate 'mysql-service'. * gnu/services/databases.scm (mysql-service): Define in terms of DEFINE-DEPRECATED. * gnu/tests/databases.scm (%mysql-os): Adjust accordingly. * doc/guix.texi (Database Services): Adjust the MariaDB/MySQL section to document MYSQL-SERVICE-TYPE instead of MYSQL-SERVICE. While at it, document the EXTRA-CONTENT field. --- doc/guix.texi | 18 ++++++++++-------- gnu/services/databases.scm | 8 ++------ gnu/tests/databases.scm | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) (limited to 'gnu/tests') diff --git a/doc/guix.texi b/doc/guix.texi index b0126b961d..f0c95f586c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -19121,16 +19121,14 @@ is the key, and the remaining elements are the values. @subsubheading MariaDB/MySQL -@deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)] -Return a service that runs @command{mysqld}, the MySQL or MariaDB -database server. - -The optional @var{config} argument specifies the configuration for -@command{mysqld}, which should be a @code{} object. -@end deffn +@defvr {Scheme Variable} mysql-service-type +This is the service type for a MySQL or MariaDB database server. Its value +is a @code{mysql-configuration} object that specifies which package to use, +as well as various settings for the @command{mysqld} daemon. +@end defvr @deftp {Data Type} mysql-configuration -Data type representing the configuration of @var{mysql-service}. +Data type representing the configuration of @var{mysql-service-type}. @table @asis @item @code{mysql} (default: @var{mariadb}) @@ -19142,6 +19140,10 @@ For MariaDB, the root password is empty. @item @code{port} (default: @code{3306}) TCP port on which the database server listens for incoming connections. + +@item @code{extra-content} (default: @code{""}) +Additional settings for the @file{my.cnf} configuration file. + @end table @end deftp diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index d7b4594b9e..bb0a0c28f2 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -568,12 +568,8 @@ FLUSH PRIVILEGES; mysql-shepherd-service))) (default-value (mysql-configuration)))) -(define* (mysql-service #:key (config (mysql-configuration))) - "Return a service that runs @command{mysqld}, the MySQL or MariaDB -database server. - -The optional @var{config} argument specifies the configuration for -@command{mysqld}, which should be a @code{} object." +(define-deprecated (mysql-service #:key (config (mysql-configuration))) + mysql-service-type (service mysql-service-type config)) diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index d3045cc3f7..1d7f53ec3e 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -271,7 +271,7 @@ (define %mysql-os (simple-operating-system - (mysql-service))) + (service mysql-service-type))) (define* (run-mysql-test) "Run tests in %MYSQL-OS." -- cgit v1.2.3 From e20388ad7f94e72a7a71272a742031fb5c1fbb4b Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Sat, 28 Nov 2020 17:42:22 +0100 Subject: services: MySQL: Upgrade database schemas automatically. * gnu/services/databases.scm (): Add AUTO-UPGRADE? field. (mysql-upgrade-wrapper, mysql-upgrade-shepherd-service, mysql-shepherd-services): New variables. (mysql-service-type): Use MYSQL-SHEPHERD-SERVICES instead of MYSQL-SHEPHERD-SERVICE. * doc/guix.texi (Database Services): Document the AUTO-UPGRADE? field of MYSQL-SERVICE-TYPE. * gnu/tests/databases.scm (run-mysql-test): Test that mysql_upgrade has run. --- doc/guix.texi | 6 ++++++ gnu/services/databases.scm | 52 ++++++++++++++++++++++++++++++++++++++++++++-- gnu/tests/databases.scm | 4 ++++ 3 files changed, 60 insertions(+), 2 deletions(-) (limited to 'gnu/tests') diff --git a/doc/guix.texi b/doc/guix.texi index bef42e160a..2a98dda324 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -19151,6 +19151,12 @@ Socket file to use for local (non-network) connections. @item @code{extra-content} (default: @code{""}) Additional settings for the @file{my.cnf} configuration file. +@item @code{auto-upgrade?} (default: @code{#t}) +Whether to automatically run @command{mysql_upgrade} after starting the +service. This is necessary to upgrade the @dfn{system schema} after +``major'' updates (such as switching from MariaDB 10.4 to 10.5), but can +be disabled if you would rather do that manually. + @end table @end deftp diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 5a88b70d74..60b31e0373 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2018 Clément Lassieur ;;; Copyright © 2018 Julien Lepiller ;;; Copyright © 2019 Robert Vollmert +;;; Copyright © 2020 Marius Bakke ;;; ;;; This file is part of GNU Guix. ;;; @@ -468,7 +469,8 @@ storage: (bind-address mysql-configuration-bind-address (default "127.0.0.1")) (port mysql-configuration-port (default 3306)) (socket mysql-configuration-socket (default "/run/mysqld/mysqld.sock")) - (extra-content mysql-configuration-extra-content (default ""))) + (extra-content mysql-configuration-extra-content (default "")) + (auto-upgrade? mysql-configuration-auto-upgrade? (default #t))) (define %mysql-accounts (list (user-group @@ -559,6 +561,52 @@ FLUSH PRIVILEGES; #:user "mysql" #:group "mysql"))) (stop #~(make-kill-destructor))))) +(define (mysql-upgrade-wrapper mysql socket-file) + ;; The MySQL socket and PID file may appear before the server is ready to + ;; accept connections. Ensure the socket is responsive before attempting + ;; to run the upgrade script. + (program-file + "mysql-upgrade-wrapper" + #~(begin + (let ((mysql-upgrade #$(file-append mysql "/bin/mysql_upgrade")) + (timeout 10)) + (begin + (let loop ((i 0)) + (catch 'system-error + (lambda () + (let ((sock (socket PF_UNIX SOCK_STREAM 0))) + (connect sock AF_UNIX #$socket-file) + (close-port sock) + ;; The socket is ready! + (execl mysql-upgrade mysql-upgrade + (string-append "--socket=" #$socket-file)))) + (lambda args + (if (< i timeout) + (begin + (sleep 1) + (loop (+ 1 i))) + ;; No luck, give up. + (throw 'timeout-error + "MySQL server did not appear in time!")))))))))) + +(define (mysql-upgrade-shepherd-service config) + (list (shepherd-service + (provision '(mysql-upgrade)) + (requirement '(mysql)) + (one-shot? #t) + (documentation "Upgrade MySQL database schemas.") + (start (let ((mysql (mysql-configuration-mysql config)) + (socket (mysql-configuration-socket config))) + #~(make-forkexec-constructor + (list #$(mysql-upgrade-wrapper mysql socket)) + #:user "mysql" #:group "mysql")))))) + +(define (mysql-shepherd-services config) + (if (mysql-configuration-auto-upgrade? config) + (append (mysql-shepherd-service config) + (mysql-upgrade-shepherd-service config)) + (mysql-shepherd-service config))) + (define mysql-service-type (service-type (name 'mysql) @@ -568,7 +616,7 @@ FLUSH PRIVILEGES; (service-extension activation-service-type %mysql-activation) (service-extension shepherd-root-service-type - mysql-shepherd-service))) + mysql-shepherd-services))) (default-value (mysql-configuration)))) (define-deprecated (mysql-service #:key (config (mysql-configuration))) diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index 1d7f53ec3e..dd1af1dbcc 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Christopher Baines +;;; Copyright © 2020 Marius Bakke ;;; ;;; This file is part of GNU Guix. ;;; @@ -311,6 +312,9 @@ ((pid) (number? pid)))))) marionette)) + (test-assert "mysql_upgrade completed" + (wait-for-file "/var/lib/mysql/mysql_upgrade_info" marionette)) + (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) -- cgit v1.2.3 From 97c4fd21bdd7470da91c4a47aab1d6357bdc8080 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Sat, 28 Nov 2020 19:42:22 +0100 Subject: services: MySQL: Add more tests. * gnu/tests/databases.scm (run-mysql-test): Try creating a database and inserting data. --- gnu/tests/databases.scm | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'gnu/tests') diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index dd1af1dbcc..31d5ae4c6a 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -315,6 +315,45 @@ (test-assert "mysql_upgrade completed" (wait-for-file "/var/lib/mysql/mysql_upgrade_info" marionette)) + (test-eq "create database" + 0 + (marionette-eval + '(begin + (system* #$(file-append mariadb "/bin/mysql") + "-e" "CREATE DATABASE guix;")) + marionette)) + + (test-eq "create table" + 0 + (marionette-eval + '(begin + (system* + #$(file-append mariadb "/bin/mysql") "guix" + "-e" "CREATE TABLE facts (id INT, data VARCHAR(12));")) + marionette)) + + (test-eq "insert data" + 0 + (marionette-eval + '(begin + (system* #$(file-append mariadb "/bin/mysql") "guix" + "-e" "INSERT INTO facts VALUES (1, 'awesome')")) + marionette)) + + (test-equal "retrieve data" + "awesome\n" + (marionette-eval + '(begin + (use-modules (ice-9 popen)) + (let* ((port (open-pipe* + OPEN_READ + #$(file-append mariadb "/bin/mysql") "guix" + "-NB" "-e" "SELECT data FROM facts WHERE id=1;")) + (output (get-string-all port))) + (close-pipe port) + output)) + marionette)) + (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) -- cgit v1.2.3