diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 16:15:14 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 19:16:37 -0300 |
| commit | b3cf70c686d1505bc687cb1f0935959ffa5d119d (patch) | |
| tree | 526fad4b764fbbd34c1cc12f76a7f3754c00933c /test | |
| parent | 60caa16b99c60713c5ae27832d76809a2b4a2d5a (diff) | |
| download | pardes-b3cf70c686d1505bc687cb1f0935959ffa5d119d.tar.gz pardes-b3cf70c686d1505bc687cb1f0935959ffa5d119d.zip | |
tests: daemon.py's upgrade from the build before counts the state file's fd: a session keeps its state file open (Db.zig) where the build before opened Recent's file for each use, so after an Upgrade from it the session holds one fd more, the state file's, and only that one may be (`state_fds`, a session's fds on `pardes.xitdb`); when the level is missed it says what the fds are open on (`links`), where it gave their bare numbers; `daemon.py --upgrade <old> <new>` failed here with ('fds', (13, 8), (14, 8), …) and passes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
| -rw-r--r-- | test/daemon.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/test/daemon.py b/test/daemon.py index 33806575..b0c02690 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -198,6 +198,25 @@ def fds(pid): return -1 +def links(pid): + """What its fds are open on.""" + if not procfs: + return [line.split()[-1] for line in subprocess.run(['procstat', '-f', str(pid)], capture_output=True, + text=True).stdout.splitlines()[1:] if line.split()] + out = [] + for fd in os.listdir(f'/proc/{pid}/fd'): + try: + out.append(os.readlink(f'/proc/{pid}/fd/{fd}')) + except OSError: + pass + return out + + +def state_fds(pid): + """Its fds on the state file, which a session keeps open (Db.zig).""" + return sum(1 for path in links(pid) if path.endswith('/pardes.xitdb')) + + def semantics(binary): """What a replica's build must share with its session's (--version).""" out = subprocess.run([binary, '--version'], capture_output=True, check=True).stdout.decode() @@ -1463,6 +1482,7 @@ def upgrades(old, new): os.write(term.master, b'\x1b[I') wait_for('the newer build said', lambda: 'a newer pardes is installed' in screen_text(client)) fds_before = fds(session), fds(daemon) + state_before = state_fds(session) rcs = sorted(Path('/tmp').glob(f'pardes-osc133-*-{session}-*')) t = time.monotonic() client.write('/ctl', b'Upgrade\n') @@ -1497,13 +1517,15 @@ def upgrades(old, new): wait_for('the prompt files level', lambda: len(list(Path('/tmp').glob(f'pardes-osc133-*-{session}-*'))) == len(rcs)) assert sorted(Path('/tmp').glob(f'pardes-osc133-*-{session}-*')) != rcs or not rcs # Nothing kept that was not: the old binary let go, every fd back. - # (The replicas' connections are two fewer.) - level = fds_before[0] - 2, fds_before[1] + # (The replicas' connections are two fewer; the state file's one + # more after a build that opened Recent's file for each use, and + # only one: a session holds it once.) + def level(): + return fds_before[0] - 2 + min(state_fds(session), 1) - state_before, fds_before[1] try: - wait_for('the fds level', lambda: (fds(session), fds(daemon)) == level, timeout=5) + wait_for('the fds level', lambda: (fds(session), fds(daemon)) == level(), timeout=5) except TimeoutError: - raise AssertionError(('fds', level, (fds(session), fds(daemon)), - os.listdir(f'/proc/{session}/fd') if procfs else None)) + raise AssertionError(('fds', level(), (fds(session), fds(daemon)), links(session))) # The edit and its undo. assert client.read(f'/pane/{text}/body') == b'one\ntwo\nunsaved\n' assert any(row.split()[0] == str(text).encode() and row.split()[2] == b'1' for row in client.read('/index').splitlines()), client.read('/index') |
