mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -06:00
test(agents): accelerate local service timeout fixture (#118104)
Co-authored-by: Peter Steinberger <steipete@mac-studio-sf2.local>
This commit is contained in:
committed by
GitHub
parent
d02101d7ce
commit
18ee52bbc1
@@ -820,19 +820,34 @@ describe("provider local service", () => {
|
||||
const tempDir = tempDirs.make("openclaw-local-service-failed-unref-");
|
||||
const servicePidPath = path.join(tempDir, "service.pid");
|
||||
const moduleUrl = new URL("./provider-local-service.ts", import.meta.url).href;
|
||||
// The assertion targets diagnostic-pipe cleanup after failed readiness.
|
||||
// Give the nested Node child enough startup time under loaded CI.
|
||||
const failedServiceReadyTimeoutMs = 5_000;
|
||||
const failedServiceReadyTimeoutMs = 60_000;
|
||||
const serviceScript = [
|
||||
`const fs=require("node:fs");`,
|
||||
`fs.writeFileSync(${JSON.stringify(servicePidPath)},String(process.pid));`,
|
||||
`process.on("SIGTERM",()=>{});`,
|
||||
`setInterval(()=>process.stderr.write("tick\\n"),10);`,
|
||||
].join("");
|
||||
// Advance only the nested host's readiness clock after the service PID exists.
|
||||
// This preserves live-child failure cleanup without spending the deadline in wall time.
|
||||
const script = [
|
||||
`import fs from "node:fs";`,
|
||||
`import { ensureProviderLocalService } from ${JSON.stringify(moduleUrl)};`,
|
||||
`if (!process.send) throw new Error("missing one-shot host IPC");`,
|
||||
`process.on("disconnect", () => {});`,
|
||||
`const realNow = Date.now.bind(Date);`,
|
||||
`const realSetTimeout = globalThis.setTimeout.bind(globalThis);`,
|
||||
`let clockOffsetMs = 0;`,
|
||||
`Date.now = () => realNow() + clockOffsetMs;`,
|
||||
`globalThis.setTimeout = (callback, delay, ...args) => {`,
|
||||
` if (clockOffsetMs === 0 && fs.existsSync(${JSON.stringify(servicePidPath)})) {`,
|
||||
` return realSetTimeout(() => {`,
|
||||
` clockOffsetMs = ${failedServiceReadyTimeoutMs + 1};`,
|
||||
` globalThis.setTimeout = realSetTimeout;`,
|
||||
` callback(...args);`,
|
||||
` }, 0);`,
|
||||
` }`,
|
||||
` return realSetTimeout(callback, delay, ...args);`,
|
||||
`};`,
|
||||
`try {`,
|
||||
` await ensureProviderLocalService({`,
|
||||
` providerId: "local-failed-unref",`,
|
||||
@@ -843,7 +858,10 @@ describe("provider local service", () => {
|
||||
` readyTimeoutMs: ${failedServiceReadyTimeoutMs},`,
|
||||
` },`,
|
||||
` });`,
|
||||
`} catch {}`,
|
||||
`} catch (error) {`,
|
||||
` if (!(error instanceof Error) || !error.message.includes("did not become ready")) throw error;`,
|
||||
`}`,
|
||||
`if (clockOffsetMs === 0) throw new Error("test clock did not advance");`,
|
||||
`process.send({ kind: ${JSON.stringify(ONE_SHOT_HOST_READY_KIND)} });`,
|
||||
].join("\n");
|
||||
const parent = spawn(
|
||||
|
||||
Reference in New Issue
Block a user