diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/behaviour/addons_pdf.zig | 16 | ||||
| -rw-r--r-- | test/daemon.py | 304 | ||||
| -rw-r--r-- | test/process/look_and_exec.zig | 14 | ||||
| -rw-r--r-- | test/process/terminals.zig | 17 | ||||
| -rw-r--r-- | test/replicas.zig | 122 |
5 files changed, 345 insertions, 128 deletions
diff --git a/test/behaviour/addons_pdf.zig b/test/behaviour/addons_pdf.zig index cf5c8009..18fa503c 100644 --- a/test/behaviour/addons_pdf.zig +++ b/test/behaviour/addons_pdf.zig @@ -132,6 +132,22 @@ test "addons: a PDF's / lists its hits as file.pdf:P:H rows in a +Search, n walk try std.testing.expect(try s.focused() != n); } +test "addons: a PDF's / of what its page has not, and f on a PDF with no outline, each say so and the session goes on (the bridge's none is a NULL with a count of 0: a safe build's abort before)" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const n = try s.lookFile("docs/design.pdf"); + // No page has it: page 1's hits of it asked, none; a hit of it a miss. + try s.keys("/zzqxv\r"); + try std.testing.expectEqual(@as(u32, 1), (try s.pdfPage(n))[0]); + _ = try s.refused(s.at("/pane/{d}/look", .{n}), ":1:1\n"); + try std.testing.expect(has(try s.read("/log"), "design.pdf has no search hit 1 on page 1")); + // tall.pdf has no outline. + const t = try s.lookFile("test/pdf-fixtures/tall.pdf"); + try s.keys("f"); + try std.testing.expect(has(try s.read("/log"), "PdfSections: this PDF has no outline")); + try std.testing.expectEqual(t, try s.focused()); +} + test "addons: a PDF's f is its PdfSections, its outline as places a Look in it goes to (none once the PDF is gone), and a jump back over a far one is Ctrl-o's, Forward's on, two places on a page a window apart two" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); diff --git a/test/daemon.py b/test/daemon.py index dc1abcbc..f456837b 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -188,14 +188,16 @@ def run(client, serial, line): client.close(fid) -def adopted_pid(client, pane): - """An adopted shell's `echo $$`, once it answers: sized twice at its - adoption (dev/Ptys.zig `take`), it draws its prompt again, and a run - sent into a prompt redrawn under it reads as not run (core/ninep/pty.zig - `noteMarks`).""" - wait_for('the adopted shell answers', lambda: run(client, pane, b'true\n') == b'exit 0\n') +def pid_in(client, pane): + """The pid of terminal `pane`'s shell, its `echo $$` by pty/run, asked + at once: a run written before its first prompt (or before the prompt + after its greeting) waits for it, and one under a prompt drawn again + (a window's first size, an adoption's two) is still the line run + (core/ninep/pty.zig). Any other answer is said whole.""" said = run(client, pane, b'echo $$\n') - return said.split(b'\n')[1], said + pid = re.fullmatch(rb'exit 0\n([0-9]+)\n', said) + assert pid, f'pane {pane}: `echo $$` answered {said!r}' + return int(pid[1]) # FreeBSD has no /proc: ps and procstat answer instead. @@ -286,6 +288,31 @@ def links(pid): return out +def sockets(pid): + """The sockets process `pid` holds (`socket:[inode]`): a client's link + among them, the same one while it joins again over it.""" + out = set() + for fd in os.listdir(f'/proc/{pid}/fd'): + try: + link = os.readlink(f'/proc/{pid}/fd/{fd}') + except OSError: + continue + if link.startswith('socket:'): + out.add(link) + return out + + +def session_stats(path): + """A session's PARDES_REPLICA_STATS line, its words a dict, and its joins' + count (`joins_us`'s).""" + text = path.read_text() if path.exists() else '' + line = next((l for l in text.splitlines() if l.startswith('session inputs')), '') + w = line.split() + d = {w[i]: w[i + 1] for i in range(1, len(w) - 1, 2)} + joins = next((len(l.split()) - 2 for l in text.splitlines() if l.startswith('session joins_us')), 0) + return d, joins + + 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')) @@ -489,8 +516,10 @@ def clients(binary): started = [] terms = [] try: - sess = subprocess.Popen([binary, '--detach=files', str(notes)], env=env, cwd=root, stdin=subprocess.DEVNULL, - stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True) + # Its joins counted at its end (PARDES_REPLICA_STATS): those over a + # client's own link (`again`) and all of them (`joins_us`). + sess = subprocess.Popen([binary, '--detach=files', str(notes)], env=dict(env, PARDES_REPLICA_STATS=str(root / 'session.stats')), + cwd=root, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True) started.append(sess.pid) sock = root / 'pardes-replica.sock' wait_for('the replica socket', sock.exists) @@ -536,6 +565,7 @@ def clients(binary): started.append(d.pid) wait_for('client D\'s first frame', lambda: b'line 3 of the notes' in td.text(), timeout=20) made_live(td, root / 'd.check') + d_links = sockets(d.pid) shown = view_panes(nine) nine.write('/exec', b'New\n') mine = wait_for('a pane in client D\'s view', lambda: view_panes(nine) - shown).pop() @@ -546,6 +576,9 @@ def clients(binary): os.write(ta.master, b'jk') time.sleep(.2) assert d.poll() is None + # Over its own link: the same connection, no hand-over (counted at + # the session's end). + assert sockets(d.pid) == d_links, ('client D joined again over its own link', d_links, sockets(d.pid)) made_live(td, root / 'd.check') assert mine in view_panes(nine), ('client D in its own view again', mine, nine.read('/layout')) seen = len(checks(root / 'd.check')) @@ -580,7 +613,8 @@ def clients(binary): c = tc.spawn([binary, f'--attach={sock}:files'], dict(env, PARDES_REPLICA_CHECK=str(root / 'c.check'))) started.append(c.pid) wait_for('client C\'s first frame', lambda: b'$' in tc.text(), timeout=20) - run(nine, shell, b'echo from-the-session\n') + said = run(nine, shell, b'echo from-the-session\n') + assert said == b'exit 0\nfrom-the-session\n', said os.write(tc.master, b'echo from-C\r') wait_for('client C\'s keys in the shell', lambda: b'from-C' in nine.read(f'/pane/{shell}/body')) wait_for('client C agrees with a shell\'s output', lambda: agreed(root / 'c.check', 0)) @@ -598,8 +632,12 @@ def clients(binary): exit_session(nine, pane) sess.wait(timeout=60) nine.socket.close() + said, joins = session_stats(root / 'session.stats') + here = int(said.get('again', '-1')) + assert here >= 1, ('the session joined client D again over its link', said) wait_for('nothing left', lambda: not [p for p in processes(root) if alive(p)], timeout=10) - print('daemon: replica clients\' session ended, nothing left behind') + print(f'daemon: replica clients\' session ended, nothing left behind; its joins: {joins}, of them over a ' + f'client\'s own link {here}, handed by the daemon {joins - here}') finally: for t in terms: t.close() @@ -948,6 +986,86 @@ def pair_rows(binary): shutil.rmtree(root, ignore_errors=True) +def pair_back(binary): + """A pair with no daemon (PARDES_DAEMON=off, the pair's default-to-be + with none reachable): its client put off the session's state + (PARDES_TEST_DIVERGE), and apart from that stopped 3 s while the + session's file is edited over 9P (SIGSTOP: past replica.behind_max_ms): + each time it joins again over its own link ("joined again" on its + screen, its socket the same), the session lives on with the text typed + in it, unsaved, and the client agrees; its terminal closed, the session + ends with its last link. Before pardes-link-1 its rejoin dialled the + daemon's socket, nothing took it, and the whole session went (the + client exit 1: reports/pardes-pair-12.md, 2b).""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='rb-', dir=scratch)) + env = base_env() + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', + SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_PAIR='1', PARDES_DAEMON='off') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + notes = root / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30))) + terms = [] + try: + for how in ('diverged', 'behind'): + t = Term(30, 100) + terms.append(t) + check = root / f'{how}.check' + e = dict(env, PARDES_REPLICA_CHECK=str(check), **({'PARDES_TEST_DIVERGE': '3'} if how == 'diverged' else {})) + c = t.spawn([binary, f'--9p={how}', str(notes)], e) + wait_for('the socket', (root / f'pardes-9p-{how}.sock').exists) + nine = Client(root / f'pardes-9p-{how}.sock') + session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) + pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text') + wait_for('drawn', lambda: b'line 3 of the notes' in t.text(), timeout=30) + links = sockets(c.pid) + mark = len(t.text()) + words = f'unsaved-{how}'.encode() + os.write(t.master, b'O' + words + b'\x1b') + wait_for('its keys in the session\'s text', lambda: words in nine.read(f'/pane/{pane}/body')) + if how == 'behind': + os.kill(c.pid, signal.SIGSTOP) + for k in range(30): + nine.write(f'/pane/{pane}/exec', f'Edit 3a/ edit {k} /\n'.encode()) + time.sleep(.1) + os.kill(c.pid, signal.SIGCONT) + deadline = time.monotonic() + 30 + while b'joined again' not in t.text()[mark:]: + went = [w for w, gone in (('the client', c.poll() is not None), ('the session', not alive(session))) if gone] + assert not went, (f'{how}: {" and ".join(went)} went (client exit {c.poll()}); ' + f'its terminal\'s last bytes: {t.text()[-600:]!r}') + assert time.monotonic() < deadline, f'{how}: the client joined again' + os.write(t.master, b'jk') + time.sleep(.2) + said = b'this client diverged' if how == 'diverged' else b' s behind' + wait_for(f'{how}: its notice says why', lambda: said in t.text()[mark:], timeout=10) + assert c.poll() is None and alive(session), (how, c.poll()) + assert sockets(c.pid) == links, (f'{how}: joined again over its own link', links, sockets(c.pid)) + assert words in nine.read(f'/pane/{pane}/body'), how + seen = len(checks(check)) + os.write(t.master, b'jj') + wait_for(f'{how}: the client agrees after it', lambda: agreed(check, seen), timeout=30) + nine.socket.close() + t.close() + terms.remove(t) + c.wait(timeout=20) + wait_for(f'{how}: the session ended with its last link', lambda: not alive(session), timeout=20) + print(f'pair back: no daemon, its client {how}: joined again over its own link, the session alive, ' + f'its unsaved text there, agreed; its terminal closed, the session ended') + wait_for('nothing left', lambda: not [p for p in processes(root) if alive(p)], timeout=20) + finally: + for p in processes(root): + try: + os.kill(p, signal.SIGKILL) + except OSError: + pass + for t in terms: + t.close() + shutil.rmtree(root, ignore_errors=True) + + 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 @@ -1217,12 +1335,18 @@ def pair_upgrade_views(binary): shutil.rmtree(root, ignore_errors=True) -def pair_exec_reaps(old, new): +def pair_exec_reaps(old, new, early=False): """PARDES_PAIR across builds: a pair started from `root/bin` (old), its session upgraded to the build installed there since (new): its client, the session's parent, execs that build (the blink) and is still its parent; Exit typed then: the client returns once the session is gone, - reaped, its status the session's (0), as before the exec.""" + reaped, its status the session's (0), as before the exec. `early`: old + and new the same build, installed again at once, before the session's + first pass round its loop, where it first looks its start path up + (upgrade.zig `locate`), and as the client starts the daemon from its + own (daemon.zig `spawn`): the path is the path, not Linux's "PATH + (deleted)", so the daemon starts and the session execs it; the client, + its build the session's still, joins again in place (no exec).""" scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rpx-', dir=scratch)) @@ -1237,36 +1361,48 @@ def pair_exec_reaps(old, new): notes = root / 'notes.txt' notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30))) terms = [] + sock = root / 'pardes-9p-px.sock' + c = session = None try: t = Term(30, 100) terms.append(t) c = t.spawn([str(binary), '--9p=px', str(notes)], env) - sock = root / 'pardes-9p-px.sock' + if early: + install(new, binary) wait_for('the socket', sock.exists) nine = Client(sock) session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) assert ppid(session) == c.pid wait_for('drawn', lambda: b'line 3 of the notes' in t.text(), timeout=30) - install(new, binary) + if not early: + install(new, binary) ino = sock.stat().st_ino # Before the Upgrade: the exec'd client can draw before its exec is seen. mark = len(t.text()) nine.write('/ctl', b'Upgrade\n') nine.socket.close() wait_for('the session exec\'d', lambda: sock.stat().st_ino != ino, timeout=60) - wait_for('the client on the new build', lambda: exe_of(c.pid) == (str(binary), True), timeout=30) + if early: + wait_for('joined again in place', lambda: b'joined again' in t.text()[mark:], timeout=30) + else: + wait_for('the client on the new build', lambda: on_build(c, binary), timeout=30) nine = reconnect(sock) assert ppid(session) == c.pid # The blink: its screen left and entered again, the notes drawn there. - wait_for('drawn again', lambda: (lambda x: x.rfind(b'\x1b[?1049h') > x.rfind(b'\x1b[?1049l') > mark - and b'line 3 of the notes' in x[x.rfind(b'\x1b[?1049h'):])(t.text()), timeout=30) + if not early: + wait_for('drawn again', lambda: b'line 3 of the notes' in (entered_again(t.text(), mark) or b''), timeout=30) nine.write('/ctl', b'Exit\n') nine.socket.close() assert c.wait(timeout=30) == 0, c.returncode # Its parent's wait returned: the session reaped, not a zombie left # to whoever takes it in. assert not os.path.exists(f'/proc/{session}') if procfs else not alive(session), open(f'/proc/{session}/stat').read() - print('pair exec reaps: a pair\'s client exec\'d at its session\'s Upgrade still reaps it at Exit, status 0') + print('pair exec reaps: a pair\'s client exec\'d at its session\'s Upgrade still reaps it at Exit, status 0' + + (' (the same build installed again before the session looked its path up: joined again in place)' if early else '')) + except (TimeoutError, AssertionError, OSError, EOFError, subprocess.TimeoutExpired) as err: + kept = keep_evidence('pair-exec', root, env, binary, sock, [('session', session)] if session else [], + [('client', t, c, root / 'client.check', root / 'client.stats')] if c else []) + raise AssertionError(f'{type(err).__name__}: {err} (kept: {kept})') from None finally: for p in processes(root): try: @@ -1324,8 +1460,8 @@ def far_exec(old, new): nine.socket.close() wait_for('the session exec\'d', lambda: sock.stat().st_ino != ino, timeout=60) nine = reconnect(sock) - wait_for('the far client on the new build', lambda: exe_of(c.pid) == (str(binary), True), timeout=30) - wait_for('the terminal entered again', lambda: t.text().rfind(b'\x1b[?1049h') > t.text().rfind(b'\x1b[?1049l') > mark, timeout=30) + wait_for('the far client on the new build', lambda: on_build(c, binary), timeout=30) + wait_for('the terminal entered again', lambda: entered_again(t.text(), mark), timeout=30) # Its environment read once the new image runs (it entered the # screen): an exec names the new file in /proc/PID/exe before it has # written where the environment is, and a read between gets nothing @@ -1403,7 +1539,7 @@ def pair_window_geometry(gui_binary, new_gui): nine.write('/ctl', b'Upgrade\n') nine.socket.close() wait_for('the session exec\'d', lambda: sock.stat().st_ino != ino, timeout=60) - wait_for('the window on the new build', lambda: exe_of(p.pid) == (str(gui), True), timeout=30) + wait_for('the window on the new build', lambda: on_build(p, gui), timeout=30) nine = reconnect(sock) time.sleep(3) assert grid(nine) == sized, ('the exec\'d window the size it had', grid(nine), sized, plain) @@ -1458,8 +1594,7 @@ def manage(binary): c.write('/pane/1/exec', b'Term\n') wait_for(f'session {name}\'s shell', lambda: terminals(c)) shell = terminals(c)[0] - wait_for(f'session {name}\'s shell answers', lambda: run(c, shell, b'true\n') == b'exit 0\n') - shells[name] = int(run(c, shell, b'echo $$\n').split(b'\n')[1]) + shells[name] = pid_in(c, shell) started.append(shells[name]) daemon = [p for p in processes(root) if cmdline(p)[1:2] == [b'--daemon']][0] started.append(daemon) @@ -1563,8 +1698,7 @@ def relink(binary): work.write('/pane/1/exec', b'Term\n') wait_for('its shell', lambda: terminals(work)) shell = terminals(work)[0] - wait_for('its shell answers', lambda: run(work, shell, b'true\n') == b'exit 0\n') - shell_pid = int(run(work, shell, b'echo $$\n').split(b'\n')[1]) + shell_pid = pid_in(work, shell) started.append(shell_pid) term = Term() terms.append(term) @@ -1576,7 +1710,7 @@ def relink(binary): started.append(own_pid) wait_for('its first frame', lambda: b'\x1b[?1049h' in term.text()) own_shell = terminals(own)[0] - own_shell_pid = int(run(own, own_shell, b'echo $$\n').split(b'\n')[1]) + own_shell_pid = pid_in(own, own_shell) started.append(own_shell_pid) expected = [f'session work {session} {listed_as("detached")}', f'session own {own_pid} {listed_as("has a frontend")}', f'shell {shell_pid}', f'shell {own_shell_pid}'] @@ -1608,8 +1742,7 @@ def relink(binary): before = set(terminals(own)) own.write(f'/pane/{min(before)}/exec', b'Adopt\n') pane = wait_for('the adopted pane', lambda: set(terminals(own)) - before).pop() - pid, said = adopted_pid(own, pane) - assert pid == str(shell_pid).encode(), (said, shell_pid) + assert (pid := pid_in(own, pane)) == shell_pid, (pid, shell_pid) print(f'relink: a client attached to the session through the new daemon; killed outright, its shell {shell_pid} was adopted') exit_session(own, pane) stub.wait(timeout=10) @@ -1659,7 +1792,7 @@ def answer_late(binary): one = Client(root / 'pardes-9p-one.sock') session = int(dict(line.split(maxsplit=1) for line in one.read('/status').decode().splitlines())['pid']) started.append(session) - shell_pid = int(run(one, terminals(one)[0], b'echo $$\n').split(b'\n')[1]) + shell_pid = pid_in(one, terminals(one)[0]) started.append(shell_pid) daemon = [p for p in processes(root) if cmdline(p)[1:2] == [b'--daemon']][0] started.append(daemon) @@ -1683,8 +1816,7 @@ def answer_late(binary): two.write(f'/pane/{min(before)}/exec', b'Adopt\n') took = time.monotonic() - asked pane = wait_for('the adopted pane', lambda: set(terminals(two)) - before).pop() - pid, said = adopted_pid(two, pane) - assert pid == str(shell_pid).encode(), (said, shell_pid) + assert (pid := pid_in(two, pane)) == shell_pid, (pid, shell_pid) print(f'answer late: an Adopt asked while the daemon was stopped waited {took:.1f} s for its answer, ' f'and shell {shell_pid} was adopted') exit_session(two, pane) @@ -2233,8 +2365,8 @@ def far_flood(binary): started = [] terms = [] try: - sess = subprocess.Popen([binary, '--detach=files', str(notes)], env=env, cwd=root, stdin=subprocess.DEVNULL, - stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True) + sess = subprocess.Popen([binary, '--detach=files', str(notes)], env=dict(env, PARDES_REPLICA_STATS=str(root / 'session.stats')), + cwd=root, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True) started.append(sess.pid) sock = root / 'pardes-replica.sock' wait_for('the replica socket', sock.exists) @@ -2258,13 +2390,24 @@ def far_flood(binary): dict(env, PARDES_REPLICA_FAR='1', PARDES_REPLICA_CHECK=str(check), PARDES_REPLICA_STATS=str(stats))) started.append(c.pid) wait_for('the far client\'s first frame', lambda: b'line 3 of the notes' in t.text(), timeout=60) + links = sockets(c.pid) nine.write(f'/pane/{shell}/pty/data', b'timeout 20 yes; echo yes-done\r') wait_for('yes ended', lambda: b'yes-done' in nine.read(f'/pane/{shell}/body').replace(b'\r', b''), timeout=60) + ended_at = time.monotonic() seen = len(checks(check)) wait_for('the far client agrees once yes ended', lambda: agreed(check, seen), timeout=120) # Queued behind the flood, let go for its lag, joined again from a # dump: a link of its ended (its stats line), and its notice says why. assert joins(stats), ('no link of the far client ended under the flood', checks(stats)) + # Fallen behind, a far client dials again (core/replica.zig + # `Link.backHere`: the second road until bounded flight): a new + # connection, not what the old one holds for it read through; each + # join's time and the KB it was sent; the flood's end to its agreement. + same = sockets(c.pid) == links + print(f'far flood: the far client\'s link {"the same" if same else "another"} after {len(joins(stats))} joins again ' + f'(join ms {[j.get("join_ms") for j in joins(stats)]}, sent KB {[j.get("sent_kb") for j in joins(stats)]}); ' + f'agreed {time.monotonic() - ended_at:.1f} s after yes ended') + assert not same, ('the far client behind dialled again: another connection', links, sockets(c.pid)) wait_for('the far client\'s notice of its join again', lambda: b'joined again: ' in t.text() and b' s behind' in t.text(), timeout=30) os.write(t.master, b'echo from-far\r') wait_for('the far client\'s keys in the shell', lambda: b'from-far' in nine.read(f'/pane/{shell}/body'), timeout=30) @@ -2726,6 +2869,46 @@ def cpu_ticks(pid): return int(stat[11]) + int(stat[12]) +def killed_session(binary): + """A terminal's session killed outright (KILL, as the OOM killer does): + the job its terminal waits on ends with it, and says nothing of its own + (no trace): the own path's stub dead of the same signal, as a job is + (daemon.zig `stubWait`, which aborted re-raising a KILL); a pair's + client let go of its session, 1.""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='rk-', dir=scratch)) + env = base_env() + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + notes = root / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30))) + t = Term(30, 100) + try: + c = t.spawn([binary, '--9p=k', str(notes)], env) + sock = root / 'pardes-9p-k.sock' + wait_for('the socket', sock.exists) + with Client(sock) as nine: + session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) + wait_for('drawn', lambda: b'line 3 of the notes' in t.text(), timeout=30) + os.kill(session, signal.SIGKILL) + code = c.wait(timeout=30) + said = t.last() + assert b'panic' not in said and b'unreachable' not in said, said[-1500:] + assert code == (1 if WITH_PAIR else -signal.SIGKILL), (code, said[-600:]) + print(f'killed session: its terminal\'s job ended {code} with it, no trace') + finally: + for p in processes(root): + try: + os.kill(p, signal.SIGKILL) + except OSError: + pass + t.close() + shutil.rmtree(root, ignore_errors=True) + + def kitty_image(binary, secs=5): """A plain attach watching a terminal in which a program shows a kitty image (the corpus's scene 10's: 8x8 RGB, 10x4 cells): it @@ -2825,6 +3008,7 @@ def main(binary, cycles): launch(binary) pair(binary) pair_rows(binary) + pair_back(binary) attach_upgrading(binary) kept_views(binary) pair_upgrade_views(binary) @@ -2833,7 +3017,7 @@ def main(binary, cycles): answer_late(binary) kitty_image(binary) shell = terminals(client)[0] - shell_pid = int(run(client, shell, b'echo $$\n').split(b'\n')[1]) + shell_pid = pid_in(client, shell) started.append(shell_pid) # Detach in the terminal it was born with: the stub ends (exit 0, # its words), the terminal put back; the session runs on detached, @@ -2974,8 +3158,7 @@ def main(binary, cycles): client.write(f'/pane/{min(before)}/exec', b'Adopt\n') adopted = wait_for('the adopted pane', lambda: set(terminals(client)) - before) pane = adopted.pop() - pid, said = adopted_pid(client, pane) - assert pid == str(shell_pid).encode(), said + assert (pid := pid_in(client, pane)) == shell_pid, (pid, shell_pid) print(f'daemon: shell {shell_pid} outlived kill -9 of its session and was adopted') # Attached again: a client. (After the runs: a pty/run under a # client puts it off the session's state, and it joins again; one @@ -3265,7 +3448,10 @@ def exe_of(pid): if not procfs: rows = subprocess.run(['procstat', '-b', str(pid)], capture_output=True).stdout.decode().splitlines() return (rows[-1].split()[-1] if len(rows) > 1 else ''), None - link = os.readlink(f'/proc/{pid}/exe') + try: + link = os.readlink(f'/proc/{pid}/exe') + except OSError: # gone, or a zombie: it runs nothing + return '', False try: same = os.stat(f'/proc/{pid}/exe').st_ino == os.stat(link).st_ino except OSError: @@ -3273,6 +3459,22 @@ def exe_of(pid): return link, same +def entered_again(text, mark): + """The blink of a client exec'd at an Upgrade: its terminal's screen + left at or after `mark` (the text's length before the Upgrade: when the + reader had read all the old client wrote, the leave is its very next + byte) and entered again. What was drawn since that enter, or None.""" + enter, leave = text.rfind(b'\x1b[?1049h'), text.rfind(b'\x1b[?1049l') + return text[enter:] if enter > leave >= mark else None + + +def on_build(proc, binary): + """Whether the test's child `proc` runs `binary` now (exe_of); one that + ended says so with its status at once, not as a wait run out.""" + assert proc.poll() is None, f'pid {proc.pid} ended ({proc.returncode}) before it ran {binary}' + return exe_of(proc.pid) == (str(binary), True) + + def ppid(pid): if not procfs: return int(ps('-o', 'ppid=', '-p', str(pid))) @@ -3382,7 +3584,7 @@ def upgrades(old, new): daemon = wait_for('the daemon', lambda: [p for p in processes(root) if cmdline(p)[1:2] == [b'--daemon']])[0] started.append(daemon) shell = terminals(client)[0] - shell_pid = int(run(client, shell, b'echo $$\n').split(b'\n')[1]) + shell_pid = pid_in(client, shell) started.append(shell_pid) client.write(f'/pane/{shell}/look', f'{notes}\n'.encode()) text = int(client.read('/look')) @@ -3572,7 +3774,7 @@ def upgrades(old, new): 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' - assert run(client, shell, b'echo $$\n').split(b'\n')[1] == str(shell_pid).encode() + assert (pid := pid_in(client, shell)) == shell_pid, (pid, shell_pid) print('upgrade: a build that refused the dump fell back to the one running; the shell ran on') # One that refuses it everywhere: a fresh session, the shells adopted. @@ -3585,8 +3787,8 @@ def upgrades(old, new): kept = client.read('/dumps').decode() assert any(line.split()[0].startswith(f'upgrade-{session}') for line in kept.splitlines()), kept assert alive(shell_pid) and ppid(shell_pid) == session, ('the shell under the fresh session', shell_pid, alive(shell_pid) and ppid(shell_pid), session) - pids = {p: run(client, p, b'echo $$\n') for p in terminals(client)} - adopted = [p for p, out in pids.items() if out.split(b'\n')[1:2] == [str(shell_pid).encode()]] + pids = {p: pid_in(client, p) for p in terminals(client)} + adopted = [p for p, pid in pids.items() if pid == shell_pid] assert adopted, ('the shell is a pane of the fresh session', shell_pid, pids, client.read('/index')) print(f'upgrade: a build that refused it everywhere started afresh, shell {shell_pid} adopted, the dump kept') @@ -3623,8 +3825,7 @@ def upgrades(old, new): before = set(terminals(client)) client.write(f'/pane/{min(before)}/exec', b'Adopt\n') pane = wait_for('the adopted pane', lambda: set(terminals(client)) - before).pop() - pid, said = adopted_pid(client, pane) - assert pid == str(shell_pid).encode(), (said, shell_pid) + assert (pid := pid_in(client, pane)) == shell_pid, (pid, shell_pid) print(f'upgrade: the upgraded daemon kept shell {shell_pid} through kill -9 of its session, and it was adopted') exit_session(client, pane) stub.wait(timeout=10) @@ -3723,7 +3924,7 @@ def upgrade_clients(old, new): nine = Client(sock) session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) shell = terminals(nine)[0] - shell_pid = int(run(nine, shell, b'echo $$\n').split(b'\n')[1]) + shell_pid = pid_in(nine, shell) t = Term(30, 100) terms.append(t) tc = t.spawn([str(binary), 'attach', 'up'], dict(env, PARDES_REPLICA_CHECK=str(root / 't.check'))) @@ -3761,7 +3962,7 @@ def upgrade_clients(old, new): wait_for('the terminal client on the new build', lambda: exe_of(tc.pid) == (str(binary), True), timeout=30) wait_for('the window client on the new build', lambda: exe_of(w.pid) == (str(gui_binary), True), timeout=30) # The blink: its screen left, and entered again. - wait_for('the terminal entered again', lambda: t.text().rfind(b'\x1b[?1049h') > t.text().rfind(b'\x1b[?1049l') > mark, timeout=30) + wait_for('the terminal entered again', lambda: entered_again(t.text(), mark), timeout=30) assert tc.poll() is None and w.p.poll() is None for (key, check), pane, theirs in zip(owners, mine, reversed(mine)): if knows_exec(new): @@ -3828,7 +4029,7 @@ def gui_upgrades(old, new): daemon = wait_for('the daemon', lambda: [p for p in processes(root) if cmdline(p)[1:2] == [b'--daemon']])[0] started.append(daemon) shell = terminals(client)[0] - shell_pid = int(run(client, shell, b'echo $$\n').split(b'\n')[1]) + shell_pid = pid_in(client, shell) started.append(shell_pid) client.write(f'/pane/{shell}/look', f'{notes}\n'.encode()) text = int(client.read('/look')) @@ -3908,6 +4109,9 @@ if __name__ == '__main__': far_exec(old, new) else: print('far exec: skipped: the old build\'s far client, cut at the Upgrade with no last word, takes it for its session\'s end (no PARDES_JOIN_SIZE)') + # A reinstall of the new build before the pair's first look: the + # new build's own, whatever the old one does. + pair_exec_reaps(new, new, early=True) # With a pardes-gui beside each: the clients carried too. if all(a.with_name('pardes-gui').exists() for a in (old, new)): upgrade_clients(old, new) @@ -3927,8 +4131,11 @@ if __name__ == '__main__': elif sys.argv[1:2] == ['--pair']: pair(sys.argv[2]) pair_rows(sys.argv[2]) + pair_back(sys.argv[2]) attach_upgrading(sys.argv[2], dump=False) pair_upgrade_views(sys.argv[2]) + elif sys.argv[1:2] == ['--pair-back']: + pair_back(sys.argv[2]) elif sys.argv[1:2] == ['--attach-upgrading']: attach_upgrading(sys.argv[2]) elif sys.argv[1:2] == ['--relink']: @@ -3941,6 +4148,8 @@ if __name__ == '__main__': far_flood(sys.argv[2]) by_hash(sys.argv[2]) far_find(sys.argv[2]) + elif sys.argv[1:2] == ['--far-flood']: + far_flood(sys.argv[2]) elif sys.argv[1:2] == ['--far-find']: far_find(sys.argv[2]) elif sys.argv[1:2] == ['--kitty-image']: @@ -3960,3 +4169,4 @@ if __name__ == '__main__': gui_pair(args[0]) else: main(sys.argv[1], int(sys.argv[2]) if len(sys.argv) > 2 else 50) + killed_session(sys.argv[1]) diff --git a/test/process/look_and_exec.zig b/test/process/look_and_exec.zig index 9829797b..8ba52534 100644 --- a/test/process/look_and_exec.zig +++ b/test/process/look_and_exec.zig @@ -118,18 +118,8 @@ fn canary(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // A terminal: pty/run failing then passing. const term = try f.madeBy(1, "Term\n"); - { - const deadline = process.nowMs() + 10_000; - while (true) { - const answer = try f.run(term, "true\n"); - if (std.mem.eql(u8, answer, "exit 0\n")) break; - if (process.nowMs() > deadline) { - std.debug.print("pty/run answered {s}\n", .{answer}); - return error.Timeout; - } - process.nap(50); - } - } + // Asked at once: a run waits for its first prompt and its greeting. + try std.testing.expectEqualStrings("exit 0\n", try f.run(term, "true\n")); try std.testing.expectEqualStrings("exit 1\n", try f.run(term, "false\n")); try std.testing.expectEqualStrings("exit 0\npassed\n", try f.run(term, "echo passed\n")); // (A run's answer is its record: the log has no err for these.) diff --git a/test/process/terminals.zig b/test/process/terminals.zig index 151b221b..8d595120 100644 --- a/test/process/terminals.zig +++ b/test/process/terminals.zig @@ -111,15 +111,6 @@ fn sizeLines(a: std.mem.Allocator, c: *process.Conn, n: u32) ![]const []const u8 return out.items; } -/// A shell takes runs: its first prompt, or the one started again. -fn prompted(a: std.mem.Allocator, c: *process.Conn, term: u32) !void { - const deadline = eh.nowMs() + 10_000; - while (!std.mem.eql(u8, try run(a, c, term, "true\n"), "exit 0\n")) { - if (eh.nowMs() > deadline) return error.NoPrompt; - process.sleep(50); - } -} - fn sizedFork(gpa: std.mem.Allocator, exe: [:0]const u8) !void { var d = try process.Detached.start(gpa, exe, "sized", .{}); defer d.deinit(); @@ -135,7 +126,7 @@ fn sizedFork(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // the screen's 160x50. try c.write("/exec", "Term\n"); const term = try c.newest(gpa); - try prompted(a, c, term); + // Asked at once: a run waits for its first prompt and its greeting. var got = try sttySize(a, c, term); try expect(!std.mem.eql(u8, got[1], "50 160")); try expectEqualStrings(got[1], got[0]); @@ -200,11 +191,7 @@ fn runFile(gpa: std.mem.Allocator, exe: [:0]const u8) !void { const serial = try std.fmt.parseInt(u32, w.next().?, 10); if (std.mem.eql(u8, w.next().?, "term")) term = @max(term, serial); } - const deadline = eh.nowMs() + 10_000; - while (std.mem.eql(u8, try run(a, c, term, "true\n"), "busy\n")) { // deadline its first prompt - if (eh.nowMs() > deadline) return error.NoPrompt; - process.sleep(50); - } + try expectEqualStrings("exit 0\n", try run(a, c, term, "true\n")); // asked at once: it waits for the first prompt, and the greeting's try expectEqualStrings("exit 1\n", try run(a, c, term, "false\n")); try expectEqualStrings("exit 0\none\ntwo\n", try run(a, c, term, "printf \"one\\ntwo\\n\"\n")); // then what it printed try expectEqualStrings("exit 7\n", try run(a, c, term, "sh -c \"exit 7\"\n")); diff --git a/test/replicas.zig b/test/replicas.zig index 8f3e5ca5..3aa9263e 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -251,6 +251,8 @@ const Totals = struct { /// Joins from a dump, refused, again after a divergence put on it /// (PARDES_TEST_DIVERGE's), and clients that left; quiet checks. joins: u64 = 0, + /// ...of them again over the client's own link (no dial). + here: u64 = 0, refused: u64 = 0, /// A pair's client's own boot the session's core at its join (`--pair`), /// or not (its dump loaded instead, the fields that differ said). @@ -527,11 +529,10 @@ const Client = struct { stops: @FieldType(replica.Stats, "stops") = @splat(.{}), /// Its Peer's writer's (`Soak.write`): the batch swapped out of the /// session's queue for it (the Peers' allocator's), how much of it went - /// down the link, whether a cut's words end it, a wake asked for room; - /// how much of the queue carries the soak's clock (`Soak.stamp`). + /// down the link, a wake asked for room; how much of the queue carries + /// the soak's clock (`Soak.stamp`). sending: std.ArrayListUnmanaged(u8) = .empty, at: usize = 0, - last: bool = false, draining: bool = false, marked: usize = 0, /// The session's unit its last join's dump came after. @@ -752,14 +753,17 @@ fn describe(buf: []u8, ev: pardes.Event) []const u8 { } catch "?"; } -/// Its link ended (it diverged, or it quits): its bye, and its join again -/// for its view after a divergence (`Link.rejoins`), the core it leaves -/// held until the dump comes, as `replica.join` holds it. +/// Its link ended (it diverged, fell behind, was cut off, or it quits): +/// its join again for its view (`Link.rejoins`), over its link while that +/// is up (its goodbye and hello said there: runtime/client.zig `run`), the +/// core it leaves held until the dump comes, as `replica.join` holds it; +/// else its bye. fn ended(cl: *Client, c: usize, net: *Net, now: u64, totals: *Totals, run_: Run, typing: *usize) !void { const r = cl.r.?; const link = &cl.loop.link; + const here = link.backHere() and replica.comeBack(link.fd, "soak", r.view); // Its link ended by the session (a Detach), it says nothing more. - if (!link.gone) replica.bye(link.fd, .{ .again = r.diverged != null or link.lagged != 0 }); + if (!here and !link.gone) replica.bye(link.fd, .{ .again = r.diverged != null or link.lagged != 0 }); try drain(cl, c, net, now); cl.live = 0; if (link.lagged != 0) { @@ -775,6 +779,10 @@ fn ended(cl: *Client, c: usize, net: *Net, now: u64, totals: *Totals, run_: Run, if (link.rejoins()) { cl.back = r.view; cl.dialling = true; + if (here) { + totals.here += 1; + return; + } return net.send(.{ .at = net.cross(&net.up[c], c, now, &.{}, 3), .n = 0, .kind = .dial, .who = @intCast(c + 1), .bytes = &.{} }); } try totals.add(&r.stats); @@ -1435,10 +1443,8 @@ const Soak = struct { if (!there) cl.peer = null; }; // A join taken (its Peer holds the dup handed) or refused (its dup - // closed, daemon.refuseReplica): its writer's join first (the - // welcome, then the dump with the session's blobs put back where - // they go: Peer.writeJoin), its far word read (`far` false: on - // this machine), and its pins let go at the next boundary. + // closed, daemon.refuseReplica): its writer's join first (`joinDown`), + // its far word read (`far` false: on this machine). for (s.clients, 0..) |*cl, c| if (cl.handed >= 0) { defer cl.handed = -1; const peer = for (ps.list) |slot| { @@ -1448,44 +1454,17 @@ const Soak = struct { try net.toClient(c, now, .refused, cl.gen, &.{}); continue; }; - const f = (try pardes.wire.framed(peer.welcome[0..peer.welcome_len])) orelse return error.BadWelcome; - const welcome = (try pardes.wire.decodeServer(f.tag, f.payload)).welcome; - var whole: std.ArrayListUnmanaged(u8) = .empty; - errdefer whole.deinit(gpa); - var pos: usize = 0; - for (peer.blobs.items) |b| { - try whole.appendSlice(gpa, peer.dump[pos..b.at]); - try whole.appendSlice(gpa, b.bytes); - pos = b.at; - } - try whole.appendSlice(gpa, peer.dump[pos..]); var word: [16]u8 = undefined; const far = try pardes.wire.encodeClient(&word, .{ .far = false }); _ = peer.take(far[0], far[pardes.wire.header_len..]); - ps.post(.{ .joined = peer }); - cl.peer = peer; - cl.shut = false; - cl.read_done = false; - cl.join_seq = ps.seq; - cl.sending.clearRetainingCapacity(); - cl.at = 0; - cl.last = false; - cl.marked = 0; - // What the join cost the session's step (Peers.join's measure). - s.join_worst = @max(s.join_worst, ps.join_ns); - try s.totals.join_session_ns.append(gpa, ps.join_ns); - ps.join_ns = 0; - cl.gen += 1; - cl.id = welcome.client; - cl.view = welcome.view.index(); - cl.digest = welcome.digest; - s.totals.joins += 1; - Witness.joined(c, cl, try gpa.dupe(u8, whole.items), cl.join_seq); - try net.toClient(c, now, .dump, cl.gen, try whole.toOwnedSlice(gpa)); + try s.joinDown(cl, c, peer); }; - // A Detach typed in a client's view, or one cut off for its lag: its - // link shut, it hears its end and nothing after; its reader's end - // said (the next boundary lets it go). + // A join again over a client's own link (Peers.joinAgain): its writer's + // next, the stream it leaves let go. + for (s.clients, 0..) |*cl, c| if (cl.peer) |peer| if (peer.written != peer.gen) try s.joinDown(cl, c, peer); + // A Detach typed in a client's view: its link shut, it hears its end + // and nothing after; its reader's end said (the next boundary lets + // it go). if (s.detach_view) |k| for (s.clients) |*cl| if (cl.peer) |p| if (p.view.index() == k and !cl.shut) { cl.shut = true; }; @@ -1513,6 +1492,44 @@ const Soak = struct { s.echo.clearRetainingCapacity(); } + /// Client `c`'s Peer's writer's join (Peer.writeJoin): the welcome, then + /// the dump with the session's blobs put back where they go, down its + /// link, what was queued before it let go; its pins let go at the next + /// boundary. + fn joinDown(s: *Soak, cl: *Client, c: usize, peer: *replica.Peer) !void { + const ps = &s.l.peers; + const f = (try pardes.wire.framed(peer.welcome[0..peer.welcome_len])) orelse return error.BadWelcome; + const welcome = (try pardes.wire.decodeServer(f.tag, f.payload)).welcome; + var whole: std.ArrayListUnmanaged(u8) = .empty; + errdefer whole.deinit(gpa); + var pos: usize = 0; + for (peer.blobs.items) |b| { + try whole.appendSlice(gpa, peer.dump[pos..b.at]); + try whole.appendSlice(gpa, b.bytes); + pos = b.at; + } + try whole.appendSlice(gpa, peer.dump[pos..]); + peer.written = peer.gen; + ps.post(.{ .joined = .{ .peer = peer, .gen = peer.gen } }); + cl.peer = peer; + cl.shut = false; + cl.read_done = false; + cl.join_seq = ps.seq; + cl.sending.clearRetainingCapacity(); + cl.at = 0; + cl.marked = 0; + // What the join cost the session's step (Peers.join's measure). + s.join_worst = @max(s.join_worst, ps.join_ns); + try s.totals.join_session_ns.append(gpa, ps.join_ns); + ps.join_ns = 0; + cl.gen += 1; + cl.id = welcome.client; + cl.view = welcome.view.index(); + cl.digest = welcome.digest; + s.totals.joins += 1; + Witness.joined(c, cl, try gpa.dupe(u8, whole.items), cl.join_seq); + try s.net.toClient(c, s.now, .dump, cl.gen, try whole.toOwnedSlice(gpa)); + } /// The units the session queued for client `cl` since, their heads /// carrying the soak's clock, the session's here (its host's `now`): /// what the client's lag is measured by. Its replica guesses no clock @@ -1534,7 +1551,7 @@ const Soak = struct { /// frame a message. The far link takes no more than `throttle_window` /// ahead of what has crossed: the rest waits in the queue, as it does /// for a writer blocked on its socket, until room comes (`.drain`). A - /// cut's words end a batch, and its link after them. + /// cut's words are its last until its client's hello again there. fn write(s: *Soak, cl: *Client, c: usize) !void { const peer = cl.peer orelse return; const net = s.net; @@ -1543,11 +1560,9 @@ const Soak = struct { if (cl.at == cl.sending.items.len) { cl.sending.clearRetainingCapacity(); cl.at = 0; - if (cl.last) return s.shut(cl, c); const io = s.l.peers.io; peer.lock.lockUncancelable(io); std.mem.swap(std.ArrayListUnmanaged(u8), &peer.out, &cl.sending); - cl.last = peer.cut; peer.lock.unlock(io); cl.marked = 0; if (cl.sending.items.len == 0) return; @@ -1590,11 +1605,10 @@ const Soak = struct { } /// Client `c`'s link ended at the session's side (a Detach typed in its - /// view, or the words of a cut sent): it hears its end and nothing after, - /// and its reader's end is said (the next boundary lets it go). + /// view): it hears its end and nothing after, and its reader's end is + /// said (the next boundary lets it go). fn shut(s: *Soak, cl: *Client, c: usize) !void { cl.shut = true; - cl.last = false; if (cl.read_done) return; cl.read_done = true; s.l.peers.post(.{ .gone = cl.peer.? }); @@ -3400,7 +3414,7 @@ pub fn main(init: std.process.Init) !void { try stop_lines.print(gpa, "{d:>4} {d:>8} {d:>6} {d:>6} {d:>3}/{d}/{d} ", .{ rtt, t.unlisted, t.wakes, t.draws, t.asked[0], t.asked[1], t.asked[2] }); for (t.stops) |st| if (st.n > 0) try stop_lines.print(gpa, "{s}:{d} ", .{ st.name, st.n }); try stop_lines.append(gpa, '\n'); - try join_lines.print(gpa, "{d:>4} {d:>5} {d:>7} {d:>8} {d:>8} {d:>6} {d:>5}/{d:<5} {d:>5}/{d:<6} {d:>7} {d:>5}/{d}/{d}\n", .{ rtt, t.joins, t.refused, t.rejoined, t.detached, t.detach_words, t.agree, t.differ, t.checks, t.units, t.resizes, t.kind_panes[0], t.kind_panes[1], t.kind_panes[2] }); + try join_lines.print(gpa, "{d:>4} {d:>5} {d:>4} {d:>7} {d:>8} {d:>8} {d:>6} {d:>5}/{d:<5} {d:>5}/{d:<6} {d:>7} {d:>5}/{d}/{d}\n", .{ rtt, t.joins, t.here, t.refused, t.rejoined, t.detached, t.detach_words, t.agree, t.differ, t.checks, t.units, t.resizes, t.kind_panes[0], t.kind_panes[1], t.kind_panes[2] }); try far_lines.print(gpa, "{d:>4} {d:>5} {d:>4} {d:>6.1}/{d:<6.1} {d:>6.1}/{d:<6.1} {d:>8} {d:>3} {d:>6.1}/{d:<6.1} {d:>6.1}/{d:<6.1} ({d}) {d:>6.0}/{d:<6.0} {d}\n", .{ rtt, t.far_joins, t.far_lags, secs(pct(t.far_gaps.items, 50)), secs(pct(t.far_gaps.items, 100)), @@ -3419,8 +3433,8 @@ pub fn main(init: std.process.Init) !void { } std.debug.print("terminals: a peer's unit bytes a second under the flood (the pty's bytes ride in them); KB of units sent to the peers in all\n", .{}); std.debug.print(" rtt unit B/s units KB\n{s}", .{term_lines.items}); - std.debug.print("clients: joins from a dump, refused (every view taken), joined again after a divergence put on them, left (of them by a Detach); quiet checks of the session's digest agreed/differed; the digests the clients compared (units and quiet), of the units they took; resizes the windows posted; the kinds' panes the session opened (image/life/pdf)\n", .{}); - std.debug.print(" rtt joins refused rejoined detached detach agree/differ checks/units resizes kinds\n{s}", .{join_lines.items}); + std.debug.print("clients: joins from a dump (here: of them again over the client's own link, no dial), refused (every view taken), joined again after a divergence put on them, left (of them by a Detach); quiet checks of the session's digest agreed/differed; the digests the clients compared (units and quiet), of the units they took; resizes the windows posted; the kinds' panes the session opened (image/life/pdf)\n", .{}); + std.debug.print(" rtt joins here refused rejoined detached detach agree/differ checks/units resizes kinds\n{s}", .{join_lines.items}); std.debug.print("stops: the wakes the clients' loops asked, the frames they drew, the yanks, pastes and links their frontends did (y/p/l), and what stopped their inputs (a stop counted again as its input is applied again), by name; those at a name replica.may_wait does not list fail the run\n", .{}); std.debug.print(" rtt unlisted wakes draws y/p/l stops\n{s}", .{stop_lines.items}); std.debug.print("far: the third client's link 1 Mbit/s and 200 ms each way (zstd's bytes): its joins from a dump, of them for its lag (Link.behind past replica.behind_max_ms), s between two from the flood's start (p50/max), s from the flood's end to its final screen (p50/max: a run that never shows it fails), the session's queue for it at most, clients cut off; a join's cost to the replicas there before it, ms on this process's clock (p50/max): the session's step (reloads and dump), a client's unit (reloads), how many; ms behind the session at most (Link.behind), the far client and the others, and the others' joins for it (0, or the run fails)\n", .{}); |
