test(core): Stabilize flaky task runner process connect waits (no-changelog) (#32514)

This commit is contained in:
Tomi Turtiainen
2026-06-18 10:19:51 +03:00
committed by GitHub
parent dcbdb10a2b
commit 78d37ec45e
@@ -13,6 +13,11 @@ describe('TaskRunnerProcess', () => {
// per-test timeout, so give this spawn-heavy suite extra headroom.
jest.setTimeout(30_000);
// Every `start()` spawns a `node` child process and waits for the WebSocket
// handshake to complete. Under CI load that can comfortably exceed the default
// 5s `retryUntil` window, so allow a longer window for all connect waits.
const CONNECT_TIMEOUT_MS = 15_000;
const { config, server: taskRunnerServer } = setupBrokerTestServer({
mode: 'internal',
});
@@ -45,7 +50,9 @@ describe('TaskRunnerProcess', () => {
expect(runnerProcess.isRunning).toBeTruthy();
// Wait until the runner has connected
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1));
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1), {
timeoutMs: CONNECT_TIMEOUT_MS,
});
expect(getNumRegisteredRunners()).toBe(1);
});
@@ -54,7 +61,9 @@ describe('TaskRunnerProcess', () => {
await runnerProcess.start();
// Wait until the runner has connected
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1));
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1), {
timeoutMs: CONNECT_TIMEOUT_MS,
});
expect(getNumRegisteredRunners()).toBe(1);
// Act
@@ -73,7 +82,9 @@ describe('TaskRunnerProcess', () => {
await runnerProcess.start();
// Wait until the runner has connected
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1));
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1), {
timeoutMs: CONNECT_TIMEOUT_MS,
});
const processId = runnerProcess.pid;
// Act
@@ -87,7 +98,9 @@ describe('TaskRunnerProcess', () => {
// Wait until the runner has connected again. Restarting spawns a fresh
// child process and re-runs the WebSocket handshake, which is slower and
// more load-sensitive than the initial connect, so allow a longer window.
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1), { timeoutMs: 15_000 });
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1), {
timeoutMs: CONNECT_TIMEOUT_MS,
});
expect(getNumConnectedRunners()).toBe(1);
expect(getNumRegisteredRunners()).toBe(1);
expect(runnerProcess.pid).not.toBe(processId);