This document codifies the best practice for interacting with test flakes on Fuchsia.
A flaky test is a test that sometimes passes and sometimes fails, when run using the exact same revision of the code.
Flaky tests are bad because they:
This document is specific to test flakes, not infrastructure flakes.
The process for identifying and fixing flake is intentionally decoupled from between two parties:
Observer: An individual who has witnessed flake on bots.
Resolver: An individual who has the ability to remove flake from the bots.
This separation satisfies requirement (3): if someone contributes to Fuchsia, it is their responsibility to act as an observer for the entire codebase, and their responsibility to act as a resolver for code they touch.
We recommend the following four-step process for dealing with flakes:
Flake can appear in many locations: CQ dry-runs, an actual CQ run, or in the roller into global integration. In any of these cases, flake can be identified as a test that sometimes passes and sometimes fails, with the same revision of the codebase. When a test is identified this way, a log should be captured, providing context and revealing which subtest failed.
(Googlers-Only) File a bug under go/test-flake: Link to the failing bot, and include the name of the failing test.
A resolver should prioritize, above all else, disabling the test from the commit queue. This can be achieved in a number of recommended ways:
These mechanisms are recommended: They remove the faulty test, and prevent the commit queue becoming unreliable. The first option (reverting code) is preferred, but it is not as easy as the second option (disabling test), which reduces test coverage. Importantly, neither of these options prevent diagnosis and fixing of the flake, but they allow it to be processed offline.
There is a third alternative to disable tests, but it is explicitly not recommended:
This alternative is not recommended, because it combines the steps of “disable the test” with “fixing the test offline”. Although this is the most straight-line path for removing flake, it has a serious cost: it causes the CQ to be unreliable for all other contributors, which allows additional flakes to compound in the codebase.
At this point, the resolver can take the bug filed by the observer, locally re-enable the test, and work on reproducing the failure. This will enable them to find the root cause, and fix the issue. Once the issue has been fixed, the bug can be closed, and the test can be re-enabled. If any reverted patches need to re-land, they can re-land safely.
Ongoing efforts to improve tooling surrounding flake are currently in progress.
When these improvments are available, this document will update to include the adjusted policy.