mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 18:04:32 +00:00
test: stabilize session lock tests and move out of e2e
This commit is contained in:
@@ -110,7 +110,7 @@ describe("acquireSessionWriteLock", () => {
|
|||||||
|
|
||||||
it("derives max hold from timeout plus grace", () => {
|
it("derives max hold from timeout plus grace", () => {
|
||||||
expect(resolveSessionLockMaxHoldFromTimeout({ timeoutMs: 600_000 })).toBe(720_000);
|
expect(resolveSessionLockMaxHoldFromTimeout({ timeoutMs: 600_000 })).toBe(720_000);
|
||||||
expect(resolveSessionLockMaxHoldFromTimeout({ timeoutMs: 1_000, minMs: 5_000 })).toBe(123_000);
|
expect(resolveSessionLockMaxHoldFromTimeout({ timeoutMs: 1_000, minMs: 5_000 })).toBe(121_000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clamps max hold for effectively no-timeout runs", () => {
|
it("clamps max hold for effectively no-timeout runs", () => {
|
||||||
@@ -181,6 +181,9 @@ describe("acquireSessionWriteLock", () => {
|
|||||||
|
|
||||||
it("removes held locks on termination signals", async () => {
|
it("removes held locks on termination signals", async () => {
|
||||||
const signals = ["SIGINT", "SIGTERM", "SIGQUIT", "SIGABRT"] as const;
|
const signals = ["SIGINT", "SIGTERM", "SIGQUIT", "SIGABRT"] as const;
|
||||||
|
const originalKill = process.kill.bind(process);
|
||||||
|
process.kill = ((_pid: number, _signal?: NodeJS.Signals) => true) as typeof process.kill;
|
||||||
|
try {
|
||||||
for (const signal of signals) {
|
for (const signal of signals) {
|
||||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-lock-cleanup-"));
|
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-lock-cleanup-"));
|
||||||
try {
|
try {
|
||||||
@@ -202,6 +205,9 @@ describe("acquireSessionWriteLock", () => {
|
|||||||
await fs.rm(root, { recursive: true, force: true });
|
await fs.rm(root, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
process.kill = originalKill;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("registers cleanup for SIGQUIT and SIGABRT", () => {
|
it("registers cleanup for SIGQUIT and SIGABRT", () => {
|
||||||
Reference in New Issue
Block a user