Merge pull request 'Fix abort, missing goto, offline schedules and the cron 500' (#66) from fix-known-bugs into main
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 1m41s
CI / Security (npm audit) (push) Successful in 1m0s
CI / Test (jest) (push) Failing after 1m5s
CI / Scan (secrets, workflows, shell) (push) Successful in 4m25s
CI / Integration (api) (push) Failing after 4m31s
CI / UI (playwright) (push) Successful in 5m23s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Successful in 4s
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 1m41s
CI / Security (npm audit) (push) Successful in 1m0s
CI / Test (jest) (push) Failing after 1m5s
CI / Scan (secrets, workflows, shell) (push) Successful in 4m25s
CI / Integration (api) (push) Failing after 4m31s
CI / UI (playwright) (push) Successful in 5m23s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Successful in 4s
This commit was merged in pull request #66.
This commit is contained in:
commit
1a031515e7
5 files changed
+166
-32
No files matched your search
+16
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
const vm = require('vm');
|
||||
const { evaluateCondition, checkCondition } = require('../lib/condition');
|
||||
const { evalCondition, conditionErrors } = require('../lib/utils');
|
||||
const { evalCondition, conditionErrors, gotoErrors } = require('../lib/utils');
|
||||
|
||||
// Every condition used by the production workflows (2026-11-22).
|
||||
const PRODUCTION = [
|
||||
@@ -135,3 +135,18 @@ describe('conditionErrors', () => {
|
||||
expect(conditionErrors('{not json')).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('gotoErrors (#20)', () => {
|
||||
test('lists jumps to step ids that do not exist; end is always valid', () => {
|
||||
const problems = gotoErrors({ steps: [
|
||||
{ id: 'a', type: 'execute', goto: 'c' },
|
||||
{ id: 'b', type: 'route', conditions: [{ if: 'true', goto: 'nope' }, { default: true, goto: 'end' }] },
|
||||
{ id: 'c', type: 'prompt', routes: { Yes: 'a', No: '__end__', Maybe: 'missing' } },
|
||||
] });
|
||||
expect(problems.map(p => `${p.step}->${p.goto}`)).toEqual(['b->nope', 'c->missing']);
|
||||
});
|
||||
test('accepts a JSON string and ignores malformed JSON', () => {
|
||||
expect(gotoErrors(JSON.stringify({ steps: [{ id: 'x', goto: 'y' }] }))).toHaveLength(1);
|
||||
expect(gotoErrors('{oops')).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -72,15 +72,13 @@ test('only admins can create schedules, and bad input is refused', async () => {
|
||||
expect((await createSchedule({ command: 'true', worker_ids: [worker.id], schedule_value: '-5' })).status).toBe(400);
|
||||
});
|
||||
|
||||
// Known bug: calculateNextRun throws on a bad cron expression, and the route answers 500.
|
||||
test.failing('an invalid cron expression is a 400, not a server error', async () => {
|
||||
test('an invalid cron expression is a 400, not a server error', async () => {
|
||||
const worker = await workerByName('node-01');
|
||||
const r = await createSchedule({ command: 'true', worker_ids: [worker.id], schedule_type: 'cron', schedule_value: 'not a cron' });
|
||||
expect(r.status).toBe(400);
|
||||
});
|
||||
|
||||
// Known bug #9: a schedule whose worker is offline is skipped silently, leaving no trace.
|
||||
test.failing('a schedule whose worker is offline records a failed run (#9)', async () => {
|
||||
test('a schedule whose worker is offline records a failed run (#9)', async () => {
|
||||
const workerName = `int-sched-${unique()}`;
|
||||
const w = await startWorker(workerName);
|
||||
const name = `int ${unique()}`;
|
||||
@@ -93,5 +91,7 @@ test.failing('a schedule whose worker is offline records a failed run (#9)', asy
|
||||
const runs = await executionsOf(name);
|
||||
expect(runs).toHaveLength(1);
|
||||
expect(runs[0].status).toBe('failed');
|
||||
const ex = await waitForExecution(runs[0].id);
|
||||
expect(commandResult(ex).error).toMatch(/offline/i);
|
||||
} finally { await w.stop(); }
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
// The workflow engine (executeWorkflowSteps in server.js), driven through the API
|
||||
// with real workers. Known bugs are written as test.failing: they document today's
|
||||
// behaviour and start failing (so the marker must be removed) once the bug is fixed.
|
||||
// with real workers. Known bugs, when there are any, are written as test.failing: they
|
||||
// document today's behaviour and start failing once the bug is fixed.
|
||||
const { sso, waitFor, waitForExecution, sleep } = require('./helpers');
|
||||
|
||||
const unique = () => `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
||||
@@ -134,8 +134,7 @@ test('an aborted execution stays failed', async () => {
|
||||
expect(ex.status).toBe('failed');
|
||||
});
|
||||
|
||||
// Known bug #8: abort marks the execution failed but the engine keeps going.
|
||||
test.failing('abort stops the workflow before its next step (#8)', async () => {
|
||||
test('abort stops the workflow before its next step (#8)', async () => {
|
||||
const id = await start(await createWorkflow([
|
||||
{ id: 'pause', type: 'wait', duration: 2 },
|
||||
{ id: 'after', type: 'execute', command: 'echo after-abort', targets: ['node-01'] },
|
||||
@@ -147,13 +146,34 @@ test.failing('abort stops the workflow before its next step (#8)', async () => {
|
||||
expect(logs(ex, 'step_started').map(l => l.step)).toEqual([1]);
|
||||
});
|
||||
|
||||
// Known bug #20: a goto to a step that doesn't exist ends as 'completed'.
|
||||
test.failing('a goto to a missing step fails the execution (#20)', async () => {
|
||||
const id = await start(await createWorkflow([
|
||||
test('a goto to a missing step is refused on save (#20)', async () => {
|
||||
const r = await sso('POST', '/api/workflows', { name: `int ${unique()}`, definition: { steps: [
|
||||
{ id: 'jump', type: 'route', conditions: [{ default: true, goto: 'no-such-step' }] },
|
||||
]));
|
||||
const ex = await waitForExecution(id);
|
||||
] } });
|
||||
expect(r.status).toBe(400);
|
||||
expect(r.json.problems[0]).toMatchObject({ step: 'jump', goto: 'no-such-step' });
|
||||
});
|
||||
|
||||
test('a saved workflow whose goto is missing fails at runtime instead of completing (#20)', async () => {
|
||||
// Workflows saved before the check existed can still contain one: write it directly.
|
||||
const mysql = require('mysql2/promise');
|
||||
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',
|
||||
});
|
||||
const wf = require('crypto').randomUUID();
|
||||
try {
|
||||
await db.query('INSERT INTO workflows (id, name, description, definition, created_by) VALUES (?, ?, ?, ?, ?)', [
|
||||
wf, `int legacy ${unique()}`, '', JSON.stringify({ steps: [
|
||||
{ id: 'jump', type: 'route', conditions: [{ default: true, goto: 'no-such-step' }] },
|
||||
{ id: 'after', type: 'execute', command: 'echo should-not-run', targets: ['node-01'] },
|
||||
] }), 'int.tester',
|
||||
]);
|
||||
} finally { await db.end(); }
|
||||
const ex = await waitForExecution(await start(wf));
|
||||
expect(ex.status).toBe('failed');
|
||||
expect(logs(ex, 'goto_error')[0]).toMatchObject({ target: 'no-such-step' });
|
||||
expect(outputs(ex)).toEqual([]);
|
||||
});
|
||||
|
||||
test('a workflow whose condition does not parse is refused on save', async () => {
|
||||
@@ -169,3 +189,18 @@ test('a workflow whose condition does not parse is refused on save', async () =>
|
||||
] } });
|
||||
expect(update.status).toBe(400);
|
||||
});
|
||||
|
||||
test('abort during a long command stops the workflow at once, without waiting for the command (#8)', async () => {
|
||||
const id = await start(await createWorkflow([
|
||||
{ id: 'slow', type: 'execute', command: 'sleep 20', targets: ['node-02'] },
|
||||
{ id: 'after', type: 'execute', command: 'echo after-abort', targets: ['node-02'] },
|
||||
]));
|
||||
await sleep(1000);
|
||||
const t0 = Date.now();
|
||||
expect((await sso('POST', `/api/executions/${id}/abort`)).status).toBe(200);
|
||||
await sleep(2500);
|
||||
const ex = (await sso('GET', `/api/executions/${id}`)).json;
|
||||
expect(ex.status).toBe('failed');
|
||||
expect(logs(ex, 'step_started').map(l => l.step)).toEqual([1]);
|
||||
expect(Date.now() - t0).toBeLessThan(10_000);
|
||||
});
|
||||
Reference in new issue
Block a user