first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import { GenericContainer, Wait } from 'testcontainers';
|
||||
|
||||
import { createSilentLogConsumer } from '../helpers/utils';
|
||||
import { TEST_CONTAINER_IMAGES } from '../test-containers';
|
||||
import { EXTERNAL_HOST, type Service, type ServiceResult } from './types';
|
||||
|
||||
export interface TaskRunnerConfig {
|
||||
taskBrokerUri: string;
|
||||
}
|
||||
|
||||
export interface TaskRunnerMeta {
|
||||
taskBrokerUri: string;
|
||||
}
|
||||
|
||||
export type TaskRunnerResult = ServiceResult<TaskRunnerMeta>;
|
||||
|
||||
export const taskRunner: Service<TaskRunnerResult> = {
|
||||
description: 'Task Runner',
|
||||
shouldStart: (ctx) => ctx.mains > 0 || ctx.workers > 0,
|
||||
|
||||
getOptions(ctx) {
|
||||
if (ctx.external) {
|
||||
return { taskBrokerUri: `http://${EXTERNAL_HOST}:5679` } as TaskRunnerConfig;
|
||||
}
|
||||
const { workers, mains, projectName } = ctx;
|
||||
const taskBrokerHost =
|
||||
workers > 0
|
||||
? `${projectName}-n8n-worker-1`
|
||||
: mains > 1
|
||||
? `${projectName}-n8n-main-1`
|
||||
: `${projectName}-n8n`;
|
||||
return { taskBrokerUri: `http://${taskBrokerHost}:5679` } as TaskRunnerConfig;
|
||||
},
|
||||
|
||||
async start(network, projectName, config?: unknown): Promise<TaskRunnerResult> {
|
||||
const { taskBrokerUri } = config as TaskRunnerConfig;
|
||||
const { consumer, throwWithLogs } = createSilentLogConsumer();
|
||||
|
||||
try {
|
||||
const container = await new GenericContainer(TEST_CONTAINER_IMAGES.taskRunner)
|
||||
.withNetwork(network)
|
||||
.withNetworkAliases(`${projectName}-task-runner`)
|
||||
.withExposedPorts(5680)
|
||||
.withEnvironment({
|
||||
N8N_RUNNERS_AUTH_TOKEN: 'test',
|
||||
N8N_RUNNERS_LAUNCHER_LOG_LEVEL: 'debug',
|
||||
N8N_RUNNERS_TASK_BROKER_URI: taskBrokerUri,
|
||||
N8N_RUNNERS_MAX_CONCURRENCY: '5',
|
||||
N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT: '0', // Disabled in tests to prevent cold-start delays
|
||||
})
|
||||
.withWaitStrategy(Wait.forListeningPorts())
|
||||
.withLabels({
|
||||
'com.docker.compose.project': projectName,
|
||||
'com.docker.compose.service': 'task-runner',
|
||||
})
|
||||
.withName(`${projectName}-task-runner`)
|
||||
.withReuse()
|
||||
.withLogConsumer(consumer)
|
||||
.start();
|
||||
|
||||
return {
|
||||
container,
|
||||
meta: {
|
||||
taskBrokerUri,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
return throwWithLogs(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user