Skip to content

Add nightly job collecting median per-test-case durations - #111389

Merged
maxknv merged 1 commit into
masterfrom
collect-test-duration-statistics
Jul 23, 2026
Merged

maxknv merged 1 commit into
masterfrom
collect-test-duration-statistics

Conversation

@maxknv

@maxknv maxknv commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Adds a new Collect Test Duration Statistics job to the NightlyStatistics workflow. It collects the median duration of every test case per CI job from master CI runs (pull_request_number = 0 and head_ref = 'master') over the last 2 days, and uploads the result to S3 as JSON:

{ "<check name>": [ { "<test name>": <median_duration_ms> }, ... ], ... }

The batch suffix (e.g. , 1/2) is stripped from the job name so all batches of a job are merged into a single entry.

Also renames the existing per-job Collect Statistics job/script to Collect Job Duration Statistics (collect_job_duration_statistics.py) to disambiguate it from the new per-test job.

Changelog category (leave one):

  • CI Fix or Improvement

Version info

  • Merged into: 26.7.1.1371 (included in 26.7 and later)

Adds a new `Collect Test Duration Statistics` job to the `NightlyStatistics`
workflow. It collects the median duration of every test case per CI job from
master CI runs (`pull_request_number = 0` and `head_ref = 'master'`) over the
last 2 days, and uploads the result to S3 as JSON:

    { "<check name>": [ { "<test name>": <median_duration_ms> }, ... ], ... }

The batch suffix (e.g. `, 1/2`) is stripped from the job name so all batches of
a job are merged into a single entry.

Also renames the existing per-job `Collect Statistics` job/script to
`Collect Job Duration Statistics` (`collect_job_duration_statistics.py`) to
disambiguate it from the new per-test job.

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 [5288182]

Summary: ✅


AI Review

Summary

This PR adds a new nightly Praktika job that exports median per-test durations from CI DB and renames the existing job-duration collector for clarity. The workflow wiring is fine, but the new query does not actually isolate ClickHouse master runs, so the published statistics can be polluted by fork data.

Findings

⚠️ Majors

  • [ci/jobs/collect_test_duration_statistics.py:38-39] The PR promises medians from ClickHouse master CI, but pull_request_number = 0 AND head_ref = 'master' also matches push or manual runs on forks whose default branch is master. That silently corrupts the exported medians as soon as a fork reports into the shared CI DB. Suggested fix: add a repo guard such as startsWith(head_repo, 'ClickHouse/') or an explicit allowlist for the repositories whose master runs should count.
Final Verdict

Status: ⚠️ Request changes

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 22, 2026

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Changes look good; I cannot understand why they were made from PR description - if we need a statistics, we can query ClickHouse in runtime without adding a separate CI job

@maxknv
maxknv added this pull request to the merge queue Jul 23, 2026
@maxknv

maxknv commented Jul 23, 2026 •

Copy link
Copy Markdown
Member Author

Changes look good; I cannot understand why they were made from PR description - if we need statistics, we can query ClickHouse in runtime without adding a separate CI job

I prefer prepared data because it is simpler from a job infrastructure perspective. It works locally, requires no secrets, and is more reliable on the scale of thousands of jobs running at any given moment. Also, queries may become more complex (would be nice to track memory usage per test in the future), with this extra step, CI is more protected against a wide range of issues, from bugs in the queries to network issues

Merged via the queue into master with commit d80fb73 Jul 23, 2026
179 of 180 checks passed
@maxknv
maxknv deleted the collect-test-duration-statistics branch July 23, 2026 08:06
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 23, 2026
maxknv added a commit that referenced this pull request Jul 24, 2026
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]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ation-statistics

Add nightly job collecting median per-test-case durations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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