mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-30 16:27:21 +08:00
Share durable permits across manual, scheduled and recovered runs, prioritize short ready tasks with aging, and record global queue occupancy. Reduce launch, log polling, dashboard and SQLite overhead while preserving transactional receipts, cancellation, recovery and script hook compatibility. Keep ordinary CRUD in ORM and bound SQL on measured execution hot paths. Fix supervisor descendant tracking, asynchronous log draining, concurrent log directory creation, Linux fallback launches and snapshot clock rollback. Include regression coverage, SQL audits and evolution/review documentation. Validation: five review rounds; local full suite 1478 passed, 28 platform skips; dev suites 415 passed, no failures/skips; backend types and formatting passed.
74 lines
2.2 KiB
JavaScript
74 lines
2.2 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const { spawnSync } = require('node:child_process');
|
|
const text = fs.readFileSync('shell/share.sh', 'utf8');
|
|
const start = text.indexOf('handle_task_end() {');
|
|
const helper = text.slice(start, text.indexOf('\n}', start) + 2);
|
|
|
|
test('authorized supervisor removes redundant finish HTTP calls; standalone wrappers retain receipts and log trailers', () => {
|
|
for (const [flag, trigger, expected] of [
|
|
['1', 'run-id', false],
|
|
['', 'run-id', true],
|
|
['1', '', true],
|
|
]) {
|
|
const result = spawnSync(
|
|
'bash',
|
|
[
|
|
'-c',
|
|
helper +
|
|
`\n
|
|
update_cron(){ echo STATUS >&2; }; record_cron_stat(){ echo STATS >&2; }; t(){ printf "$@"; }
|
|
ID=1; is_macos=0; time_format='%Y-%m-%d %H:%M:%S'; begin_timestamp=0; _task_exit_code=7
|
|
handle_task_end
|
|
`,
|
|
],
|
|
{
|
|
env: {
|
|
...process.env,
|
|
QL_TRIGGER_ID: trigger,
|
|
QL_SUPERVISOR_RECEIPT: flag,
|
|
},
|
|
encoding: 'utf8',
|
|
},
|
|
);
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(result.stderr.includes('STATUS'), expected);
|
|
assert.equal(result.stderr.includes('STATS'), expected);
|
|
assert.match(result.stdout, /退出码 7/);
|
|
}
|
|
});
|
|
|
|
test('only a prebound manual log skips shell start HTTP; scheduled and standalone tasks publish their log path', () => {
|
|
const offset = text.indexOf('handle_task_start() {');
|
|
const startHelper = text.slice(offset, text.indexOf('\n}', offset) + 2);
|
|
for (const [flag, trigger, expected] of [
|
|
['1', 'run-id', false],
|
|
['', 'run-id', true],
|
|
['1', '', true],
|
|
]) {
|
|
const result = spawnSync(
|
|
'bash',
|
|
[
|
|
'-c',
|
|
startHelper +
|
|
`\n
|
|
update_cron(){ echo START >&2; }; t(){ printf "$@"; }
|
|
ID=1; begin_time=now; handle_task_start
|
|
`,
|
|
],
|
|
{
|
|
env: {
|
|
...process.env,
|
|
QL_TRIGGER_ID: trigger,
|
|
QL_SUPERVISOR_LOG_BOUND: flag,
|
|
},
|
|
encoding: 'utf8',
|
|
},
|
|
);
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(result.stderr.includes('START'), expected);
|
|
assert.match(result.stdout, /开始执行/);
|
|
}
|
|
});
|