test(e2e): isolate kitchen sink rpc gateway

This commit is contained in:
Vincent Koc
2026-05-21 23:54:33 +08:00
parent 277a4b6952
commit da1925cb67

View File

@@ -25,6 +25,7 @@ const COMMAND_TIMEOUT_MS = readPositiveInt(
);
const RPC_TIMEOUT_MS = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_CALL_MS, 60000);
const MAX_RSS_MIB = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_MAX_RSS_MIB, 2048);
const DEFAULT_PORT = 19000 + Math.floor(Math.random() * 1000);
let callGatewayModulePromise;
@@ -357,7 +358,7 @@ function startGateway(runner, port, env, logPath) {
const child = childProcess.spawn(command.command, command.args, {
...command.options,
env,
detached: false,
detached: process.platform !== "win32",
});
fs.closeSync(log);
return child;
@@ -367,16 +368,26 @@ async function stopGateway(child) {
if (!child || child.exitCode !== null) {
return;
}
child.kill("SIGTERM");
signalGateway(child, "SIGTERM");
const started = Date.now();
while (child.exitCode === null && Date.now() - started < 10000) {
await delay(100);
}
if (child.exitCode === null) {
child.kill("SIGKILL");
signalGateway(child, "SIGKILL");
}
}
function signalGateway(child, signal) {
if (process.platform !== "win32" && typeof child.pid === "number") {
try {
process.kill(-child.pid, signal);
return;
} catch {}
}
child.kill(signal);
}
async function waitForGatewayReady(child, port, logPath) {
const started = Date.now();
let lastError = "";
@@ -555,7 +566,7 @@ function isNonEmptyString(value) {
async function main() {
const runner = resolveOpenClawRunner();
const port = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_PORT, 19173);
const port = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_PORT, DEFAULT_PORT);
const { root, env } = makeEnv();
const logPath = path.join(root, "gateway.log");