sched: server lifecycle service with bounded real execution (T12 core)
This commit is contained in:
@@ -208,12 +208,12 @@ def test_canonical_windows_path_handling_retained(tmp_path: Path) -> None:
|
||||
|
||||
|
||||
def test_non_sibling_store_pairs_have_no_lock_identity(tmp_path: Path) -> None:
|
||||
"""Only distinct siblings under one composition root share a lock file.
|
||||
"""Cross pairs reusing one protected store have no single lock file.
|
||||
|
||||
Cross pairs that reuse one protected store (shared schedule store or
|
||||
shared run store), nested pairs, and same-directory dual use would map
|
||||
to different lock files while covering the same store files, so they
|
||||
have no lock identity at all: guards must reject them outright.
|
||||
A shared schedule store (or run store) with a different partner maps
|
||||
to no lock identity: no held lock can authorize such a pair, so two
|
||||
compositions can never gain independent authority over the same
|
||||
store files through different layouts.
|
||||
"""
|
||||
overlap = tmp_path / "overlap"
|
||||
sched_store, run_store = _stores(overlap)
|
||||
@@ -222,11 +222,40 @@ def test_non_sibling_store_pairs_have_no_lock_identity(tmp_path: Path) -> None:
|
||||
assert canonical_lock_root(sched_store.root, other_runs.root) is None
|
||||
# Shared run store, different schedule store.
|
||||
assert canonical_lock_root(other_sched.root, run_store.root) is None
|
||||
# Nested pairs: one store inside the other.
|
||||
assert canonical_lock_root(overlap, sched_store.root) is None
|
||||
assert canonical_lock_root(sched_store.root, overlap) is None
|
||||
# Same directory serving as both stores.
|
||||
assert canonical_lock_root(sched_store.root, sched_store.root) is None
|
||||
# Split layouts across different parents.
|
||||
assert canonical_lock_root(sched_store.root, tmp_path / "elsewhere") is None
|
||||
|
||||
|
||||
def test_nested_and_shared_roots_unify_on_one_lock(tmp_path: Path) -> None:
|
||||
"""Identical and nested roots map to the same single lock file.
|
||||
|
||||
The server layout points both stores at the composition root itself,
|
||||
and a nested pair shares its outer root: every composition covering
|
||||
the same store files through identical, sibling, or nested roots
|
||||
contends on one lock file instead of holding independent locks.
|
||||
"""
|
||||
overlap = tmp_path / "overlap"
|
||||
sched_store, run_store = _stores(overlap)
|
||||
assert canonical_lock_root(overlap, overlap) == canonical_store_path(overlap)
|
||||
assert canonical_lock_root(
|
||||
sched_store.root, sched_store.root
|
||||
) == canonical_store_path(sched_store.root)
|
||||
assert canonical_lock_root(overlap, sched_store.root) == canonical_store_path(
|
||||
overlap
|
||||
)
|
||||
assert canonical_lock_root(sched_store.root, overlap) == canonical_store_path(
|
||||
overlap
|
||||
)
|
||||
# One lock file: a second owner of the unified identity is rejected.
|
||||
owner = SchedulerOwnership(overlap, owner="owner").acquire()
|
||||
try:
|
||||
assert owner.covers(overlap, overlap) is True
|
||||
with pytest.raises(SecondOwnerError):
|
||||
SchedulerOwnership(overlap, owner="second").acquire()
|
||||
nested = SchedulerOwnership(sched_store.root, owner="nested")
|
||||
assert nested.covers(sched_store.root, overlap) is False
|
||||
finally:
|
||||
owner.release()
|
||||
|
||||
|
||||
def test_shared_schedule_store_cannot_gain_independent_authority(
|
||||
|
||||
Reference in New Issue
Block a user