fix(runtime): fail closed on offline artifact misses
This commit is contained in:
@@ -15,6 +15,7 @@ import pytest
|
||||
import k1link.sessions.recording as recording_module
|
||||
from k1link.artifact_gateway import (
|
||||
ArtifactGateway,
|
||||
ArtifactStoreUnavailable,
|
||||
CentralArtifactStore,
|
||||
LocalArtifactCache,
|
||||
)
|
||||
@@ -184,7 +185,7 @@ def test_materializer_restores_exact_central_recording_without_export(
|
||||
assert exporter.calls == 0
|
||||
|
||||
|
||||
def test_default_recording_cache_has_no_application_byte_quota(
|
||||
def test_default_recording_cache_has_a_bounded_application_quota(
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
@@ -195,7 +196,42 @@ def test_default_recording_cache_has_no_application_byte_quota(
|
||||
exporter=FakeExporter(),
|
||||
)
|
||||
|
||||
assert materializer.cache_max_bytes is None
|
||||
assert materializer.cache_max_bytes == 8 * 1024 * 1024 * 1024
|
||||
|
||||
|
||||
def test_materializer_does_not_rebuild_when_central_store_is_offline(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
command = _command(tmp_path / "source")
|
||||
exporter = FakeExporter()
|
||||
|
||||
class OfflineGateway:
|
||||
def resolve_role(
|
||||
self,
|
||||
namespace: str,
|
||||
key: str,
|
||||
role: str,
|
||||
) -> object:
|
||||
assert (namespace, key, role) == (
|
||||
"sessions",
|
||||
command.session_id,
|
||||
"base-rrd",
|
||||
)
|
||||
raise ArtifactStoreUnavailable("offline cache miss")
|
||||
|
||||
materializer = SessionRecordingMaterializer(
|
||||
tmp_path / "private",
|
||||
exporter=exporter,
|
||||
artifact_gateway=OfflineGateway(), # type: ignore[arg-type]
|
||||
)
|
||||
|
||||
with pytest.raises(
|
||||
RecordingMaterializationError,
|
||||
match="not present in the local artifact cache",
|
||||
):
|
||||
materializer.materialize(command)
|
||||
|
||||
assert exporter.calls == 0
|
||||
|
||||
|
||||
def test_delete_cached_refuses_a_live_lease_then_removes_the_exact_cache(
|
||||
|
||||
Reference in New Issue
Block a user