test: fix salvage test imports; drop WAL worker-thread test superseded by read pool

- tests/cron/test_sessiondb_init_hang.py: add threading/time imports the
  salvaged late-close regression tests rely on.
- tests/test_hermes_state.py: drop
  test_close_closes_wal_read_connection_created_on_worker_thread — main
  replaced per-thread WAL reader ownership with the pooled read-connection
  design (permits + checkout/return), so cross-thread reader draining no
  longer exists in the form the test asserted.
This commit is contained in:
Teknium
2026-08-14 20:52:41 -07:00
parent 38709ae6f2
commit dac3c44afc
2 changed files with 2 additions and 35 deletions
+2
View File
@@ -21,6 +21,8 @@ suite stays free of timing flakes under parallel load.
"""
import concurrent.futures
import threading
import time
from unittest.mock import MagicMock, patch
from cron.scheduler import run_job
-35
View File
@@ -177,41 +177,6 @@ class TestConnectionLifecycle:
pass
db.close()
def test_close_closes_wal_read_connection_created_on_worker_thread(
self, tmp_path
):
"""SessionDB.close() must drain read conns created by other threads."""
from hermes_cli.sqlite_safe_read import has_live_connection
db_path = tmp_path / "state.db"
db = SessionDB(db_path=db_path)
db._wal_active = True
opened = threading.Event()
release = threading.Event()
errors = []
def open_read_connection():
try:
assert db._get_read_conn() is not None
opened.set()
release.wait(timeout=10)
except BaseException as exc:
errors.append(exc)
opened.set()
worker = threading.Thread(target=open_read_connection)
worker.start()
assert opened.wait(timeout=10)
assert not errors
db.close()
assert has_live_connection(db_path) is False
release.set()
worker.join(timeout=10)
assert not worker.is_alive()
assert not errors
def test_read_only_close_never_requests_wal_checkpoint(self, tmp_path):
db_path = tmp_path / "state.db"
writable = SessionDB(db_path=db_path)