summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-21 05:49:21 -0300
committerGabriel Schneider <[email protected]>2026-11-21 06:21:57 -0300
commit744f1029ee2a02a43cb0fc70e32f70b60b100b75 (patch)
tree2c2ae2a7cb32b088c7785557914b73f6f4c0cf11 /test
parente29ff73bbb2c198afbb894ee98854da2d9a7be7d (diff)
downloadpardes-744f1029ee2a02a43cb0fc70e32f70b60b100b75.tar.gz
pardes-744f1029ee2a02a43cb0fc70e32f70b60b100b75.zip
client: a link an Upgrade's exec cuts with no last word joins again: `Peers.refuseAll` queues each client's `refused` after what it is still being sent and gives the writers 200 ms (`flushed200`), then `drop` cuts every link, so a client whose join's dump was still on its way read the cut as its session's end and exited 1 ("'NAME' let this client go"), with PARDES_PAIR or without (a `new --detach` session holding a 100 MB file, the Upgrade written as the attach is listed: 3 of 3 on main's ReleaseSafe build, 3 of 3 Debug); now a near link that ends with no last word asks this machine's daemon whether its session is listed still (`replica.cutListed`), and listed, joins again as one told `upgrading` (runtime/client.zig `Loop.run`; a first join cut mid-dump likewise, `replica.join`), so no flush bound decides a client's fate; a patient redial stops at once at "no session called" (`redial`: a session killed outright costs no 20 s of dialling); a far client and a no-daemon pair ask nobody (nothing changes); test/daemon.py `attach_upgrading` gains the round (two attaches to a 100 MB session, the Upgrade written as each joins; plain mode and --attach-upgrading): failed on merge48's builds, passes on both builds; tui core-test 885/1045 (160 skipped)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/daemon.py38
1 files changed, 35 insertions, 3 deletions
diff --git a/test/daemon.py b/test/daemon.py
index 2c86c04f..83c024c4 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -871,7 +871,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
@@ -915,8 +915,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:
@@ -3486,7 +3518,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])