feat(benchmark): New options for n8n benchmark (#10741)

This commit is contained in:
Tomi Turtiainen
2024-09-10 09:25:41 +03:00
committed by GitHub
parent 96db501a61
commit d81f21d08e
14 changed files with 165 additions and 117 deletions

View File

@@ -6,6 +6,7 @@
import path from 'path';
import { $, argv, fs } from 'zx';
import { DockerComposeClient } from './clients/dockerComposeClient.mjs';
import { flagsObjectToCliArgs } from './utils/flags.mjs';
const paths = {
n8nSetupsDir: path.join(__dirname, 'n8nSetups'),
@@ -27,6 +28,8 @@ async function main() {
const n8nLicenseCert = argv.n8nLicenseCert || process.env.N8N_LICENSE_CERT || undefined;
const n8nLicenseActivationKey = process.env.N8N_LICENSE_ACTIVATION_KEY || '';
const n8nLicenseTenantId = argv.n8nLicenseTenantId || process.env.N8N_LICENSE_TENANT_ID || '';
const vus = argv.vus;
const duration = argv.duration;
if (!fs.existsSync(baseRunDir)) {
console.error(
@@ -66,7 +69,21 @@ async function main() {
try {
await dockerComposeClient.$('up', '-d', '--remove-orphans', 'n8n');
await dockerComposeClient.$('run', 'benchmark', 'run', `--scenarioNamePrefix=${n8nSetupToUse}`);
const tags = Object.entries({
N8nVersion: n8nTag,
N8nSetup: n8nSetupToUse,
})
.map(([key, value]) => `${key}=${value}`)
.join(',');
const cliArgs = flagsObjectToCliArgs({
scenarioNamePrefix: n8nSetupToUse,
vus,
duration,
tags,
});
await dockerComposeClient.$('run', 'benchmark', 'run', ...cliArgs);
} catch (error) {
console.error('An error occurred while running the benchmarks:');
console.error(error.message);