Skip to content

Commit 4159bed

Browse files
[iris] Isolate per-test ThreadContainer to drop 5s controller test teardowns
Controller tests under lib/iris/tests/cluster/controller that construct a Controller without calling .stop() leak the non-daemon log-server uvicorn thread, tripping the top-level _thread_cleanup autouse fixture's 5s wait. Install thread_container_scope as an autouse fixture so the container's on_stop hook signals server.should_exit and the thread exits immediately. Fixes #4872
1 parent 8400841 commit 4159bed

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/iris/tests/cluster/controller/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import pytest
1414

15+
from iris.managed_thread import thread_container_scope
1516
from iris.cluster.bundle import BundleStore
1617
from iris.cluster.constraints import (
1718
Constraint,
@@ -112,6 +113,17 @@ def close(self) -> None:
112113
pass
113114

114115

116+
@pytest.fixture(autouse=True)
117+
def _isolated_thread_container():
118+
"""Install a per-test ThreadContainer so Controller-spawned threads are
119+
stopped at test end. Without this, tests that construct a Controller but
120+
never call ``.stop()`` leak the uvicorn log-server thread and hit the 5s
121+
leak-detection wait in the top-level ``_thread_cleanup`` fixture.
122+
"""
123+
with thread_container_scope(name="controller-test"):
124+
yield
125+
126+
115127
@pytest.fixture
116128
def state():
117129
"""Create a fresh ControllerTransitions with temp DB and log store."""

0 commit comments

Comments
 (0)