Skip to content

PromQL support: Simplify evaluation test#93350

Merged
nikitamikhaylov merged 2 commits intoClickHouse:masterfrom
vitlibar:promql-refactor-evaluation-test
Jan 5, 2026
Merged

PromQL support: Simplify evaluation test#93350
nikitamikhaylov merged 2 commits intoClickHouse:masterfrom
vitlibar:promql-refactor-evaluation-test

Conversation

@vitlibar
Copy link
Copy Markdown
Member

@vitlibar vitlibar commented Jan 2, 2026

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

PromQL support: Simplify evaluation test test_prometheus_protocols/test_evaluation.py

Part of #89356

@vitlibar vitlibar requested a review from Copilot January 2, 2026 22:25
@vitlibar vitlibar marked this pull request as draft January 2, 2026 22:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the PromQL evaluation test file to improve code organization and maintainability. The main changes include moving test data setup into the fixture, consolidating test logic into reusable helper functions, and splitting a single large test into multiple focused test functions.

Key changes:

  • Test data setup moved from individual tests into the start_cluster fixture
  • Two new helper functions do_query_test and do_range_query_test replace repetitive assertion code
  • The large test_first function split into three focused tests: test_range_selectors, test_instant_selectors, and test_function_over_time

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/integration/test_prometheus_protocols/test_evaluation.py Refactored test structure by introducing helper functions and splitting tests into smaller, more focused test cases
src/Storages/TimeSeries/PrometheusHTTPProtocolAPI.cpp Simplified query execution by removing redundant context setup and settings configuration

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Jan 2, 2026

Workflow [PR], commit [a1d942a]

Summary:

job_name test_name status info comment
Integration tests (amd_asan, db disk, old analyzer, 1/6) failure
test_storage_s3_queue/test_6.py::test_ordered_mode_with_hive[AzureQueue-1-16-2] FAIL cidb
test_storage_s3_queue/test_6.py::test_ordered_mode_with_hive[AzureQueue-4-1-2] FAIL cidb
test_storage_s3_queue/test_6.py::test_ordered_mode_with_hive[AzureQueue-4-16-2] FAIL cidb
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: (STID: 1941-1bfa) FAIL cidb, issue

@clickhouse-gh clickhouse-gh bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jan 2, 2026
if (!sql_query)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Failed to convert PromQL to SQL");

auto query_context = getContext();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I changed this code because at this point the query context is already completely initialized in PrometheusRequestHandler::QueryAPIImpl::makeContext() and trying to set query_id again here is not only unnecessary but also can trigger this assertion in executeQuery().

@vitlibar vitlibar marked this pull request as ready for review January 2, 2026 22:38
False,
)

queries = [ # array of tuples (query, timestamp, http_api_result, result of prometheusQuery, flag is ClickHouse HTTP API result is same as Prometheus one)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Here I changed the test approach. Instead of the big list containing all promql queries, now each test calls function do_query_test() once per each promql query. The new approach is easier for debugging because it makes easier to see points of failure.

@nikitamikhaylov nikitamikhaylov self-assigned this Jan 2, 2026
@nikitamikhaylov nikitamikhaylov added this pull request to the merge queue Jan 5, 2026
Merged via the queue into ClickHouse:master with commit 0964d59 Jan 5, 2026
128 of 131 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jan 5, 2026
@JTCunning JTCunning added the comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... label Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... pr-not-for-changelog This PR should not be mentioned in the changelog 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.

5 participants