fix: serialize session lifecycle transitions
This commit is contained in:
@@ -66,6 +66,27 @@ test("l'exit del VECCHIO child non elimina il nuovo runtime (exit identity-check
|
||||
mgr.teardown("respawn-id");
|
||||
});
|
||||
|
||||
test("identity-checked teardown cannot kill a replacement runtime", () => {
|
||||
const cfg = loadConfig({ THT_HARNESS_DIR: "../harness" });
|
||||
const firstChild = recordingChild();
|
||||
const secondChild = recordingChild();
|
||||
firstChild.kill = vi.fn();
|
||||
secondChild.kill = vi.fn();
|
||||
const children = [firstChild, secondChild];
|
||||
const mgr = new PiProcessManager(cfg, { spawnFn: () => children.shift() as any });
|
||||
const first = mgr.createFor("replace-id", {});
|
||||
mgr.teardown("replace-id");
|
||||
const second = mgr.createFor("replace-id", {});
|
||||
|
||||
expect(mgr.teardownIfCurrent("replace-id", first)).toBe(false);
|
||||
expect(mgr.get("replace-id")).toBe(second);
|
||||
expect(secondChild.kill).not.toHaveBeenCalled();
|
||||
|
||||
expect(mgr.teardownIfCurrent("replace-id", second)).toBe(true);
|
||||
expect(mgr.get("replace-id")).toBeUndefined();
|
||||
expect(secondChild.kill).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
test("oltre maxPiProcesses solleva errore", async () => {
|
||||
const cfg = { ...loadConfig({}), maxPiProcesses: 1 };
|
||||
const mgr = new PiProcessManager(cfg, { spawnFn: () => spawn("node", [FAKE, SCRIPT]) as any });
|
||||
|
||||
Reference in New Issue
Block a user