From 624cc2557bde0d379ec40e9ca40279ea804e3c77 Mon Sep 17 00:00:00 2001 From: apostasie Date: Sat, 6 Jul 2024 14:35:55 -0700 Subject: [PATCH] Fix test: wait for systemd to come up Signed-off-by: apostasie --- cmd/nerdctl/container_run_systemd_linux_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/nerdctl/container_run_systemd_linux_test.go b/cmd/nerdctl/container_run_systemd_linux_test.go index 770c62a438f..546f82b66bb 100644 --- a/cmd/nerdctl/container_run_systemd_linux_test.go +++ b/cmd/nerdctl/container_run_systemd_linux_test.go @@ -46,7 +46,16 @@ func TestRunWithSystemdTrueEnabled(t *testing.T) { base.Cmd("inspect", "--format", "{{json .Config.Labels}}", containerName).AssertOutContains("SIGRTMIN+3") - base.Cmd("exec", containerName, "systemctl", "list-jobs").AssertOutContains("jobs listed.") + base.Cmd("exec", containerName, "sh", "-c", "--", `tries=0 +until [ -e /run/systemd/io.system.ManagedOOM ]; do + sleep 1s + tries=$(( tries + 1)) + [ $tries -lt 10 ] || { + >&2 printf "Failed waiting for systemd to come up in a reasonable amount of time\n" + exit 1 + } +done +systemctl list-jobs`).AssertOutContains("jobs listed.") } func TestRunWithSystemdTrueDisabled(t *testing.T) {