tests: oci-container: Set explicit timeouts.

* gnu/tests/docker.scm: Simplify %test-oci-container test case and add
explicit timeouts to tests outcomes.

Change-Id: I75868479dcce031f3edc98064b1ebcf975f598f5
Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop>
This commit is contained in:
Giacomo Leidi 2025-08-24 16:59:44 +02:00 committed by Maxim Cournoyer
parent 0aef9716b6
commit d6200cefcc
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -1,7 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org>
;;; Copyright © 2019-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2024, 2025 Giacomo Leidi <goodoldpaul@autistici.org>
;;;
;;; This file is part of GNU Guix.
;;;
@ -414,46 +414,19 @@ docker-image} inside Docker.")
(test-runner-current (system-test-runner #$output))
(test-begin "oci-container")
(test-assert "containerd service running"
(marionette-eval
'(begin
(use-modules (gnu services herd))
(match (start-service 'containerd)
(#f #f)
(('service response-parts ...)
(match (assq-ref response-parts 'running)
((pid) pid)))))
marionette))
(test-assert "containerd PID file present"
(wait-for-file "/run/containerd/containerd.pid" marionette))
(test-assert "dockerd running"
(marionette-eval
'(begin
(use-modules (gnu services herd))
(match (start-service 'dockerd)
(#f #f)
(('service response-parts ...)
(match (assq-ref response-parts 'running)
((pid) pid)))))
marionette))
(sleep 10) ; let service start
(wait-for-file "/run/containerd/containerd.pid" marionette)
(test-assert "docker-guile running"
(marionette-eval
'(begin
(use-modules (gnu services herd))
(match (start-service 'docker-guile)
(#f #f)
(('service response-parts ...)
(match (assq-ref response-parts 'running)
((pid) pid)))))
(wait-for-service 'docker-guile #:timeout 120)
#t)
marionette))
(test-equal "passing host environment variables and volumes"
'("value" "hello")
(test-assert "passing host environment variables and volumes"
(begin
(define (run-test)
(marionette-eval
`(begin
(use-modules (ice-9 popen)
@ -479,6 +452,16 @@ docker-image} inside Docker.")
(display (call-with-input-file \"/shared.txt\" read-line)))")))
(list response1 response2)))
marionette))
;; Allow services to come up on slower machines
(let loop ((attempts 0))
(if (= attempts 60)
(error "Service didn't come up after more than 60 seconds")
(if (equal? '("value" "hello")
(run-test))
#t
(begin
(sleep 1)
(loop (+ 1 attempts))))))))
(test-end))))