2021-07-06 13:04:49 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
2022-07-18 12:25:14 +00:00
|
|
|
cluster = ClickHouseCluster(__file__)
|
2023-07-20 15:05:07 +00:00
|
|
|
node1 = cluster.add_instance("node1", with_zookeeper=False, allow_analyzer=False)
|
2022-03-22 16:39:58 +00:00
|
|
|
node2 = cluster.add_instance(
|
|
|
|
"node2",
|
|
|
|
with_zookeeper=False,
|
|
|
|
image="yandex/clickhouse-server",
|
2023-10-27 14:59:14 +00:00
|
|
|
tag="21.6",
|
2022-03-22 16:39:58 +00:00
|
|
|
stay_alive=True,
|
|
|
|
with_installed_binary=True,
|
2023-07-20 15:05:07 +00:00
|
|
|
allow_analyzer=False,
|
2022-03-22 16:39:58 +00:00
|
|
|
)
|
2021-07-06 13:04:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def start_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
|
|
|
def test_cte_distributed(start_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
node2.query(
|
|
|
|
"""
|
2021-07-06 13:04:49 +00:00
|
|
|
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
|
2022-03-22 16:39:58 +00:00
|
|
|
)"""
|
|
|
|
)
|
2021-07-06 13:04:49 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
node1.query(
|
|
|
|
"""
|
2021-07-06 13:04:49 +00:00
|
|
|
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
|
2022-03-22 16:39:58 +00:00
|
|
|
)"""
|
|
|
|
)
|