Skip to content

Commit

Permalink
feat: add indiscriminate logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hassy committed Mar 29, 2024
1 parent faca110 commit 91743d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions packages/artillery-engine-playwright/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class PlaywrightEngine {
this.enablePlaywrightTracing = this.config.trace !== false;
}

console.log('🌀 enablePlaywrightTracing', this.enablePlaywrightTracing);
console.log(this.config.trace);

// We use this to make sure only one VU is recording at one time:
this.playwrightRecordTraceForNextVU = this.enablePlaywrightTracing;

Expand Down Expand Up @@ -142,6 +145,7 @@ class PlaywrightEngine {
if (self.playwrightRecordTraceForNextVU) {
self.playwrightRecordTraceForNextVU = false;
initialContext.vars.isRecording = true; // used by the VU to discard the trace if needed
console.log('🌀 trace start');
await context.tracing.start({ screenshots: true, snapshots: true });
}

Expand Down Expand Up @@ -355,6 +359,7 @@ class PlaywrightEngine {
initialContext.vars.$testId
}-${initialContext.vars.$uuid}-${Date.now()}.zip`;
await context.tracing.stop({ path: tracePath });
console.log('🌀 trace saved:', tracePath);
self.lastTraceRecordedTime = Date.now();
self.tracesRecordedCount++;
self.tracePaths.push(tracePath);
Expand Down
24 changes: 18 additions & 6 deletions packages/artillery/lib/platform/cloud/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ class ArtilleryCloudPlugin {
typeof process.env.ARTILLERY_CLOUD_API_KEY !== 'undefined';

if (!isInteractiveUse && !enabledInCloudWorker) {
console.log('⛅ cloud plugin not enabled');
console.log(
process.env.WORKER_ID,
process.env.ARTILLERY_CLOUD_API_KEY?.slice(0, 5),
flags.record
);
return this;
}

this.enabled = true;

console.log('⛅ cloud plugin enabled');

this.apiKey = flags.key || process.env.ARTILLERY_CLOUD_API_KEY;

this.baseUrl =
Expand Down Expand Up @@ -247,6 +255,7 @@ class ArtilleryCloudPlugin {
);

watcher.on('add', (fp) => {
console.log('⛅ new file:', fp);
if (path.basename(fp).startsWith('trace-') && fp.endsWith('.zip')) {
this._uploadAsset(fp);
}
Expand All @@ -261,7 +270,8 @@ class ArtilleryCloudPlugin {
filenames: [path.basename(localFilename)]
};

debug(payload);
console.log('⛅ payload');
console.log(payload);

let url;
try {
Expand All @@ -272,11 +282,13 @@ class ArtilleryCloudPlugin {
});

const body = JSON.parse(res.body);
debug(body);
console.log('⛅ body');
console.log(body);

url = body.urls[path.basename(localFilename)];
} catch (err) {
debug(err);
console.log('⛅ err');
console.log(err);
}

if (!url) {
Expand All @@ -289,15 +301,15 @@ class ArtilleryCloudPlugin {
body: fileStream
});
} catch (error) {
console.error('Failed to upload Playwright trace recording:', error);
console.error('Failed to upload Playwright trace recording:', error);
console.log(error.code, error.name, error.message, error.stack);
} finally {
this.uploading--;
artillery.globalEvents.emit('counter', 'browser.traces.uploaded', 1);
try {
fs.unlinkSync(localFilename);
} catch (err) {
debug(err);
console.log('⛅ err2');
console.log(err);
}
}
}
Expand Down

0 comments on commit 91743d9

Please sign in to comment.