Integration tests for the Gandalf contract, auth and reliability; fix worker offline status
CI / Lint (eslint) (push) Successful in 46s
CI / Security (npm audit) (push) Successful in 26s
CI / Integration (api) (push) Successful in 1m31s
CI / Test (jest) (pull_request) Successful in 50s
CI / UI (playwright) (push) Successful in 2m31s
CI / Integration (api) (pull_request) Successful in 1m58s
CI / Test (jest) (push) Successful in 13s
CI / Deploy (push) Skipped
CI / Notify (push) Skipped
CI / UI (playwright) (pull_request) Successful in 2m16s
CI / Lint (eslint) (pull_request) Successful in 15s
CI / Security (npm audit) (pull_request) Successful in 15s
CI / Deploy (pull_request) Skipped
CI / Notify (pull_request) Skipped

New CI job `Integration (api)` (#45 phase 3) runs the real server and three
workers on Node 20 against MariaDB and tests them as a black box over HTTP
and WebSocket (20 tests, about 12 s):

- Gandalf contract: submit and poll, stdout from command_result, failures
  with exit code and stderr, 401 for wrong or missing key, 400 for missing
  fields or an unknown worker, 404 for an unknown execution
- Auth: SSO identity, 401/403, heartbeat key, /healthz exposes only status;
  WebSocket upgrade refused without credentials, with a wrong key or a wrong
  group; live events reach a signed-in browser; a browser socket cannot
  forge a command result
- Reliability: a worker killed mid-command fails the execution at once; a
  worker at capacity answers with a failure; an aborted execution stays
  failed when the late result arrives; a disconnected worker shows offline

The last test found a bug from #42: the close handler deleted the worker's
runtime-id entry before checking whether the socket was still live under its
database id, and the two ids are normally the same key. So a disconnected
worker was never marked offline and showed 'online' until the stale
heartbeat sweep. Gandalf was unaffected (it checks live sockets).

MariaDB setup for CI moves to scripts/ci/mariadb.sh, shared by both jobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-22 14:14:28 -05:00
1 parent 1d5b8cdd53
commit def926d41e
11 files changed
+391 -21

No files matched your search

+7 -3
View File
@@ -733,13 +733,17 @@ wss.on('connection', (ws, req) => {
}
browserClients.delete(ws);
workerClients.delete(ws);
// Only if this socket is still the live connection for the worker: after a
// reconnect, the old socket closing must not unmap the new one or mark it offline.
// Decide before unmapping anything: the runtime and database ids are usually the
// same key, so deleting one first made the database check always fail and left
// disconnected workers 'online'.
const liveForDb = !!ws.dbWorkerId && workers.get(ws.dbWorkerId) === ws;
if (ws.workerId && workers.get(ws.workerId) === ws) {
workers.delete(ws.workerId);
console.log(`Worker ${ws.workerId} (runtime ID) disconnected`);
}
// Only if this socket is still the live connection for the worker: after a
// reconnect, the old socket closing must not unmap the new one or mark it offline.
if (ws.dbWorkerId && workers.get(ws.dbWorkerId) === ws) {
if (liveForDb) {
workers.delete(ws.dbWorkerId);
console.log(`Worker ${ws.dbWorkerId} (database ID) disconnected`);
// Mark worker offline in DB