From 673b22258da45c66997120f36525012911ebd9d4 Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:12:09 +0300 Subject: [PATCH 1/3] feat(benchmark): Add n8n with postgres setup (no-changelog) --- .../n8nSetups/postgres/docker-compose.yml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/@n8n/benchmark/scripts/n8nSetups/postgres/docker-compose.yml diff --git a/packages/@n8n/benchmark/scripts/n8nSetups/postgres/docker-compose.yml b/packages/@n8n/benchmark/scripts/n8nSetups/postgres/docker-compose.yml new file mode 100644 index 0000000000000..7e9c48e01b3a3 --- /dev/null +++ b/packages/@n8n/benchmark/scripts/n8nSetups/postgres/docker-compose.yml @@ -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} From bb0250a313ce660f1338273b186f81c3755e3356 Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:17:07 +0300 Subject: [PATCH 2/3] fix: Create separate dir for every n8n setup To ensure they don't conflict with each others --- packages/@n8n/benchmark/scripts/runForN8nSetup.mjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/@n8n/benchmark/scripts/runForN8nSetup.mjs b/packages/@n8n/benchmark/scripts/runForN8nSetup.mjs index 1bd31a1b5e2f9..77cdf0df295c9 100755 --- a/packages/@n8n/benchmark/scripts/runForN8nSetup.mjs +++ b/packages/@n8n/benchmark/scripts/runForN8nSetup.mjs @@ -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, From f18d0b918a534c62d0cae7edeab68d1278b7dbfd Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:21:05 +0300 Subject: [PATCH 3/3] fix: Use --remove-orphans to suppress docker compose warning --- packages/@n8n/benchmark/scripts/runForN8nSetup.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@n8n/benchmark/scripts/runForN8nSetup.mjs b/packages/@n8n/benchmark/scripts/runForN8nSetup.mjs index 77cdf0df295c9..c7f1e88904880 100755 --- a/packages/@n8n/benchmark/scripts/runForN8nSetup.mjs +++ b/packages/@n8n/benchmark/scripts/runForN8nSetup.mjs @@ -45,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) {