Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor flaky tests #21

Open
MrGreenTea opened this issue Feb 2, 2024 · 10 comments
Open

Monitor flaky tests #21

MrGreenTea opened this issue Feb 2, 2024 · 10 comments
Labels
developer experience Improves the developer experience needs:goal This issue has no clear goal state defined tests Adds or updates the tests

Comments

@MrGreenTea
Copy link
Contributor

MrGreenTea commented Feb 2, 2024

With this port the playwright tests seem to have gotten somewhat flaky. We have added the retries: 3 config to playwright.config.ts to hide some of the flakiness. One goal of this issue would be to remove that config and make the tests stable again.

We should make sure to monitor this as flaky tests suck. See this action for example: https://github.com/WithSecureOpenSource/flaky-test-ci

@MrGreenTea
Copy link
Contributor Author

We could get a history starting by saving some JUnit reports from playwright in the CI.

MrGreenTea added a commit that referenced this issue Feb 8, 2024
Use the python package flaky-tests-detection to analyse all JUnit reports in the  directory.

note: This is just a bare-bones proof of concept for now.

See issue #21
@MrGreenTea
Copy link
Contributor Author

MrGreenTea commented Feb 8, 2024

On the branch is a small script to download all previous artifacts. It needs requests to be installed into your virtual environment.

python download_artifacts.py https://api.github.com/repos/YoungVision-eV/homepage-astro/actions/artifacts $GITHUB_TOKEN playwright-results ($BRANCH_NAME or ALL)

You have to generate a personal access token first and use it. The branch name is optional and defaults to main.

After that you can pip install flaky-tests-detection and run the flakiness-report.sh script to generate the top 5 flaky tests.

The script was copied and adapted from here: https://github.com/WithSecureOpenSource/flaky-test-ci/blob/main/download_artifacts.py

@MrGreenTea
Copy link
Contributor Author

Perhaps using another solution for visual comparisons helps? Options like percy and lost-pixel should be evaluated.

As I understand it percy for example does not create a screenshot but sends the whole DOM and so could be more stable as the visual comparison happens in their cloud.

MrGreenTea added a commit that referenced this issue Feb 10, 2024
Use the python package flaky-tests-detection to analyse all JUnit reports in the  directory.

note: This is just a bare-bones proof of concept for now.

See issue #21
@MrGreenTea MrGreenTea added tests Adds or updates the tests developer experience Improves the developer experience labels Feb 10, 2024
@MrGreenTea
Copy link
Contributor Author

I would like some kind of continous monitoring. There is no flakiness in the last 7 days apparently, but with a window of 14 days there is:

❯ flaky --junit-files=reports --grouping-option=days --window-size=1 --window-count=14 --top-n=5

Top 5 flaky tests based on latest window exponential weighted moving average fliprate score
index.spec.ts::index page screenshot --- score: 0.06917
about-us.spec.ts::About Us page screenshot --- score: 0.04001

@MrGreenTea
Copy link
Contributor Author

What's the goal of this issue? When can we close it?

@MrGreenTea
Copy link
Contributor Author

Current status with 14 day history and 3 day windows

> flaky --junit-files=reports --grouping-option=runs --window-size=3 --window-count=14 --top-n=5

No flaky tests.

@MrGreenTea
Copy link
Contributor Author

The "real" flakiness is pretty much masked by our usage of the retries option.

See this issue: microsoft/playwright#29446

@MrGreenTea MrGreenTea added the needs:goal This issue has no clear goal state defined label Mar 1, 2024
@MrGreenTea MrGreenTea reopened this Mar 15, 2024
@Han2-Ro
Copy link
Collaborator

Han2-Ro commented Mar 15, 2024

await page.getByRole('contentinfo').scrollIntoViewIfNeeded();

I think this line is an often cause for retries. Maybe using forceLoadImages instead could be a solution?

@MrGreenTea
Copy link
Contributor Author

await page.getByRole('contentinfo').scrollIntoViewIfNeeded();

I think this line is an often cause for retries. Maybe using forceLoadImages instead could be a solution?

That could be. When I look at the failures it seems that the found element isn't attached to the DOM (yet).
The forceLoadImages can have some issues as well because it uses Locator.all() which can cause some issues in rare cases.

@MrGreenTea
Copy link
Contributor Author

MrGreenTea added a commit that referenced this issue Jul 4, 2024
MrGreenTea added a commit that referenced this issue Jul 25, 2024
MrGreenTea added a commit that referenced this issue Jul 25, 2024
MrGreenTea added a commit that referenced this issue Jul 25, 2024
MrGreenTea added a commit that referenced this issue Aug 1, 2024
MrGreenTea added a commit that referenced this issue Aug 1, 2024
MrGreenTea added a commit that referenced this issue Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer experience Improves the developer experience needs:goal This issue has no clear goal state defined tests Adds or updates the tests
Projects
None yet
Development

No branches or pull requests

2 participants