Repository navigation
ci(tests): Let filtered pytest-selected runs opt into the per-file plan - #133153
Merged
Merged
Conversation
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
joshuarli
approved these changes
Dec 2, 2026
This was referenced Dec 2, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Snuba's CI runs Sentry's tests filtered with
-m 'snuba_ci or snuba'(or-m snuba_ci) and-k 'not __In'. When-m/-kis present,pytest-selected.pyskips the per-file plan, so every shard, and every xdist worker in it, collects the whole Sentry suite before keeping its hash share. In Snuba's API-change runs that collection takes about 6–7 minutes of every shard, and adding shards doesn't shrink it.The fallback exists because a filter can leave some shards with no selected tests. This adds an opt-in,
PYTEST_SELECTED_FILTERED_PLAN=1, for callers that accept that:plan_full_shardsplan as unfiltered ones. Every candidate file still goes to a shard, including files missing from the durations, so no file is dropped. Pytest then applies-m/-kto the files it collects, so marker inheritance, parametrization, and hook-added markers behave as before.Snuba turns this on in getsentry/snuba#8772.
Known limit: balancing still uses the full backend durations, so a filtered run's selected tests can spread unevenly across shards. Snuba-specific weights are a follow-up only if the measured slowest shard shows it.
via @joshuarli.
--
View Session [Sentry]