1
0
mirror of https://github.com/home-assistant/operating-system.git synced 2025-12-24 20:35:31 +00:00

Improve handling of timeouts in tests (#2890)

* Improve handling of timeouts in tests

Make timeout handling in tests more transparent. Added a custom shell
driver that allows to define global timeout for commands in the config
file, and replaced for/sleep constructs with infinite loops that will be
eventually terminated by pytest-timeout plugin. Current timeouts taken
from last runs on Github CI with some extra headroom.

* test_supervisor_is_updated shouldn't be skipped if no update was needed

* Allow more time for system startup

* Allow even more time for system startup
This commit is contained in:
Jan Čermák
2023-10-31 18:16:49 +01:00
committed by GitHub
parent c33fc03fd6
commit 2888ccf28e
7 changed files with 53 additions and 32 deletions

View File

@@ -4,6 +4,7 @@ import os
import attr
from labgrid import target_factory, step
from labgrid.driver import ShellDriver
from labgrid.strategy import Strategy, StrategyError
@@ -13,6 +14,19 @@ class Status(enum.Enum):
shell = 2
@target_factory.reg_driver
@attr.s(eq=False)
class CustomTimeoutShellDriver(ShellDriver):
"""ShellDriver with a config-customizable timeout for run and run_check."""
command_timeout = attr.ib(default=30, validator=attr.validators.instance_of(int))
def run(self, cmd: str, *, timeout=None, codec="utf-8", decodeerrors="strict"):
return super().run(cmd, timeout=timeout or self.command_timeout, codec=codec, decodeerrors=decodeerrors)
def run_check(self, cmd: str, *, timeout=None, codec="utf-8", decodeerrors="strict"):
return super().run_check(cmd, timeout=timeout or self.command_timeout, codec=codec, decodeerrors=decodeerrors)
@target_factory.reg_driver
@attr.s(eq=False)
class QEMUShellStrategy(Strategy):
@@ -20,7 +34,7 @@ class QEMUShellStrategy(Strategy):
bindings = {
"qemu": "QEMUDriver",
"shell": "ShellDriver",
"shell": "CustomTimeoutShellDriver",
}
status = attr.ib(default=Status.unknown)