fix(qa): reject duplicate gateway cpu controls

This commit is contained in:
Vincent Koc 2026-06-23 17:30:37 +02:00
parent 0850d83de1
commit b8811b7dde
No known key found for this signature in database
2 changed files with 27 additions and 0 deletions

View file

@ -24,6 +24,13 @@ const DEFAULT_QA_SCENARIOS = [
"memory-failure-fallback",
"gateway-restart-inflight-run",
];
const SINGLE_VALUE_FLAGS = new Set([
"--cpu-core-warn",
"--hot-wall-warn-ms",
"--output-dir",
"--runs",
"--warmup",
]);
const DEFAULT_CPU_CORE_WARN = 0.9;
const DEFAULT_HOT_WALL_WARN_MS = 30_000;
const PRIVATE_QA_REQUIRED_DIST_ENTRIES = [
@ -49,8 +56,15 @@ function parseArgs(argv) {
cpuCoreWarn: DEFAULT_CPU_CORE_WARN,
hotWallWarnMs: DEFAULT_HOT_WALL_WARN_MS,
};
const seenSingleValueFlags = new Set();
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
if (SINGLE_VALUE_FLAGS.has(arg)) {
if (seenSingleValueFlags.has(arg)) {
throw new Error(`${arg} was provided more than once`);
}
seenSingleValueFlags.add(arg);
}
const readValue = () => {
const value = args[index + 1];
if (!value || value.startsWith("-")) {

View file

@ -111,6 +111,19 @@ describe("gateway CPU scenario guard", () => {
}
});
it("rejects duplicate single-value controls before running scenarios", () => {
expect(() =>
testing.parseArgs(["--output-dir", makeTempRoot(), "--output-dir", makeTempRoot()]),
).toThrow("--output-dir was provided more than once");
const result = runCli("--runs", "1", "--runs", "2");
expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr.trim()).toBe("--runs was provided more than once");
expectNoNodeStack(result.stderr);
});
it("reports CLI argument errors without a Node stack trace", () => {
const result = runCli("--wat");