refactor(core): Centralize scaling mode (no-changelog) (#9835)

This commit is contained in:
Iván Ovejero
2024-08-07 13:50:46 +02:00
committed by GitHub
parent ee968b7163
commit e31d017bdd
17 changed files with 529 additions and 453 deletions

View File

@@ -1,5 +1,4 @@
import { BinaryDataService } from 'n8n-core';
import { mock } from 'jest-mock-extended';
import { Worker } from '@/commands/worker';
import config from '@/config';
@@ -11,7 +10,7 @@ import { OrchestrationHandlerWorkerService } from '@/services/orchestration/work
import { OrchestrationWorkerService } from '@/services/orchestration/worker/orchestration.worker.service';
import { License } from '@/License';
import { ExternalHooks } from '@/ExternalHooks';
import { type JobQueue, Queue } from '@/Queue';
import { ScalingService } from '@/scaling/scaling.service';
import { setupTestCommand } from '@test-integration/utils/testCommand';
import { mockInstance } from '../../shared/mocking';
@@ -28,12 +27,10 @@ const license = mockInstance(License);
const messageEventBus = mockInstance(MessageEventBus);
const logStreamingEventRelay = mockInstance(LogStreamingEventRelay);
const orchestrationHandlerWorkerService = mockInstance(OrchestrationHandlerWorkerService);
const queue = mockInstance(Queue);
const scalingService = mockInstance(ScalingService);
const orchestrationWorkerService = mockInstance(OrchestrationWorkerService);
const command = setupTestCommand(Worker);
queue.getBullObjectInstance.mockReturnValue(mock<JobQueue>({ on: jest.fn() }));
test('worker initializes all its components', async () => {
const worker = await command.run();
@@ -45,9 +42,9 @@ test('worker initializes all its components', async () => {
expect(externalHooks.init).toHaveBeenCalledTimes(1);
expect(externalSecretsManager.init).toHaveBeenCalledTimes(1);
expect(messageEventBus.initialize).toHaveBeenCalledTimes(1);
expect(scalingService.setupQueue).toHaveBeenCalledTimes(1);
expect(scalingService.setupWorker).toHaveBeenCalledTimes(1);
expect(logStreamingEventRelay.init).toHaveBeenCalledTimes(1);
expect(queue.init).toHaveBeenCalledTimes(1);
expect(queue.process).toHaveBeenCalledTimes(1);
expect(orchestrationWorkerService.init).toHaveBeenCalledTimes(1);
expect(orchestrationHandlerWorkerService.initWithOptions).toHaveBeenCalledTimes(1);
expect(messageEventBus.send).toHaveBeenCalledTimes(1);