mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-08 02:02:53 +00:00
fix(gateway): bound benchmark teardown waits
This commit is contained in:
@@ -261,6 +261,42 @@ node 1234 user 12u IPv4 0t0 TCP localhost:1234
|
||||
expect(child.kill).toHaveBeenCalledWith("SIGTERM");
|
||||
});
|
||||
|
||||
it("bounds teardown when the child ignores termination signals", async () => {
|
||||
const child = new EventEmitter() as EventEmitter & {
|
||||
exitCode: number | null;
|
||||
kill: ReturnType<typeof vi.fn>;
|
||||
signalCode: NodeJS.Signals | null;
|
||||
stderr: { destroy: ReturnType<typeof vi.fn> };
|
||||
stdin: { destroy: ReturnType<typeof vi.fn> };
|
||||
stdout: { destroy: ReturnType<typeof vi.fn> };
|
||||
unref: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
child.exitCode = null;
|
||||
child.signalCode = null;
|
||||
child.kill = vi.fn(() => true);
|
||||
child.stderr = { destroy: vi.fn() };
|
||||
child.stdin = { destroy: vi.fn() };
|
||||
child.stdout = { destroy: vi.fn() };
|
||||
child.unref = vi.fn();
|
||||
|
||||
await expect(
|
||||
testing.stopChild(child as unknown as Parameters<typeof testing.stopChild>[0], {
|
||||
killGraceMs: 1,
|
||||
teardownGraceMs: 1,
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
exitedBeforeTeardown: false,
|
||||
exitCode: null,
|
||||
signal: "SIGKILL",
|
||||
});
|
||||
expect(child.kill).toHaveBeenNthCalledWith(1, "SIGTERM");
|
||||
expect(child.kill).toHaveBeenNthCalledWith(2, "SIGKILL");
|
||||
expect(child.stdin.destroy).toHaveBeenCalledOnce();
|
||||
expect(child.stdout.destroy).toHaveBeenCalledOnce();
|
||||
expect(child.stderr.destroy).toHaveBeenCalledOnce();
|
||||
expect(child.unref).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("marks clean and signaled pre-teardown child exits as benchmark failures", () => {
|
||||
expect(
|
||||
testing.resolveSampleExitFailure({
|
||||
|
||||
@@ -325,6 +325,42 @@ describe("gateway startup benchmark script", () => {
|
||||
expect(child.kill).toHaveBeenCalledWith("SIGTERM");
|
||||
});
|
||||
|
||||
it("bounds teardown when the child ignores termination signals", async () => {
|
||||
const child = new EventEmitter() as EventEmitter & {
|
||||
exitCode: number | null;
|
||||
kill: ReturnType<typeof vi.fn>;
|
||||
signalCode: NodeJS.Signals | null;
|
||||
stderr: { destroy: ReturnType<typeof vi.fn> };
|
||||
stdin: { destroy: ReturnType<typeof vi.fn> };
|
||||
stdout: { destroy: ReturnType<typeof vi.fn> };
|
||||
unref: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
child.exitCode = null;
|
||||
child.signalCode = null;
|
||||
child.kill = vi.fn(() => true);
|
||||
child.stderr = { destroy: vi.fn() };
|
||||
child.stdin = { destroy: vi.fn() };
|
||||
child.stdout = { destroy: vi.fn() };
|
||||
child.unref = vi.fn();
|
||||
|
||||
await expect(
|
||||
testing.stopChild(child as unknown as Parameters<typeof testing.stopChild>[0], {
|
||||
killGraceMs: 1,
|
||||
teardownGraceMs: 1,
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
exitedBeforeTeardown: false,
|
||||
exitCode: null,
|
||||
signal: "SIGKILL",
|
||||
});
|
||||
expect(child.kill).toHaveBeenNthCalledWith(1, "SIGTERM");
|
||||
expect(child.kill).toHaveBeenNthCalledWith(2, "SIGKILL");
|
||||
expect(child.stdin.destroy).toHaveBeenCalledOnce();
|
||||
expect(child.stdout.destroy).toHaveBeenCalledOnce();
|
||||
expect(child.stderr.destroy).toHaveBeenCalledOnce();
|
||||
expect(child.unref).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("collects Count-suffixed startup trace metrics", () => {
|
||||
const startupTrace: Record<string, number> = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user