Skip to content

Pass the selected tests to clickhouse-test through a file - #126545

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:flaky-check-test-list-file
Oct 21, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:flaky-check-test-list-file

Conversation

@groeneai

@groeneai groeneai commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

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):

The stateless flaky check and targeted check pass their selected tests to clickhouse-test through a file, so a PR that changes thousands of tests no longer fails these jobs with Argument list too long.

Description

Related: #126194 (failing job).

run_tests puts the selected tests after -- in one bash -c command, and Linux caps a single argument at 128 KiB (MAX_ARG_STRLEN), so execve fails with [Errno 7] Argument list too long: '/bin/bash' before clickhouse-test starts. The 2745 selectors of #126194 take 224,183 bytes. The anchored selectors from my #122059 doubled their length, so the limit is now reached at about 1,580 changed tests.

A file alone would expose a second problem: get_selected_tests calls re.search for every selector on every suite file, and re caches only 512 compiled patterns. For 2745 selectors that is about 41 minutes of selection (extrapolated from 142.6 s on 1,000 of the 17,433 test files), charged to --global_time_limit.

Changes:

  • clickhouse-test: new --test-list-file, one selector per line, added to the positional ones. A file that lists nothing is an error, so an empty list never runs the whole suite.
  • clickhouse-test: the selectors are compiled once.
  • run_tests writes the selection to ci/tmp/test_list.txt and passes that file. The unused Targeting.selection_args and its smoke case are removed.

I did not cap the number of tests: the targeted check keeps every changed test on purpose, and the flaky check is already bounded by its time limit.

Validation (local, no test for the test infrastructure): the real run_tests with the 2745 selectors fails with E2BIG before and hands over the byte-identical list after; selecting them takes 3.3 s and gives the same tests as the positional form; a flaky-check run of that list against a local server started running tests after 4 s.


Workflow [PR]
Sync PR [sync-upstream/pr/126545]

Version info

  • Merged into: 26.11.1.468-master (included in 26.11 and later)

`run_tests` ran the whole `clickhouse-test` command as one `bash -c`
argument with every selected test after `--`. Linux caps a single
argument at 128 KiB (MAX_ARG_STRLEN), so a PR that changes about 1,580
or more stateless tests (ClickHouse#126194: 2745 tests, 224,183 bytes of
selectors) failed every flaky-check and targeted job with
`[Errno 7] Argument list too long: '/bin/bash'` before the runner
started.

`run_tests` now writes the selection to `ci/tmp/test_list.txt` and
passes it with the new `clickhouse-test --test-list-file` option (one
selector per line, added to the positional ones; a file that lists
nothing is an error, so an empty list never means the whole suite).

`get_selected_tests` searched every selector in every suite file with
`re.search`, and `re` caches only 512 compiled patterns, so with more
selectors each call recompiled: about 41 minutes for 2745 selectors
over 17,433 files, charged to `--global_time_limit`. The selectors are
now compiled once (3.3 s for the same list, identical selection).

`Targeting.selection_args` (shell quoting for the old command line) and
its smoke case are no longer needed and are removed.

Related: ClickHouse#126194

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand): 0 changes requested, 2 findings dismissed with evidence
Finding Verdict
⚠️ The file transport has no executable proof that it keeps the full selection and avoids the E2BIG Dismissed: local runs of the real run_tests with the 2745 selectors of #126194 fail with E2BIG before and pass a byte-identical list after (sha256 match); selection from the file equals the positional form; an empty or blank file exits 2. No self-test, per the no-tests-for-test-infrastructure decision in #119766.
💡 Use the full URL in the Related: line Dismissed: the template's linked-issues block already has the full URL; the Description line is prose.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes: the real run_tests with the 2745 selectors of #126194 fails with [Errno 7] Argument list too long: '/bin/bash' on every run; 3 selectors pass.
b Root cause explained? One bash -c argument of 224,183 bytes, above the 131,072-byte MAX_ARG_STRLEN. Behind it, get_selected_tests recompiled every selector for every file once there are more than 512 (re cache size).
c Fix matches root cause? Yes: the list goes through --test-list-file, and the selectors are compiled once. No cap, no truncation.
d Test intent preserved / new tests added? No test for the test infrastructure; the smoke case of the removed helper goes with it; the selection smoke still passes (18 tests).
e Both directions demonstrated? E2BIG before, byte-identical list after (sha256 match). Selection on 1,000 files: 142.55 s before, 0.29 s after, same result.
f Fix is general across code paths? Every run_tests caller (flaky, targeted, default, bugfix validation, local --test) uses the same branch. The diagnostics rerun is capped at 10 names; integration jobs pass at most 51,111 bytes of modules.
g Fix generalizes across inputs (params/datatypes/wrappers)? No tests: no option, full suite as before. 3, 400 and 2745 selectors checked. Empty or blank file: error, never the whole suite. Missing file: exit 1.
h Backward compatible? (maintainer-approved exception only) Yes: positional selectors unchanged, the option is additive, and both scripts ship together.
i Invariants and contracts preserved? args.test stays a list of selector strings (positional plus file); the matched-selector set keeps strings; re.compile(p).search(s) equals re.search(p, s).

Session id: cron:clickhouse-impl-slot-5:20261017-234400

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this and add the can be tested label so CI runs? run_tests now hands the selected tests to clickhouse-test through a file instead of one bash -c argument (which hit E2BIG on #126194), using a new --test-list-file that, unlike the one in your closed #111408, holds regex selectors added to the positional ones; the selectors are also compiled once.

@clickhouse-gh

clickhouse-gh Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [391d3d6]

Summary: ✅


AI Review

Summary

PR #126545 passes selected stateless test regexes through --test-list-file and compiles them once per suite, avoiding E2BIG and repeated pattern compilation for large selections. Review of commit 391d3d684a6ead4f830cc4a85d2b6ca6324875fd found no actionable issues.

Final Verdict

✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 18, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 18, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Oct 18, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good.

@alexey-milovidov alexey-milovidov self-assigned this Oct 21, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 21, 2026
Merged via the queue into ClickHouse:master with commit be84294 Oct 21, 2026
352 of 353 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants