Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix flaky task-runner integration test #11302

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/cli/src/runners/task-runner-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ export class TaskRunnerProcess {
return this.process?.pid;
}

/** Promise that resolves when the process has exited */
public get runPromise() {
return this._runPromise;
}

private process: ChildProcess | null = null;

/** Promise that resolves after the process has exited */
private runPromise: Promise<void> | null = null;
private _runPromise: Promise<void> | null = null;

private isShuttingDown = false;

Expand Down Expand Up @@ -97,7 +101,7 @@ export class TaskRunnerProcess {
} else {
this.killNode();
}
await this.runPromise;
await this._runPromise;

this.isShuttingDown = false;
}
Expand Down Expand Up @@ -128,7 +132,7 @@ export class TaskRunnerProcess {
}

private monitorProcess(taskRunnerProcess: ChildProcess) {
this.runPromise = new Promise((resolve) => {
this._runPromise = new Promise((resolve) => {
taskRunnerProcess.on('exit', (code) => {
this.onProcessExit(code, resolve);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ describe('TaskRunnerProcess', () => {
// @ts-expect-error private property
runnerProcess.process?.kill('SIGKILL');

// Assert
// Wait until the runner is running again
await retryUntil(() => expect(runnerProcess.isRunning).toBeTruthy());
expect(runnerProcess.pid).not.toBe(processId);
// Wait until the runner has exited
await runnerProcess.runPromise;

// Assert
// Wait until the runner has connected again
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1));
expect(getNumConnectedRunners()).toBe(1);
expect(getNumRegisteredRunners()).toBe(1);
expect(runnerProcess.pid).not.toBe(processId);
});

it('should launch runner directly if not using a launcher', async () => {
Expand Down
Loading