diff --git a/cmd/nerdctl/container_run_systemd_linux_test.go b/cmd/nerdctl/container_run_systemd_linux_test.go index 770c62a438f..80d39128419 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 5 ] || { + >&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) {