Worker unit tests, coverage floors, and an SBOM per main build #52

Merged
jared merged 3 commits from ci-sbom-worker-tests into main 2026-11-22 16:01:39 -05:00
Showing only changes of commit 67a9e1c009 - Show all commits
+13 -2
View File
@@ -74,10 +74,18 @@ async function startWorker(name, env = {}) {
let log = '';
child.stdout.on('data', d => { log += d; });
child.stderr.on('data', d => { log += d; });
const fail = e => { child.kill('SIGKILL'); throw new Error(`${e.message}\n${log}`); };
// The first heartbeat marks the worker 'online' before its WebSocket is connected,
// so wait until the server actually accepts a command for it (a harmless `true`).
const worker = await waitFor(async () => {
const w = await workerByName(name);
return w && w.status === 'online' ? w : null;
}, { what: `worker ${name} to come online` }).catch(e => { child.kill('SIGKILL'); throw new Error(`${e.message}\n${log}`); });
}, { what: `worker ${name} to register` }).catch(fail);
const probe = await waitFor(async () => {
const r = await gandalf('POST', '/api/internal/command', { worker_id: worker.id, command: 'true' });
return r.status === 200 ? r.json.execution_id : null;
}, { what: `worker ${name} to connect its WebSocket` }).catch(fail);
await waitForExecution(probe).catch(fail);
return {
id: worker.id,
child,
@@ -88,7 +96,10 @@ async function startWorker(name, env = {}) {
await new Promise(r => child.once('exit', r));
}
// Remove it so other suites (and the UI tests' worker counts) don't see it.
await waitFor(async () => (await workerByName(name))?.status === 'offline', { timeout: 5_000, what: `${name} to show offline` });
// Never throws: cleanup must not hide the test's own failure. The offline
// status itself is asserted by its own test in reliability.int.js.
await waitFor(async () => (await workerByName(name))?.status === 'offline', { timeout: 5_000, what: `${name} offline` })
.catch(e => console.warn(`cleanup: ${e.message}`));
await sso('DELETE', `/api/workers/${worker.id}`);
},
};