fix(tests): add 5-second timeout to docker_available() to prevent hang on KVM runner
test / integration-firecracker (pull_request) Successful in 5s
test / integration-docker (pull_request) Successful in 9s
test / unit (pull_request) Successful in 31s
lint / lint (push) Successful in 44s
test / coverage (pull_request) Failing after 1h49m32s

On the self-hosted KVM runner Docker is on PATH but the daemon socket
is unreachable (firewalled/dropped). subprocess.run(["docker", "info"])
with no timeout hangs indefinitely on a dropped connection, stalling the
coverage job for hours — one hang per @skip_unless_docker()-decorated
class, ~8 per integration suite run.

Add timeout=5 with a TimeoutExpired → False fallback so the check
resolves quickly to "unreachable" rather than blocking.
This commit is contained in:
2026-07-19 00:56:43 +00:00
parent f5fec38ca8
commit 2edb22bfbd
+13 -9
View File
@@ -10,15 +10,19 @@ import unittest
def docker_available() -> bool: def docker_available() -> bool:
if shutil.which("docker") is None: if shutil.which("docker") is None:
return False return False
return ( try:
subprocess.run( return (
["docker", "info"], subprocess.run(
stdout=subprocess.DEVNULL, ["docker", "info"],
stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
check=False, stderr=subprocess.DEVNULL,
).returncode check=False,
== 0 timeout=5,
) ).returncode
== 0
)
except subprocess.TimeoutExpired:
return False
def skip_unless_docker(reason: str = "docker unreachable"): def skip_unless_docker(reason: str = "docker unreachable"):