Handle flaky tests and quarantine
A flaky event is a failed and a passed execution of the same job or test at the same revision: a retry that passed, or another run of the same commit. A unit with enough flaky events in the window (by default 2 within 30 days) becomes a candidate for quarantine.
People decide what is quarantined, in the repository’s setting
quarantine on Repository settings in Fistron. Fistron proposes
entries as a change of that setting; it waits under Proposed changes
until a manager confirms or rejects it, and nothing is written to the
repository. Today the quarantine is in shadow mode: nothing in your
pipeline changes, and the record states what the quarantine would have
done, including every failure it would have hidden.
Before you start
- A CI history of the project:
history-collectfor GitHub Actions, GitLab CI or Jenkins (Run and schedule work). - A quarantine record, computed from that history: measured from the page itself (below), or on a schedule every morning.
- To analyse or propose: the role Engineer in the project, not under an access grant.
- To confirm a proposal: the role Manager of the organisation (Set your repositories’ settings).
Measure the flaky tests
The Flaky tests page starts the measurement itself, so the step “Measure the flaky tests” of a solution’s checklist always has something to start:
- Open the project’s Flaky tests page. Without a quarantine record it shows Measure the flaky tests and lists the CI histories the project holds, one per job or repository whose history was collected, each with when.
- Leave ticked the ones to measure and click Measure the flaky tests now. The project’s agent reads each history and writes its quarantine record, and measures the same history to say of each test whether it is likely broken or likely flaky; each is a work you can follow from the list. A job whose history was kept under two spellings of its name is listed once, with its newest history.
- When they end, the page shows the candidates. Later, Measure again (the last tab) reads a newer history the same way.
When the project has no CI history yet, the page says so and leads to the first audit, which collects it for the jobs you choose.
Every day
Under the button, Every day sets the daily measurement in one click (the role Manager of the project, since it adds schedules):
- Leave ticked the jobs to measure every day.
- Enter the time of the day at Collect every day at, in your time zone, and click Measure every day.
For each ticked job Fistron adds two schedules: one collects the job’s CI history again, as it was collected first, with its window moved to the day; the other measures the newest history when the collection is done (half an hour later, or twice what the first collection took). A job whose history a schedule collects already keeps that schedule, and only the measurement is added. Half an hour after the measurement a third schedule looks for the open issues of the job’s flaky tests (below). The page then says of each job when it is collected, measured and its open issues searched. Change the time, pause or delete the schedules on the Schedules page (Run and schedule work).
A history that no work of the project collected (one you uploaded) cannot be collected again this way: the page says so, and you add its collection on the Schedules page first.
See the flaky tests
- Open the project’s Flaky tests page. It reads the newest quarantine record of each job (one per schedule), whatever the spelling of the job’s name. At the top the flaky tests at a glance: the candidates with a ring beside the tests likely broken and those quarantined, the flaky events week by week and the candidates with the most of them. Under it, its numbers in words: the flaky events of the candidates, of the tests likely broken and of the whole jobs, with what a flaky event is and the rule a test is listed by. The records it read are folded under From N records.
- In the candidates table, the most flaky test comes first:
- Test: the test by its feature and scenario (its class and name), the job it ran in below, and Fistron’s verdict: likely flaky, with a likelihood and its reason;
- Flaky events: how many in the window, and how often the test passed of its runs;
- Open issue: the open issue that names the test, once Fistron has looked (below);
- Newest: links to the run that failed and the one that passed, and whether the pass came from a retry or the same revision;
- Record: the record it comes from.
- Under Quarantined test, see each quarantined test’s State, Owner and Details.
Candidates an engineer said are not tests are not in the table; they are listed under Not tests (below). A whole job without a test report is listed apart (below), and so is a test likely broken (below).
Why the dashboard and the audit count more
The audits (and the dashboard’s Flaky tests widget under them) count every flaky event of every test and job in their history’s window, also of the tests with fewer events than the rule. This page lists a test only once it has enough events (by default 2 within 30 days), and leaves out the tests you dismissed. The dashboard says the candidates of the newest record of each repository with their rule, and the audits’ events with what they count; from it, the candidates among them opens this page with the audits’ number, which the page says next to its own.
For the jobs of a CI server, the page says that the revision is the job’s pipeline’s only: a nightly job tests a new product build in a newly deployed environment each run, so a test that failed and passed at the same revision did not run under the same conditions. Its verdict is less likely flaky for that, and says so.
| State | Means |
|---|---|
flaky |
flaky events in the window: the quarantine would have kept them from blocking |
failing |
failures without a pass at their revision: possibly real failures the quarantine would have hidden |
stable |
executed without flaky events or hidden failures |
exit_proposed |
enough passes without a failure: propose to end the quarantine |
absent |
not executed in the window: retired or renamed |
overdue |
past its review_by date |
unknown |
not executed in the window, but the history has gaps |
Analyse the newest failure
For a candidate on GitHub Actions:
- Click Analyze the newest failure in its row.
- The agent imports the failed job’s case (
case-import), then analyses it with the project’s reasoner (analyze). Follow the links to both works. - Open the report on the
analyzework’s page (use-analyze-failure.md).
For a candidate of Jenkins or GitLab, click Investigate the newest failure: Fistron finds the failed build’s link in the CI history and opens Investigate a failed build with it and the test (Investigate a failed build).
A repair of a test (its cause removed in the test itself) is for tests written in Python: a scenario or a test in another language says so in its row, and is fixed from Investigate a failed build with Fix it with Fistron once its cause is found.
A flaky test’s open issue
A test that fails once in a while often has an issue someone opened and no one works on. Fistron looks for it in the repositories the agent reads, on GitHub and on GitLab; a tracker outside them is not read.
- On the Candidates tab, click Find their open issues. The project’s agent searches the open issues and requests that name each test, or a scenario’s feature file, as a whole name.
- When it ends, the Open issue column shows the first: an issue that names the test before a request, with how long it has been open, who is assigned and the bugs it cites; the others are folded under it. A test with none says None found. Above the table, how many of the tests have one, when and in how many repositories it was searched.
- From an issue:
- Comment on it opens Investigate an issue with it: read it, investigate its job, and post the update it proposes, once you approve it (Investigate an issue).
- Quarantine the test with it opens Propose a quarantine for the test alone, with the issue as the issue that tracks its fix: enter the repository and the owner, Preview, then Propose.
Every day looks for them after each daily measurement.
A test likely broken, not flaky
A test that failed in half of its runs or more is broken, not flaky, even when it passed once at the same revision. The tab Likely broken lists such tests apart, each with its verdict, for example “likely broken, not flaky (89 %): failed 8 of 9 runs, passed once”, and its Runs. They are not counted as flaky candidates, as the audit and the dashboard do not count them, and Propose the quarantine leaves them out: investigate a broken test, do not quarantine it.
- Click Analyze the newest failure in its row to find its cause.
- Follow the link to Broken tests, the project’s register, which keeps each broken test with its cause and its state (Keep the register of broken tests).
The verdicts come from the project’s newest flaky measurements: the one the page starts with each measurement, and the one each audit makes.
A flaky job without a test report
Sometimes a whole job fails and then passes at the same revision, and no test report of it names a failed test, so Fistron cannot say which test failed: the job was often run again after an infrastructure failure, its setup failed, or its reports were not kept (an artifact that expired). Such jobs are listed under Flaky jobs without a test report, not with the tests, and are never proposed for quarantine: quarantining a whole job would hide every test in it.
- In the job’s row, click Why no test report?. Fistron reads the history the record was computed from and says why, for example “its test reports were not read: artifact cucumber_json_reports_2: expired”, “no artifact named like … for this job”, or “its test reports name no failed test: the job failed outside its tests”.
- Click Analyze the newest failure to have the agent find the cause of the failed run, often the infrastructure.
- When it is no test at all, or you do not want it listed, click Not a test and say why, as below.
Reports that expired are kept longer by the CI (GitHub: the artifacts’ retention); a history collected more often reads them before they expire.
A candidate that is not a test
Some candidates are checks of the pull or merge request rather than tests, for example a check that the description’s checkboxes are ticked: it fails, someone ticks the boxes, and it passes at the same commit. Quarantining it would hide what it checks. Say once that it is not a test:
- In the candidate’s row, click Not a test.
- In Why it is not a test, write the reason, for example “checks the request’s description”.
- Click Dismiss. When the work succeeds, the candidate leaves the table and is listed under Not tests with its reason, who dismissed it and when.
It stays dismissed in every later record: it is not shown, not counted in the page’s facts or the status report, and Propose the quarantine leaves it out (as it leaves out every whole job). The record keeps it as the core’s evidence. To bring it back, click Undo next to it under Not tests.
To decide against quarantining a real test, keep it as rejected in the setting instead (see below): that decision is kept with its reason.
Propose the quarantine
-
Under Propose the quarantine of
, enter: - Repository:
owner/nameorgroup/project, the repository of the tests. A CI server’s record names its job, not a repository, so the field offers none; - Owner of the entries, for example
@qa-team.
- Repository:
-
Click Preview. The agent runs a dry run and lists the entries it would propose. The tests likely broken are left out, and the card says which.
-
Click Propose. When it succeeds, the card says the proposal waits on Repository settings.
-
A manager opens Repository settings. Under Proposed changes each proposal shows the setting as proposed and as it is now:
Decision Means Confirm the entries are quarantined from then on: a new version of the setting Reject, with a Note nothing changes; the entries are proposed again next time To keep one entry out for good, confirm, then turn its
[[entry]]into[[rejected]]with a reason in the settingquarantine: it is not proposed again.
Every entry needs an owner, an issue where the fix is tracked, a
reason and a since date.
In the local UI, Proposals lists the same proposed changes (admin-local-ui.md).
Measure the time lost
The operation quarantine-measure computes, from the CI history alone, the
time from each flaky failure to its passing run and the CI minutes of the
failed executions, per job. With a record, it also says what the quarantine
would have saved.
Repair instead of quarantine
A repair of a flaky test, removing its cause, is proposed once the closed core has written it for the test. The Repairs page shows those (Repair tests that work badly).
Troubleshooting
| You see | Cause and fix |
|---|---|
| No flaky tests measured yet | The project has no CI history: start the first audit from the link on the page, then measure. |
| “No test is flaky enough to propose.” | No unit reaches the candidate rule (min_events within window_days). |
| “Not opened: its CI’s address is not in the history” | The history names no CI server: start Investigate a failed build with the build’s link yourself. |
| The page lists fewer flaky events than the dashboard or the audit | Expected: they count every test and job, also below the rule; see why. |
| “Nothing new to propose: every candidate has an entry.” | Every candidate is already quarantined, rejected or dismissed as not a test. |
| “Left out as not tests: …” on the proposal | Those candidates are dismissed under Not tests; Undo one to propose it. |
| The dismiss work fails | Open it: the reason is empty, or the dismissal was already undone. |
| The propose work fails | Open it: the record is not one the agent can read, or the repository is not owner/name. |
| Confirm says the setting does not read | The proposed setting breaks its format, often an entry that overlaps another: reject it and fix the setting on Repository settings. |
| “history incomplete” next to a record | No exit is proposed while the history has gaps; candidates are still listed. |
fistron quarantine check reports an error |
Entries must not overlap, and owner, issue, reason and since are required. |
Check a quarantine file yourself with fistron quarantine check <file>.
Details: quarantine.md, settings.md.