summaryrefslogtreecommitdiff
path: root/test/daemon.py
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 02:01:30 -0300
committerGabriel Schneider <[email protected]>2026-10-30 03:13:15 -0300
commitf8a56c962d5103b84453d4305cd27973a71d4aa3 (patch)
tree95da95264b53fab6637808bd62410f7740b2880c /test/daemon.py
parent6118ad214bb74744e7b38004b34e4487a6635be1 (diff)
downloadpardes-f8a56c962d5103b84453d4305cd27973a71d4aa3.tar.gz
pardes-f8a56c962d5103b84453d4305cd27973a71d4aa3.zip
replica clients join again: one that diverged (a digest the session's unit did not end on) and one the session let go to upgrade dial it again, the same join as the first, and say why in a line over their frame until a key; a client of another build is told "session upgraded to a newer pardes: upgrade this client too"
tty.zig `remote` is a loop of joins over one terminal: the link ended, its reader joined, the replica let go, the session dialled again (an upgrade's exec and load, and its daemon's, retried for 20 s), its dump loaded, its view's size sent again. `Remote.notify` draws the line (`noticeLine`, the client's own, never the session's core). The welcome carries the session's semantics: the daemon judged the hello by the hash it last heard, which an upgrade under way may not have said yet. replica.zig `Peers.refuseAll`: before an Upgrade's dump each client is sent `refused` after what it was sent (up to 200 ms) and let go, its view with it. "A newer pardes is installed" is a Host call (`newer_build`) the core makes in its focus step, so replica clients take the line from the tape; the GUI still says it itself. PARDES_TEST_DIVERGE=<n> puts a client's core off the session's once quiet after its n-th unit. test/daemon.py: the clients test has one rejoin and agree; the upgrade test has a client of the old build told to upgrade and one of the build running join again and agree. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/daemon.py')
-rw-r--r--test/daemon.py56
1 files changed, 53 insertions, 3 deletions
diff --git a/test/daemon.py b/test/daemon.py
index b54b2b54..273c29e0 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -337,6 +337,26 @@ def clients(binary):
and b'from-B' in nine.read(f'/pane/{pane}/body'))
wait_for('client A agrees once quiet', lambda: agreed(root / 'a.check', 0))
wait_for('client B agrees once quiet', lambda: agreed(root / 'b.check', 0))
+ # One put off the session's state (PARDES_TEST_DIVERGE): the next
+ # unit's digest finds it, it says so in a line and joins again, and
+ # its keys after go in and it agrees.
+ td = Term(24, 90)
+ terms.append(td)
+ d = td.spawn([binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_CHECK=str(root / 'd.check'), PARDES_TEST_DIVERGE='1'))
+ started.append(d.pid)
+ wait_for('client D\'s first frame', lambda: b'line 3 of the notes' in td.text(), timeout=20)
+ os.write(td.master, b'jj')
+ time.sleep(.5)
+ # Another's unit, replayed on D's core: its digest finds it.
+ os.write(ta.master, b'jj')
+ wait_for('client D diverged and joined again', lambda: b'joined again' in td.text(), timeout=20)
+ assert d.poll() is None
+ seen = len(checks(root / 'd.check'))
+ os.write(td.master, b'Oafter-rejoin-D\x1b')
+ wait_for('client D\'s keys after its rejoin', lambda: b'after-rejoin-D' in nine.read(f'/pane/{pane}/body'))
+ wait_for('client D agrees after its rejoin', lambda: agreed(root / 'd.check', seen))
+ os.write(td.master, b' sD')
+ wait_for('client D let go', lambda: d.poll() is not None, timeout=10)
# Killed outright: the session and the other client carry on.
os.kill(b.pid, signal.SIGKILL)
b.wait(timeout=10)
@@ -373,6 +393,7 @@ def clients(binary):
wait_for('the session\'s fds level', lambda: fds(sess.pid) == alone, timeout=10)
print(f'daemon: two replica clients (one through a 40 ms relay) typed into a detached session; '
f'digests agreed {len(checks(root / "a.check"))} and {len(checks(root / "b.check"))} times; '
+ f'one put off the session\'s state joined again and agreed {len(checks(root / "d.check"))} times; '
f'one killed, the other typed on and detached; a third typed into a shell, agreed '
f'{len(checks(root / "c.check"))} times, and was hung up')
try:
@@ -767,6 +788,12 @@ def upgrades(old, new):
old_build = semantics(old)
replica = Replica(root / 'pardes-replica.sock')
assert replica.hello('work', old_build)[0] == 'welcome'
+ # A replica client of the old build: let go at the upgrade, it dials
+ # again and is told to upgrade too.
+ term3 = Term(24, 90)
+ stale = term3.spawn([str(old), f'--attach={root / "pardes-replica.sock"}:work'], env)
+ started.append(stale.pid)
+ wait_for('the old build\'s client drawn', lambda: b'\x1b[?1049h' in term3.text() and b'one' in term3.text())
before = len(term.text()), len(term2.text())
install(new, binary)
@@ -794,16 +821,23 @@ def upgrades(old, new):
else:
wait_for('the daemon exec\'d again', lambda: any(a.startswith(b'--upgraded=') for a in cmdline(daemon)))
assert alive(daemon) and stub.poll() is None and stub2.poll() is None
- # A replica of the old build is told why it is let go.
+ # A replica of the old build is told why it is let go, after what it
+ # was sent (units, terminals).
tag, body = replica.read()
+ while tag in (0x05, 0x06, 0x07):
+ tag, body = replica.read()
assert tag == 0x02 and b'upgrading to another build' in body, (tag, body)
replica.close()
+ stale.wait(timeout=30)
+ assert b'upgrade this client too' in term3.text(), term3.text()[-400:]
+ term3.close()
+ print('upgrade: a replica client of the old build was let go, dialled again and was told to upgrade too')
# The old image's prompt files swept, the new one's made.
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 replica's connection is the one fewer.)
- level = fds_before[0] - 1, fds_before[1]
+ # (The replicas' connections are two fewer.)
+ level = fds_before[0] - 2, fds_before[1]
try:
wait_for('the fds level', lambda: (fds(session), fds(daemon)) == level, timeout=5)
except TimeoutError:
@@ -842,10 +876,26 @@ def upgrades(old, new):
install(refuser, binary)
if procfs:
running = os.stat(f'/proc/{session}/exe').st_ino
+ # A replica client of the build running: let go at the upgrade,
+ # it joins again once the session is back, says so, and agrees.
+ term4 = Term(24, 90)
+ again = term4.spawn([str(new), f'--attach={root / "pardes-replica.sock"}:work'],
+ dict(env, PARDES_REPLICA_CHECK=str(root / 'e.check')))
+ started.append(again.pid)
+ wait_for('the client of the build running drawn', lambda: b'\x1b[?1049h' in term4.text() and b'one' in term4.text())
refusing('1')
client.write(f'/pane/{shell}/exec', b'Upgrade\n')
client.socket.close()
client = saying(sock, 'it goes on as')
+ wait_for('the client joined again', lambda: b'joined again: the session is upgrading' in term4.text(), timeout=30)
+ assert again.poll() is None
+ seen = len(checks(root / 'e.check'))
+ os.write(term4.master, b'gg')
+ wait_for('the client agrees after it joined again', lambda: agreed(root / 'e.check', seen), timeout=20)
+ again.send_signal(signal.SIGHUP)
+ again.wait(timeout=10)
+ term4.close()
+ print('upgrade: a replica client of the build running joined again after the upgrade, said so and agreed')
assert os.stat(f'/proc/{session}/exe').st_ino == running, 'back on the build that ran'
assert alive(shell_pid) and ppid(shell_pid) == session and stub.poll() is None
assert client.read(f'/pane/{text}/body') == b'one\ntwo\n'