fix: Fixes to cloud benchmarks (no-changelog) (#10634)

This commit is contained in:
Tomi Turtiainen
2024-09-02 14:58:24 +03:00
committed by GitHub
parent 56354151d4
commit afc4d4e144
19 changed files with 272 additions and 45 deletions

View File

@@ -16,6 +16,7 @@ async function main() {
validateN8nSetup(n8nSetupToUse);
const composeFilePath = path.join(paths.n8nSetupsDir, n8nSetupToUse);
const setupScriptPath = path.join(paths.n8nSetupsDir, n8nSetupToUse, 'setup.mjs');
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;
@@ -30,9 +31,13 @@ async function main() {
const runDir = path.join(baseRunDir, n8nSetupToUse);
fs.emptyDirSync(runDir);
// Make sure the n8n container user (node) has write permissions to the run directory
await $`chmod 777 ${runDir}`;
if (!process.getuid) {
console.error('Windows is not supported');
process.exit(1);
}
const currentUserId = process.getuid();
const dockerComposeClient = new DockerComposeClient({
$: $({
cwd: composeFilePath,
@@ -42,10 +47,17 @@ async function main() {
BENCHMARK_VERSION: benchmarkTag,
K6_API_TOKEN: k6ApiToken,
RUN_DIR: runDir,
RUN_USER_AND_GROUP: `${currentUserId}:${currentUserId}`,
},
}),
});
// Run the setup script if it exists
if (fs.existsSync(setupScriptPath)) {
const setupScript = await import(setupScriptPath);
await setupScript.setup({ runDir });
}
try {
await dockerComposeClient.$('up', '-d', '--remove-orphans', 'n8n');