feat: Add n8n postgres setup to benchmarks (no-changelog) (#10604)

This commit is contained in:
Tomi Turtiainen 2024-08-30 09:41:50 +03:00 committed by GitHub
parent 1dcb814ced
commit 4e899ea55f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 4 deletions

View file

@ -0,0 +1,29 @@
services:
postgres:
image: postgres:16
restart: always
environment:
- POSTGRES_DB=n8n
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
n8n:
image: ghcr.io/n8n-io/n8n:${N8N_VERSION:-latest}
environment:
- N8N_DIAGNOSTICS_ENABLED=false
- N8N_USER_FOLDER=/n8n
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PASSWORD=password
ports:
- 5678:5678
volumes:
- ${RUN_DIR}:/n8n
depends_on:
- postgres
benchmark:
image: ghcr.io/n8n-io/n8n-benchmark:${N8N_BENCHMARK_VERSION:-latest}
depends_on:
- n8n
environment:
- N8N_BASE_URL=http://n8n:5678
- K6_API_TOKEN=${K6_API_TOKEN}

View file

@ -19,15 +19,18 @@ async function main() {
const n8nTag = argv.n8nDockerTag || process.env.N8N_DOCKER_TAG || 'latest'; const n8nTag = argv.n8nDockerTag || process.env.N8N_DOCKER_TAG || 'latest';
const benchmarkTag = argv.benchmarkDockerTag || process.env.BENCHMARK_DOCKER_TAG || 'latest'; const benchmarkTag = argv.benchmarkDockerTag || process.env.BENCHMARK_DOCKER_TAG || 'latest';
const k6ApiToken = argv.k6ApiToken || process.env.K6_API_TOKEN || undefined; const k6ApiToken = argv.k6ApiToken || process.env.K6_API_TOKEN || undefined;
const runDir = argv.runDir || process.env.RUN_DIR || '/n8n'; const baseRunDir = argv.runDir || process.env.RUN_DIR || '/n8n';
if (!fs.existsSync(runDir)) { if (!fs.existsSync(baseRunDir)) {
console.error( console.error(
`The run directory "${runDir}" does not exist. Please specify a valid directory using --runDir`, `The run directory "${baseRunDir}" does not exist. Please specify a valid directory using --runDir`,
); );
process.exit(1); process.exit(1);
} }
const runDir = path.join(baseRunDir, n8nSetupToUse);
fs.emptyDirSync(runDir);
const dockerComposeClient = new DockerComposeClient({ const dockerComposeClient = new DockerComposeClient({
$: $({ $: $({
cwd: composeFilePath, cwd: composeFilePath,
@ -42,7 +45,7 @@ async function main() {
}); });
try { try {
await dockerComposeClient.$('up', '-d', 'n8n'); await dockerComposeClient.$('up', '-d', '--remove-orphans', 'n8n');
await dockerComposeClient.$('run', 'benchmark', 'run', `--scenarioNamePrefix=${n8nSetupToUse}`); await dockerComposeClient.$('run', 'benchmark', 'run', `--scenarioNamePrefix=${n8nSetupToUse}`);
} catch (error) { } catch (error) {