summaryrefslogtreecommitdiff
path: root/test/daemon.py
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-21 09:10:24 -0300
committerGabriel Schneider <[email protected]>2026-11-21 09:10:24 -0300
commitc4f7bb9477c7aa4c8864f14edb9e85b6c8c08437 (patch)
tree9b60bce9e53f96855b40f2ba53e23945a7798ddf /test/daemon.py
parentf7de6f49ee3d9ac241575f5244743193c9943841 (diff)
parent5ad6067936f306271b875aaf182d4866055da10d (diff)
downloadpardes-c4f7bb9477c7aa4c8864f14edb9e85b6c8c08437.tar.gz
pardes-c4f7bb9477c7aa4c8864f14edb9e85b6c8c08437.zip
integration: the pair's round 5 and the layers' round 2 on the gathered line: pardes-pair-5 (`ssrtxkzx`, on pardes-merge48: a link an Upgrade cuts with no last word asks the daemon whether its session is listed still and joins again (`replica.cutListed`): an upgrade from the installed build carries its clients; a no-daemon pair refuses Restore in words (P42); /dev/tty opened before the pair forks; a TERMed or hung-up client dies of the signal; the process suite as pairs 13 to 8 of 145) and pardes-layers-2 (`myxnnquu`, on pardes-merge49: the click on path@rev tested, a revision read-only from 9P, Syntax off in a patch keeps the patch's colours); no conflict; core-test 893/1053 (160 skipped), shell-test 1095/1098; its gate: .scratch/sketch/reorg/merge50, the numbers in PARDES.md (2026-11-21)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/daemon.py')
-rw-r--r--test/daemon.py58
1 files changed, 50 insertions, 8 deletions
diff --git a/test/daemon.py b/test/daemon.py
index 041bc75b..5c075520 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -806,13 +806,14 @@ def pair_rows(binary):
# Not kept: a client's close (its terminal closed, a TERM) ends the
# session when it was the last; a KILL is a loss, it runs on.
t, c, nine, session, pane = started('nk', env)
- assert ended_by('HUP', *attached('nk')) == 0
+ # Dead of the signal, its goodbye said, as the own path's stub dies.
+ assert ended_by('HUP', *attached('nk')) == -signal.SIGHUP
assert alive(session) and state_of('nk') == '(tty)', ('not its last client', listed())
os.kill(c.pid, signal.SIGKILL)
c.wait(timeout=10)
wait_for('the client unlisted', lambda: f'client {c.pid} ' not in listed())
assert alive(session) and state_of('nk') == '(tty)', ('a loss', listed())
- assert ended_by('TERM', *attached('nk')) == 0
+ assert ended_by('TERM', *attached('nk')) == -signal.SIGTERM
wait_for('the session ended at its last client\'s close', lambda: not alive(session), timeout=20)
assert state_of('nk') is None, listed()
nine.socket.close()
@@ -826,7 +827,7 @@ def pair_rows(binary):
nine.socket.close()
t.close()
terms.remove(t)
- assert c.wait(timeout=20) == 0, c.returncode
+ assert c.wait(timeout=20) == -signal.SIGHUP, c.returncode
wait_for('the session ended with its terminal', lambda: not alive(session), timeout=20)
print('pair rows: not kept, upgraded: its terminal closed (exit 0): the session ended')
# Without the variable nothing changes: an attach client's TERM
@@ -834,7 +835,7 @@ def pair_rows(binary):
own_env = {k: v for k, v in env.items() if k != 'PARDES_PAIR'}
t, c, nine, session, pane = started('own', own_env)
assert state_of('own') == '(tty, has a frontend)', listed()
- assert ended_by('TERM', *attached('own')) == 0
+ assert ended_by('TERM', *attached('own')) == -signal.SIGTERM
assert alive(session) and state_of('own') == '(tty, has a frontend)', listed()
nine.socket.close()
t.close()
@@ -888,7 +889,7 @@ def pair_rows(binary):
shutil.rmtree(root, ignore_errors=True)
-def attach_upgrading(binary, rounds=6):
+def attach_upgrading(binary, rounds=6, dump=True):
"""`pardes attach` as its session upgrades: started at once after the
Upgrade's word, it is handed to the session before the exec; told the
session is upgrading (never cut by the exec unanswered: "hung up before
@@ -932,8 +933,40 @@ def attach_upgrading(binary, rounds=6):
nine.socket.close()
assert subprocess.run([binary, 'kill', name], env=e, capture_output=True, timeout=30).returncode == 0
wait_for('the session ended', lambda: not alive(session), timeout=30)
+ # A join whose dump is still on its way when the Upgrade comes (a
+ # 100 MB file: the flush before the exec lets it go cut): it joins
+ # again, as one told so does; never "let this client go".
+ # Once a run (plain mode, --attach-upgrading): a slow round.
+ if dump:
+ big = root / 'big.txt'
+ with open(big, 'w') as f:
+ f.write('a line of a big file, long enough to be a fair line of text in a log: 0123456789\n' * 1_250_000)
+ out = subprocess.run([binary, 'new', '--detach=big', str(big)], env=env, cwd=root, capture_output=True,
+ timeout=60, stdin=subprocess.DEVNULL)
+ assert out.returncode == 0, out
+ sock = root / 'pardes-9p-big.sock'
+ nine = Client(sock)
+ session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid'])
+ for k in range(2):
+ t = Term(30, 100)
+ terms.append(t)
+ a = t.spawn([binary, 'attach', 'big'], env)
+ listed = lambda: subprocess.run([binary, 'ps'], env=env, capture_output=True).stdout.decode() # noqa: E731
+ wait_for('the attach joined', lambda: f'client {a.pid} ' in listed() or a.poll() is not None, timeout=60)
+ before = sock.stat().st_ino
+ nine.write('/ctl', b'Upgrade\n')
+ wait_for('joined again, or gone', lambda: b'joined again' in t.text() or a.poll() is not None, timeout=180)
+ assert a.poll() is None, ('a join cut mid-dump', k, a.returncode, t.text()[-120:])
+ a.terminate()
+ a.wait(timeout=20)
+ wait_for('the session exec\'d', lambda: sock.stat().st_ino != before, timeout=60)
+ nine.socket.close()
+ nine = reconnect(sock)
+ nine.socket.close()
+ assert subprocess.run([binary, 'kill', 'big'], env=env, capture_output=True, timeout=30).returncode == 0
+ wait_for('the big session ended', lambda: not alive(session), timeout=30)
print(f'attach upgrading: an attach started as its session upgrades joins the new process ({rounds} of {rounds}, '
- 'without the variable and with it)')
+ 'without the variable and with it)' + ('; a join whose 100 MB dump the exec cut joined again, 2 of 2' if dump else ''))
finally:
for p in processes(root):
try:
@@ -3259,6 +3292,12 @@ def upgrades(old, new):
shutil.rmtree(root, ignore_errors=True)
+def knows_size(gui_binary):
+ """Whether a build's window exec'd at an Upgrade comes back the size
+ it had (PARDES_JOIN_SIZE: client.zig `execAgain`)."""
+ return b'PARDES_JOIN_SIZE' in Path(gui_binary).read_bytes()
+
+
def knows_exec(binary):
"""Whether a build's client execs the build at its start path at an
Upgrade, for the view it is handed (PARDES_JOIN_VIEW)."""
@@ -3489,7 +3528,10 @@ if __name__ == '__main__':
if all(a.with_name('pardes-gui').exists() for a in (old, new)):
upgrade_clients(old, new)
if knows_exec(old):
- pair_window_geometry(old.with_name('pardes-gui'), new.with_name('pardes-gui'))
+ if knows_size(old.with_name('pardes-gui')):
+ pair_window_geometry(old.with_name('pardes-gui'), new.with_name('pardes-gui'))
+ else:
+ print('pair window geometry: skipped: the old build\'s window passes no size at its exec (no PARDES_JOIN_SIZE)')
elif sys.argv[1:2] == ['--upgrade-clients']:
upgrade_clients(Path(sys.argv[2]).resolve(), Path(sys.argv[3]).resolve())
elif sys.argv[1:2] == ['--clients']:
@@ -3501,7 +3543,7 @@ if __name__ == '__main__':
elif sys.argv[1:2] == ['--pair']:
pair(sys.argv[2])
pair_rows(sys.argv[2])
- attach_upgrading(sys.argv[2])
+ attach_upgrading(sys.argv[2], dump=False)
pair_upgrade_views(sys.argv[2])
elif sys.argv[1:2] == ['--attach-upgrading']:
attach_upgrading(sys.argv[2])