fix: preserve automation queue safety limit

This commit is contained in:
Sucukdeluxe
2026-08-26 08:58:21 +02:00
parent 9bc872bc00
commit 41ae750e97
2 changed files with 48 additions and 4 deletions
+35
View File
@@ -49,6 +49,16 @@ test('automation settings normalize invalid limits intervals and pause timestamp
});
});
test('automation settings allow only numeric and trimmed string zero to disable the queue limit', () => {
const invalidLimits = [null, '', ' ', false, true, {}, undefined, NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, '0.0', '00', '+0', '-0'];
assert.deepEqual(
invalidLimits.map((queueLimitJobs) => normalizeAutomationSettings({ queueLimitJobs }).queueLimitJobs),
invalidLimits.map(() => 15000)
);
assert.equal(normalizeAutomationSettings({ queueLimitJobs: 0 }).queueLimitJobs, 0);
assert.equal(normalizeAutomationSettings({ queueLimitJobs: ' 0 ' }).queueLimitJobs, 0);
});
test('capacity counts only executable and running queue jobs', () => {
const statuses = ['preview', 'queued', 'getting-server', 'uploading', 'retrying', 'done', 'error', 'aborted', 'skipped'];
assert.equal(countAutomaticQueueJobs(statuses.map((status, index) => ({ id: String(index), status }))), 5);
@@ -111,6 +121,31 @@ test('admission tolerates malformed candidates and numeric inputs', () => {
});
});
test('admission allows only numeric and trimmed string zero to disable the queue limit', () => {
const invalidLimits = [null, '', ' ', false, true, {}, undefined, NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, '0.0', '00', '+0', '-0'];
const candidate = { path: 'large.mkv', mtimeMs: 1, eligibleJobCount: 16000 };
assert.deepEqual(
invalidLimits.map((queueLimitJobs) => planAtomicAdmissions({ candidates: [candidate], queueLimitJobs })),
invalidLimits.map(() => ({
admittedPaths: [],
deferredPaths: ['large.mkv'],
currentJobCount: 0,
plannedJobs: 0,
availableSlots: 15000
}))
);
assert.deepEqual(
[0, ' 0 '].map((queueLimitJobs) => planAtomicAdmissions({ candidates: [candidate], queueLimitJobs })),
[0, ' 0 '].map(() => ({
admittedPaths: ['large.mkv'],
deferredPaths: [],
currentJobCount: 0,
plannedJobs: 16000,
availableSlots: null
}))
);
});
test('daily telemetry resets atomically on the local calendar day boundary', () => {
const before = { dateKey: '2026-08-25', detected: 8, queued: 4, skipped: 2, deferred: 1 };
const now = new Date(2026, 7, 26, 0, 0, 1).getTime();