From f817fb4e746cfda28c3eba9cb6c2ef6684f67d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Mon, 7 Jul 2025 12:06:40 +0200 Subject: [PATCH] fix(core): Fix worker view (#17052) --- .../cli/src/commands/__tests__/worker.test.ts | 22 +++++++++++++++++++ packages/cli/src/commands/worker.ts | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 packages/cli/src/commands/__tests__/worker.test.ts 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() {