Skip to content

Commit

Permalink
refactor: revert pw engine and set sleep in otel
Browse files Browse the repository at this point in the history
  • Loading branch information
InesNi committed Jan 23, 2024
1 parent b2a6b37 commit e57a380
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
29 changes: 26 additions & 3 deletions packages/artillery-engine-playwright/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class PlaywrightEngine {
typeof script.config.engines.playwright.showAllPageMetrics !==
'undefined';

this.useSeparateBrowserPerVU =
typeof script.config.engines.playwright.useSeparateBrowserPerVU === 'boolean' ?
script.config.engines.playwright.useSeparateBrowserPerVU : false;

return this;
}

Expand Down Expand Up @@ -64,8 +68,18 @@ class PlaywrightEngine {

const contextOptions = self.contextOptions || {};

const browser = await chromium.launch(launchOptions);
debug('browser created');
let browser;
if (self.useSeparateBrowserPerVU) {
browser = await chromium.launch(launchOptions);
debug('new browser created');
} else {
if (!global.artillery.__browser) {
global.artillery.__browser = await chromium.launch(launchOptions);
debug('shared browser created');
}
browser = global.artillery.__browser;
}

const context = await browser.newContext(contextOptions);

context.setDefaultNavigationTimeout(self.defaultNavigationTimeout);
Expand Down Expand Up @@ -96,7 +110,13 @@ class PlaywrightEngine {

debug('page created');

page.on('response', (response) => {
const status = response.status();
events.emit('counter', 'browser.page.codes.' + status, 1);
});

page.on('domcontentloaded', async (page) => {

if (!self.extendedMetrics) {
return;
}
Expand Down Expand Up @@ -226,7 +246,10 @@ class PlaywrightEngine {
}
} finally {
await context.close();
await browser.close();

if (self.useSeparateBrowserPerVU) {
await browser.close(); // TODO: check if need to remove browser from global object/set to false
}
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class OTelTraceBase {
debug('Waiting for pending traces ...');
await new Promise((resolve) => setTimeout(resolve, 500));
}
await new Promise((resolve) => setTimeout(resolve, 10000));
debug('Pending traces done');
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,10 @@ async function ensureTaskExists(context) {
{
name: 'DD_SITE',
value: 'datadoghq.com'
},
{
name: 'DD_LOG_LEVEL',
value: 'WARN'
}
],
logConfiguration: {
Expand Down

0 comments on commit e57a380

Please sign in to comment.