Skip to content

Add clickhouse-test --test-list-file and --list-tests for job-side test distribution - #111408

Closed
maxknv wants to merge 5 commits into
masterfrom
functional-tests-list-file
Closed

maxknv wants to merge 5 commits into
masterfrom
functional-tests-list-file

Conversation

@maxknv

@maxknv maxknv commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Lets functional_tests.py control which functional tests run in a batched job instead of delegating batching to clickhouse-test --run-by-hash-*. The job asks clickhouse-test --list-tests for the exact selectable set, splits it across batches balanced by median per-test duration, and passes this job's share back via --test-list-file.

New clickhouse-test options:

  • --list-tests FILE: write the exact set of tests that would be selected (respecting tags, --no-long, --no-parallel/--no-sequential, and --test-list-file) to FILE, one name per line, then exit without running anything or connecting to a server.
  • --test-list-file FILE: select exactly the tests named in FILE by exact identity (extension-agnostic) rather than as regexes, and run them in the file's order. It is mutually exclusive with --run-by-hash-num/--run-by-hash-total and positional test-name patterns (asserts if combined), so the "exact list" contract holds.

Distribution uses the nightly median per-test durations published by collect_test_duration_statistics (#111389). functional_tests.py fetches test_statistics.json.gz from the public report bucket over plain HTTP (works locally without AWS auth) and assigns tests to batches with the greedy longest-processing-time heuristic, bringing per-batch estimated durations to within ~1s of each other on real data. Missing/stale statistics degrade to balancing by test count rather than failing. If listing or distribution yields no tests the job fails explicitly (ERROR) rather than silently changing the distribution.

Related: #111389

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

🤖 Generated with Claude Code

…st distribution

functional_tests.py can now distribute batched functional tests itself
instead of relying on `clickhouse-test --run-by-hash-*`:

- `clickhouse-test --list-tests FILE` writes the exact set of tests it would
  select (respecting tags, --no-long, --no-parallel/--no-sequential, and
  --test-list-file) to FILE, one per line, and exits without running anything
  or connecting to a server.
- `clickhouse-test --test-list-file FILE` selects exactly the tests named in
  FILE by exact identity (extension-agnostic) rather than as regexes. When an
  explicit list is used, the parallel test order is no longer shuffled so the
  caller's order is preserved.
- functional_tests.py lists the selectable tests, splits them round-robin into
  this job's batch, and passes the batch via --test-list-file. It fails the job
  explicitly (ERROR) if listing/distribution yields no tests. --run-by-hash-*
  remains supported in run_tests as a fallback for callers still using it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2196adc]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_asan_ubsan, distributed plan, parallel) FAIL
03742_nested_loop_join_long FAIL cidb
03216_arrayWithConstant_limits FAIL cidb

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 22, 2026
Comment thread tests/clickhouse-test Resolved
Comment thread tests/clickhouse-test Resolved
@StackSlayerAI

Copy link
Copy Markdown
Contributor

CI Triage (bot) — head 38757623 — 2026-07-22

Verdict: LIKELY FLAKE — 02481_i43247_ubsan_in_minmaxany in Stateless tests (amd_asan_ubsan, distributed plan, parallel)

A single test 02481_i43247_ubsan_in_minmaxany failed in the distributed plan stateless run. This PR only modifies ci/jobs/functional_tests.py and tests/clickhouse-test (test infrastructure changes, not MinMax aggregate logic), making a PR-introduced regression in 02481_i43247_ubsan_in_minmaxany very unlikely.

A retry is recommended to confirm this is a transient failure.

Run ID: 29931032059

…rve its order

Addresses review on PR #111408:

- --test-list-file now asserts it is not combined with
  --run-by-hash-num/--run-by-hash-total or positional test-name patterns.
  Previously the "exact list" was only intersected with those filters, so
  `--test-list-file list.txt --run-by-hash-total 2 --run-by-hash-num 0` could
  silently drop entries, making the exact-list contract false.

- The list is loaded into an ordered mapping (test identity -> position in the
  file) instead of a set, and TestSuite orders the run by that position (in
  addition to skipping the shuffle). A precomputed, ordered schedule (e.g. a
  duration-balanced one) is therefore honored rather than re-sorted into numeric
  order.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread ci/jobs/functional_tests.py Resolved
Comment thread tests/clickhouse-test Resolved
maxknv and others added 3 commits July 24, 2026 17:20
Use the nightly per-test duration statistics (published by
collect_test_duration_statistics, PR #111389) to balance batches by time
instead of by count:

- load_test_durations downloads test_statistics.json.gz from the public report
  bucket over plain HTTP (curl), so it works locally without AWS auth, and
  returns {test_identity: median_ms} for this job (batch suffix stripped to match
  the merged key). Missing/unavailable stats degrade to balancing by count rather
  than failing.
- distribute_tests_into_batch now assigns tests with the greedy
  longest-processing-time heuristic (longest test to the least-loaded batch),
  which brings the per-batch estimated durations to within a second of each other
  on real data. Deterministic (ties broken by name); the group is written
  longest-first and --test-list-file preserves that order.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Listing/distribution deliberately runs without a server, so it cannot apply the
per-test runtime skips from `TestCase.should_skip_test` (build-flag/tag skips
like `no-asan`/`no-azure-blob-storage`, `--no-long`, the skip lists, cloud
filters) - those depend on `args.build_flags`, which needs a running server. A
lane-skipped test is still listed and distributed into a batch, then reported
SKIPPED when that batch runs, which is harmless (it would not run anyway). Only
the docs over-claimed: correct the `--list-tests` help and the
`list_all_tests`/`list_selected_tests` docstrings to describe the pre-skip
candidate set instead of the exact runnable set.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
load_test_durations referenced test_identity, which only existed in
tests/clickhouse-test - undefined in this module (F821, and a runtime NameError).
Add a local helper mirroring clickhouse-test's normalization so duration-stats
names match the listed test identities.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread tests/clickhouse-test
# But when the caller supplied an explicit test list (--test-list-file),
# it already controls the exact set and their order (e.g. a precomputed,
# deterministically distributed batch); preserve that order instead of
# reshuffling it here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_list_order only preserves the caller's order inside self.all_tests. The next loop immediately repartitions that ordered list into parallel_tests and sequential_tests, and do_run_tests always drains the parallel bucket before the sequential one. A file like [00024_random_counters, 00001_select_1] therefore still runs 00001_select_1 first, so the new "--test-list-file runs tests in file order" contract is still false for any batch that mixes no-parallel and parallel tests.

Please either preserve one global ordered schedule while honoring sequential-only tests, or stop claiming exact file-order execution and generate/document the list in the runner's actual parallel -> sequential order.

@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 4, 2026
@maxknv
maxknv marked this pull request as draft September 8, 2026 09:44
@maxknv maxknv closed this Sep 27, 2026
@maxknv
maxknv deleted the functional-tests-list-file branch September 28, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants