mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 09:45:36 +08:00
feat(cron): expose run receipts and modularize execution
Return committed trigger IDs and add CLI wait and trigger-specific logs while preserving API, CLI, transaction, deduplication and unknown-result semantics. Move scheduling, lifecycle, settlement, queries and legacy adapters into back/cron; remove obsolete internal import paths and circular dependencies. Apply project formatting across the repository, cover CJS/MJS in formatting hooks, add prettier:check and require formatting checks in AGENTS.md. Validation: backend build; 1398 backend/frontend tests passed (17 platform skips); 327 CLI tests passed (6 platform skips); 670 files pass format checks.
This commit is contained in:
1 parent
77ece406ac
commit
c5458596c8
346 files changed
+32133
-11556
No files matched your search
@@ -74,7 +74,9 @@ test('create and update reject invalid extra schedules before calling the servic
|
||||
const load = require('../helpers/load-security-module.cjs');
|
||||
const mutations = [];
|
||||
const service = {
|
||||
async status(value) { return value; },
|
||||
async status(value) {
|
||||
return value;
|
||||
},
|
||||
async create(value) {
|
||||
mutations.push(value);
|
||||
return { id: 1, ...value };
|
||||
@@ -113,17 +115,31 @@ test('create and update reject invalid extra schedules before calling the servic
|
||||
|
||||
// Released CLI wrappers reuse this execution_id for start and exit; both must reach the same receipt.
|
||||
const uuid = require('node:crypto').randomUUID();
|
||||
const statusRequest = (status, extra = {}) => fetch(`http://127.0.0.1:${server.address().port}/crons/status`, {
|
||||
method: 'PUT', headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ ids: [1], pid: '122', status, execution_id: `legacy-system:123:${uuid}`, ...extra }),
|
||||
});
|
||||
const statusRequest = (status, extra = {}) =>
|
||||
fetch(`http://127.0.0.1:${server.address().port}/crons/status`, {
|
||||
method: 'PUT',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
ids: [1],
|
||||
pid: '122',
|
||||
status,
|
||||
execution_id: `legacy-system:123:${uuid}`,
|
||||
...extra,
|
||||
}),
|
||||
});
|
||||
for (const status of ['0', '1']) {
|
||||
const res = await statusRequest(status);
|
||||
assert.equal(res.status, 200);
|
||||
assert.equal((await res.json()).data.trigger_id, `system-cli-123-${uuid}`);
|
||||
}
|
||||
assert.equal((await statusRequest('1', { trigger_id: 'another' })).status, 400);
|
||||
assert.equal((await statusRequest('1', { execution_id: 'broken' })).status, 400);
|
||||
assert.equal(
|
||||
(await statusRequest('1', { trigger_id: 'another' })).status,
|
||||
400,
|
||||
);
|
||||
assert.equal(
|
||||
(await statusRequest('1', { execution_id: 'broken' })).status,
|
||||
400,
|
||||
);
|
||||
|
||||
for (const method of ['POST', 'PUT']) {
|
||||
const payload = {
|
||||
@@ -184,9 +200,16 @@ test('create and update reject invalid extra schedules before calling the servic
|
||||
});
|
||||
|
||||
test('saving a migrated task accepts a null pending policy and rejects invalid input', () => {
|
||||
const task = { name: 'legacy', command: 'task old.sh', schedule: '1 * * * *' };
|
||||
const task = {
|
||||
name: 'legacy',
|
||||
command: 'task old.sh',
|
||||
schedule: '1 * * * *',
|
||||
};
|
||||
for (const value of [null, false, true]) {
|
||||
assert.equal(schema.validate({ ...task, skip_if_pending: value }).error, undefined);
|
||||
assert.equal(
|
||||
schema.validate({ ...task, skip_if_pending: value }).error,
|
||||
undefined,
|
||||
);
|
||||
}
|
||||
assert.ok(schema.validate({ ...task, skip_if_pending: 'invalid' }).error);
|
||||
});
|
||||
Reference in new issue
Block a user