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
6 changes: 6 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ jobs:
env:
TAU_RELEASE_TAG: ${{ env.RELEASE_TAG }}
run: sh scripts/build-release-binaries.sh
# Hosted Linux runs in a service cgroup: the server starts the local host in its own systemd scope.
- name: Allow isolated native fixture scopes
run: |
rule="polkit.addRule(function(action, subject) { if (action.id === 'org.freedesktop.systemd1.manage-units' && subject.user === '$(id -un)' && /\\.scope$/.test(action.lookup('unit') || '')) { return polkit.Result.YES; } });"
printf '%s\n' "$rule" | sudo tee /etc/polkit-1/rules.d/49-tau-fixture-scopes.rules >/dev/null
systemd-run --scope --quiet --collect --no-ask-password true
- run: npm run smoke -- --binary release/tau-linux-x64/tau

- name: Publish the prerelease
Expand Down
30 changes: 23 additions & 7 deletions lib/hosts/local-daemon-start.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,30 @@ async function startFromServer(name) {
/** Kills a host and waits until its endpoint stops answering, so the next start sees no daemon. */
async function stopHost(pid) {
kill(pid);
for (let attempt = 0; attempt < 50; attempt++) {
try { await requestHostControl("status"); }
catch (error) {
if (["ENOENT", "ECONNREFUSED"].includes(error.code)) return;
// Each caller's timeout covers its own work plus this deadline and one 3 s status request; nothing is killed after it.
const deadline = Date.now() + 8_000;
let last;
let intruder;
while (Date.now() < deadline) {
try {
const answering = (await requestHostControl("status")).pid;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
last = `host ${answering} answered`;
// Another host took the endpoint: stop it too so later tests start clean, then fail this one.
if (answering !== pid && answering !== process.pid && Date.now() < deadline) {
intruder = answering;
launched.add(answering);
kill(answering);
}
} catch (error) {
if (["ENOENT", "ECONNREFUSED"].includes(error.code)) {
if (intruder) throw new Error(`a second host ${intruder} answered after host ${pid} was killed`);
return;
}
last = `${error.code ?? "error"}: ${error.message}`;
}
await sleep(100);
}
throw new Error(`host ${pid} still answers after SIGKILL`);
throw new Error(`host ${pid} still answers after SIGKILL (last: ${last})`);
}

test("with no daemon, the server prepares the link, then starts the host it launched", { timeout: 30_000 }, async () => {
Expand All @@ -114,7 +130,7 @@ test("an existing daemon, current or drained, is reused and nothing is launched"
assert.deepEqual(await ensureLocalHostDaemon({ env: prodEnv(), launch: missingLaunch }), { started: false, pid: process.pid });
});

test("a registered native supervisor owns startup beyond the old grace without a foreground fallback", { timeout: 15_000 }, async () => {
test("a registered native supervisor owns startup beyond the old grace without a foreground fallback", { timeout: 30_000 }, async () => {
let supervised;
const result = await ensureLocalHostDaemon({
env: prodEnv(),
Expand Down Expand Up @@ -205,7 +221,7 @@ test("an active leased server update is not replaced by autostart, even if its c
}
});

test("an expired server update does not block autostart", { timeout: 20_000 }, async (t) => {
test("an expired server update does not block autostart", { timeout: 40_000 }, async (t) => {
const state = await import("../self-update-state.ts");
const root = state.resolveSelfUpdateTempRoot();
mkdirSync(root, { recursive: true, mode: 0o700 });
Expand Down
8 changes: 6 additions & 2 deletions lib/message-outbox-review.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ async function parallelAdds(workers, perWorker, bytes, timeoutMs) {
const sid = '11111111-2222-4333-8444-' + number.toString(16).padStart(12, '0');
const response = await o.runOutboxCommand(sid, {type:'outbox_add', scope, id:'quota-'+number, mode:'prompt', message:'x'.repeat(${bytes})}, 'owner');
const body = await response.json();
statuses.push([response.status, body.code]);
statuses.push([response.status, body.code, body.error]);
}
await new Promise(resolve => setTimeout(resolve, 50));
o.closeOutboxStore();
Expand Down Expand Up @@ -1402,7 +1402,11 @@ test("concurrent processes share the 1000-row active pool across arbitrary UUIDs
outbox.outboxScope();
const results = await parallelAdds(6, 180, 1, 29_000);
assert.equal(results.filter(([status]) => status === 200).length, 1000);
assert.equal(results.filter(([status, code]) => status === 429 && code === "outbox_full").length, 80);
// The rest are refused as full. A slow runner may exceed SQLite's 5 s busy timeout once or twice (a 500 the
// browser retries); more than that is the per-add lock contention ompweb#535 fixed.
const busy = results.filter(([status, , error]) => status === 500 && /database is locked|SQLITE_BUSY/.test(error ?? ""));
assert.ok(busy.length <= 2, `${busy.length} adds hit the busy timeout`);
assert.equal(results.filter(([status, code]) => status === 429 && code === "outbox_full").length, 80 - busy.length);
const database = globalThis.__tauOutboxStore.db;
assert.equal(database.prepare("SELECT COUNT(*) AS count FROM entries WHERE state != 'delivered'").get().count, 1000);
const known = database.prepare("SELECT id, session_id FROM entries LIMIT 1").get();
Expand Down
Loading