summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/daemon.py43
1 files changed, 37 insertions, 6 deletions
diff --git a/test/daemon.py b/test/daemon.py
index ebee286f..1086dac3 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -557,6 +557,14 @@ class Window:
return self.p.returncode
+def sessions_listed(binary, env, root):
+ """`pardes --ps`'s session lines, each `[name, pid, (kind, state)]`."""
+ out = subprocess.run([binary, '--ps'], env=env, cwd=root, capture_output=True, timeout=30)
+ assert out.returncode == 0, out
+ rows = [line.split(maxsplit=3)[1:] for line in out.stdout.decode().splitlines() if line.lstrip().startswith('session ')]
+ return [[name, pid, rest] for name, pid, rest in rows]
+
+
def window_clients(binary, gui_binary):
"""Window replica clients (`pardes-gui --attach=<socket>:<name>`): of a
terminal's detached session, directly and through the delay relay at
@@ -587,7 +595,6 @@ def window_clients(binary, gui_binary):
nine = Client(root / 'pardes-9p-files.sock')
pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text')
body = lambda: nine.read(f'/pane/{pane}/body')
- alone = fds(sess.pid)
# A terminal's client beside the windows, typing as they do.
ta = Term(30, 100)
terms.append(ta)
@@ -617,6 +624,10 @@ def window_clients(binary, gui_binary):
wait_for('the terminal client normal again', lambda: normal_again(ta), timeout=20)
wait_for(f'the window client agrees ({rtt} ms)', lambda: agreed(check, 0), timeout=30)
wait_for('the terminal client agrees', lambda: agreed(root / 'a.check', seen), timeout=30)
+ if not rtt:
+ # Its clients are no sessions of the daemon's.
+ listed = sessions_listed(binary, env, root)
+ assert [(n, k) for n, _, k in listed] == [('files', '(tty, detached)')], listed
# Moved and scrolled, its own view only: agreed again.
n = len(checks(check))
w.keys(b'jjjjjkkk\x06\x06\x02')
@@ -628,8 +639,12 @@ def window_clients(binary, gui_binary):
relay.wait()
# One put off the session's state (PARDES_TEST_DIVERGE): the next
# unit it replays finds it, it joins again, and its keys after go in.
+ # Far (PARDES_REPLICA_FAR, as through ssh): its first join sent its
+ # blobs by hash, in zstd; its rejoin finds them in the core it left.
dcheck = root / 'wd.check'
- wd = Window(root, 'wd', [gui_binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_CHECK=str(dcheck), PARDES_TEST_DIVERGE='1'))
+ wd = Window(root, 'wd', [gui_binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_CHECK=str(dcheck), PARDES_TEST_DIVERGE='1',
+ PARDES_REPLICA_FAR='1', PARDES_REPLICA_STATS=str(root / 'wd.stats'),
+ XDG_CACHE_HOME=str(root / 'wd-cache')))
windows.append(wd)
started.append(wd.pid)
time.sleep(2)
@@ -642,16 +657,30 @@ def window_clients(binary, gui_binary):
wd.keys(b'Oafter-rejoin-W\x1b')
wait_for('the window\'s keys after its rejoin', lambda: b'after-rejoin-W' in body(), timeout=30)
wait_for('the window client agrees after its rejoin', lambda: agreed(dcheck, seen), timeout=30)
+ # An Upgrade (to the same build): the session lets it go in words
+ # (`refused`), it dials again, joins, and its keys after go in.
+ nine.write('/ctl', b'Upgrade\n')
+ wait_for('the window client joined again after the upgrade', lambda: 'joined again: the session is upgrading' in wd.said(), timeout=60)
+ nine.socket.close()
+ nine = reconnect(root / 'pardes-9p-files.sock')
+ seen = len(checks(dcheck))
+ wd.keys(b'jjjOafter-upgrade-W\x1b')
+ wait_for('the window\'s keys after the upgrade', lambda: b'after-upgrade-W' in body(), timeout=30)
+ wait_for('the window client agrees after the upgrade', lambda: agreed(dcheck, seen), timeout=30)
+ assert wd.p.poll() is None
# Detach typed in it: it alone goes, and says why.
wd.keys(b' sD')
wait_for('the window client let go', lambda: wd.p.poll() is not None, timeout=15)
assert 'let this client go' in wd.said(), wd.said()[-500:]
+ # A link a line: the first join sent every blob, its rejoins held them.
+ links = joins(root / 'wd.stats')
+ assert len(links) == 3 and links[0]['blobs'] > 0 and links[0]['from_memory'] + links[0]['from_disk'] == 0, links
+ assert links[1]['from_memory'] == links[1]['blobs'] and links[1]['sent_kb'] == 0, links
os.write(ta.master, b' sD')
wait_for('the terminal client let go', lambda: a.poll() is not None, timeout=10)
- wait_for('the session\'s fds level', lambda: fds(sess.pid) == alone, timeout=10)
print(f'daemon: window clients of a terminal\'s session at 0/30/80/207 ms beside a terminal\'s, digests agreed '
- f'{agreements} and {len(checks(root / "a.check"))} times; one put off the session\'s state joined again and '
- f'agreed {len(checks(dcheck))} times; one detached')
+ f'{agreements} and {len(checks(root / "a.check"))} times; one put off the session\'s state joined again, '
+ f'joined again across an Upgrade, agreed {len(checks(dcheck))} times and detached (far: its joins {joins(root / "wd.stats")})')
try:
nine.write(f'/pane/{pane}/exec', b'Exit\n')
except OSError as e:
@@ -690,12 +719,14 @@ def window_clients(binary, gui_binary):
win.keys(b'jj')
wait_for('the terminal client agrees with the window', lambda: agreed(root / 'b.check', nb), timeout=30)
wait_for('the window client agrees with the window', lambda: agreed(root / 'g.check', ng), timeout=30)
+ listed = sessions_listed(binary, env, root)
+ assert [(n, k) for n, _, k in listed] == [('win', '(gui, attached)')], listed
assert wg.close() == 0, wg.said()[-800:]
os.write(tb.master, b' sD')
wait_for('the terminal client let go', lambda: b.poll() is not None, timeout=10)
assert win.p.poll() is None
print(f'daemon: a window\'s session served a terminal\'s client and a window\'s, digests agreed '
- f'{len(checks(root / "b.check"))} and {len(checks(root / "g.check"))} times')
+ f'{len(checks(root / "b.check"))} and {len(checks(root / "g.check"))} times; --ps listed it alone, (gui, attached)')
win.close()
nine.socket.close()
wait_for('nothing left', lambda: not [p for p in processes(root) if alive(p)], timeout=15)