fix: repair proven unsent sync chain with signed archived receipt
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Checkpoint repair against a fresh, isolated PostgreSQL; no deployed state."""
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import uuid
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
NAME = "rmm-checkpoint-repair-" + uuid.uuid4().hex[:10]
|
||||
|
||||
|
||||
def command(args, data=None, timeout=120):
|
||||
result = subprocess.run(args, input=data, capture_output=True, timeout=timeout)
|
||||
if result.returncode:
|
||||
raise RuntimeError(result.stderr.decode(errors="replace")[-4000:])
|
||||
return result.stdout
|
||||
|
||||
|
||||
def main():
|
||||
command(["docker", "run", "-d", "--network", "none", "--name", NAME,
|
||||
"-e", "POSTGRES_HOST_AUTH_METHOD=trust", "postgres:17.6-bookworm"])
|
||||
try:
|
||||
for _ in range(100):
|
||||
logs = command(["docker", "logs", NAME])
|
||||
probe = subprocess.run(["docker", "exec", NAME, "pg_isready", "-U", "postgres"],
|
||||
capture_output=True)
|
||||
if b"init process complete" in logs and probe.returncode == 0:
|
||||
break
|
||||
time.sleep(.2)
|
||||
else:
|
||||
raise RuntimeError("ISOLATED_POSTGRES_NOT_READY")
|
||||
|
||||
def sql(statement):
|
||||
return command(["docker", "exec", "-i", NAME, "psql", "-X", "-qAt",
|
||||
"-v", "ON_ERROR_STOP=1", "-U", "postgres"], statement.encode())
|
||||
|
||||
sql("CREATE ROLE rmm_app LOGIN NOINHERIT NOSUPERUSER NOBYPASSRLS;")
|
||||
for path in sorted((ROOT / "migrations").glob("*.sql")):
|
||||
sql(path.read_text())
|
||||
# Current source with a pre-Windows dependency manifest uses the cached
|
||||
# Linux toolchain; Windows is outside this Linux checkpoint test.
|
||||
manifests = tempfile.TemporaryDirectory(prefix="rmm-checkpoint-linux-manifest-")
|
||||
manifest = Path(manifests.name)
|
||||
for name in ("Cargo.toml", "Cargo.lock"):
|
||||
(manifest / name).write_bytes(command([
|
||||
"git", "-C", str(ROOT), "show", "a5c2dce:" + name]))
|
||||
output = command([
|
||||
"docker", "run", "--rm", "--network", "container:" + NAME,
|
||||
"--read-only", "--tmpfs", "/tmp:rw,size=512m",
|
||||
"-v", str(ROOT) + ":/src:ro",
|
||||
"-v", str(manifest / "Cargo.toml") + ":/src/Cargo.toml:ro",
|
||||
"-v", str(manifest / "Cargo.lock") + ":/src/Cargo.lock:ro",
|
||||
"-v", str(ROOT / "devstate/windows-client/target-linux") + ":/target",
|
||||
"-e", "CARGO_TARGET_DIR=/target",
|
||||
"-e", "RMM_TEST_REPAIR_ADMIN_URL=postgres://postgres@127.0.0.1/postgres",
|
||||
"-e", "RMM_TEST_REPAIR_APP_URL=postgres://rmm_app@127.0.0.1/postgres",
|
||||
"--entrypoint", "cargo", "rust-discovery-dev-build:local",
|
||||
"test", "--locked", "--offline", "-p", "rmm-server",
|
||||
"checkpoint_repair", "--", "--include-ignored", "--nocapture"], timeout=300)
|
||||
print(output.decode())
|
||||
print("PASS: isolated PostgreSQL repair, scope/revocation/stale-head/committed-request rejection, exact replay; zero jobs/outbox/permits and no readiness.")
|
||||
manifests.cleanup()
|
||||
finally:
|
||||
subprocess.run(["docker", "rm", "-f", NAME], capture_output=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user