diff --git a/packages/cli/src/commands/__tests__/worker.test.ts b/packages/cli/src/commands/__tests__/worker.test.ts new file mode 100644 index 0000000000..4aece1b360 --- /dev/null +++ b/packages/cli/src/commands/__tests__/worker.test.ts @@ -0,0 +1,22 @@ +import { mockInstance } from '@n8n/backend-test-utils'; +import { Container } from '@n8n/di'; + +import { Worker } from '../worker'; + +import { PubSubRegistry } from '@/scaling/pubsub/pubsub.registry'; +import { Subscriber } from '@/scaling/pubsub/subscriber.service'; +import { WorkerStatusService } from '@/scaling/worker-status.service.ee'; +import { RedisClientService } from '@/services/redis-client.service'; + +mockInstance(RedisClientService); +mockInstance(PubSubRegistry); +mockInstance(Subscriber); +mockInstance(WorkerStatusService); + +test('should instantiate WorkerStatusService during orchestration setup', async () => { + const containerGetSpy = jest.spyOn(Container, 'get'); + + await new Worker().initOrchestration(); + + expect(containerGetSpy).toHaveBeenCalledWith(WorkerStatusService); +}); diff --git a/packages/cli/src/commands/worker.ts b/packages/cli/src/commands/worker.ts index 674ef87217..861647fcb7 100644 --- a/packages/cli/src/commands/worker.ts +++ b/packages/cli/src/commands/worker.ts @@ -15,6 +15,7 @@ import type { ScalingService } from '@/scaling/scaling.service'; import type { WorkerServerEndpointsConfig } from '@/scaling/worker-server'; import { BaseCommand } from './base-command'; +import { WorkerStatusService } from '@/scaling/worker-status.service.ee'; const flagsSchema = z.object({ concurrency: z.number().int().default(10).describe('How many jobs can run in parallel.'), @@ -129,6 +130,7 @@ export class Worker extends BaseCommand> { Container.get(PubSubRegistry).init(); await Container.get(Subscriber).subscribe('n8n.commands'); + Container.get(WorkerStatusService); } async setConcurrency() {