Repository navigation
Match selected tests by exact file name in the flaky and targeted stateless checks - #122059
alexey-milovidov merged 3 commits into
Conversation
`Targeting.get_changed_tests()` appended a bare `.` to a test's base name, commented "precisely match this test only", and that value became a positional argument of `clickhouse-test`. Those arguments are regexes and `TestSuite.get_selected_tests` searches them against the suite file name including its extension, so the unescaped, unanchored `.` also matched `<name>_<anything>`: every test whose name is a prefix of a sibling's dragged its siblings into the job. A flaky check then spent its 50 repetitions, its `--jobs nproc-1` workers and its `--max-failures 5` budget on tests the pull request never touched, and could report the PR red for one of them (`03711_top_k_by_skip_index_handle_ties`, killed at 600 s on ClickHouse#117968, which had changed only `03711_top_k_by_skip_index.sql`). Over the suite, 320 of 15,646 base names selected more than one test, worst case 22. The conversion to an exact-filename selector happens at the one boundary where the value becomes a `clickhouse-test` argv word, not in the producers, because `get_changed_tests()`'s output is also consumed as a *name*: the targeted AST fuzzer's `Path(test).stem` lookup would miss every changed query, and the coverage dedup key and selection manifest would record one test twice. One site also covers the targeted check's previously-failed and coverage arms. `run_tests` hands one bash command string to `Shell.run`, so the selectors are `shlex.quote`d there. That half is load-bearing, not decoration: bash quote removal deletes the backslash of an unquoted word, so escaping alone produces a pattern byte-identical to the old one at the point of use. With the anchored form the two halves are welded, since `(` and `)` make an unquoted join a bash syntax error rather than a silent reversion. The extension alternation is built from `_TEST_FILE_EXTENSIONS` instead of spelling `.sql`, which would select nothing for `.sh`, `.sql.j2`, `.py` and `.expect` tests, and `$` keeps `.sql` from shadowing `.sql.j2`. Measured over the whole suite: 320 over-selecting names become 0, no name selects 0 (a selector matching nothing makes the job exit 1), and all five extensions still select their own test. A hand-written `--test` keeps loose matching. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding; bounded: 1 full pass
Both load-bearing measurements were re-run cold rather than trusted: the new selector selects Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20260924-171100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260924-164100 |
|
Workflow [PR], commit [c704a20] Summary: ✅ AI ReviewSummaryThis PR fixes the stateless flaky and targeted selectors by turning Findings
Final VerdictChanges requested. The regex fix itself looks correct, but the new tests are still weaker than the user-visible contract because they do not cover the production path that makes LLVM Coverage Report |
|
@groeneai, fix conflicts. |
…est-selector Master reverted ClickHouse#118223 in ClickHouse#122110, and this branch was built on top of it: - ci/jobs/scripts/test_selection_smoke.py: deleted on master, modified here. Take the deletion. The two selector checks that were added to it go with the file; nothing on master runs a unit suite for find_tests.py. - ci/jobs/scripts/find_tests.py: merged cleanly as text, but selection_pattern called selection_test_name, which the revert removed. The name is now normalized in selection_pattern itself: normalize_stateless_test_name for the .gen / .gen.sql report names, then the trailing dot, then one file extension, because per-test coverage names a test by its case file name (00001_x.sql). Re-validated on the merged tree: every one of the 15,747 stateless test sources is selected alone by its selector, from every name shape a producer emits (X., X, X.gen, X.gen.sql, X<ext>), through the real run_tests command line, bash, and the tests/clickhouse-test matcher. Without the extension strip all 15,558 coverage-shaped names would select nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@groeneai, one more time, please. |
…est-selector Master re-landed ClickHouse#118223 (74c90e9, ClickHouse#122111), which restores Targeting.selection_test_name and ci/jobs/scripts/test_selection_smoke.py and drops DIRECT_CALL_MAX_DEPTH: - ci/jobs/scripts/find_tests.py: selection_pattern builds on selection_test_name again, as before the revert, instead of repeating its normalization. DIRECT_CALL_MAX_DEPTH stays removed. - ci/jobs/scripts/test_selection_smoke.py: the two selector checks are back. The targeted job runs this suite when find_tests.py changes. Re-validated on the merged tree: the smoke suite passes 16/16 and each selector check fails under its mutation; every one of the 15,806 stateless test sources is selected alone by its selector from every name shape a producer emits, through the real run_tests command line, bash and the tests/clickhouse-test matcher. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| # A selection made by `Targeting` names whole tests, so it becomes an exact | ||
| # selector. A hand-written `--test` stays the free-form regex it was typed as. | ||
| if tests and not args.test: | ||
| tests = [Targeting.selection_pattern(test) for test in tests] |
There was a problem hiding this comment.
The exact-selection contract now depends on this rebinding, but the new smoke coverage never reaches it: test_selection_smoke.py only exercises Targeting.selection_pattern / selection_args directly, and Targeting.SELECTION_SOURCES still omits ci/jobs/functional_tests.py.
That leaves the regression evidence weaker than the behavior this PR is claiming here. If a later edit drops this conversion, sibling over-selection comes back silently while the new smoke suite stays green. Please factor the "Targeting-produced vs hand-written --test selectors" decision into a small pure helper and cover that helper, or add a harness that actually executes this branch.
Could you explain why you decided not to select tests based on coverage? |
|
I did not drop coverage selection. The old title read that way, so I changed it to "Match selected tests by exact file name in the flaky and targeted stateless checks". Which tests are selected is unchanged: the flaky check runs only the changed tests, as on master (functional_tests.py#L869-L873), and the targeted selection is still the union of changed, previously failed and coverage tests (find_tests.py#L884-L906). The PR changes only how each selected name is passed to Coverage hits had the same problem. |
Related: #117968
Related: #121387
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
A failing job this fixes:
Stateless tests (amd_debug, flaky check). #117968 changed03711_top_k_by_skip_index.sql; the job also repeated_dynamic,_handle_tiesand_negative, and went red on_handle_tiesat 600 s.Root cause.
Targeting.get_changed_tests()appends a bare.to a test's base name ("precisely match this test only") and hands it toclickhouse-testas a positional argument. Those are regexes, searched against the suite file name including the extension (TestSuite.get_selected_tests), so the unescaped, unanchored.also matches<name>_<anything>and a test whose name is a prefix of a sibling's drags its siblings in. Over the suite, 320 of 15,806 test names select more than one test, worst case 22.Fix. The selector becomes an exact-filename regex at the one boundary where it becomes an argv word, so the producers keep emitting names:
^<escaped name>(?:\.sql\.j2|\.sql|\.sh|\.py|\.expect)$, extensions from_TEST_FILE_EXTENSIONS. Not inget_changed_tests: that value is also consumed as a name (the AST fuzzer'sPath(test).stem, the coverage dedup key, the manifest), which a regex breaks.run_testsbuilds one bash command string, so selectors areshlex.quoted; without that, quote removal deletes the escape and the pattern arrives unchanged.Validation. Measured end to end, through bash into the real
clickhouse-testmatcher: for #117968's input the job selects 4 tests before, 1 after. Over the suite the 320 becomes 0: every test is selected alone from each name shape a producer emits (X.,X,X.gen, coverage'sX.sql), across all five extensions, and none selects 0 (that makes the job exit 1). Dropping the quoting is a bash syntax error rather than a silent reversion, since(is a metacharacter. Twotest_selection_smoke.pymethods, each with a negative control.A hand-written
clickhouse-test <regex>keeps loose matching: only aTargetingselection is converted. #121387 fixes the other half of this false red, the 600 s kill of alongtest.Workflow [PR]
Sync PR [sync-upstream/pr/122059]
Version info
26.10.1.850-master(included in26.10and later)