Skip to content

Commit

Permalink
feat: Add n8n postgres setup to benchmarks (no-changelog) (#10604)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomi authored Aug 30, 2024
1 parent 1dcb814 commit 4e899ea
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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}
11 changes: 7 additions & 4 deletions packages/@n8n/benchmark/scripts/runForN8nSetup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ async function main() {
const n8nTag = argv.n8nDockerTag || process.env.N8N_DOCKER_TAG || 'latest';
const benchmarkTag = argv.benchmarkDockerTag || process.env.BENCHMARK_DOCKER_TAG || 'latest';
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(
`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);
}

const runDir = path.join(baseRunDir, n8nSetupToUse);
fs.emptyDirSync(runDir);

const dockerComposeClient = new DockerComposeClient({
$: $({
cwd: composeFilePath,
Expand All @@ -42,7 +45,7 @@ async function main() {
});

try {
await dockerComposeClient.$('up', '-d', 'n8n');
await dockerComposeClient.$('up', '-d', '--remove-orphans', 'n8n');

await dockerComposeClient.$('run', 'benchmark', 'run', `--scenarioNamePrefix=${n8nSetupToUse}`);
} catch (error) {
Expand Down

0 comments on commit 4e899ea

Please sign in to comment.