mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
fix(qa): reject duplicate gateway cpu controls
This commit is contained in:
parent
0850d83de1
commit
b8811b7dde
2 changed files with 27 additions and 0 deletions
|
|
@ -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("-")) {
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue