test: complete runtime config lease matrix
This commit is contained in:
@@ -236,6 +236,18 @@ def write_all(fd: int, data: bytes) -> None:
|
||||
pos += n
|
||||
|
||||
|
||||
def publication_fsync(fd: int, stage: str) -> None:
|
||||
"""Fsync one publication boundary, with an explicit test-only fault seam.
|
||||
|
||||
The seam is inert unless the caller opts in with the exact stage name. It is
|
||||
intentionally kept here (rather than in TypeScript) so the real helper's
|
||||
durable ordering can be exercised without weakening production behaviour.
|
||||
"""
|
||||
if os.environ.get("THT_RUNTIME_CONFIG_FSYNC_FAIL") == stage:
|
||||
fail(f"runtime config fsync failed at {stage}")
|
||||
os.fsync(fd)
|
||||
|
||||
|
||||
def read_all(fd: int, limit: int = 16 * 1024 * 1024) -> bytes:
|
||||
os.lseek(fd, 0, os.SEEK_SET)
|
||||
chunks: list[bytes] = []
|
||||
@@ -361,7 +373,7 @@ def publish(inp: dict) -> dict:
|
||||
try:
|
||||
write_all(fd, content)
|
||||
os.fchmod(fd, 0o400)
|
||||
os.fsync(fd)
|
||||
publication_fsync(fd, "config-file")
|
||||
try:
|
||||
_rename_noreplace(stage, name, cfgdir, "config")
|
||||
except FileExistsError:
|
||||
@@ -384,7 +396,7 @@ def publish(inp: dict) -> dict:
|
||||
fail("same-revision runtime configuration changed")
|
||||
finally:
|
||||
os.close(fd)
|
||||
os.fsync(cfgdir)
|
||||
publication_fsync(cfgdir, "config-parent")
|
||||
# Identity is deliberately recorded after final no-replace publication.
|
||||
got = current(cfgdir, name, 0o400)
|
||||
assert got
|
||||
@@ -423,7 +435,7 @@ def publish(inp: dict) -> dict:
|
||||
try:
|
||||
write_all(fd, mb)
|
||||
os.fchmod(fd, 0o600)
|
||||
os.fsync(fd)
|
||||
publication_fsync(fd, "manifest-file")
|
||||
try:
|
||||
_rename_noreplace(stage, mname, mandir, "manifest")
|
||||
except FileExistsError:
|
||||
@@ -449,7 +461,7 @@ def publish(inp: dict) -> dict:
|
||||
os.unlink(stage, dir_fd=mandir)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
os.fsync(mandir)
|
||||
publication_fsync(mandir, "manifest-parent")
|
||||
return {
|
||||
"path": f"{root}/sessions/{wid}/preprocessing/runtime-config/{name}",
|
||||
"manifestPath": f"{root}/sessions/{wid}/preprocessing/runtime-config-manifests/{mname}",
|
||||
|
||||
Reference in New Issue
Block a user