From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:34514) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ic7dz-0003W9-Fb for guix-patches@gnu.org; Tue, 03 Dec 2019 07:51:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ic7dv-0006YU-Qo for guix-patches@gnu.org; Tue, 03 Dec 2019 07:51:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ic7dv-0006XV-KI for guix-patches@gnu.org; Tue, 03 Dec 2019 07:51:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ic7du-0002gG-ID for guix-patches@gnu.org; Tue, 03 Dec 2019 07:51:02 -0500 Subject: [bug#38429] [PATCH 4/5] scron: add system test Resent-Message-ID: From: Robert Vollmert Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Tue, 3 Dec 2019 13:50:22 +0100 References: <20191203124632.1987-1-rob@vllmrt.net> <20191203124632.1987-4-rob@vllmrt.net> In-Reply-To: <20191203124632.1987-4-rob@vllmrt.net> Message-Id: <1207941E-B025-4E37-88EE-E8AABD91C1CB@vllmrt.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 38429@debbugs.gnu.org I=E2=80=99ve checked that the tests compile, and run the test cron jobs by hand to ensure they behave as tested, but I wasn=E2=80=99t able to = run the system tests themselves. > On 3. Dec 2019, at 13:46, Robert Vollmert wrote: >=20 > --- > gnu/tests/base.scm | 86 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 86 insertions(+) >=20 > diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm > index a891711844..b80e77be66 100644 > --- a/gnu/tests/base.scm > +++ b/gnu/tests/base.scm > @@ -28,6 +28,7 @@ > #:use-module (gnu services dbus) > #:use-module (gnu services avahi) > #:use-module (gnu services mcron) > + #:use-module (gnu services scron) > #:use-module (gnu services shepherd) > #:use-module (gnu services networking) > #:use-module (gnu packages base) > @@ -48,6 +49,7 @@ > %test-halt > %test-cleanup > %test-mcron > + %test-scron > %test-nss-mdns)) >=20 > (define %simple-os > @@ -720,6 +722,90 @@ non-ASCII names from /tmp.") > (description "Make sure the mcron service works as advertised.") > (value (run-mcron-test name)))) >=20 > +=0C > +;;; > +;;; Scron. > +;;; > + > +(define %scron-os > + ;; System with an scron service, with one scron job for "root" and = one scron > + ;; job for an unprivileged user. > + (let ((job1 > + (scron-job > + (schedule "* * * * *") > + (command "(id -u; id -g) > witness"))) > + (job2 > + (scron-job > + (schedule "* * * * *") > + (command "su -c '(id -u; id -g) > ~/witness' alice"))) > + (job3 > + (scron-job > + (schedule "* * * * *") > + (command "touch witness-touch")))) > + (simple-operating-system > + (service scron-service-type > + (scron-configuration (jobs (list job1 job2 job3))))))) > + > +(define (run-scron-test name) > + (define os > + (marionette-operating-system > + %scron-os > + #:imported-modules '((gnu services herd) > + (guix combinators)))) > + > + (define test > + (with-imported-modules '((gnu build marionette)) > + #~(begin > + (use-modules (gnu build marionette) > + (srfi srfi-64) > + (ice-9 match)) > + > + (define marionette > + (make-marionette (list #$(virtual-machine os)))) > + > + (mkdir #$output) > + (chdir #$output) > + > + (test-begin "scron") > + > + (test-assert "service running" > + (marionette-eval > + '(begin > + (use-modules (gnu services herd)) > + (start-service 'scron)) > + marionette)) > + > + ;; Make sure root's scron job runs, has its cwd set to "/", = and > + ;; runs with the right UID/GID. > + (test-equal "root's job" > + '(0 0) > + (wait-for-file "/witness" marionette)) > + > + ;; Likewise for Alice's job. We cannot know what its GID = is since > + ;; it's chosen by 'groupadd', but it's strictly positive. > + (test-assert "alice's job" > + (match (wait-for-file "/home/alice/witness" marionette) > + ((1000 gid) > + (>=3D gid 100)))) > + > + ;; Last, the job that uses a command; allows us to test = whether > + ;; $PATH is sane. > + (test-equal "root's job with command" > + "" > + (wait-for-file "/witness-touch" marionette > + #:read '(@ (ice-9 rdelim) read-string))) > + > + (test-end) > + (exit (=3D (test-runner-fail-count (test-runner-current)) = 0))))) > + > + (gexp->derivation name test)) > + > +(define %test-scron > + (system-test > + (name "scron") > + (description "Make sure the scron service works as advertised.") > + (value (run-scron-test name)))) > + >=20 > ;;; > ;;; Avahi and NSS-mDNS. > --=20 > 2.24.0 >=20