mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
add a test
This commit is contained in:
parent
c892e2c01d
commit
ebd03fbd77
@ -0,0 +1,34 @@
|
|||||||
|
<clickhouse>
|
||||||
|
<remote_servers>
|
||||||
|
<test_cluster>
|
||||||
|
<shard>
|
||||||
|
<internal_replication>true</internal_replication>
|
||||||
|
<replica>
|
||||||
|
<host>node1</host>
|
||||||
|
<port>9000</port>
|
||||||
|
</replica>
|
||||||
|
<replica>
|
||||||
|
<host>node2</host>
|
||||||
|
<port>9000</port>
|
||||||
|
</replica>
|
||||||
|
<replica>
|
||||||
|
<host>node3</host>
|
||||||
|
<port>9000</port>
|
||||||
|
</replica>
|
||||||
|
</shard>
|
||||||
|
</test_cluster>
|
||||||
|
</remote_servers>
|
||||||
|
<query_log>
|
||||||
|
<database>system</database>
|
||||||
|
<table>query_log</table>
|
||||||
|
<partition_by>toYYYYMM(event_date)</partition_by>
|
||||||
|
<ttl>event_date + INTERVAL 30 DAY DELETE</ttl>
|
||||||
|
<!--
|
||||||
|
<engine>ENGINE = MergeTree PARTITION BY toYYYYMM(event_date) ORDER BY (event_date, event_time) SETTINGS index_granularity = 1024</engine>
|
||||||
|
-->
|
||||||
|
<flush_interval_milliseconds>100</flush_interval_milliseconds>
|
||||||
|
<reserved_size_rows>8192</reserved_size_rows>
|
||||||
|
<buffer_size_rows_flush_threshold>524288</buffer_size_rows_flush_threshold>
|
||||||
|
<flush_on_crash>false</flush_on_crash>
|
||||||
|
</query_log>
|
||||||
|
</clickhouse>
|
@ -0,0 +1,71 @@
|
|||||||
|
import pytest
|
||||||
|
from helpers.cluster import ClickHouseCluster
|
||||||
|
|
||||||
|
|
||||||
|
def fill_nodes(nodes, shard):
|
||||||
|
for node in nodes:
|
||||||
|
node.query(
|
||||||
|
"""
|
||||||
|
CREATE DATABASE test;
|
||||||
|
|
||||||
|
CREATE TABLE test.test_table(date Date, id UInt32)
|
||||||
|
ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/{shard}/replicated/test_table', '{replica}') ORDER BY id PARTITION BY toYYYYMM(date);
|
||||||
|
""".format(
|
||||||
|
shard=shard, replica=node.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
cluster = ClickHouseCluster(__file__)
|
||||||
|
node1 = cluster.add_instance(
|
||||||
|
"node1", with_zookeeper=True, main_configs=["configs/replicated_servers.xml"]
|
||||||
|
)
|
||||||
|
node2 = cluster.add_instance(
|
||||||
|
"node2", with_zookeeper=True, main_configs=["configs/replicated_servers.xml"]
|
||||||
|
)
|
||||||
|
node3 = cluster.add_instance(
|
||||||
|
"node3", with_zookeeper=True, main_configs=["configs/replicated_servers.xml"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def start_cluster():
|
||||||
|
try:
|
||||||
|
cluster.start()
|
||||||
|
|
||||||
|
fill_nodes([node1, node2, node3], 1)
|
||||||
|
|
||||||
|
yield cluster
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
print(ex)
|
||||||
|
|
||||||
|
finally:
|
||||||
|
cluster.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
def test_truncate_database_replicated(start_cluster):
|
||||||
|
node1.query("SELECT 1", query_id="query_node1")
|
||||||
|
node2.query("SELECT 1", query_id="query_node2")
|
||||||
|
node3.query("SELECT 1", query_id="query_node3")
|
||||||
|
node1.query("SYSTEM FLUSH LOGS")
|
||||||
|
node2.query("SYSTEM FLUSH LOGS")
|
||||||
|
node3.query("SYSTEM FLUSH LOGS")
|
||||||
|
assert (
|
||||||
|
node1.query(
|
||||||
|
"SELECT hostname from system.query_log where query_id='query_node1' LIMIT 1"
|
||||||
|
)
|
||||||
|
== "node1\n"
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
node2.query(
|
||||||
|
"SELECT hostname from system.query_log where query_id='query_node2' LIMIT 1"
|
||||||
|
)
|
||||||
|
== "node2\n"
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
node3.query(
|
||||||
|
"SELECT hostname from system.query_log where query_id='query_node3' LIMIT 1"
|
||||||
|
)
|
||||||
|
== "node3\n"
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user