mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-26 17:38:36 +00:00
test(sessions): prove the connector reached the lock before asserting blocked
Closes the last false-pass window @helix4u flagged on #71779. He explicitly said not to hold the PR for it; it is two lines, so worth doing rather than leaving a known-soft assertion in a concurrency test. connection_opened.wait(1.0) proved the connection had not opened, but not that the connector thread had actually reached connect_tracked() -- an unscheduled thread produces the same observation. The connector now sets connect_attempted immediately before the blocking call, and the test waits on that first, so "still blocked" means blocked at the lock rather than not yet started. 15/15 stable at ~1.1s. Removed-lock sabotage still fails.
This commit is contained in:
parent
c8aa0c7a34
commit
36926af266
1 changed files with 8 additions and 1 deletions
|
|
@ -315,6 +315,7 @@ def test_snapshot_blocks_connections_opened_during_the_copy(
|
|||
|
||||
inside_copy = threading.Event()
|
||||
release_copy = threading.Event()
|
||||
connect_attempted = threading.Event()
|
||||
connection_opened = threading.Event()
|
||||
errors: list[str] = []
|
||||
real_copy2 = recovery_module.shutil.copy2
|
||||
|
|
@ -333,6 +334,10 @@ def test_snapshot_blocks_connections_opened_during_the_copy(
|
|||
errors.append(f"copy failed: {exc}")
|
||||
|
||||
def do_connect():
|
||||
# Signal immediately before the blocking call so a timed "still
|
||||
# blocked" assertion cannot pass merely because this thread had not
|
||||
# been scheduled yet.
|
||||
connect_attempted.set()
|
||||
try:
|
||||
conn = connect_tracked(source, isolation_level=None, timeout=30.0)
|
||||
connection_opened.set()
|
||||
|
|
@ -348,7 +353,9 @@ def test_snapshot_blocks_connections_opened_during_the_copy(
|
|||
assert inside_copy.wait(30), "copy never reached the patched operation"
|
||||
|
||||
connector.start()
|
||||
# While the copy holds the lifecycle lock the connection must not open.
|
||||
assert connect_attempted.wait(30), "connector thread never started"
|
||||
# The connector is at the lock. While the copy holds it, the
|
||||
# connection must not open.
|
||||
assert not connection_opened.wait(1.0), (
|
||||
"connect_tracked() completed while raw copy descriptors were open "
|
||||
"— the guard is not holding the lifecycle lock across the copy"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue