mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
add test
This commit is contained in:
parent
a0683ce460
commit
d8ae52118b
@ -0,0 +1,42 @@
|
||||
<yandex>
|
||||
<zookeeper>
|
||||
<node index="1">
|
||||
<host>zoo1</host>
|
||||
<port>2181</port>
|
||||
</node>
|
||||
<node index="2">
|
||||
<host>zoo2</host>
|
||||
<port>2181</port>
|
||||
</node>
|
||||
<node index="3">
|
||||
<host>zoo3</host>
|
||||
<port>2181</port>
|
||||
</node>
|
||||
</zookeeper>
|
||||
<auxiliary_zookeepers>
|
||||
<zookeeper2>
|
||||
<node index="1">
|
||||
<host>zoo1</host>
|
||||
<port>2181</port>
|
||||
</node>
|
||||
<node index="2">
|
||||
<host>zoo2</host>
|
||||
<port>2181</port>
|
||||
</node>
|
||||
</zookeeper2>
|
||||
</auxiliary_zookeepers>
|
||||
<remote_servers>
|
||||
<test_cluster>
|
||||
<shard>
|
||||
<replica>
|
||||
<host>node1</host>
|
||||
<port>9000</port>
|
||||
</replica>
|
||||
<replica>
|
||||
<host>node2</host>
|
||||
<port>9000</port>
|
||||
</replica>
|
||||
</shard>
|
||||
</test_cluster>
|
||||
</remote_servers>
|
||||
</yandex>
|
@ -0,0 +1,68 @@
|
||||
import time
|
||||
|
||||
import helpers.client as client
|
||||
import pytest
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
from helpers.test_tools import TSV
|
||||
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
node1 = cluster.add_instance("node1", main_configs=["configs/config.xml"], with_zookeeper=True)
|
||||
node2 = cluster.add_instance("node2", main_configs=["configs/config.xml"], with_zookeeper=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def started_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
|
||||
yield cluster
|
||||
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
def drop_table(nodes, table_name):
|
||||
for node in nodes:
|
||||
node.query("DROP TABLE IF EXISTS {} NO DELAY".format(table_name))
|
||||
|
||||
# Create table with default zookeeper.
|
||||
def test_create_replicated_merge_tree_with_default_zookeeper(started_cluster):
|
||||
drop_table([node1, node2], "test_default_zookeeper")
|
||||
for node in [node1, node2]:
|
||||
node.query(
|
||||
'''
|
||||
CREATE TABLE test_default_zookeeper(a Int32)
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/test_default_zookeeper', '{replica}')
|
||||
ORDER BY a;
|
||||
'''.format(replica=node.name))
|
||||
|
||||
# Insert data into node1, and query it from node2.
|
||||
node1.query("INSERT INTO test_default_zookeeper VALUES (1)")
|
||||
time.sleep(5)
|
||||
|
||||
expected = "1\n"
|
||||
assert TSV(node1.query("SELECT a FROM test_default_zookeeper")) == TSV(expected)
|
||||
assert TSV(node2.query("SELECT a FROM test_default_zookeeper")) == TSV(expected)
|
||||
|
||||
# Create table with auxiliary zookeeper.
|
||||
def test_create_replicated_merge_tree_with_auxiliary_zookeeper(started_cluster):
|
||||
drop_table([node1, node2], "test_auxiliary_zookeeper")
|
||||
for node in [node1, node2]:
|
||||
node.query(
|
||||
'''
|
||||
CREATE TABLE test_auxiliary_zookeeper(a Int32)
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/test_auxiliary_zookeeper', '{replica}')
|
||||
ORDER BY a;
|
||||
'''.format(replica=node.name))
|
||||
|
||||
# Insert data into node1, and query it from node2.
|
||||
node1.query("INSERT INTO test_auxiliary_zookeeper VALUES (1)")
|
||||
time.sleep(5)
|
||||
|
||||
expected = "1\n"
|
||||
assert TSV(node1.query("SELECT a FROM test_auxiliary_zookeeper")) == TSV(expected)
|
||||
assert TSV(node2.query("SELECT a FROM test_auxiliary_zookeeper")) == TSV(expected)
|
Loading…
Reference in New Issue
Block a user