all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Giacomo Leidi via Guix-patches via <guix-patches@gnu.org>
To: 75203@debbugs.gnu.org
Cc: Giacomo Leidi <goodoldpaul@autistici.org>
Subject: [bug#75203] [PATCH v2 1/2] services: tests: Add delay for rootless Podman system test.
Date: Mon,  6 Jan 2025 22:05:51 +0100	[thread overview]
Message-ID: <d60af6778225b87f6f9f94fcdaf46eaec849384d.1736197552.git.goodoldpaul@autistici.org> (raw)
In-Reply-To: <1881b153-9191-4322-8c71-195b5eef5651@autistici.org>

* gnu/tests/containers.scm (run-rootless-podman-test): Add 60 seconds
long delay before tests are actually run.

Change-Id: Ifcf70f7258f9e0886bf829884d7daedc9803352b
---
 gnu/tests/containers.scm | 113 +++++++++++++++++++++------------------
 1 file changed, 60 insertions(+), 53 deletions(-)

diff --git a/gnu/tests/containers.scm b/gnu/tests/containers.scm
index ba2fb22df6..69cd311c82 100644
--- a/gnu/tests/containers.scm
+++ b/gnu/tests/containers.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org>
+;;; Copyright © 2024, 2025 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -97,17 +97,65 @@ (define (run-rootless-podman-test oci-tarball)
 
           (test-runner-current (system-test-runner #$output))
           (test-begin "rootless-podman")
-
-          (test-assert "service started"
-            (marionette-eval
-             '(begin
-                (use-modules (gnu services herd))
-                (match (start-service 'cgroups2-fs-owner)
-                  (#f #f)
-                  ;; herd returns (running #f), likely because of one shot,
-                  ;; so consider any non-error a success.
-                  (('service response-parts ...) #t)))
-             marionette))
+          (marionette-eval
+           '(begin
+              (use-modules (gnu services herd))
+              (wait-for-service 'file-system-/sys/fs/cgroup))
+           marionette)
+
+          (test-assert "services started successfully and /sys/fs/cgroup has correct permissions"
+            (begin
+              (define (run-test)
+                (marionette-eval
+                 `(begin
+                    (use-modules (ice-9 popen)
+                                 (ice-9 match)
+                                 (ice-9 rdelim))
+
+                    (define (read-lines file-or-port)
+                      (define (loop-lines port)
+                        (let loop ((lines '()))
+                          (match (read-line port)
+                            ((? eof-object?)
+                             (reverse lines))
+                            (line
+                             (loop (cons line lines))))))
+
+                      (if (port? file-or-port)
+                          (loop-lines file-or-port)
+                          (call-with-input-file file-or-port
+                            loop-lines)))
+
+                    (define slurp
+                      (lambda args
+                        (let* ((port (apply open-pipe* OPEN_READ args))
+                               (output (read-lines port))
+                               (status (close-pipe port)))
+                          output)))
+                    (let* ((bash
+                            ,(string-append #$bash "/bin/bash"))
+                           (response1
+                            (slurp bash "-c"
+                                   (string-append "ls -la /sys/fs/cgroup | "
+                                                  "grep -E ' \\./?$' | awk '{ print $4 }'")))
+                           (response2 (slurp bash "-c"
+                                             (string-append "ls -l /sys/fs/cgroup/cgroup"
+                                                            ".{procs,subtree_control,threads} | "
+                                                            "awk '{ print $4 }' | sort -u"))))
+                      (list (string-join response1 "\n") (string-join response2 "\n"))))
+                 marionette))
+              ;; Allow services to come up on slower machines
+              (let loop ((attempts 0))
+                (if (= attempts 60)
+                    (error "Services didn't come up after more than 60 seconds")
+                    (if (equal? '("cgroup" "cgroup")
+                                (run-test))
+                        #t
+                        (begin
+                          (sleep 1)
+                          (format #t "Services didn't come up yet, retrying with attempt ~a~%"
+                                  (+ 1 attempts))
+                          (loop (+ 1 attempts))))))))
 
           (test-equal "/sys/fs/cgroup/cgroup.subtree_control content is sound"
             (list "cpu" "cpuset" "memory" "pids")
@@ -144,47 +192,6 @@ (define (run-rootless-podman-test oci-tarball)
                   (sort-list (string-split (first response1) #\space) string<?)))
              marionette))
 
-          (test-equal "/sys/fs/cgroup has correct permissions"
-            '("cgroup" "cgroup")
-            (marionette-eval
-             `(begin
-                (use-modules (ice-9 popen)
-                             (ice-9 match)
-                             (ice-9 rdelim))
-
-                (define (read-lines file-or-port)
-                  (define (loop-lines port)
-                    (let loop ((lines '()))
-                      (match (read-line port)
-                        ((? eof-object?)
-                         (reverse lines))
-                        (line
-                         (loop (cons line lines))))))
-
-                  (if (port? file-or-port)
-                      (loop-lines file-or-port)
-                      (call-with-input-file file-or-port
-                        loop-lines)))
-
-                (define slurp
-                  (lambda args
-                    (let* ((port (apply open-pipe* OPEN_READ args))
-                           (output (read-lines port))
-                           (status (close-pipe port)))
-                      output)))
-                (let* ((bash
-                        ,(string-append #$bash "/bin/bash"))
-                       (response1
-                        (slurp bash "-c"
-                               (string-append "ls -la /sys/fs/cgroup | "
-                                              "grep -E ' \\./?$' | awk '{ print $4 }'")))
-                       (response2 (slurp bash "-c"
-                                         (string-append "ls -l /sys/fs/cgroup/cgroup"
-                                                        ".{procs,subtree_control,threads} | "
-                                                        "awk '{ print $4 }' | sort -u"))))
-                  (list (string-join response1 "\n") (string-join response2 "\n"))))
-             marionette))
-
           (test-equal "Load oci image and run it (unprivileged)"
             '("hello world" "hi!" "JSON!" #o1777)
             (marionette-eval

base-commit: ee3673217b82d50e97434ae85145b8d68f077446
-- 
2.47.1





  parent reply	other threads:[~2025-01-06 21:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-30 15:54 [bug#75203] Fix rootless podman system tests and support I/O delegation paul via Guix-patches via
2024-12-30 15:55 ` [bug#75203] [PATCH 1/2] services: tests: Add delay for rootless Podman system test Giacomo Leidi via Guix-patches via
2024-12-30 15:55   ` [bug#75203] [PATCH 2/2] services: rootless-podman: Enable I/O delegation Giacomo Leidi via Guix-patches via
2024-12-31 12:58   ` [bug#75203] [PATCH 1/2] services: tests: Add delay for rootless Podman system test Tomas Volf
2025-01-06 21:05     ` paul via Guix-patches via
2025-01-06 21:05 ` Giacomo Leidi via Guix-patches via [this message]
2025-01-06 21:05   ` [bug#75203] [PATCH v2 2/2] services: rootless-podman: Enable I/O delegation Giacomo Leidi via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d60af6778225b87f6f9f94fcdaf46eaec849384d.1736197552.git.goodoldpaul@autistici.org \
    --to=guix-patches@gnu.org \
    --cc=75203@debbugs.gnu.org \
    --cc=goodoldpaul@autistici.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.