Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI test fix: wait for systemd to come up #3198

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cmd/nerdctl/container_run_systemd_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use AssertOutWithFunc to check stdout == "No jobs running." || stdout == "jobs listed"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see the point in testing stdout at all here.

We should not be in the business of testing systemd, especially on matching random mundane non-error messages.
What matters here is that systemd is up and running (exit code 0), and that we have a test that does not fail randomly (that is the point of this PR).

I would rather leave this stuff as-is for now - until we come back here to write more useful versions of these tests.

What do you think?

}

func TestRunWithSystemdTrueDisabled(t *testing.T) {
Expand Down