Skip to content

Commit b8811b7

Browse files
committed
fix(qa): reject duplicate gateway cpu controls
1 parent 0850d83 commit b8811b7

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

scripts/check-gateway-cpu-scenarios.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ const DEFAULT_QA_SCENARIOS = [
2424
"memory-failure-fallback",
2525
"gateway-restart-inflight-run",
2626
];
27+
const SINGLE_VALUE_FLAGS = new Set([
28+
"--cpu-core-warn",
29+
"--hot-wall-warn-ms",
30+
"--output-dir",
31+
"--runs",
32+
"--warmup",
33+
]);
2734
const DEFAULT_CPU_CORE_WARN = 0.9;
2835
const DEFAULT_HOT_WALL_WARN_MS = 30_000;
2936
const PRIVATE_QA_REQUIRED_DIST_ENTRIES = [
@@ -49,8 +56,15 @@ function parseArgs(argv) {
4956
cpuCoreWarn: DEFAULT_CPU_CORE_WARN,
5057
hotWallWarnMs: DEFAULT_HOT_WALL_WARN_MS,
5158
};
59+
const seenSingleValueFlags = new Set();
5260
for (let index = 0; index < args.length; index += 1) {
5361
const arg = args[index];
62+
if (SINGLE_VALUE_FLAGS.has(arg)) {
63+
if (seenSingleValueFlags.has(arg)) {
64+
throw new Error(`${arg} was provided more than once`);
65+
}
66+
seenSingleValueFlags.add(arg);
67+
}
5468
const readValue = () => {
5569
const value = args[index + 1];
5670
if (!value || value.startsWith("-")) {

test/scripts/check-gateway-cpu-scenarios.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ describe("gateway CPU scenario guard", () => {
111111
}
112112
});
113113

114+
it("rejects duplicate single-value controls before running scenarios", () => {
115+
expect(() =>
116+
testing.parseArgs(["--output-dir", makeTempRoot(), "--output-dir", makeTempRoot()]),
117+
).toThrow("--output-dir was provided more than once");
118+
119+
const result = runCli("--runs", "1", "--runs", "2");
120+
121+
expect(result.status).toBe(1);
122+
expect(result.stdout).toBe("");
123+
expect(result.stderr.trim()).toBe("--runs was provided more than once");
124+
expectNoNodeStack(result.stderr);
125+
});
126+
114127
it("reports CLI argument errors without a Node stack trace", () => {
115128
const result = runCli("--wat");
116129

0 commit comments

Comments
 (0)