Performance journeys: log how many visualisations were loaded / rendered out of expected count (#144422)

* [performance/utils] extend error message for waitForVisualizations

* revert test change

* remove new line

Co-authored-by: Liza Katz <liza.katz@elastic.co>
This commit is contained in:
Dzmitry Lemechko 2022-11-03 10:30:14 +01:00 committed by GitHub
parent 4a44fd31bb
commit 6482b22d1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 19 deletions

View file

@ -11,8 +11,8 @@ import { waitForVisualizations } from '../utils';
export const journey = new Journey({
kbnArchives: ['test/functional/fixtures/kbn_archiver/stress_test'],
esArchives: ['test/functional/fixtures/es_archiver/stress_test'],
}).step('Go to dashboard', async ({ page, kbnUrl, kibanaServer }) => {
}).step('Go to dashboard', async ({ page, kbnUrl, kibanaServer, log }) => {
await kibanaServer.uiSettings.update({ 'histogram:maxBars': 100 });
await page.goto(kbnUrl.get(`/app/dashboards#/view/92b143a0-2e9c-11ed-b1b6-a504560b392c`));
await waitForVisualizations(page, 1);
await waitForVisualizations(page, log, 1);
});

View file

@ -19,7 +19,7 @@ export const journey = new Journey({
await page.waitForSelector('#dashboardListingHeading');
})
.step('Go to Ecommerce Dashboard', async ({ page }) => {
.step('Go to Ecommerce Dashboard', async ({ page, log }) => {
await page.click(subj('dashboardListingTitleLink-[eCommerce]-Revenue-Dashboard'));
await waitForVisualizations(page, 13);
await waitForVisualizations(page, log, 13);
});

View file

@ -19,7 +19,7 @@ export const journey = new Journey({
await page.waitForSelector('#dashboardListingHeading');
})
.step('Go to Flights Dashboard', async ({ page }) => {
.step('Go to Flights Dashboard', async ({ page, log }) => {
await page.click(subj('dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard'));
await waitForVisualizations(page, 14);
await waitForVisualizations(page, log, 14);
});

View file

@ -17,7 +17,6 @@ export const journey = new Journey({
})
.step('Go to Discover Page', async ({ page, kbnUrl }) => {
await page.goto(kbnUrl.get(`/app/discover`));
await waitForChrome(page);
await page.waitForSelector(subj('discoverDocTable'));
})

View file

@ -50,6 +50,6 @@ export const journey = new Journey({
await page.click(subj('superDatePickerCommonlyUsed_Last_30 days'));
})
.step('Wait for visualization animations to finish', async ({ page }) => {
await waitForVisualizations(page, 1);
.step('Wait for visualization animations to finish', async ({ page, log }) => {
await waitForVisualizations(page, log, 1);
});

View file

@ -19,7 +19,7 @@ export const journey = new Journey({
await page.waitForSelector('#dashboardListingHeading');
})
.step('Go to Web Logs Dashboard', async ({ page }) => {
.step('Go to Web Logs Dashboard', async ({ page, log }) => {
await page.click(subj('dashboardListingTitleLink-[Logs]-Web-Traffic'));
await waitForVisualizations(page, 11);
await waitForVisualizations(page, log, 11);
});

View file

@ -5,19 +5,28 @@
* 2.0.
*/
import { ToolingLog } from '@kbn/tooling-log';
import { Page } from 'playwright';
export async function waitForChrome(page: Page) {
return page.waitForSelector('.headerGlobalNav', { state: 'attached' });
}
export async function waitForVisualizations(page: Page, visCount: number) {
return await page.waitForFunction(function renderCompleted(cnt) {
const visualizations = Array.from(document.querySelectorAll('[data-rendering-count]'));
const visualizationElementsLoaded = visualizations.length === cnt;
const visualizationAnimationsFinished = visualizations.every(
(e) => e.getAttribute('data-render-complete') === 'true'
export async function waitForVisualizations(page: Page, log: ToolingLog, visCount: number) {
try {
await page.waitForFunction(function renderCompleted(cnt) {
const visualizations = Array.from(document.querySelectorAll('[data-rendering-count]'));
const allVisLoaded = visualizations.length === cnt;
return allVisLoaded
? visualizations.every((e) => e.getAttribute('data-render-complete') === 'true')
: false;
}, visCount);
} catch (err) {
const loadedVis = await page.$$('[data-rendering-count]');
const renderedVis = await page.$$('[data-rendering-count][data-render-complete="true"]');
log.error(
`'waitForVisualizations' failed: loaded - ${loadedVis.length}, rendered - ${renderedVis.length}, expected - ${visCount}`
);
return visualizationElementsLoaded && visualizationAnimationsFinished;
}, visCount);
throw err;
}
}