mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 03:56:24 +00:00
fix(e2e): bound kitchen sink RPC probes
This commit is contained in:
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { setTimeout as delay } from "node:timers/promises";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
appendBoundedOutput,
|
||||
assertDiagnosticStabilityClean,
|
||||
@@ -23,6 +23,10 @@ import {
|
||||
|
||||
const posixIt = process.platform === "win32" ? it.skip : it;
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
describe("kitchen-sink RPC isolated state", () => {
|
||||
it("cleans up the generated temporary home tree", async () => {
|
||||
const { root, env } = makeEnv();
|
||||
@@ -459,6 +463,29 @@ describe("kitchen-sink RPC process sampling", () => {
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("times out stalled HTTP probe response bodies", async () => {
|
||||
vi.useFakeTimers();
|
||||
const fetchImpl = vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
text: () => new Promise(() => undefined),
|
||||
});
|
||||
|
||||
const result = fetchJson("http://127.0.0.1:19680/readyz", {
|
||||
attempts: 1,
|
||||
fetchImpl,
|
||||
timeoutMs: 100,
|
||||
});
|
||||
const rejection = expect(result).rejects.toMatchObject({
|
||||
code: "ETIMEDOUT",
|
||||
message: "fetch http://127.0.0.1:19680/readyz timed out after 100ms",
|
||||
});
|
||||
|
||||
await vi.advanceTimersByTimeAsync(100);
|
||||
await rejection;
|
||||
expect(fetchImpl.mock.calls[0]?.[1]?.signal.aborted).toBe(true);
|
||||
});
|
||||
|
||||
it("fails when the sampled RSS exceeds the configured ceiling", () => {
|
||||
expect(() => assertResourceCeiling({ rssMiB: 2049 })).toThrow(
|
||||
"gateway RSS exceeded 2048 MiB: 2049 MiB",
|
||||
|
||||
Reference in New Issue
Block a user