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,68 @@
|
||||
import { MySqlContainer, type StartedMySqlContainer } from '@testcontainers/mysql';
|
||||
import type { StartedNetwork } from 'testcontainers';
|
||||
|
||||
import { TEST_CONTAINER_IMAGES } from '../test-containers';
|
||||
import type { Service, ServiceResult } from './types';
|
||||
|
||||
const HOSTNAME = 'mysql';
|
||||
|
||||
export interface MySqlMeta {
|
||||
database: string;
|
||||
username: string;
|
||||
password: string;
|
||||
port: number;
|
||||
internalHost: string;
|
||||
externalHost: string;
|
||||
externalPort: number;
|
||||
}
|
||||
|
||||
export type MySqlResult = ServiceResult<MySqlMeta> & {
|
||||
container: StartedMySqlContainer;
|
||||
};
|
||||
|
||||
export const mysqlService: Service<MySqlResult> = {
|
||||
description: 'MySQL database for integration testing',
|
||||
|
||||
async start(network: StartedNetwork, projectName: string): Promise<MySqlResult> {
|
||||
const container = await new MySqlContainer(TEST_CONTAINER_IMAGES.mysql)
|
||||
.withNetwork(network)
|
||||
.withNetworkAliases(HOSTNAME)
|
||||
.withDatabase('n8n_test')
|
||||
.withUsername('n8n_user')
|
||||
.withRootPassword('root_password')
|
||||
.withUserPassword('test_password')
|
||||
.withStartupTimeout(60_000)
|
||||
.withLabels({
|
||||
'com.docker.compose.project': projectName,
|
||||
'com.docker.compose.service': HOSTNAME,
|
||||
})
|
||||
.withName(`${projectName}-${HOSTNAME}`)
|
||||
.withReuse()
|
||||
.start();
|
||||
|
||||
return {
|
||||
container,
|
||||
meta: {
|
||||
database: container.getDatabase(),
|
||||
username: container.getUsername(),
|
||||
password: container.getUserPassword(),
|
||||
port: 3306,
|
||||
internalHost: HOSTNAME,
|
||||
externalHost: container.getHost(),
|
||||
externalPort: container.getPort(),
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
env(result: MySqlResult, external?: boolean): Record<string, string> {
|
||||
if (!external) return {};
|
||||
return {
|
||||
DB_TYPE: 'mysqldb',
|
||||
DB_MYSQLDB_HOST: result.meta.externalHost,
|
||||
DB_MYSQLDB_PORT: String(result.meta.externalPort),
|
||||
DB_MYSQLDB_DATABASE: result.meta.database,
|
||||
DB_MYSQLDB_USER: result.meta.username,
|
||||
DB_MYSQLDB_PASSWORD: result.meta.password,
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user