config / pids / validate / claude_accounts / launch / fork / routes_runs /
routes_accounts, mounted by a thin sidecar.py (same `sidecar:app`, same 24
routes, same startup hook). Mutable state keeps one owner module
(pids._procs, claude_accounts._account_status_cache). Includes the
_claude_args builder from 1de9426 and its test; the Dockerfile's explicit
COPY list gains the new modules.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""Run liveness on both backends: /proc (Linux host) and psutil (macOS worker)."""
|
|
|
|
import os
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
import pids
|
|
from routes_accounts import health
|
|
|
|
|
|
@pytest.fixture(params=["proc", "psutil"])
|
|
def backend(request, monkeypatch):
|
|
if request.param == "psutil":
|
|
pytest.importorskip("psutil")
|
|
monkeypatch.setattr(pids, "_HAVE_PROC", False)
|
|
elif not pids._HAVE_PROC:
|
|
pytest.skip("no /proc here")
|
|
return request.param
|
|
|
|
|
|
def test_self_is_live_and_fingerprinted(backend):
|
|
pid = os.getpid()
|
|
st = pids._proc_starttime(pid)
|
|
assert st is not None
|
|
assert pids._alive({"pid": pid, "starttime": st})
|
|
assert not pids._alive({"pid": pid, "starttime": st + 12345})
|
|
|
|
|
|
def test_zombie_is_dead(backend):
|
|
p = subprocess.Popen(["true"])
|
|
rec = {"pid": p.pid, "starttime": pids._proc_starttime(p.pid)}
|
|
# not in pids._procs, so _reap() won't wait on it: it stays a zombie
|
|
import time
|
|
time.sleep(0.3)
|
|
assert pids._proc_state(p.pid) == "Z"
|
|
assert not pids._alive(rec)
|
|
p.wait()
|
|
|
|
|
|
def test_health_reports_worker_identity(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("WORKER_STATE_DIR", str(tmp_path))
|
|
h = health()
|
|
assert h["workerId"] and h["hostname"] and h["platform"]
|
|
assert "paired" in h and h["permissionMode"]
|