Add a test with negative priority in test_distributed_load_balancing

This commit is contained in:
Azat Khuzhin 2020-06-30 11:09:06 +03:00
parent 3395276748
commit 0eb9c8e430
2 changed files with 35 additions and 2 deletions

View File

@ -27,6 +27,7 @@
<replica>
<host>n2</host>
<port>9000</port>
<!-- will not be quieried, if n1 and n3 has errors_count == 0 -->
<!-- <priority>1</priority> -->
</replica>
<replica>
@ -37,6 +38,27 @@
</shard>
</replicas_priority_cluster>
<replicas_priority_negative_cluster>
<shard>
<replica>
<host>n1</host>
<port>9000</port>
<priority>-1</priority>
</replica>
<replica>
<host>n2</host>
<port>9000</port>
<!-- will not be quieried, if n1 and n3 has errors_count == 0 -->
<priority>0</priority>
</replica>
<replica>
<host>n3</host>
<port>9000</port>
<priority>-1</priority>
</replica>
</shard>
</replicas_priority_negative_cluster>
<!-- For JOIN with system.clusters -->
<shards_cluster>
<node>

View File

@ -50,6 +50,13 @@ def bootstrap():
currentDatabase(),
data)
""".format())
n.query("""
CREATE TABLE dist_priority_negative AS data
Engine=Distributed(
replicas_priority_negative_cluster,
currentDatabase(),
data)
""".format())
def make_uuid():
return uuid.uuid4().hex
@ -134,10 +141,14 @@ def test_load_balancing_round_robin():
assert len(unique_nodes) == nodes, unique_nodes
assert unique_nodes == set(['n1', 'n2', 'n3'])
def test_load_balancing_priority_round_robin():
@pytest.mark.parametrize('dist_table', [
('dist_priority'),
('dist_priority_negative'),
])
def test_load_balancing_priority_round_robin(dist_table):
unique_nodes = set()
for _ in range(0, nodes):
unique_nodes.add(get_node(n1, 'dist_priority', settings={'load_balancing': 'round_robin'}))
unique_nodes.add(get_node(n1, dist_table, settings={'load_balancing': 'round_robin'}))
assert len(unique_nodes) == 2, unique_nodes
# n2 has bigger priority in config
assert unique_nodes == set(['n1', 'n3'])