fix(e2e): add minimum multiplier floor 4.0× for calibration

- Calibration smoke test only measures basic app launch

- Heavy operations (nsfw watcher) need more time than smoke test captures

- MIN_MULTIPLIER=4.0 ensures 100s minimum step timeout

- Actual multiplier: max(4.0, min(5.0, measured))

- Fast CI still gets 4.0×, very slow CI caps at 5.0×
This commit is contained in:
linonetwo 2026-05-04 16:29:31 +08:00
parent 7e51bf9e7c
commit f8ebf2fb0f
2 changed files with 7 additions and 3 deletions

View file

@ -53,7 +53,11 @@ function readCalibrationRecord(): CalibrationRecord | null {
export function writeCalibrationResult(actualDurationMs: number): number {
const raw = actualDurationMs / REFERENCE_SMOKE_DURATION_MS;
const multiplier = Math.min(MAX_MULTIPLIER, Math.max(1.0, raw));
// Cap at MAX_MULTIPLIER, but also enforce a minimum floor
// Heavy operations (nsfw watcher init, file system watch) need more time
// than the basic calibration smoke test exercises
const MIN_MULTIPLIER = 4.0;
const multiplier = Math.min(MAX_MULTIPLIER, Math.max(MIN_MULTIPLIER, raw));
fs.mkdirSync(path.dirname(CALIBRATION_FILE), { recursive: true });
fs.writeFileSync(
@ -102,7 +106,7 @@ export function getPerformanceMultiplier(): number {
}
// Fallback if calibration preflight did not run.
// Conservative 4.0× to accommodate slow CI environments and native module initialization
// Should match MIN_MULTIPLIER floor in writeCalibrationResult
console.warn(
'[E2E Calibration] Calibration file not found, using fallback multiplier 4.0×',
);

View file

@ -1,7 +1,7 @@
import { setDefaultTimeout } from '@cucumber/cucumber';
import { getPerformanceMultiplier, isCalibrated } from './calibration';
const isCI = Boolean(process.env.CI);
const isCI = process.env.CI;
/**
* Get the performance multiplier based on calibration.