From af2f1402ff58fe794879f5e3c5288da4c3dcb00f 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 | 12 +++++++++++- 1 file changed, 11 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..e1757c3950b 100644 --- a/cmd/nerdctl/container_run_systemd_linux_test.go +++ b/cmd/nerdctl/container_run_systemd_linux_test.go @@ -46,7 +46,17 @@ 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 systemctl is-system-running >/dev/null 2>&1; do + >&2 printf "Waiting for systemd to come up...\n" + sleep 1s + tries=$(( tries + 1)) + [ $tries -lt 10 ] || { + >&2 printf "systemd failed to come up in a reasonable amount of time\n" + exit 1 + } +done +systemctl list-jobs`).AssertOutContains("jobs") } func TestRunWithSystemdTrueDisabled(t *testing.T) {