Skip to content

Commit

Permalink
Merge pull request #2717 from artilleryio/hassy-art-1808-enospc-error…
Browse files Browse the repository at this point in the history
…s-on-fargate

fix: write Playwright traces to a unique directory
  • Loading branch information
hassy committed May 9, 2024
2 parents c0a74fe + 35096e8 commit 99513b7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
4 changes: 3 additions & 1 deletion packages/artillery-engine-playwright/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/artillery/lib/cmds/run-fargate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions packages/artillery/lib/cmds/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 19 additions & 12 deletions packages/artillery/lib/platform/cloud/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
Expand Down

0 comments on commit 99513b7

Please sign in to comment.