Skip to content

Commit

Permalink
add sleep before tearing down the browser page to guarantee transacti…
Browse files Browse the repository at this point in the history
…ons are uploaded to apm
  • Loading branch information
Cavit Baturalp Gurdin committed Apr 12, 2022
1 parent 485f2d1 commit 091e840
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion x-pack/test/performance/services/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ apm.start({
secretToken: 'CTs9y3cvcfq13bQqsB',
});

export const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));

export interface StepCtx {
page: Page;
kibanaUrl: string;
Expand Down Expand Up @@ -105,7 +107,7 @@ export class PerformanceTestingService extends FtrService {
}
return await this.withSpan('browser creation', 'setup', async () => {
const headless = !!(process.env.TEST_BROWSER_HEADLESS || process.env.CI);
this.browser = await playwright.chromium.launch({ headless, timeout: 60000 });
this.browser = await playwright.chromium.launch({ headless: false, timeout: 60000 });
return this.browser;
});
}
Expand Down Expand Up @@ -166,6 +168,7 @@ export class PerformanceTestingService extends FtrService {

private async tearDown(page: Page, client: CDPSession, context: BrowserContext) {
if (page) {
await sleep(5000);
apm.flush();
await client.detach();
await page.close();
Expand Down

0 comments on commit 091e840

Please sign in to comment.