Skip to content

Commit cbe0700

Browse files
authored
perf(test): trigger restart probe timeout deterministically (#126664)
1 parent bb96493 commit cbe0700

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/cli/daemon-cli/restart-health-probe.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe("restart health", () => {
3131
const gateway = new WebSocketServer({ host: "127.0.0.1", port: 0 });
3232
await once(gateway, "listening");
3333
const port = (gateway.address() as AddressInfo).port;
34+
const timeoutSpy = failure === "timeout" ? vi.spyOn(globalThis, "setTimeout") : undefined;
3435
gateway.on("connection", (socket) => {
3536
sendMinimalGatewayConnectChallenge(socket);
3637
socket.on("message", (data) => {
@@ -46,7 +47,9 @@ describe("restart health", () => {
4647
...hello,
4748
server: { ...hello.server, version: "2026.8.1" },
4849
});
49-
} else if (failure !== "timeout") {
50+
} else if (failure === "timeout") {
51+
timeoutSpy?.mock.calls.findLast(([, delay]) => delay === 3_000)?.[0]();
52+
} else {
5053
socket.send(
5154
JSON.stringify({
5255
type: "res",
@@ -88,6 +91,10 @@ describe("restart health", () => {
8891
expect(snapshot.gatewayVersion).toBe("2026.8.1");
8992
expect(snapshot.versionMismatch).toBeUndefined();
9093
expect(snapshot.probeError).toBe(failure);
94+
expect(firstCallArg(probeGateway)).toMatchObject({
95+
includeDetails: true,
96+
timeoutMs: 3_000,
97+
});
9198
expect(renderRestartDiagnostics(snapshot)).toContain(`Gateway probe failed: ${failure}`);
9299
} finally {
93100
await closeMinimalGatewayServer(gateway);

0 commit comments

Comments
 (0)