Skip to content

The agent that grows with you

test: verify ordinary daemon replay and release fixture stores

Tekniume8f57b7fbcfa
diff --git a/tests/gateway/test_authority_events.py b/tests/gateway/test_authority_events.py
index 6640e04dfc0..9bedeec264a 100644
--- a/tests/gateway/test_authority_events.py
+++ b/tests/gateway/test_authority_events.py
@@ -120,4 +120,4 @@ async def test_replay_matches_subscription_watermark_or_requires_snapshot(tmp_pa
finally:
await a.close()
await b.close()
- db.close()
+ store.close_all_db_handles()
diff --git a/tests/gateway/test_normal_runtime_boot.py b/tests/gateway/test_normal_runtime_boot.py
index da06028ecb2..8050deb8fd4 100644
--- a/tests/gateway/test_normal_runtime_boot.py
+++ b/tests/gateway/test_normal_runtime_boot.py
@@ -84,6 +84,7 @@ async def handshake(home, descriptor):
created = await rpc(ws, 'session.create', request_id='ordinary-launch', source='cli')
sid = created['session_id']
assert sid == created['stored_session_id']
+ initial = await rpc(ws, 'session.resume', session_id=sid)
admitted = await rpc(ws, 'prompt.submit', session_id=sid, input_id='ordinary-input', text='WS_SHARED')
assert admitted['status'] == 'queued', admitted
# A fresh control ticket and socket must see the same committed execution.
@@ -97,6 +98,22 @@ async def handshake(home, descriptor):
break
await asyncio.sleep(.05)
assert snapshot['stored_session_id'] == sid
+ # Transcript persistence precedes terminal publication; await the actual
+ # replay receipt rather than assuming a persisted reply means settlement.
+ async with asyncio.timeout(25):
+ while True:
+ replay = await rpc(viewer, 'session.events.since', session_id=sid,
+ replay_epoch=initial['replay_epoch'],
+ last_sequence=initial['last_sequence'])
+ assert not replay['snapshot_required'], replay
+ completed = [event for event in replay['events'] if event['type'] == 'message.complete']
+ if completed:
+ break
+ await asyncio.sleep(.05)
+ assert len(completed) == 1, replay
+ assert 'LOCAL_ACK_WS_SHARED' in completed[0]['payload']['text'], replay
+ snapshot = await rpc(viewer, 'session.resume', session_id=sid)
+ assert completed[0]['seq'] <= snapshot['last_sequence']
edit = {'session_id': sid, 'request_id': 'ordinary-rename',
'expected_revision': snapshot['revision'], 'operation': 'rename',
'payload': {'title': 'Shared metadata receipt'}}
@@ -110,7 +127,7 @@ async def handshake(home, descriptor):
**{**edit, 'request_id': 'stale-rename', 'payload': {'title': 'Stale overwrite'}})
listing = await rpc(viewer, 'session.list')
assert next(row for row in listing['sessions'] if row['session_id'] == sid)['title'] == renamed['title']
- print(json.dumps({'ordinary_created_session': sid, 'reply_persisted': True,
+ print(json.dumps({'ordinary_created_session': sid, 'reply_persisted': True, 'reconnect_event_replay': True,
'mutation_retry_after_reconnect': True, 'stale_mutation_rejected': True}))
with pytest.raises(InvalidStatus):
async with connect(url, subprotocols=protocols):
diff --git a/tests/gateway/test_replace_child_reap.py b/tests/gateway/test_replace_child_reap.py
index 86b60de90c8..b8d047f00cd 100644
--- a/tests/gateway/test_replace_child_reap.py
+++ b/tests/gateway/test_replace_child_reap.py
@@ -195,6 +195,7 @@ async def test_start_gateway_replace_reaps_old_gateway_children_posix(
return True
async def stop(self):
+ self.session_store.close_all_db_handles()
self._session_db.close()
_pid_state = {"alive": True}
diff --git a/tests/gateway/test_runner_startup_failures.py b/tests/gateway/test_runner_startup_failures.py
index df31e462b9e..02d8e55ad38 100644
--- a/tests/gateway/test_runner_startup_failures.py
+++ b/tests/gateway/test_runner_startup_failures.py
@@ -109,6 +109,7 @@ async def test_start_gateway_verbosity_imports_redacting_formatter(monkeypatch,
return True
async def stop(self):
+ self.session_store.close_all_db_handles()
self._session_db.close()
monkeypatch.setattr("gateway.status.get_running_pid", lambda: None)
@@ -255,6 +256,7 @@ async def test_start_gateway_replace_writes_takeover_marker_before_sigterm(
return True
async def stop(self):
+ self.session_store.close_all_db_handles()
self._session_db.close()
_pid_state = {"alive": True}
@@ -470,6 +472,7 @@ async def test_start_gateway_propagates_fatal_config_exit_code(monkeypatch, tmp_
return True
async def stop(self):
+ self.session_store.close_all_db_handles()
self._session_db.close()
monkeypatch.setattr("gateway.status.get_running_pid", lambda: None)
diff --git a/tests/gateway/test_startup_restart_race.py b/tests/gateway/test_startup_restart_race.py
index 45305c70deb..33e3407f8b5 100644
--- a/tests/gateway/test_startup_restart_race.py
+++ b/tests/gateway/test_startup_restart_race.py
@@ -215,6 +215,7 @@ async def test_start_gateway_does_not_start_cron_after_aborted_startup(tmp_path,
return None
async def stop(self):
+ self.session_store.close_all_db_handles()
self._session_db.close()
def fail_if_cron_starts(*args, **kwargs):
@@ -267,6 +268,7 @@ async def test_start_gateway_preserves_service_restart_fallback_after_aborted_st
return None
async def stop(self):
+ self.session_store.close_all_db_handles()
self._session_db.close()
def fail_if_cron_starts(*args, **kwargs):
@@ -328,6 +330,7 @@ async def test_start_gateway_classifies_startup_signal_exit(
return None
async def stop(self):
+ self.session_store.close_all_db_handles()
self._session_db.close()
def capture_signal_state(runner, state):