mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 12:32:04 +00:00
format test case codes
This commit is contained in:
parent
8210e8c58c
commit
7b4c90784e
@ -1,11 +1,14 @@
|
||||
import pytest
|
||||
import time;
|
||||
import time
|
||||
from helpers.client import QueryRuntimeException
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
from helpers.test_tools import TSV
|
||||
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
node = cluster.add_instance("node", main_configs=["configs/zookeeper_config.xml", "configs/merge_tree.xml"], with_zookeeper=True)
|
||||
node = cluster.add_instance(
|
||||
"node",
|
||||
main_configs=["configs/zookeeper_config.xml", "configs/merge_tree.xml"],
|
||||
with_zookeeper=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@ -17,22 +20,24 @@ def start_cluster():
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
def test_without_auto_optimize_merge_tree(start_cluster):
|
||||
node.query(
|
||||
"CREATE TABLE test (i Int64) ENGINE = MergeTree ORDER BY i;"
|
||||
)
|
||||
node.query("CREATE TABLE test (i Int64) ENGINE = MergeTree ORDER BY i;")
|
||||
node.query("INSERT INTO test SELECT 1")
|
||||
node.query("INSERT INTO test SELECT 2")
|
||||
node.query("INSERT INTO test SELECT 3")
|
||||
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
expected = TSV('''3\n''')
|
||||
assert TSV(node.query("SELECT count(*) FROM system.parts where table='test' and active=1")) == expected
|
||||
assert TSV(
|
||||
node.query(
|
||||
"SELECT count(*) FROM system.parts where table='test' and active=1"
|
||||
)) == expected
|
||||
|
||||
node.query("DROP TABLE test;")
|
||||
|
||||
|
||||
def test_auto_optimize_merge_tree(start_cluster):
|
||||
node.query(
|
||||
"CREATE TABLE test (i Int64) ENGINE = MergeTree ORDER BY i SETTINGS auto_optimize_partition_after_seconds=5;"
|
||||
@ -41,14 +46,17 @@ def test_auto_optimize_merge_tree(start_cluster):
|
||||
node.query("INSERT INTO test SELECT 2")
|
||||
node.query("INSERT INTO test SELECT 3")
|
||||
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
expected = TSV('''1\n''')
|
||||
assert TSV(node.query("SELECT count(*) FROM system.parts where table='test' and active=1")) == expected
|
||||
assert TSV(
|
||||
node.query(
|
||||
"SELECT count(*) FROM system.parts where table='test' and active=1"
|
||||
)) == expected
|
||||
|
||||
node.query("DROP TABLE test;")
|
||||
|
||||
|
||||
def test_auto_optimize_replicated_merge_tree(start_cluster):
|
||||
node.query(
|
||||
"CREATE TABLE test (i Int64) ENGINE = ReplicatedMergeTree('/clickhouse/testing/test', 'node') ORDER BY i SETTINGS auto_optimize_partition_after_seconds=5;"
|
||||
@ -57,10 +65,12 @@ def test_auto_optimize_replicated_merge_tree(start_cluster):
|
||||
node.query("INSERT INTO test SELECT 2")
|
||||
node.query("INSERT INTO test SELECT 3")
|
||||
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
expected = TSV('''1\n''')
|
||||
assert TSV(node.query("SELECT count(*) FROM system.parts where table='test' and active=1")) == expected
|
||||
assert TSV(
|
||||
node.query(
|
||||
"SELECT count(*) FROM system.parts where table='test' and active=1"
|
||||
)) == expected
|
||||
|
||||
node.query("DROP TABLE test;")
|
||||
|
Loading…
Reference in New Issue
Block a user