mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Replace database with ordinary
This commit is contained in:
parent
c883b7d154
commit
6aecb62416
@ -69,16 +69,17 @@ def get_fake_zk(nodename, timeout=30.0):
|
|||||||
def test_blocade_leader(started_cluster):
|
def test_blocade_leader(started_cluster):
|
||||||
wait_nodes()
|
wait_nodes()
|
||||||
for i, node in enumerate([node1, node2, node3]):
|
for i, node in enumerate([node1, node2, node3]):
|
||||||
node.query("CREATE TABLE t1 (value UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/t1', '{}') ORDER BY tuple()".format(i + 1))
|
node.query("CREATE DATABASE IF NOT EXISTS ordinary ENGINE=Ordinary")
|
||||||
|
node.query("CREATE TABLE ordinary.t1 (value UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/t1', '{}') ORDER BY tuple()".format(i + 1))
|
||||||
|
|
||||||
node2.query("INSERT INTO t1 SELECT number FROM numbers(10)")
|
node2.query("INSERT INTO ordinary.t1 SELECT number FROM numbers(10)")
|
||||||
|
|
||||||
node1.query("SYSTEM SYNC REPLICA t1", timeout=10)
|
node1.query("SYSTEM SYNC REPLICA ordinary.t1", timeout=10)
|
||||||
node3.query("SYSTEM SYNC REPLICA t1", timeout=10)
|
node3.query("SYSTEM SYNC REPLICA ordinary.t1", timeout=10)
|
||||||
|
|
||||||
assert node1.query("SELECT COUNT() FROM t1") == "10\n"
|
assert node1.query("SELECT COUNT() FROM ordinary.t1") == "10\n"
|
||||||
assert node2.query("SELECT COUNT() FROM t1") == "10\n"
|
assert node2.query("SELECT COUNT() FROM ordinary.t1") == "10\n"
|
||||||
assert node3.query("SELECT COUNT() FROM t1") == "10\n"
|
assert node3.query("SELECT COUNT() FROM ordinary.t1") == "10\n"
|
||||||
|
|
||||||
with PartitionManager() as pm:
|
with PartitionManager() as pm:
|
||||||
pm.partition_instances(node2, node1)
|
pm.partition_instances(node2, node1)
|
||||||
@ -86,12 +87,12 @@ def test_blocade_leader(started_cluster):
|
|||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node2.query("SYSTEM RESTART REPLICA t1")
|
node2.query("SYSTEM RESTART REPLICA ordinary.t1")
|
||||||
node2.query("INSERT INTO t1 SELECT rand() FROM numbers(100)")
|
node2.query("INSERT INTO ordinary.t1 SELECT rand() FROM numbers(100)")
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
try:
|
try:
|
||||||
node2.query("ATTACH TABLE t1")
|
node2.query("ATTACH TABLE ordinary.t1")
|
||||||
except Exception as attach_ex:
|
except Exception as attach_ex:
|
||||||
print("Got exception node2", smaller_exception(attach_ex))
|
print("Got exception node2", smaller_exception(attach_ex))
|
||||||
print("Got exception node2", smaller_exception(ex))
|
print("Got exception node2", smaller_exception(ex))
|
||||||
@ -103,12 +104,12 @@ def test_blocade_leader(started_cluster):
|
|||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node3.query("SYSTEM RESTART REPLICA t1")
|
node3.query("SYSTEM RESTART REPLICA ordinary.t1")
|
||||||
node3.query("INSERT INTO t1 SELECT rand() FROM numbers(100)")
|
node3.query("INSERT INTO ordinary.t1 SELECT rand() FROM numbers(100)")
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
try:
|
try:
|
||||||
node3.query("ATTACH TABLE t1")
|
node3.query("ATTACH TABLE ordinary.t1")
|
||||||
except Exception as attach_ex:
|
except Exception as attach_ex:
|
||||||
print("Got exception node3", smaller_exception(attach_ex))
|
print("Got exception node3", smaller_exception(attach_ex))
|
||||||
print("Got exception node3", smaller_exception(ex))
|
print("Got exception node3", smaller_exception(ex))
|
||||||
@ -121,11 +122,11 @@ def test_blocade_leader(started_cluster):
|
|||||||
for n, node in enumerate([node1, node2, node3]):
|
for n, node in enumerate([node1, node2, node3]):
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node.query("SYSTEM RESTART REPLICA t1")
|
node.query("SYSTEM RESTART REPLICA ordinary.t1")
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
try:
|
try:
|
||||||
node.query("ATTACH TABLE t1")
|
node.query("ATTACH TABLE ordinary.t1")
|
||||||
except Exception as attach_ex:
|
except Exception as attach_ex:
|
||||||
print("Got exception node{}".format(n + 1), smaller_exception(attach_ex))
|
print("Got exception node{}".format(n + 1), smaller_exception(attach_ex))
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ def test_blocade_leader(started_cluster):
|
|||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node1.query("INSERT INTO t1 SELECT rand() FROM numbers(100)")
|
node1.query("INSERT INTO ordinary.t1 SELECT rand() FROM numbers(100)")
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print("Got exception node1", smaller_exception(ex))
|
print("Got exception node1", smaller_exception(ex))
|
||||||
@ -149,12 +150,12 @@ def test_blocade_leader(started_cluster):
|
|||||||
for n, node in enumerate([node1, node2, node3]):
|
for n, node in enumerate([node1, node2, node3]):
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node.query("SYSTEM RESTART REPLICA t1")
|
node.query("SYSTEM RESTART REPLICA ordinary.t1")
|
||||||
node.query("SYSTEM SYNC REPLICA t1", timeout=10)
|
node.query("SYSTEM SYNC REPLICA ordinary.t1", timeout=10)
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
try:
|
try:
|
||||||
node.query("ATTACH TABLE t1")
|
node.query("ATTACH TABLE ordinary.t1")
|
||||||
except Exception as attach_ex:
|
except Exception as attach_ex:
|
||||||
print("Got exception node{}".format(n + 1), smaller_exception(attach_ex))
|
print("Got exception node{}".format(n + 1), smaller_exception(attach_ex))
|
||||||
|
|
||||||
@ -165,13 +166,13 @@ def test_blocade_leader(started_cluster):
|
|||||||
dump_zk(node, '/clickhouse/t1', '/clickhouse/t1/replicas/{}'.format(num + 1))
|
dump_zk(node, '/clickhouse/t1', '/clickhouse/t1/replicas/{}'.format(num + 1))
|
||||||
assert False, "Cannot sync replica node{}".format(n+1)
|
assert False, "Cannot sync replica node{}".format(n+1)
|
||||||
|
|
||||||
if node1.query("SELECT COUNT() FROM t1") != "310\n":
|
if node1.query("SELECT COUNT() FROM ordinary.t1") != "310\n":
|
||||||
for num, node in enumerate([node1, node2, node3]):
|
for num, node in enumerate([node1, node2, node3]):
|
||||||
dump_zk(node, '/clickhouse/t1', '/clickhouse/t1/replicas/{}'.format(num + 1))
|
dump_zk(node, '/clickhouse/t1', '/clickhouse/t1/replicas/{}'.format(num + 1))
|
||||||
|
|
||||||
assert node1.query("SELECT COUNT() FROM t1") == "310\n"
|
assert node1.query("SELECT COUNT() FROM ordinary.t1") == "310\n"
|
||||||
assert node2.query("SELECT COUNT() FROM t1") == "310\n"
|
assert node2.query("SELECT COUNT() FROM ordinary.t1") == "310\n"
|
||||||
assert node3.query("SELECT COUNT() FROM t1") == "310\n"
|
assert node3.query("SELECT COUNT() FROM ordinary.t1") == "310\n"
|
||||||
|
|
||||||
|
|
||||||
def dump_zk(node, zk_path, replica_path):
|
def dump_zk(node, zk_path, replica_path):
|
||||||
@ -192,16 +193,17 @@ def dump_zk(node, zk_path, replica_path):
|
|||||||
def test_blocade_leader_twice(started_cluster):
|
def test_blocade_leader_twice(started_cluster):
|
||||||
wait_nodes()
|
wait_nodes()
|
||||||
for i, node in enumerate([node1, node2, node3]):
|
for i, node in enumerate([node1, node2, node3]):
|
||||||
node.query("CREATE TABLE t2 (value UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/t2', '{}') ORDER BY tuple()".format(i + 1))
|
node.query("CREATE DATABASE IF NOT EXISTS ordinary ENGINE=Ordinary")
|
||||||
|
node.query("CREATE TABLE ordinary.t2 (value UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/t2', '{}') ORDER BY tuple()".format(i + 1))
|
||||||
|
|
||||||
node2.query("INSERT INTO t2 SELECT number FROM numbers(10)")
|
node2.query("INSERT INTO ordinary.t2 SELECT number FROM numbers(10)")
|
||||||
|
|
||||||
node1.query("SYSTEM SYNC REPLICA t2", timeout=10)
|
node1.query("SYSTEM SYNC REPLICA ordinary.t2", timeout=10)
|
||||||
node3.query("SYSTEM SYNC REPLICA t2", timeout=10)
|
node3.query("SYSTEM SYNC REPLICA ordinary.t2", timeout=10)
|
||||||
|
|
||||||
assert node1.query("SELECT COUNT() FROM t2") == "10\n"
|
assert node1.query("SELECT COUNT() FROM ordinary.t2") == "10\n"
|
||||||
assert node2.query("SELECT COUNT() FROM t2") == "10\n"
|
assert node2.query("SELECT COUNT() FROM ordinary.t2") == "10\n"
|
||||||
assert node3.query("SELECT COUNT() FROM t2") == "10\n"
|
assert node3.query("SELECT COUNT() FROM ordinary.t2") == "10\n"
|
||||||
|
|
||||||
with PartitionManager() as pm:
|
with PartitionManager() as pm:
|
||||||
pm.partition_instances(node2, node1)
|
pm.partition_instances(node2, node1)
|
||||||
@ -209,12 +211,12 @@ def test_blocade_leader_twice(started_cluster):
|
|||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node2.query("SYSTEM RESTART REPLICA t2")
|
node2.query("SYSTEM RESTART REPLICA ordinary.t2")
|
||||||
node2.query("INSERT INTO t2 SELECT rand() FROM numbers(100)")
|
node2.query("INSERT INTO ordinary.t2 SELECT rand() FROM numbers(100)")
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
try:
|
try:
|
||||||
node2.query("ATTACH TABLE t2")
|
node2.query("ATTACH TABLE ordinary.t2")
|
||||||
except Exception as attach_ex:
|
except Exception as attach_ex:
|
||||||
print("Got exception node2", smaller_exception(attach_ex))
|
print("Got exception node2", smaller_exception(attach_ex))
|
||||||
print("Got exception node2", smaller_exception(ex))
|
print("Got exception node2", smaller_exception(ex))
|
||||||
@ -226,12 +228,12 @@ def test_blocade_leader_twice(started_cluster):
|
|||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node3.query("SYSTEM RESTART REPLICA t2")
|
node3.query("SYSTEM RESTART REPLICA ordinary.t2")
|
||||||
node3.query("INSERT INTO t2 SELECT rand() FROM numbers(100)")
|
node3.query("INSERT INTO ordinary.t2 SELECT rand() FROM numbers(100)")
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
try:
|
try:
|
||||||
node3.query("ATTACH TABLE t2")
|
node3.query("ATTACH TABLE ordinary.t2")
|
||||||
except Exception as attach_ex:
|
except Exception as attach_ex:
|
||||||
print("Got exception node3", smaller_exception(attach_ex))
|
print("Got exception node3", smaller_exception(attach_ex))
|
||||||
print("Got exception node3", smaller_exception(ex))
|
print("Got exception node3", smaller_exception(ex))
|
||||||
@ -247,14 +249,14 @@ def test_blocade_leader_twice(started_cluster):
|
|||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
try:
|
try:
|
||||||
node3.query("INSERT INTO t2 SELECT rand() FROM numbers(100)")
|
node3.query("INSERT INTO ordinary.t2 SELECT rand() FROM numbers(100)")
|
||||||
assert False, "Node3 became leader?"
|
assert False, "Node3 became leader?"
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
try:
|
try:
|
||||||
node2.query("INSERT INTO t2 SELECT rand() FROM numbers(100)")
|
node2.query("INSERT INTO ordinary.t2 SELECT rand() FROM numbers(100)")
|
||||||
assert False, "Node2 became leader?"
|
assert False, "Node2 became leader?"
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
@ -263,11 +265,11 @@ def test_blocade_leader_twice(started_cluster):
|
|||||||
for n, node in enumerate([node1, node2, node3]):
|
for n, node in enumerate([node1, node2, node3]):
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node.query("SYSTEM RESTART REPLICA t2")
|
node.query("SYSTEM RESTART REPLICA ordinary.t2")
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
try:
|
try:
|
||||||
node.query("ATTACH TABLE t2")
|
node.query("ATTACH TABLE ordinary.t2")
|
||||||
except Exception as attach_ex:
|
except Exception as attach_ex:
|
||||||
print("Got exception node{}".format(n + 1), smaller_exception(attach_ex))
|
print("Got exception node{}".format(n + 1), smaller_exception(attach_ex))
|
||||||
|
|
||||||
@ -281,7 +283,7 @@ def test_blocade_leader_twice(started_cluster):
|
|||||||
for n, node in enumerate([node1, node2, node3]):
|
for n, node in enumerate([node1, node2, node3]):
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node.query("INSERT INTO t2 SELECT rand() FROM numbers(100)")
|
node.query("INSERT INTO ordinary.t2 SELECT rand() FROM numbers(100)")
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print("Got exception node{}".format(n + 1), smaller_exception(ex))
|
print("Got exception node{}".format(n + 1), smaller_exception(ex))
|
||||||
@ -294,12 +296,12 @@ def test_blocade_leader_twice(started_cluster):
|
|||||||
for n, node in enumerate([node1, node2, node3]):
|
for n, node in enumerate([node1, node2, node3]):
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
try:
|
try:
|
||||||
node.query("SYSTEM RESTART REPLICA t2")
|
node.query("SYSTEM RESTART REPLICA ordinary.t2")
|
||||||
node.query("SYSTEM SYNC REPLICA t2", timeout=10)
|
node.query("SYSTEM SYNC REPLICA ordinary.t2", timeout=10)
|
||||||
break
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
try:
|
try:
|
||||||
node.query("ATTACH TABLE t2")
|
node.query("ATTACH TABLE ordinary.t2")
|
||||||
except Exception as attach_ex:
|
except Exception as attach_ex:
|
||||||
print("Got exception node{}".format(n + 1), smaller_exception(attach_ex))
|
print("Got exception node{}".format(n + 1), smaller_exception(attach_ex))
|
||||||
|
|
||||||
@ -310,10 +312,10 @@ def test_blocade_leader_twice(started_cluster):
|
|||||||
dump_zk(node, '/clickhouse/t2', '/clickhouse/t2/replicas/{}'.format(num + 1))
|
dump_zk(node, '/clickhouse/t2', '/clickhouse/t2/replicas/{}'.format(num + 1))
|
||||||
assert False, "Cannot reconnect for node{}".format(n + 1)
|
assert False, "Cannot reconnect for node{}".format(n + 1)
|
||||||
|
|
||||||
assert node1.query("SELECT COUNT() FROM t2") == "510\n"
|
assert node1.query("SELECT COUNT() FROM ordinary.t2") == "510\n"
|
||||||
if node2.query("SELECT COUNT() FROM t2") != "510\n":
|
if node2.query("SELECT COUNT() FROM ordinary.t2") != "510\n":
|
||||||
for num, node in enumerate([node1, node2, node3]):
|
for num, node in enumerate([node1, node2, node3]):
|
||||||
dump_zk(node, '/clickhouse/t2', '/clickhouse/t2/replicas/{}'.format(num + 1))
|
dump_zk(node, '/clickhouse/t2', '/clickhouse/t2/replicas/{}'.format(num + 1))
|
||||||
|
|
||||||
assert node2.query("SELECT COUNT() FROM t2") == "510\n"
|
assert node2.query("SELECT COUNT() FROM ordinary.t2") == "510\n"
|
||||||
assert node3.query("SELECT COUNT() FROM t2") == "510\n"
|
assert node3.query("SELECT COUNT() FROM ordinary.t2") == "510\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user