mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat: Start Task Runner via Launcher (no-changelog) (#11071)
This commit is contained in:
@@ -18,6 +18,11 @@ describe('TaskRunnerProcess', () => {
|
||||
const taskBroker = Container.get(TaskBroker);
|
||||
const taskRunnerService = Container.get(TaskRunnerService);
|
||||
|
||||
const startLauncherSpy = jest.spyOn(runnerProcess, 'startLauncher');
|
||||
const startNodeSpy = jest.spyOn(runnerProcess, 'startNode');
|
||||
const killLauncherSpy = jest.spyOn(runnerProcess, 'killLauncher');
|
||||
const killNodeSpy = jest.spyOn(runnerProcess, 'killNode');
|
||||
|
||||
beforeAll(async () => {
|
||||
await taskRunnerServer.start();
|
||||
// Set the port to the actually used port
|
||||
@@ -30,6 +35,11 @@ describe('TaskRunnerProcess', () => {
|
||||
|
||||
afterEach(async () => {
|
||||
await runnerProcess.stop();
|
||||
|
||||
startLauncherSpy.mockClear();
|
||||
startNodeSpy.mockClear();
|
||||
killLauncherSpy.mockClear();
|
||||
killNodeSpy.mockClear();
|
||||
});
|
||||
|
||||
const getNumConnectedRunners = () => taskRunnerService.runnerConnections.size;
|
||||
@@ -88,4 +98,46 @@ describe('TaskRunnerProcess', () => {
|
||||
expect(getNumConnectedRunners()).toBe(1);
|
||||
expect(getNumRegisteredRunners()).toBe(1);
|
||||
});
|
||||
|
||||
it('should launch runner directly if not using a launcher', async () => {
|
||||
globalConfig.taskRunners.useLauncher = false;
|
||||
|
||||
await runnerProcess.start();
|
||||
|
||||
expect(startLauncherSpy).toBeCalledTimes(0);
|
||||
expect(startNodeSpy).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should use a launcher if configured', async () => {
|
||||
globalConfig.taskRunners.useLauncher = true;
|
||||
globalConfig.taskRunners.launcherPath = 'node';
|
||||
|
||||
await runnerProcess.start();
|
||||
|
||||
expect(startLauncherSpy).toBeCalledTimes(1);
|
||||
expect(startNodeSpy).toBeCalledTimes(0);
|
||||
globalConfig.taskRunners.useLauncher = false;
|
||||
});
|
||||
|
||||
it('should kill the process directly if not using a launcher', async () => {
|
||||
globalConfig.taskRunners.useLauncher = false;
|
||||
|
||||
await runnerProcess.start();
|
||||
await runnerProcess.stop();
|
||||
|
||||
expect(killLauncherSpy).toBeCalledTimes(0);
|
||||
expect(killNodeSpy).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should kill the process using a launcher if configured', async () => {
|
||||
globalConfig.taskRunners.useLauncher = true;
|
||||
globalConfig.taskRunners.launcherPath = 'node';
|
||||
|
||||
await runnerProcess.start();
|
||||
await runnerProcess.stop();
|
||||
|
||||
expect(killLauncherSpy).toBeCalledTimes(1);
|
||||
expect(killNodeSpy).toBeCalledTimes(0);
|
||||
globalConfig.taskRunners.useLauncher = false;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user