summaryrefslogtreecommitdiff
path: root/test/replicas.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 02:40:21 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit757cdaa826131dc5ff2d3ff0b270b8abe041c81a (patch)
tree96de2e4537bc009d502bdf74b453e6964a12dff0 /test/replicas.zig
parent83b9d45b8665a80bdb70934aa23bbde5cc03d202 (diff)
downloadpardes-757cdaa826131dc5ff2d3ff0b270b8abe041c81a.tar.gz
pardes-757cdaa826131dc5ff2d3ff0b270b8abe041c81a.zip
plumber: external ports (docs/next-plumber.md, phase 3): every port a rule names has a file, plumb/<port> (0444), listed after rules and send in the order rules named them and never dropped (Plumb.ports, dumped: seeded at boot from the rules in force, grown by each apply, refused past 32), its node a third family in the tree beside panes and columns (Node.ofPort, Target.port; port_bit is 1 << 40, clear of the host tree's and the archive's high bits, which 1 << 57 hit); an open reads (Open.what.port, an events.Queue of its own, 64 KiB): the messages sent from then on, packed, one a read, a short read the front and the next the rest, a read with none held until one comes (p.fs.news, answered by the listener as event reads are); every open gets its copy (fanOut, plumber(4)'s queuesend), one over the queue is not sent to it and the log says so; a port pardes reads itself (edit, web, a loaded kind) hands its readers copies without asking anyone, so a look stays speculated whole; another port's readers are the authority's to know, asked through tape.authority (a replica's own look waits for the first answer and guesses the last), with none its rule set's start runs, or its client, the message held in p.fs.plumb_held for the port's first opener (Plumb.opened, plumber(4)'s queueheld); test: plumber.zig, two opens of plumb/edit each read a look's message while the file opens, an open made after reads nothing, a client's message reaches the first opener and the next goes to the reader with nothing started, a port is not written; monkey9p.zig gains the plumb/ files, rules and messages that start no program, the ports' reads as held reads, and plumb/rules' rest read at the close (whose refusal is the log's alone, as a line file's: restAtClose); replicas.zig: a look to a port a program reads, the second of a replica's own speculated whole and confirmed, digests equal; tree.zig's readdir test lists web and edit; the reference's tree and plumber section, fs-help and the changelog say so
Diffstat (limited to 'test/replicas.zig')
-rw-r--r--test/replicas.zig47
1 files changed, 46 insertions, 1 deletions
diff --git a/test/replicas.zig b/test/replicas.zig
index 0f23d5a8..5e49a3ac 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -608,7 +608,52 @@ fn plumbCase(dir: []const u8) !bool {
ok = false;
}
};
- std.debug.print("plumb: a URL and a commit hash looked at by the authority and as a replica's own input: {s}\n", .{if (ok) "the same session" else "FAILED"});
+ // A rule to a port a program reads (plumb/seemail), of a URL, which a
+ // look reads no disk for: whether the port is read is the authority's
+ // 9P state, asked through the tape. A replica's own look waits for the
+ // first answer, then guesses the last; the second look speculates whole
+ // and is confirmed with no rollback.
+ {
+ // The rule from the session's plumbing file, read at boot.
+ var pbuf: [256]u8 = undefined;
+ try writeText(try std.fmt.bufPrintSentinel(&pbuf, "{s}/plumbing", .{dir}, 0), "type is text\ndata matches 'https://letters/.*'\nplumb to seemail\n\ninclude basic\n");
+ const a = try replica.Authority.init(gpa, .{ .cols = 100, .rows = 30, .boot = .tty, .config_dir = dir }, host.host(), true);
+ defer a.deinit();
+ const first = try gpa.dupe(u8, try a.unit(0, 0));
+ defer gpa.free(first);
+ const rp = try replica.Replica.init(gpa, 1, first, true);
+ defer rp.deinit();
+ rp.confirm(try a.local(.{ .command = open }));
+ rp.settle();
+ if (pardes.Plumb.portIndex(rp.core(), "seemail") == null) {
+ std.debug.print("plumb: a look to a port: the plumbing file's port is not the replica's\n", .{});
+ ok = false;
+ }
+ for (0..2) |n| {
+ const before = rp.stats;
+ const msg = try gpa.dupe(u8, try rp.input(.{ .command = "Look https://letters/42" }));
+ defer gpa.free(msg);
+ if (n == 1 and (rp.stats.stopped != before.stopped or rp.stats.speculated == before.speculated)) {
+ std.debug.print("plumb: a look to a port: the replica's second look did not speculate whole ({d} stopped, {d} applied)\n", .{ rp.stats.stopped - before.stopped, rp.stats.speculated - before.speculated });
+ ok = false;
+ }
+ if (try a.pending()) |batch| rp.confirm(batch);
+ rp.confirm(try a.take(msg));
+ rp.settle();
+ }
+ if (rp.diverged) |why| {
+ std.debug.print("plumb: a look to a port: the replica diverged: {s}\n", .{why});
+ ok = false;
+ } else if (!rp.quiet() or rp.digest() != replica.digestOf(a)) {
+ std.debug.print("plumb: a look to a port: the replica's digest is not the authority's\n", .{});
+ ok = false;
+ }
+ if (rp.stats.mispredicted + rp.stats.foreign != 0) {
+ std.debug.print("plumb: a look to a port: {d} rollbacks\n", .{rp.stats.mispredicted + rp.stats.foreign});
+ ok = false;
+ }
+ }
+ std.debug.print("plumb: a URL, a commit hash and a look to a port read by programs, by the authority and as a replica's own input: {s}\n", .{if (ok) "the same session" else "FAILED"});
return ok;
}