test(bench): trim shared helper duplicates (#121745)

This commit is contained in:
Peter Steinberger
2026-08-10 16:34:59 -07:00
committed by GitHub
parent 7e03fe3ba0
commit a2dc90765c
2 changed files with 1 additions and 24 deletions
+1 -10
View File
@@ -6,12 +6,7 @@ import path from "node:path";
import { performance } from "node:perf_hooks"; import { performance } from "node:perf_hooks";
import { pathToFileURL } from "node:url"; import { pathToFileURL } from "node:url";
import { delay, stopChild } from "./lib/gateway-bench-child.ts"; import { delay, stopChild } from "./lib/gateway-bench-child.ts";
import { import { getFreePort, readProcessRssMb, readProcessTreeCpuMs } from "./lib/gateway-bench-probes.ts";
getFreePort,
parseProcessRssKb,
readProcessRssMb,
readProcessTreeCpuMs,
} from "./lib/gateway-bench-probes.ts";
import { import {
BASE_GATEWAY_BENCH_CONFIG, BASE_GATEWAY_BENCH_CONFIG,
buildGatewayBenchChildArgs, buildGatewayBenchChildArgs,
@@ -832,10 +827,6 @@ export const testing = {
collectResultFailures, collectResultFailures,
collectStartupTrace, collectStartupTrace,
parseOptions, parseOptions,
parseNonNegativeInt,
parsePositiveInt,
parseProcessRssKb,
resolveEntry,
sanitizedEnv, sanitizedEnv,
stopChild, stopChild,
summarizeCase, summarizeCase,
@@ -55,8 +55,6 @@ describe("gateway startup benchmark script", () => {
it("rejects ambiguous benchmark CLI values before spawning Node", () => { it("rejects ambiguous benchmark CLI values before spawning Node", () => {
expect(() => testing.parseOptions(["--wat"])).toThrow("Unknown argument: --wat"); expect(() => testing.parseOptions(["--wat"])).toThrow("Unknown argument: --wat");
expect(testing.parsePositiveInt("5", 1, "--runs")).toBe(5);
expect(testing.parseNonNegativeInt("0", 1, "--warmup")).toBe(0);
expect( expect(
testing.parseOptions([ testing.parseOptions([
"--case", "--case",
@@ -76,9 +74,6 @@ describe("gateway startup benchmark script", () => {
output: "startup.json", output: "startup.json",
runs: 2, runs: 2,
}); });
expect(() => testing.parsePositiveInt("2abc", 1, "--runs")).toThrow(
/--runs must be an integer/u,
);
expect(() => testing.parseOptions(["--output", "--case", "default"])).toThrow( expect(() => testing.parseOptions(["--output", "--case", "default"])).toThrow(
"--output requires a value", "--output requires a value",
); );
@@ -92,7 +87,6 @@ describe("gateway startup benchmark script", () => {
expect(() => expect(() =>
testing.parseOptions(["--output", "first.json", "--output", "second.json"]), testing.parseOptions(["--output", "first.json", "--output", "second.json"]),
).toThrow("--output was provided more than once"); ).toThrow("--output was provided more than once");
expect(() => testing.resolveEntry("--inspect")).toThrow(/must be a file path/u);
}); });
it("rejects unknown benchmark CLI args before running cases", () => { it("rejects unknown benchmark CLI args before running cases", () => {
@@ -154,14 +148,6 @@ describe("gateway startup benchmark script", () => {
expect(env.OPENCLAW_GATEWAY_STARTUP_TRACE).toBe("1"); expect(env.OPENCLAW_GATEWAY_STARTUP_TRACE).toBe("1");
}); });
it("rejects malformed ps RSS samples", () => {
expect(testing.parseProcessRssKb("2048\n")).toBe(2048);
expect(testing.parseProcessRssKb("2048kb\n")).toBeNull();
expect(testing.parseProcessRssKb("2048 4096\n")).toBeNull();
expect(testing.parseProcessRssKb("0\n")).toBeNull();
expect(testing.parseProcessRssKb("")).toBeNull();
});
it("classifies HTTP listen and gateway ready logs separately", () => { it("classifies HTTP listen and gateway ready logs separately", () => {
expect( expect(
testing.classifyGatewayReadyLog("[gateway] http server listening (0 plugins, 0.8s)"), testing.classifyGatewayReadyLog("[gateway] http server listening (0 plugins, 0.8s)"),