mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:20:43 +00:00
test: share restart health stopped-free fixture
This commit is contained in:
@@ -88,6 +88,24 @@ async function inspectAmbiguousOwnershipWithProbe(
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForStoppedFreeGatewayRestart() {
|
||||
const service = makeGatewayService({ status: "stopped" });
|
||||
inspectPortUsage.mockResolvedValue({
|
||||
port: 18789,
|
||||
status: "free",
|
||||
listeners: [],
|
||||
hints: [],
|
||||
});
|
||||
|
||||
const { waitForGatewayHealthyRestart } = await import("./restart-health.js");
|
||||
return waitForGatewayHealthyRestart({
|
||||
service,
|
||||
port: 18789,
|
||||
attempts: 120,
|
||||
delayMs: 500,
|
||||
});
|
||||
}
|
||||
|
||||
describe("inspectGatewayRestart", () => {
|
||||
beforeEach(() => {
|
||||
inspectPortUsage.mockReset();
|
||||
@@ -252,21 +270,7 @@ describe("inspectGatewayRestart", () => {
|
||||
});
|
||||
|
||||
it("annotates stopped-free early exits with the actual elapsed time", async () => {
|
||||
const service = makeGatewayService({ status: "stopped" });
|
||||
inspectPortUsage.mockResolvedValue({
|
||||
port: 18789,
|
||||
status: "free",
|
||||
listeners: [],
|
||||
hints: [],
|
||||
});
|
||||
|
||||
const { waitForGatewayHealthyRestart } = await import("./restart-health.js");
|
||||
const snapshot = await waitForGatewayHealthyRestart({
|
||||
service,
|
||||
port: 18789,
|
||||
attempts: 120,
|
||||
delayMs: 500,
|
||||
});
|
||||
const snapshot = await waitForStoppedFreeGatewayRestart();
|
||||
|
||||
expect(snapshot).toMatchObject({
|
||||
healthy: false,
|
||||
@@ -280,21 +284,8 @@ describe("inspectGatewayRestart", () => {
|
||||
|
||||
it("waits longer before stopped-free early exit on Windows", async () => {
|
||||
Object.defineProperty(process, "platform", { value: "win32", configurable: true });
|
||||
const service = makeGatewayService({ status: "stopped" });
|
||||
inspectPortUsage.mockResolvedValue({
|
||||
port: 18789,
|
||||
status: "free",
|
||||
listeners: [],
|
||||
hints: [],
|
||||
});
|
||||
|
||||
const { waitForGatewayHealthyRestart } = await import("./restart-health.js");
|
||||
const snapshot = await waitForGatewayHealthyRestart({
|
||||
service,
|
||||
port: 18789,
|
||||
attempts: 120,
|
||||
delayMs: 500,
|
||||
});
|
||||
const snapshot = await waitForStoppedFreeGatewayRestart();
|
||||
|
||||
expect(snapshot).toMatchObject({
|
||||
healthy: false,
|
||||
|
||||
Reference in New Issue
Block a user