2021-07-06 13:04:49 +00:00
|
|
|
import pytest
|
|
|
|
|
2024-02-26 12:45:20 +00:00
|
|
|
from helpers.cluster import ClickHouseCluster, CLICKHOUSE_CI_MIN_TESTED_VERSION
|
2021-07-06 13:04:49 +00:00
|
|
|
|
2022-07-18 12:25:14 +00:00
|
|
|
cluster = ClickHouseCluster(__file__)
|
2024-03-21 14:00:27 +00:00
|
|
|
node1 = cluster.add_instance("node1", with_zookeeper=False, use_old_analyzer=True)
|
2021-07-06 13:04:49 +00:00
|
|
|
node2 = cluster.add_instance(
|
|
|
|
"node2",
|
2021-07-15 05:17:22 +00:00
|
|
|
with_zookeeper=False,
|
2024-02-26 12:45:20 +00:00
|
|
|
image="clickhouse/clickhouse-server",
|
|
|
|
tag=CLICKHOUSE_CI_MIN_TESTED_VERSION,
|
2021-07-15 05:17:22 +00:00
|
|
|
stay_alive=True,
|
2021-07-06 13:04:49 +00:00
|
|
|
with_installed_binary=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def start_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
|
|
|
def test_cte_distributed(start_cluster):
|
|
|
|
node2.query(
|
|
|
|
"""
|
|
|
|
WITH
|
|
|
|
quantile(0.05)(cnt) as p05,
|
|
|
|
quantile(0.95)(cnt) as p95,
|
|
|
|
p95 - p05 as inter_percentile_range
|
2023-07-20 15:05:07 +00:00
|
|
|
SELECT
|
2021-07-06 13:04:49 +00:00
|
|
|
sum(cnt) as total_requests,
|
|
|
|
count() as data_points,
|
|
|
|
inter_percentile_range
|
|
|
|
FROM (
|
|
|
|
SELECT
|
|
|
|
count() as cnt
|
|
|
|
FROM remote('node{1,2}', numbers(10))
|
|
|
|
GROUP BY number
|
|
|
|
)"""
|
|
|
|
)
|
|
|
|
|
|
|
|
node1.query(
|
|
|
|
"""
|
|
|
|
WITH
|
|
|
|
quantile(0.05)(cnt) as p05,
|
|
|
|
quantile(0.95)(cnt) as p95,
|
|
|
|
p95 - p05 as inter_percentile_range
|
2023-07-20 15:05:07 +00:00
|
|
|
SELECT
|
2021-07-06 13:04:49 +00:00
|
|
|
sum(cnt) as total_requests,
|
|
|
|
count() as data_points,
|
|
|
|
inter_percentile_range
|
|
|
|
FROM (
|
|
|
|
SELECT
|
|
|
|
count() as cnt
|
|
|
|
FROM remote('node{1,2}', numbers(10))
|
|
|
|
GROUP BY number
|
|
|
|
)"""
|
|
|
|
)
|