diff --git a/packages/artillery-engine-playwright/index.js b/packages/artillery-engine-playwright/index.js index 6b57348cca..a9bd135eae 100644 --- a/packages/artillery-engine-playwright/index.js +++ b/packages/artillery-engine-playwright/index.js @@ -69,7 +69,9 @@ class PlaywrightEngine { 1000 * 60 * (Math.ceil(Math.random() * 5) + 5); this.tracePaths = []; - this.traceOutputDir = process.env.PLAYWRIGHT_TRACING_OUTPUT_DIR || '/tmp'; + this.traceOutputDir = + process.env.PLAYWRIGHT_TRACING_OUTPUT_DIR || + `/tmp/${global.artillery.testRunId}`; return this; } diff --git a/packages/artillery/lib/cmds/run-fargate.js b/packages/artillery/lib/cmds/run-fargate.js index 1e1d52590c..ab40f601e2 100644 --- a/packages/artillery/lib/cmds/run-fargate.js +++ b/packages/artillery/lib/cmds/run-fargate.js @@ -11,6 +11,7 @@ const { supportedRegions } = require('../platform/aws-ecs/legacy/util'); const PlatformECS = require('../platform/aws-ecs/ecs'); const { ECS_WORKER_ROLE_NAME } = require('../platform/aws/constants'); const { Plugin: CloudPlugin } = require('../platform/cloud/cloud'); +const generateId = require('../util/generate-id'); const dotenv = require('dotenv'); const path = require('path'); const fs = require('fs'); @@ -35,6 +36,9 @@ class RunCommand extends Command { dotenv.config({ path: dotEnvPath }); } + const testRunId = process.env.ARTILLERY_TEST_RUN_ID || generateId('t'); + global.artillery.testRunId = testRunId; + const cloud = new CloudPlugin(null, null, { flags }); if (cloud.enabled) { try { diff --git a/packages/artillery/lib/cmds/run.js b/packages/artillery/lib/cmds/run.js index a2057343ca..d18cb16d0f 100644 --- a/packages/artillery/lib/cmds/run.js +++ b/packages/artillery/lib/cmds/run.js @@ -140,6 +140,10 @@ RunCommand.runCommandImplementation = async function (flags, argv, args) { checkDirExists(flags.output); } + const testRunId = process.env.ARTILLERY_TEST_RUN_ID || generateId('t'); + console.log('Test run id:', testRunId); + global.artillery.testRunId = testRunId; + try { cloud = new CloudPlugin(null, null, { flags }); global.artillery.cloudEnabled = cloud.enabled; @@ -172,10 +176,6 @@ RunCommand.runCommandImplementation = async function (flags, argv, args) { } } - const testRunId = process.env.ARTILLERY_TEST_RUN_ID || generateId('t'); - console.log('Test run id:', testRunId); - global.artillery.testRunId = testRunId; - const script = await prepareTestExecutionPlan(inputFiles, flags, args); var runnerOpts = { diff --git a/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js b/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js index b70f139d22..f44cf19fb1 100644 --- a/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js +++ b/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js @@ -289,9 +289,7 @@ async function tryRunCluster(scriptPath, options, artilleryReporter) { context.extraSecrets = options.secret || []; - const testRunId = process.env.ARTILLERY_TEST_RUN_ID || generateId('t'); - context.testId = testRunId; - global.artillery.testRunId = testRunId; + context.testId = global.artillery.testRunId; if (context.namedTest) { context.s3Prefix = options.bundle; diff --git a/packages/artillery/lib/platform/cloud/cloud.js b/packages/artillery/lib/platform/cloud/cloud.js index 5ac13e8fa8..f1250a0ab2 100644 --- a/packages/artillery/lib/platform/cloud/cloud.js +++ b/packages/artillery/lib/platform/cloud/cloud.js @@ -236,22 +236,29 @@ class ArtilleryCloudPlugin { email: body.email }; - const watcher = chokidar.watch( - process.env.PLAYWRIGHT_TRACING_OUTPUT_DIR || '/tmp', - { - ignored: /(^|[\/\\])\../, // ignore dotfiles - persistent: true, - ignorePermissionErrors: true, - ignoreInitial: true + const outputDir = + process.env.PLAYWRIGHT_TRACING_OUTPUT_DIR || + `/tmp/${global.artillery.testRunId}/`; + + try { + fs.mkdirSync(outputDir, { recursive: true }); + } catch (_err) {} + + const watcher = chokidar.watch(outputDir, { + ignored: /(^|[\/\\])\../, // ignore dotfiles + persistent: true, + ignorePermissionErrors: true, + ignoreInitial: true, + awaitWriteFinish: { + stabilityThreshold: 2000, + pollInterval: 500 } - ); + }); watcher.on('add', (fp) => { if (path.basename(fp).startsWith('trace-') && fp.endsWith('.zip')) { - setTimeout(() => { - this.uploading++; - this._uploadAsset(fp); - }, 5 * 1000); + this.uploading++; + this._uploadAsset(fp); } }); }