fix(tests): the control-run test leaves headroom over a slow start
Review finding 703d87e1 (BLOCKER); the timeout and hang live in tests/helpers/timing.mjs as CONTROL_RUN. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4d5c927c5d
commit
e142556543
3 changed files with 51 additions and 5 deletions
|
|
@ -16,6 +16,7 @@ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { fastestWithin } from '../helpers/timing.mjs';
|
||||
import * as timing from '../helpers/timing.mjs';
|
||||
import { HOOK_TIMEOUT_MS, runHookWithEnv } from '../helpers/hook-helper.mjs';
|
||||
|
||||
/** A measure that returns the given durations in turn (no real waiting). */
|
||||
|
|
@ -61,3 +62,22 @@ test('hook helper: the kill limit is far above 5 s by default, and a call can se
|
|||
assert.equal(done.stdout, 'done');
|
||||
} finally { rmSync(dir, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
// The red-proof control-run test (review 630 r9, brief note 3, in
|
||||
// tests/lib/review-630.test.mjs) reads its timeout, hang and simulated slow
|
||||
// start from tests/helpers/timing.mjs (CONTROL_RUN, review 703d87e1): the
|
||||
// criteria runner saw its start point killed at 2 s under full-suite load.
|
||||
// BEFORE_703D87E1 is the record of the numbers before the fix, taken only when
|
||||
// the export is absent.
|
||||
const BEFORE_703D87E1 = Object.freeze({ timeoutMs: 2000, hangMs: 6000, slowStartMs: 2500 });
|
||||
|
||||
test('red proof control run (703d87e1): the timeout leaves headroom over a slow start and the hang outlasts it', () => {
|
||||
const c = timing.CONTROL_RUN ?? BEFORE_703D87E1;
|
||||
const seen = JSON.stringify(c);
|
||||
assert.ok(c.slowStartMs > 2000, `the simulated slow start is above the old 2 s timeout: ${seen}`);
|
||||
assert.ok(c.timeoutMs >= 15000, `the timeout leaves headroom over a loaded machine: ${seen}`);
|
||||
assert.equal(c.timeoutMs % 1000, 0, `a whole number of seconds (the reason prints Math.round(timeoutMs / 1000)): ${seen}`);
|
||||
assert.ok(c.timeoutMs >= 6 * c.slowStartMs, `the timeout is at least 6x the simulated slow start: ${seen}`);
|
||||
assert.ok(c.hangMs >= c.timeoutMs + 30000, `the hang outlasts the timeout by 30 s: ${seen}`);
|
||||
assert.ok(c.hangMs < 2 ** 31 - 1, `the hang fits a real timer (below 2^31-1 ms): ${seen}`);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue