nixos/test-driver: add wait_for_unit() timeout arg

For example, the wait_for_unit() call in the Moodle test times out for
myself and others[1], so it would be good to be able to increase it to
something less likely to be hit by a test that would otherwise pass.

[1]: https://github.com/NixOS/nixpkgs/pull/177052#issue-1266336706
This commit is contained in:
Alyssa Ross 2022-09-02 18:06:03 +00:00
parent 22a5797173
commit 488412a1db
No known key found for this signature in database
GPG Key ID: F9DBED4859B271C0

View File

@ -426,7 +426,9 @@ class Machine:
self.monitor.send(message)
return self.wait_for_monitor_prompt()
def wait_for_unit(self, unit: str, user: Optional[str] = None) -> None:
def wait_for_unit(
self, unit: str, user: Optional[str] = None, timeout: int = 900
) -> None:
"""Wait for a systemd unit to get into "active" state.
Throws exceptions on "failed" and "inactive" states as well as
after timing out.
@ -456,7 +458,7 @@ class Machine:
unit, f" with user {user}" if user is not None else ""
)
):
retry(check_active)
retry(check_active, timeout)
def get_unit_info(self, unit: str, user: Optional[str] = None) -> Dict[str, str]:
status, lines = self.systemctl('--no-pager show "{}"'.format(unit), user)