fix(qa): reject duplicate rpc rtt controls

This commit is contained in:
Vincent Koc
2026-06-23 18:00:53 +02:00
parent 9ff7abc898
commit d095d98a02
2 changed files with 14 additions and 0 deletions
+8
View File
@@ -14,6 +14,7 @@ import { resolveWindowsTaskkillPath } from "./lib/windows-taskkill.mjs";
const DEFAULT_METHODS = ["health", "config.get"];
const DEFAULT_ITERATIONS = 10;
const SINGLE_VALUE_FLAGS = new Set(["--iterations", "--methods", "--output-dir", "--repo-root"]);
/** Maximum time to wait for a spawned gateway to become reachable. */
export const READY_TIMEOUT_MS = 120_000;
/** Per-probe timeout used while polling gateway readiness endpoints. */
@@ -74,12 +75,19 @@ export function parseArgs(argv) {
iterations: DEFAULT_ITERATIONS,
methods: DEFAULT_METHODS,
};
const seenSingleValueFlags = new Set();
for (let index = 0; index < argv.length; index += 1) {
const arg = argv[index];
if (arg === "--help" || arg === "-h") {
args.help = true;
continue;
}
if (SINGLE_VALUE_FLAGS.has(arg)) {
if (seenSingleValueFlags.has(arg)) {
throw new Error(`${arg} was provided more than once.`);
}
seenSingleValueFlags.add(arg);
}
if (arg === "--output-dir") {
args.outputDir = readFlagValue(argv, index, arg);
index += 1;
+6
View File
@@ -182,6 +182,12 @@ describe("scripts/measure-rpc-rtt.mjs", () => {
expect(() =>
parseArgs(["--output-dir", "/tmp/rpc-rtt", "--methods", "health, config.get,health"]),
).toThrow("--methods contains duplicate gateway method: health");
expect(() => parseArgs(["--output-dir", "/tmp/one", "--output-dir", "/tmp/two"])).toThrow(
"--output-dir was provided more than once.",
);
expect(() =>
parseArgs(["--output-dir", "/tmp/rpc-rtt", "--methods", "health", "--methods", "config.get"]),
).toThrow("--methods was provided more than once.");
for (const value of ["--methods", "-h"]) {
for (const flag of ["--output-dir", "--repo-root", "--iterations", "--methods"]) {
expect(() => parseArgs([flag, value, "health"])).toThrow(`${flag} requires a value.`);