diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/daemon.py | 56 |
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' |
