Repository navigation
Correct nightly coverage selection and share PR test manifests - #118223
Conversation
Canonicalize coverage paths, fail selection on stale or incompatible snapshots, and replace broad admission with precise coverage evidence. Protect changed and previously failed tests under a unified ceiling. Persist one selection manifest per PR SHA, validate nightly shard exports, and report repeated execution. Keep entry-count scoring experiments and the expanded targeted matrix gated on historical evaluation. Durable CIDB run identity remains dependent on an external schema migration. Related: #117331
|
Workflow [PR], commit [21d9369] Summary: ✅ AI ReviewSummaryThis PR rewires stateless PR selection around precise coverage, per-job targeted runs, and a post-export nightly smoke. The direction is good, but I do not think the change is merge-ready yet: the targeted jobs can still be skipped from cache on reruns or some selector-only follow-ups, the new GitHub API calls are still unauthenticated inside Docker for Findings
Final VerdictNot ready to merge. The remaining issues are in the core contract this PR advertises: reruns are still bypassable through cache reuse, private-repo targeted jobs still lack GitHub API auth in Docker, and the new smoke/coverage validation still leaves real blind spots. LLVM Coverage ReportMeasured on commit 21d9369.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +148 lines in 39 files (-236 lines lost coverage) · Details |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline. |
Remove automatic harness smoke injection: CI script changes were adding six unrelated tests to the seven tests covering the `arrayCount` change. Bump the selector version to invalidate cached manifests. CI artifact replay now selects the seven coverage candidates.
Run parallel and sequential selected tests in one job per configuration. Retain the parallel runner when combining flavors and update PR dependencies. Store each selected test once in `stateless-selection.json`, with its reasons, score, and compact coverage evidence. Retain input identity and snapshots, and omit duplicated diagnostic data. Update consumers and the selector version.
Replace the single-run `selected tests` mode with `targeted` jobs in the four PR sanitizer configurations. Reuse the existing 50-run policy, including long and sequential tests, and keep one job per configuration. Targeted selection remains PR-only; master retains the full functional suite. Update workflow dependencies and exclude existing targeted configurations from the optional expanded matrix to avoid duplicate jobs.
Choose the canary seed dynamically and require coverage only for eligible source changes. Include surviving owners of deleted and renamed fixtures in mandatory selection. Scope manifests to workflow runs and attempts, carrying the current attempt into test containers. Reuse the producer in targeted jobs so failed-job-only reruns refresh previous failures and coverage snapshots. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118223&sha=0ede482faa71518a465eb8dcf427760d5b73018f&name_0=PR&name_1=Select%20functional%20tests #118223
| ) | ||
|
|
||
| # Randomized executions must remain independent even when the build is cached. | ||
| for job in functional_tests_jobs_coverage: |
There was a problem hiding this comment.
The new manifest contract is per workflow run and attempt, but these targeted stateless jobs still inherit the ordinary common_ft_job_config.digest_config. That leaves two holes:
Select functional testshas no digest of its own, sohook_cachefolds only the null digest from that dependency into the downstream cache key.- The inherited digest does not include
find_tests.py,coverage_selection.py,test_selection_manifest.py, orselect_functional_tests.py, even though those files now decide which tests this job runs.
So a rerun-all on the same SHA, or a follow-up commit that only changes the selector code, can cache-hit a previously green targeted job and skip it without ever loading the new <run_id>/<attempt>.json manifest. That breaks the "refresh previous failures / coverage snapshots on retry" contract exactly when the selection logic changes. Please disable caching for the targeted stateless jobs too, or otherwise salt their final digest with the manifest identity and current attempt.
…st-selection # Conflicts: # .github/workflows/pull_request.yml # ci/jobs/functional_tests.py # ci/jobs/scripts/find_tests.py
- Run the ASan targeted job on the large runner: it combines the parallel distributed-plan workload with the sequential `db disk` shards, whose small runner is too small for it. - Include the selector modules in the functional-test digest, so a change to them cannot cache-hit an old targeted result. - Select coverage-covered tests for changes under `programs/` and `base/` too, not only `src/`, since the PR workflow no longer runs the full sanitizer suites. - Validate manifest coverage freshness against the producer's recorded cutoff instead of the consumer's clock. - Treat `export_coverage.py` and `coverage_selection.py` as coverage-pipeline code in `filter_job.py`.
leshikus
left a comment
There was a problem hiding this comment.
I would suggest revisiting security model, we generally should not expose AWS credentials inside job container
| JobConfigs.keeper_stress_job | ||
| .set_name("Keeper Stress Tests (PR)") | ||
| .set_timeout(3 * 3600), | ||
| JobConfigs.keeper_stress_job.set_name("Keeper Stress Tests (PR)").set_timeout( |
There was a problem hiding this comment.
It's easier to review the big patch when formatting changes are separate from the logic changes in a separate PR
| raise | ||
| manifest = produce() | ||
| try: | ||
| client.put_object( |
There was a problem hiding this comment.
I believe this happens inside job docker, we generally do not allow AWS access from the job docker because this means AWS credentials can leak
| # repos; private repos require GITHUB_TOKEN (available in Actions env). | ||
| import requests | ||
|
|
||
| headers = {"Accept": "application/vnd.github+json"} | ||
| token = os.environ.get("GITHUB_TOKEN", "") |
There was a problem hiding this comment.
This private-repo branch is dead in the new selection flow. Targeting.get_diff_text now relies on os.environ["GITHUB_TOKEN"], but neither Select functional tests nor the stateless targeted jobs export that variable; enable_gh_auth only authenticates gh and mounts GH_CONFIG_DIR, it does not populate GITHUB_TOKEN for requests. So this works in ClickHouse/ClickHouse and starts failing with 401/404 on ClickHouse/ClickHouse-private exactly on the new manifest-producing path and on failed-job-only reruns that call get_selection from functional_tests.py.
Can this fetch go through gh api so the existing auth plumbing applies, or otherwise mint/export an installation token before these requests.get calls?
| SELECT if(startsWith(file, './'), substring(file, 3), file) AS canonical_file, | ||
| line_start, line_end, test_name | ||
| FROM {source} | ||
| AND (startsWith(file, 'src/') OR startsWith(file, './src/')) |
There was a problem hiding this comment.
The selector contract was widened to programs/ and base/ in the last commit, but the live seed for both the nightly post-export smoke and check_coverage_canary is still hard-coded to src/ here. A prefix-specific regression in export or path normalization can therefore leave the smoke green while PRs that only touch programs/ / base/ silently get no targeted coverage.
Can this predicate follow the same supported-prefix set as selection, or add a separate smoke that exercises the non-src/ prefixes?
The shared selection manifest was read and written in S3 from inside the job container, which exposes AWS access to PR code there. Instead, every targeted job selects its own tests, as before, and all CIDB inputs are pinned to one cutoff so the jobs of an attempt agree: - Previous failures count only checks started before the cutoff, and the query no longer depends on `now()`. - Coverage snapshots are taken as of the cutoff minus `coverage_settle_hours`, so an export still inserting rows is ignored. - The first attempt uses the workflow start time resolved by the config job; a rerun, including a rerun of failed jobs only, uses the start of its attempt from the GitHub API. Remove the `Select functional tests` job, the `STATELESS_SELECTION` artifact and the S3 manifest cache. Each targeted job runs the deterministic selection smoke and attaches its selection as `stateless-selection.json` to its report. Related: #118223 (comment)
| "ci/jobs/scripts/job_hooks/llvm_coverage_hook.py", | ||
| # Exports per-test coverage and runs the post-export selector smoke. | ||
| "ci/jobs/scripts/functional_tests/export_coverage.py", | ||
| "ci/jobs/scripts/coverage_selection.py", |
There was a problem hiding this comment.
coverage_selection.py now imports SELECTION_CONFIG, so changing ci/jobs/scripts/test_selection_config.py changes the shard count and freshness/precision thresholds that the nightly export smoke validates. Because _has_coverage_pipeline_changes still omits that file, a CI-only PR that touches only test_selection_config.py skips every llvm_coverage job and never exercises the export-side selector smoke. Please add ci/jobs/scripts/test_selection_config.py here as another coverage-pipeline input.
Edited by the nightly changelog CI job following .claude/skills/edit-changelog/SKILL.md. Changelog-revert: 119274 118919 Revert "Carry the mutation version onto a rewritten lightweight `DELETE`" Changelog-revert: 119306 119274 Revert "Revert "Carry the mutation version onto a rewritten lightweight `DELETE`"" Changelog-revert: 119334 117356 Revert "Unify the spill trigger for hash joins" Changelog-revert: 119335 119334 Revert "Revert "Unify the spill trigger for hash joins"" Changelog-revert: 121135 118279 Revert "Test the ESCAPE route into the ngram LIKE-pattern tokenizer" Changelog-revert: 121136 121135 Revert "Revert "Test the ESCAPE route into the ngram LIKE-pattern tokenizer"" Changelog-revert: 121258 118216 Revert "Do not invert an ordered comparison that can see a `NaN` in the CNF form" Changelog-revert: 121298 117578 Revert "Bound the docker buildx retry ladder by wall clock, not by the timeout divisor" Changelog-revert: 121443 114465 Revert "Fix an error reading an Iceberg table whose `current-snapshot-id` is JSON null" Changelog-revert: 121477 121096 Revert "Trim `test_max_bytes_ratio_before_external_distinct` to fit the client timeout" Changelog-revert: 121901 121869 Revert "docs(managed-postgres): updated Private Service Connect" Changelog-revert: 122110 118223 Revert "Correct nightly coverage selection and share PR test manifests" Changelog-revert: 122140 120312 Revert "Refuse a `Set` table on the right side of `IN` when a row policy applies to it" Changelog-deleted-entry: 114465 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed an error when reading an Iceberg table whose `current-snapshot-id` is JSON null, which some writers emit for a table with no current snapshot. [#114465](#114465) ([Shaohua Wang](https://github.com/tiandiwonder)). Changelog-deleted-entry: 118216 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed `convert_query_to_cnf = 1` silently dropping rows with a `NaN` in a floating point column: the conversion rewrote `NOT (x < c)` into `x >= c`, which is not an equivalent condition for `NaN`. [#118216](#118216) ([Alexey Milovidov](https://github.com/alexey-milovidov)). Changelog-deleted-entry: 118223 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Correct nightly coverage selection and share PR test manifests. [#118223](#118223) ([Nikita Fomichev](https://github.com/fm4v)). Changelog-deleted-entry: 120312 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * A row policy on a `Set`-engine table was accepted but never applied: the right side of `IN` read the prebuilt set directly and returned the rows the policy hides. Such a query now fails with `ACCESS_DENIED`, because the `Set` engine has no read path that could filter the rows. Queries that used a `Set` table covered by a database-wide row policy ran unfiltered before and now throw. [#120312](#120312) ([Harikrishnan Prabakaran](https://github.com/harikrishnan94)). Changelog-deleted-entry: 121096 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Sized `test_max_bytes_ratio_before_external_distinct` to fit the integration harness's 600 second per-query timeout. [#121096](#121096) ([Groene AI](https://github.com/groeneai)).
The snapshot query counted `uniqExact(test_name)` over the whole 14-day window of `checks_coverage_lines`: 3.5 billion rows and 57 GB, about 6 s on an idle server. Every targeted stateless job of every PR runs it, so while the per-test coverage export was inserting (2026-09-24 18:00-20:00 and 2026-09-25 02:00-04:00 UTC) it exceeded the 60 s timeout on all five attempts. 190 of the 199 "Failed to load test selection" errors since the selector was merged were this query, and as `Stateless tests (amd_asan_ubsan, db disk, distributed plan, targeted)` is a core blocking job, each of them skipped the rest of the PR pipeline. This is why #118223 was reverted in #122110. Now the distinct `check_start_time` values of the window are listed first (only that column is read, about 0.3 s), and exported tests are counted for the newest three timestamps at a time, filtered by the primary key, until every shard has `coverage_run_count` healthy snapshots. On live CIDB data the result is identical to the old query at every cutoff tried, and it reads 6-10 GB of `test_name` instead of 57 GB, in 1.4-2.3 s instead of about 6 s. Example failure: https://s3.amazonaws.com/clickhouse-test-reports/PRs/122067/925c788e633f3e3fd2f31f3cd68b916ceb728a3e/pr/stateless_tests_arm_asan_ubsan_targeted/job.log (#122067)
…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]>
…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]>
Rework coverage-based stateless test selection for pull requests and make the nightly coverage export verifiable.
Selection (
ci/jobs/scripts/find_tests.py, newcoverage_selection.py,test_selection_config.py):./-prefixed spellings are queried and merged, so current coverage builds (bare repository-relative paths) are no longer missed. Only changed lines undersrc/,programs/andbase/are considered._STATELESS_HARNESS_PATHS,STATELESS_HARNESS_SMOKE_TESTS).min_depthis treated as an LLVM function entry count rather than a call depth. Entry-count scoring runs only in shadow mode and does not affect execution.Per-job selection with pinned inputs (
find_tests.py,test_selection_manifest.py):GITHUB_RUN_ATTEMPT) is propagated into test containers (Info.run_attempt).stateless-selection.json) to its report, with the cutoff, coverage snapshots, diff coordinates and an ordered test list with compact evidence.PR workflow (
ci/workflows/pull_request.py,ci/defs/job_configs.py, newci/defs/functional_test_selection.py):selected testssanitizer jobs are replaced by three targeted configurations:amd_asan_ubsan, db disk, distributed plan, targeted(on the large runner),amd_tsan, s3 storage, targeted, and the existingarm_asan_ubsan, targeted. The ASan one is the core blocking job.expanded_targeted_matrix) until replay validation.Nightly coverage (
export_coverage.py,ci/workflows/nightly_coverage.py):Tooling:
test_selection_smoke.py(deterministic checks, also run by each targeted job before selecting, plus--livemonitoring) andevaluate_test_selection.py(replay against historical cases). Design and rollout notes are inci/jobs/scripts/test_selection.md.Limitations: coverage snapshots are keyed by shard and timestamp because CIDB has no durable run identity yet (needs an external schema migration). The precision thresholds and the below-100-tests target have not yet passed the 60 to 90 day replay gate.
Related: #117331
Related: #114725
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/118223]
Version info
26.10.1.574-master(included in26.10and later)