Skip to content
Draft
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ def wait_for(fn: Callable[[], object], msg: str | None = None, timeout_secs: int
return
if time.perf_counter() - start_time >= timeout_secs:
expected = 'True' if not invert else 'False'
suffix = ": " + msg if msg else ""
raise TimeoutError(
"Timeout reached while waiting for fn call to yield %s (%s)." % (expected, timeout_secs)
"Timed out after %ss waiting for condition to be %s%s" % (timeout_secs, expected, suffix)
Comment on lines -209 to +210

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

An example output would help

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

previously, it looked like:

FAILED tests/unit/test_rescan_block_devices_info.py::test_timeout - TimeoutError: Timeout reached while waiting for fn call to yield True (10).

with this change:

FAILED tests/unit/test_rescan_block_devices_info.py::test_timeout - TimeoutError: Timed out after 10s waiting for condition to be True: Wait for coalesce.

)
time.sleep(retry_delay_secs)

Expand Down
29 changes: 18 additions & 11 deletions tests/system/test_systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import re

from lib.common import wait_for
from lib.host import Host

# Requirements:
Expand All @@ -23,14 +24,20 @@ def test_failed_units(host: Host) -> None:

pytest.fixture(scope='module')
def test_verify_default_target(host: Host) -> None:
analyse = host.ssh('systemd-analyze verify default.target')
err = False
polkit_msg = "Cannot add dependency job for unit polkit.service, ignoring: Unit not found."
for line in analyse.splitlines():
if line == polkit_msg:
pytest.xfail(f"drbd-reactor package must be fixed to remove dep to polkit: {polkit_msg}")
if line not in white_list_issues:
logging.error(f"{line}")
err = True

assert not err
def analyse_default_target() -> bool:
# Look at what is using memory
# TODO: to remove
host.ssh('ps -eo pid,ppid,%mem,rss,args ww --sort=-rss | head -n 11')
host.ssh('free')

analyse = host.ssh('systemd-analyze verify default.target')
polkit_msg = "Cannot add dependency job for unit polkit.service, ignoring: Unit not found."
for line in analyse.splitlines():
if line == polkit_msg:
pytest.xfail(f"drbd-reactor package must be fixed to remove dep to polkit: {polkit_msg}")
if line not in white_list_issues:
logging.error(f"{line}")
return False
return True

wait_for(analyse_default_target, "Wait for systemd-analyze verify default.target to be clean")