@@ -315,7 +315,42 @@ describe("scripts/measure-rpc-rtt.mjs", () => {
|
315 | 315 | } else { |
316 | 316 | expect(kill).toHaveBeenNthCalledWith(1, -12346, 0); |
317 | 317 | expect(kill).toHaveBeenNthCalledWith(2, -12346, "SIGTERM"); |
318 | | -expect(kill).toHaveBeenLastCalledWith(-12346, "SIGKILL"); |
| 318 | +expect(kill).toHaveBeenCalledWith(-12346, "SIGKILL"); |
| 319 | +expect(child.kill).not.toHaveBeenCalled(); |
| 320 | +} |
| 321 | +}); |
| 322 | + |
| 323 | +it("waits for the process group to disappear after force kill", async () => { |
| 324 | +const child = Object.assign(new EventEmitter(), { |
| 325 | +exitCode: null, |
| 326 | +kill: vi.fn(), |
| 327 | +pid: 12350, |
| 328 | +signalCode: null, |
| 329 | +}); |
| 330 | +let sawForceKill = false; |
| 331 | +let postKillLivenessChecks = 0; |
| 332 | +const kill = vi.fn((_pid: number, signal: number | NodeJS.Signals) => { |
| 333 | +if (signal === "SIGKILL") { |
| 334 | +sawForceKill = true; |
| 335 | +return true; |
| 336 | +} |
| 337 | +if (signal === 0 && sawForceKill) { |
| 338 | +postKillLivenessChecks += 1; |
| 339 | +if (postKillLivenessChecks >= 2) { |
| 340 | +throw Object.assign(new Error("no such process"), { code: "ESRCH" }); |
| 341 | +} |
| 342 | +} |
| 343 | +return true; |
| 344 | +}); |
| 345 | + |
| 346 | +await stopGateway(child, { forceKillGraceMs: 50, killGraceMs: 1, killProcess: kill }); |
| 347 | + |
| 348 | +if (process.platform === "win32") { |
| 349 | +expect(child.kill).toHaveBeenNthCalledWith(1, "SIGTERM"); |
| 350 | +expect(child.kill).toHaveBeenNthCalledWith(2, "SIGKILL"); |
| 351 | +} else { |
| 352 | +expect(kill).toHaveBeenCalledWith(-12350, "SIGKILL"); |
| 353 | +expect(postKillLivenessChecks).toBe(2); |
319 | 354 | expect(child.kill).not.toHaveBeenCalled(); |
320 | 355 | } |
321 | 356 | }); |
@@ -336,7 +371,7 @@ describe("scripts/measure-rpc-rtt.mjs", () => {
|
336 | 371 | } else { |
337 | 372 | expect(kill).toHaveBeenNthCalledWith(1, -12347, 0); |
338 | 373 | expect(kill).toHaveBeenNthCalledWith(2, -12347, "SIGTERM"); |
339 | | -expect(kill).toHaveBeenLastCalledWith(-12347, "SIGKILL"); |
| 374 | +expect(kill).toHaveBeenCalledWith(-12347, "SIGKILL"); |
340 | 375 | expect(child.kill).not.toHaveBeenCalled(); |
341 | 376 | } |
342 | 377 | }); |
|