perf: reduce hotspot test startup and timeout costs

This commit is contained in:
Peter Steinberger
2026-02-13 20:02:53 +00:00
parent 31537c669a
commit 6442512954
6 changed files with 93 additions and 95 deletions

View File

@@ -262,22 +262,20 @@ describe("POST /tools/invoke", () => {
// oxlint-disable-next-line typescript/no-explicit-any
} as any;
const port = await getFreePort();
const server = await startGatewayServer(port, { bind: "loopback" });
const token = resolveGatewayToken();
const res = await fetch(`http://127.0.0.1:${port}/tools/invoke`, {
method: "POST",
headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
body: JSON.stringify({ tool: "sessions_spawn", args: { task: "test" }, sessionKey: "main" }),
const res = await invokeTool({
port: sharedPort,
tool: "sessions_spawn",
args: { task: "test" },
headers: { authorization: `Bearer ${token}` },
sessionKey: "main",
});
expect(res.status).toBe(404);
const body = await res.json();
expect(body.ok).toBe(false);
expect(body.error.type).toBe("not_found");
await server.close();
});
it("denies sessions_send via HTTP gateway", async () => {
@@ -286,18 +284,16 @@ describe("POST /tools/invoke", () => {
// oxlint-disable-next-line typescript/no-explicit-any
} as any;
const port = await getFreePort();
const server = await startGatewayServer(port, { bind: "loopback" });
const token = resolveGatewayToken();
const res = await fetch(`http://127.0.0.1:${port}/tools/invoke`, {
method: "POST",
headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
body: JSON.stringify({ tool: "sessions_send", args: {}, sessionKey: "main" }),
const res = await invokeTool({
port: sharedPort,
tool: "sessions_send",
headers: { authorization: `Bearer ${token}` },
sessionKey: "main",
});
expect(res.status).toBe(404);
await server.close();
});
it("denies gateway tool via HTTP", async () => {
@@ -306,18 +302,16 @@ describe("POST /tools/invoke", () => {
// oxlint-disable-next-line typescript/no-explicit-any
} as any;
const port = await getFreePort();
const server = await startGatewayServer(port, { bind: "loopback" });
const token = resolveGatewayToken();
const res = await fetch(`http://127.0.0.1:${port}/tools/invoke`, {
method: "POST",
headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
body: JSON.stringify({ tool: "gateway", args: {}, sessionKey: "main" }),
const res = await invokeTool({
port: sharedPort,
tool: "gateway",
headers: { authorization: `Bearer ${token}` },
sessionKey: "main",
});
expect(res.status).toBe(404);
await server.close();
});
it("uses the configured main session key when sessionKey is missing or main", async () => {