[pageObjects/visalize/waitForRenderingCount] wait for rendering count to be >= (#29366)

We've seen a number of flaky test failures where the tests are waiting for the rendering count to be `11` but it is `12` for some reason (which is probably totally fine). This is causing tests to regularly fail when they probably shouldn't, so I've updated the `PageObjects.visualize.waitForRenderingCount()` to accept a `minimumCount` instead of an exact count that is expected. I've also updated the function to use `retry.waitFor()` for slightly better logging.

```
[00:01:13]               │ debg Waiting up to 20000ms for rendering count to be greater than or equal to [3]...
[00:01:13]               │ debg TestSubjects.find(visualizationLoader)
[00:01:13]               │ debg findByCssSelector [data-test-subj~="visualizationLoader"]
[00:01:13]               │ debg -- currentRenderingCount=2
[00:01:13]               │ debg TestSubjects.find(visualizationLoader)
[00:01:13]               │ debg findByCssSelector [data-test-subj~="visualizationLoader"]
[00:01:13]               │ debg -- currentRenderingCount=3
```
This commit is contained in:
Spencer 2019-01-25 13:56:52 -08:00 committed by GitHub
parent 7cd0d0faa4
commit 343ce0ff31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -566,7 +566,7 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
const prevRenderingCount = await this.getVisualizationRenderingCount();
log.debug(`Before Rendering count ${prevRenderingCount}`);
await testSubjects.clickWhenNotDisabled('visualizeEditorRenderButton');
await this.waitForRenderingCount(prevRenderingCount);
await this.waitForRenderingCount(prevRenderingCount + 1);
}
async clickReset() {
@ -931,22 +931,26 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
return Number(renderingCount);
}
async waitForRenderingCount(previousCount = 0, increment = 1) {
await retry.try(async () => {
async waitForRenderingCount(minimumCount = 1) {
await retry.waitFor(`rendering count to be greater than or equal to [${minimumCount}]`, async () => {
const currentRenderingCount = await this.getVisualizationRenderingCount();
log.debug(`Readed rendering count ${previousCount} ${currentRenderingCount}`);
expect(currentRenderingCount).to.be(previousCount + increment);
log.debug(`-- currentRenderingCount=${currentRenderingCount}`);
return currentRenderingCount >= minimumCount;
});
}
async waitForVisualizationRenderingStabilized() {
//assuming rendering is done when data-rendering-count is constant within 1000 ms
await retry.try(async () => {
const previousCount = await this.getVisualizationRenderingCount();
await retry.waitFor('rendering count to stabilize', async () => {
const firstCount = await this.getVisualizationRenderingCount();
log.debug(`-- firstCount=${firstCount}`);
await PageObjects.common.sleep(1000);
const currentCount = await this.getVisualizationRenderingCount();
log.debug(`Readed rendering count ${previousCount} ${currentCount}`);
expect(currentCount).to.be(previousCount);
const secondCount = await this.getVisualizationRenderingCount();
log.debug(`-- secondCount=${secondCount}`);
return firstCount === secondCount;
});
}