Quarantining
Last updated
Last updated
Quarantining lets you isolate failures for known flaky tests so they don't fail your CI jobs, while still continuing to run them. Quarantine looks for known flaky tests and determines which tests should be isolated at runtime, so you can avoid code changes usually required to disable flaky tests.
Quarantining flaky tests lets you mitigate the negative effects of flaky tests without disabling any tests. Quarantined failures will still be uploaded to Trunk Flaky Tests and displayed in PRs through a PR Test Summary, allowing you to easily triage failures and identify real issues surfaced by flaky tests.
When a test is quarantined, it will still be run in your CI jobs and results will be uploaded to Trunk Flaky Tests so you can keep track of them. What changes are the results of your CI jobs. The Flaky Tests Uploader will check if the test is a known flaky or broken test. If the test has been failing on other PRs before yours, the results will be overridden. This means, that if all failures in a CI job are overridden by quarantining because they're known flaky or broken tests, the CI job will be overridden as passing.
When quarantining is enabled, tests that are known to be flaky or broken will be quarantined. This means tests that have already been failing and not broken by your PR will be quarantined. You can see which tests are flaky or broken by seeing the tests's status in the overview dashboard, or each test's status history.
Tests that are overridden to always quarantine will also be quarantined, even if the test breaks for the first time. Learn more about overriding.
Enabling quarantining will drastically affect the results of CI jobs. Only new test failures introduced by your PR will fail CI jobs, known flaky and broken tests will no longer fail CI jobs. Learn more about the effects of quarantining
Before tests can be quarantined on a CI job, quarantining needs to be enabled for your Analytics Uploader.
With quarantining enabled, the Analytics Uploader will compare failed test cases against known flaky tests. If a test is known to be flaky or broken, it will be quarantined. If all failed tests are flaky then the exit code of the test command will be overridden to return 0 which means the CI job will pass.
You can enable quarantining by navigating to Settings > Repositories > Flaky Tests > Quarantine Flaky Tests and selecting enabled in the drop-down.
Here's what each of these options does when enabled:
Enable Test Quarantining
When enabled, tests will be quarantined if the necessary configurations are made in CI.
Auto-Quarantine
When enabled, flaky tests are automatically quarantined. When disabled, only flaky tests which are manually marked as flaky are quarantined.
Summary Test Reports
When enabled, PRs will generate a report covering test results, test health, and quarantining status. This will be accessible in the web app and as a GitHub comment. Learn more about PR Test Summaries
Public Dashboard Access
When enabled, unauthenticated users will get read-only access to your Flaky Tests dashboard, which is particularly useful for open-source projects.
If you're using the provided GitHub Actions workflow to upload test results to Trunk, you can quarantine flaky tests by wrapping the test command or quarantining as a follow-up step. You may need to update your workflow to make sure that the test step
If you're using the Trunk Analytics Uploader Action in your GitHub Actions Workflow files, you may need to modify your workflow files to support quarantining. If you're using the Trunk CLI directly or using other CI providers, check the instructions in the Using The Trunk CLI Directly tab.
If you upload your test results as a second step after you run your tests, you need to add continue-on-error: true
on your test step so your CI job will continue even on failures. Here's an example file.
If you want to run the test command and upload in a single step, the test command must be run via the Analytics Uploader through the run: <COMMAND TO RUN TESTS>
parameter. This will override the response code of the test command. Make sure to set continue-on-error: false
so unquarantined tests are blocking.
If you have tests that should never be quarantined or should always be quarantined regardless of their current health status, you can do this by overriding individual tests.
You can update the overriding settings on each test by navigating to the details page for a specific test and clicking the Quarantining (Repo Default) selector in the top left corner.
You can choose between one of three override settings:
Quarantine
Quarantine automatically if auto-quarantine is enabled. Learn more about quarantining modes
Always Quarantine
Quarantine a test failure even if the health status is healthy.
Never Quarantine
Never quarantine failures, even if the health status is flaky or broken, and quarantining is enabled for the repo.
Trunk provides audit logs for all setting changes and overwrites for individual tests. You can access the audit log by navigating to Settings > Repositories > Flaky Tests > Quarantine Flaky Tests > Audit logs.
You will also see a record of changes in the override settings in the Status History tab in each test's details screen.
Want to chat with Trunk's engineers? Join us and 1500+ fellow engineers on Slack.