mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
test: Fix flaky task-runner integration test (#11302)
This commit is contained in:
parent
0be04c6348
commit
0aae47c295
|
@ -23,10 +23,14 @@ export class TaskRunnerProcess {
|
||||||
return this.process?.pid;
|
return this.process?.pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Promise that resolves when the process has exited */
|
||||||
|
public get runPromise() {
|
||||||
|
return this._runPromise;
|
||||||
|
}
|
||||||
|
|
||||||
private process: ChildProcess | null = null;
|
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;
|
private isShuttingDown = false;
|
||||||
|
|
||||||
|
@ -97,7 +101,7 @@ export class TaskRunnerProcess {
|
||||||
} else {
|
} else {
|
||||||
this.killNode();
|
this.killNode();
|
||||||
}
|
}
|
||||||
await this.runPromise;
|
await this._runPromise;
|
||||||
|
|
||||||
this.isShuttingDown = false;
|
this.isShuttingDown = false;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +132,7 @@ export class TaskRunnerProcess {
|
||||||
}
|
}
|
||||||
|
|
||||||
private monitorProcess(taskRunnerProcess: ChildProcess) {
|
private monitorProcess(taskRunnerProcess: ChildProcess) {
|
||||||
this.runPromise = new Promise((resolve) => {
|
this._runPromise = new Promise((resolve) => {
|
||||||
taskRunnerProcess.on('exit', (code) => {
|
taskRunnerProcess.on('exit', (code) => {
|
||||||
this.onProcessExit(code, resolve);
|
this.onProcessExit(code, resolve);
|
||||||
});
|
});
|
||||||
|
|
|
@ -88,15 +88,15 @@ describe('TaskRunnerProcess', () => {
|
||||||
// @ts-expect-error private property
|
// @ts-expect-error private property
|
||||||
runnerProcess.process?.kill('SIGKILL');
|
runnerProcess.process?.kill('SIGKILL');
|
||||||
|
|
||||||
// Assert
|
// Wait until the runner has exited
|
||||||
// Wait until the runner is running again
|
await runnerProcess.runPromise;
|
||||||
await retryUntil(() => expect(runnerProcess.isRunning).toBeTruthy());
|
|
||||||
expect(runnerProcess.pid).not.toBe(processId);
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
// Wait until the runner has connected again
|
// Wait until the runner has connected again
|
||||||
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1));
|
await retryUntil(() => expect(getNumConnectedRunners()).toBe(1));
|
||||||
expect(getNumConnectedRunners()).toBe(1);
|
expect(getNumConnectedRunners()).toBe(1);
|
||||||
expect(getNumRegisteredRunners()).toBe(1);
|
expect(getNumRegisteredRunners()).toBe(1);
|
||||||
|
expect(runnerProcess.pid).not.toBe(processId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should launch runner directly if not using a launcher', async () => {
|
it('should launch runner directly if not using a launcher', async () => {
|
||||||
|
|
Loading…
Reference in a new issue