fix(archive): preserve prepared sessions across restarts

This commit is contained in:
DCCONSTRUCTIONS
2026-07-18 11:08:27 +03:00
parent aa3680948f
commit 574a494759
13 changed files with 398 additions and 132 deletions
+40
View File
@@ -231,6 +231,46 @@ def test_manager_can_restart_across_repeated_application_lifespans(tmp_path: Pat
manager.close()
def test_published_package_restores_after_process_restart_without_export(
tmp_path: Path,
) -> None:
command = _command(tmp_path / "session")
private_root = tmp_path / "private"
calls = 0
def exporter(source: Path, destination: Path) -> dict[str, object]:
nonlocal calls
calls += 1
return _summary(source, destination, b"durable-recording")
first = SessionRecordingPreparationManager(
SessionRecordingMaterializer(private_root, exporter=exporter)
)
try:
first.enqueue(command)
ready = _wait_for_state(first, command.session_id, {"ready"})
assert ready.recording is not None
finally:
first.close()
def forbidden_exporter(_source: Path, _destination: Path) -> dict[str, object]:
raise AssertionError("a published package must not be exported again")
restarted = SessionRecordingPreparationManager(
SessionRecordingMaterializer(private_root, exporter=forbidden_exporter)
)
try:
restored = restarted.restore_published(command)
assert restored is not None
assert restored.state == "ready"
assert restored.recording is not None
assert restored.recording.path.read_bytes() == b"durable-recording"
assert calls == 1
finally:
restarted.close()
def test_noncooperative_exporter_has_no_fake_heartbeat_and_restart_waits_for_old_writer(
tmp_path: Path,
) -> None: