test(state): make FTS retry timing assertion causal
The macOS holder scan can take longer than two seconds under CI load even though the rebuild admission uses its non-blocking timeout. Assert that the real child process still holds the real lock when the retry returns instead. This preserves the timeout contract without timing the unrelated open-file scan.
This commit is contained in:
1 parent
01c22b8373
commit
28c3a010fa
1 file changed
+6
-5
@@ -524,18 +524,19 @@ class TestDeferredFtsRetryInProcess:
|
||||
d.close()
|
||||
self._mark_stale(db_path)
|
||||
|
||||
with _rebuild_lock_held_by_other_process(db_path):
|
||||
with _rebuild_lock_held_by_other_process(db_path) as holder:
|
||||
gw = SessionDB(db_path=db_path) # long-lived "gateway" open
|
||||
try:
|
||||
assert gw._fts_stale is True
|
||||
# Live holder: the retry must return quickly (timeout=0),
|
||||
# not wait out any admission budget.
|
||||
# Live holder: the retry uses timeout=0 rather than waiting out
|
||||
# the configured admission budget. Prove that contract from the
|
||||
# holder's liveness; a wall-clock bound also measures macOS's
|
||||
# load-dependent process open-file scan.
|
||||
monkeypatch.setattr(
|
||||
hermes_state_common, "_FTS_REBUILD_LOCK_TIMEOUT_SECONDS", 30.0
|
||||
)
|
||||
t0 = time.monotonic()
|
||||
assert gw.retry_deferred_fts_recovery() is False
|
||||
assert time.monotonic() - t0 < 2.0
|
||||
assert holder.poll() is None
|
||||
assert gw._fts_stale is True
|
||||
# Rate limit engaged: an immediate second call is a no-op.
|
||||
assert gw.retry_deferred_fts_recovery() is False
|
||||
|
||||
Reference in new issue
Block a user