Skip to content

Commit cac70b1

Browse files
committed
test: count only polling waits in the idle dispatcher test, and drop a stale host root
The idle dispatcher test counted every Condition wait on other threads, so a busy runner's unrelated waits failed it; it now counts only waits shorter than the idle safety timeout, which polling would add. migration_relation_for_location is no longer a native host entry, so it is no longer a dead-code root; Python code still uses it.
1 parent 9da0446 commit cac70b1

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎fensu.toml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,6 @@ modules = ["sqlbuild.executor.load.models"]
467467
symbols = ["LoadCallbacks", "LoadExecutionResult", "LoadRuntimeParams"]
468468
reason = "Native code resolves these through the sqlbuild._native_host name table."
469469

470-
[[targets.python.dead_code.roots]]
471-
modules = ["sqlbuild.executor.migrations._helpers.relation_for_location"]
472-
symbols = ["migration_relation_for_location"]
473-
reason = "Native code resolves these through the sqlbuild._native_host name table."
474-
475470
[[targets.python.dead_code.roots]]
476471
modules = ["sqlbuild.executor.old_name_views._helpers.janitor"]
477472
symbols = ["is_compatibility_view"]

‎tests/unit/src/sqlbuild/runtime/event_exporting/classes/_test_types.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class IdleDispatcherTestCase:
66
description: str
77
idle_seconds: float
8+
polling_seconds: float
89
expected_max_waits: int
910
expected_max_delivery_seconds: float
1011

‎tests/unit/src/sqlbuild/runtime/event_exporting/classes/test_dispatcher.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def publish(*, event: LifecycleEvent) -> None:
130130
IdleDispatcherTestCase(
131131
description="an idle dispatcher waits for work instead of polling",
132132
idle_seconds=0.5,
133+
polling_seconds=0.5,
133134
expected_max_waits=10,
134135
expected_max_delivery_seconds=0.5,
135136
),
@@ -165,7 +166,11 @@ def publish(*, event: LifecycleEvent) -> None:
165166
time.sleep(0.05)
166167
waits.clear()
167168
time.sleep(test_case.idle_seconds)
168-
idle_waits: int = sum(thread != caller_thread for thread, _ in waits)
169+
# Other threads of a busy process wait too; only waits shorter than the idle safety timeout poll.
170+
idle_waits: int = sum(
171+
thread != caller_thread and timeout is not None and timeout < test_case.polling_seconds
172+
for thread, timeout in waits
173+
)
169174
started: float = time.monotonic()
170175
dispatcher.enqueue(lifecycle_event())
171176

0 commit comments

Comments
 (0)