Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cmd/mistgate-edge/testdata/bridge.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -563,14 +563,14 @@ async function assertProvisioner(bytes, forwardPanel, adminCookie, initOptions,
return countedJob("cron tick with installs", () => Promise.race([forwardPanel.cron({ at: at.getTime() }), wasmFailure]));
};
await insertJob("prv_done", "failed");
// 6 for the sweeps and settings, one read of the active rollout for the updates job, one Telegram pending-code check, one
// 6 for the sweeps and settings, one read of the active rollout for the updates job, one Telegram pending-code check, one check for due notices to people, one
// cheburcheck and one bsbord settings read while off, one read of the proposals that apply and 12 for a warm evaluator pass (see "cron tick" below); nothing in an install wakes more.
assert.equal((await tick(3)).queries.sequentialQueries, 23);
assert.equal((await tick(3)).queries.sequentialQueries, 24);
assert.equal(provisionKicks, 0, "a finished install wakes nothing");
for (const [i, state] of ["queued", "running", "cancel_requested"].entries()) {
await globalThis.__d1.prepare("DELETE FROM node_provision_job WHERE id = 'prv_open'").run();
await insertJob("prv_open", state);
assert.equal((await tick(3)).queries.sequentialQueries, 23, "waking costs no query beyond the look");
assert.equal((await tick(3)).queries.sequentialQueries, 24, "waking costs no query beyond the look");
assert.equal(provisionKicks, i + 1, `a ${state} install wakes the Provisioner`);
}
await globalThis.__d1.prepare("DELETE FROM node_provision_job").run();
Expand Down Expand Up @@ -1209,8 +1209,8 @@ async function run() {
console.log(`D1 query count ${JSON.stringify(normalCronQueries)}`);
assert.equal(
normalCronQueries.sequentialQueries,
28,
"a normal cron tick costs 28 D1 calls: 6 for the sweeps and the country settings, one read of the active rollout for the updates job, one Telegram pending-code check, one cheburcheck and one bsbord settings read while off, one read of the proposals that apply (none: no lease), and 17 for the isolate's first evaluator pass: its lease, nodes, inbounds, live nodes, doctor results and acceptances, the signal batch, port checks, UDP path losses, active alerts, the interval setting (read with the silent-port result in one call), the update rollout, the country settings, the node-summary write and one batched external-source settings read, and the silent-port count of the hour (one batch of statistics and one write of the result: the fleet has servers to judge)",
29,
"a normal cron tick costs 29 D1 calls: 6 for the sweeps and the country settings, one read of the active rollout for the updates job, one Telegram pending-code check, one check for due notices to people, one cheburcheck and one bsbord settings read while off, one read of the proposals that apply (none: no lease), and 17 for the isolate's first evaluator pass: its lease, nodes, inbounds, live nodes, doctor results and acceptances, the signal batch, port checks, UDP path losses, active alerts, the interval setting (read with the silent-port result in one call), the update rollout, the country settings, the node-summary write and one batched external-source settings read, and the silent-port count of the hour (one batch of statistics and one write of the result: the fleet has servers to judge)",
);

liveProjectionQueries = 0;
Expand All @@ -1225,8 +1225,8 @@ async function run() {
console.log(`D1 query count ${JSON.stringify(cronQueries)}`);
assert.equal(
cronQueries.sequentialQueries,
25,
"one minute 10 cron tick costs 25 D1 calls: the 7 of the sweeps, the country settings and the fan-out live read, one read of the active rollout for the updates job, one Telegram pending-code check, one Telegram bot check for the watcher, one cheburcheck and one bsbord settings read while off, one read of the proposals that apply (none: no lease), plus 12 for a warm evaluator pass (no nodes or inbounds read again, no summary write, the UDP path losses, and one batched external-source settings read)",
26,
"one minute 10 cron tick costs 26 D1 calls: the 7 of the sweeps, the country settings and the fan-out live read, one read of the active rollout for the updates job, one Telegram pending-code check, one check for due notices to people, one Telegram bot check for the watcher, one cheburcheck and one bsbord settings read while off, one read of the proposals that apply (none: no lease), plus 12 for a warm evaluator pass (no nodes or inbounds read again, no summary write, the UDP path losses, and one batched external-source settings read)",
);
assert.equal(liveProjectionQueries, 3, "the node-down sweep, the evaluator and the ten-minute safety net each read live nodes once");
assert.equal(nodePokeCalls, 1, "the ten-minute safety net performs one remote fan-out");
Expand All @@ -1241,8 +1241,8 @@ async function run() {
console.log(`D1 query count ${JSON.stringify(retentionQueries)}`);
assert.equal(
retentionQueries.sequentialQueries,
45,
"a minute 17 cron tick costs 45 D1 calls: 6 for the sweeps and settings, one Telegram pending-code check, one cheburcheck and one bsbord settings read while off, one read of the proposals that apply (none: no lease), 21 for retention (the batched retention settings read and thirteen prune statements, the prune of the proposals that ended 90 days ago among them, the one count read of orphan AWG path keys, the audit log, the hourly host load and the two hourly traffic tables among them), 12 for a warm evaluator pass (including the UDP path losses and one batched external-source settings read), and 2 for the updates job (the active rollout read and its history prune)",
46,
"a minute 17 cron tick costs 46 D1 calls: 6 for the sweeps and settings, one Telegram pending-code check, one check for due notices to people, one cheburcheck and one bsbord settings read while off, one read of the proposals that apply (none: no lease), 21 for retention (the batched retention settings read and thirteen prune statements, the prune of the proposals that ended 90 days ago among them, the one count read of orphan AWG path keys, the audit log, the hourly host load and the two hourly traffic tables among them), 12 for a warm evaluator pass (including the UDP path losses and one batched external-source settings read), and 2 for the updates job (the active rollout read and its history prune)",
);

// The Overview is polled every 10 seconds. The health summary of every node is one settings row, read once: more connected
Expand Down
14 changes: 7 additions & 7 deletions edge/bridge/cron_js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ func TestCronOpRunsEdgeTickAndReleasesFanout(t *testing.T) {
awaitCronPromise(t, waitUntil)
counts := binding.Call("__endQueryCount")
ended = true
// Telegram and updates each add one read, the empty-owner watcher adds one, and cheburcheck and bsbord each read their settings
// once while off. The proposals work adds one read (the proposals that apply: none) and, with none, no lease.
// Telegram adds two reads (a link code waiting, a notice to a person due) and updates one, the empty-owner watcher adds one, and
// cheburcheck and bsbord each read their settings once while off. The proposals work adds one read (the proposals that apply: none) and, with none, no lease.
// The rest is the four sweeps, two country settings and eight evaluator calls on an empty fleet. The evaluator pass reads
// both external-source settings in one batched call, even while those sources are off.
if got := counts.Get("sequentialQueries").Int(); got != 21 {
t.Fatalf("cron used %d sequential D1 calls, want 21 (6 tick + updates read + Telegram code check + empty-owner watcher + one cheburcheck and one bsbord settings read + 8 evaluator on an empty fleet + one batched external settings read per evaluator pass + the proposals read)", got)
if got := counts.Get("sequentialQueries").Int(); got != 22 {
t.Fatalf("cron used %d sequential D1 calls, want 22 (6 tick + updates read + Telegram code check + Telegram people's notices check + empty-owner watcher + one cheburcheck and one bsbord settings read + 8 evaluator on an empty fleet + one batched external settings read per evaluator pass + the proposals read)", got)
}
if got := remote.pokeCount(); got != 1 {
t.Fatalf("minute 10 remote fan-outs = %d, want 1", got)
Expand All @@ -167,11 +167,11 @@ func TestCronOpRunsEdgeTickAndReleasesFanout(t *testing.T) {
retentionEnded = true
// The nodes are still warm in the isolate and the empty summary is unchanged, so the evaluator pass is six calls: its lease,
// the signal batch, the active alerts, the interval setting, the update rollout and the country settings. Telegram's pending
// code check adds one read on every tick. The updates job adds the active rollout read, and its history prune at minute 17.
// code check adds one read on every tick, and so does the check for a notice to a person that is due. The updates job adds the active rollout read, and its history prune at minute 17.
// The evaluator pass reads both external-source settings in one batched call, even while those sources are off. The proposals
// work adds its read of the proposals that apply, and the retention one prune of the proposals that ended 90 days ago.
if got := retentionCounts.Get("sequentialQueries").Int(); got != 39 {
t.Fatalf("minute 17 cron used %d sequential D1 calls, want 39 (5 tick + 2 updates + Telegram code check + one cheburcheck and one bsbord settings read + 21 retention (the batched retention settings read, the two hourly traffic prunes, the orphan AWG path count and the proposals prune included) + 6 evaluator + one batched external settings read + the proposals read)", got)
if got := retentionCounts.Get("sequentialQueries").Int(); got != 40 {
t.Fatalf("minute 17 cron used %d sequential D1 calls, want 40 (5 tick + 2 updates + Telegram code check + people's notices check + one cheburcheck and one bsbord settings read + 21 retention (the batched retention settings read, the two hourly traffic prunes, the orphan AWG path count and the proposals prune included) + 6 evaluator + one batched external settings read + the proposals read)", got)
}
// Three batches: the node-down sweep's live read (every tick), the evaluator's signal batch and the daily rollup; the
// prunes are single statements.
Expand Down
31 changes: 17 additions & 14 deletions gen/mistgate/usernotify/v1/usernotify.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading