mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix(qa): reject duplicate rpc rtt controls
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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.`);
|
||||
|
||||
Reference in New Issue
Block a user