Fix orphaned quick commands, prompt timeouts and worker delete (#6, #21, #34)

- #6: a quick command to a disconnected worker is refused before an
  execution is recorded, instead of leaving one stuck in 'running'.
- #21: an unanswered prompt fails the execution (prompt_timeout) instead
  of continuing as if someone had chosen; prompt and wait steps never
  wait past the execution's deadline, and a wait cut short by it fails
  with execution_timeout. PULSE_PROMPT_TIMEOUT_MS (minimum 1 s, default
  60 min) lets the test stack use 8 s.
- #34: deleting a connected worker is a 409 explaining it would
  re-register on its next heartbeat; offline workers delete as before.

Tests for each (integration 45/45).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-23 00:04:06 -05:00
1 parent 073114c92e
commit d517cae7e6
4 files changed
+85 -11

No files matched your search

+26
View File
@@ -90,3 +90,29 @@ test('aborting a command kills its process on the worker (#8)', async () => {
expect((await waitForExecution(id)).status).toBe('failed');
} finally { await w.stop(); }
});
test('a quick command to an offline worker is refused without leaving a running execution (#6)', async () => {
const mysql = require('mysql2/promise');
const marker = `offline-${unique()}`;
const w = await startWorker(unique());
w.child.kill('SIGKILL');
try {
await waitFor(async () => (await sso('POST', `/api/workers/${w.id}/command`, { command: `echo ${marker}` })).status === 400,
{ timeout: 5000, what: 'the server to notice the worker is gone' });
const db = await mysql.createConnection({
host: process.env.DB_HOST || '127.0.0.1', port: Number(process.env.DB_PORT || 3306),
user: process.env.DB_USER || 'pulse', password: process.env.DB_PASSWORD || 'ci-only', database: process.env.DB_NAME || 'pulse',
});
try {
const [rows] = await db.query('SELECT id FROM executions WHERE logs LIKE ?', [`%${marker}%`]);
expect(rows).toEqual([]);
} finally { await db.end(); }
} finally { await w.stop(); }
});
test('a connected worker cannot be deleted; it would re-register on its next heartbeat (#34)', async () => {
const node1 = await workerByName('node-01');
const r = await sso('DELETE', `/api/workers/${node1.id}`);
expect(r.status).toBe(409);
expect((await workerByName('node-01'))?.id).toBe(node1.id);
});