Skip to content

Commit

Permalink
Revert gini relaxation. Add wait_until_fully_merged.
Browse files Browse the repository at this point in the history
  • Loading branch information
amosbird committed Nov 1, 2023
1 parent c75cd61 commit e7461d1
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tests/integration/test_jbod_balancer/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest
from helpers.client import QueryRuntimeException
from helpers.cluster import ClickHouseCluster
from helpers.wait_for_helpers import wait_for_merges

cluster = ClickHouseCluster(__file__)

Expand Down Expand Up @@ -67,7 +68,7 @@ def check_balance(node, table):
partition, disk_name
)
GROUP BY partition
HAVING gini < 0.2
HAVING gini < 0.1
""".format(
table
)
Expand All @@ -76,6 +77,20 @@ def check_balance(node, table):
assert set(partitions) == set(["0", "1"])


def wait_until_fully_merged(node, table, retry=20):
for i in range(retry):
# Wait in-flight merges
wait_for_merges(node, table)

# Check if we can assign new merges
try:
node.query(f"optimize table {table} settings optimize_throw_if_noop = 1")
except e:
return

raise Exception(f"There are still merges on-going after {retry} assignments")


def test_jbod_balanced_merge(start_cluster):
try:
node1.query(
Expand Down Expand Up @@ -110,7 +125,7 @@ def task(i):

p.map(task, range(200))

time.sleep(1)
wait_until_fully_merged(node1, "tbl")

check_balance(node1, "tbl")

Expand Down Expand Up @@ -183,6 +198,8 @@ def task(i):

p.map(task, range(200))

wait_until_fully_merged(node1, "tbl")

node2.query("SYSTEM SYNC REPLICA tbl", timeout=10)

check_balance(node1, "tbl")
Expand Down

0 comments on commit e7461d1

Please sign in to comment.