mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-19 21:03:51 +00:00
RMV: fix tests with replicated db
This commit is contained in:
parent
610ee9e2c9
commit
eb42bbbf74
@ -186,6 +186,7 @@ def csv_compare(result, expected):
|
|||||||
|
|
||||||
def wait_condition(func, condition, max_attempts=10, delay=0.1):
|
def wait_condition(func, condition, max_attempts=10, delay=0.1):
|
||||||
attempts = 0
|
attempts = 0
|
||||||
|
result = None
|
||||||
while attempts < max_attempts:
|
while attempts < max_attempts:
|
||||||
result = func()
|
result = func()
|
||||||
if condition(result):
|
if condition(result):
|
||||||
@ -194,4 +195,6 @@ def wait_condition(func, condition, max_attempts=10, delay=0.1):
|
|||||||
if attempts < max_attempts:
|
if attempts < max_attempts:
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
|
|
||||||
raise Exception(f"Function did not satisfy condition after {max_attempts} attempts")
|
raise Exception(
|
||||||
|
f"Function did not satisfy condition after {max_attempts} attempts. Last result:\n{result}"
|
||||||
|
)
|
||||||
|
@ -377,8 +377,8 @@ def test_real_wait_refresh(
|
|||||||
"test_rmv",
|
"test_rmv",
|
||||||
condition=lambda x: x["last_refresh_time"] == rmv["next_refresh_time"],
|
condition=lambda x: x["last_refresh_time"] == rmv["next_refresh_time"],
|
||||||
# wait for refresh a little bit more than 10 seconds
|
# wait for refresh a little bit more than 10 seconds
|
||||||
max_attempts=12,
|
max_attempts=30,
|
||||||
delay=1,
|
delay=0.5,
|
||||||
)
|
)
|
||||||
|
|
||||||
if append:
|
if append:
|
||||||
|
@ -221,13 +221,19 @@ def fn_setup_tables():
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"select_query",
|
"select_query",
|
||||||
[
|
[
|
||||||
"SELECT now() as a, number as b FROM numbers(2)",
|
"SELECT now() as a, number as b FROM numbers(2) SETTINGS insert_deduplicate=0",
|
||||||
"SELECT now() as a, b as b FROM src1",
|
"SELECT now() as a, b as b FROM src1 SETTINGS insert_deduplicate=0",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@pytest.mark.parametrize("with_append", [True, False])
|
@pytest.mark.parametrize(
|
||||||
@pytest.mark.parametrize("empty", [True, False])
|
"with_append",
|
||||||
def test_simple_append(
|
[True, False],
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"empty",
|
||||||
|
[True, False],
|
||||||
|
)
|
||||||
|
def test_append(
|
||||||
module_setup_tables,
|
module_setup_tables,
|
||||||
fn_setup_tables,
|
fn_setup_tables,
|
||||||
select_query,
|
select_query,
|
||||||
@ -247,8 +253,6 @@ def test_simple_append(
|
|||||||
rmv = get_rmv_info(node, "test_rmv", wait_status="Scheduled")
|
rmv = get_rmv_info(node, "test_rmv", wait_status="Scheduled")
|
||||||
assert rmv["exception"] is None
|
assert rmv["exception"] is None
|
||||||
|
|
||||||
node.query("SYSTEM SYNC DATABASE REPLICA ON CLUSTER default default")
|
|
||||||
|
|
||||||
records = node.query("SELECT count() FROM test_rmv")
|
records = node.query("SELECT count() FROM test_rmv")
|
||||||
|
|
||||||
if empty:
|
if empty:
|
||||||
@ -256,20 +260,13 @@ def test_simple_append(
|
|||||||
else:
|
else:
|
||||||
assert records == "2\n"
|
assert records == "2\n"
|
||||||
|
|
||||||
for n in nodes:
|
node.query(f"SYSTEM TEST VIEW test_rmv SET FAKE TIME '{rmv['next_refresh_time']}'")
|
||||||
n.query(f"SYSTEM TEST VIEW test_rmv SET FAKE TIME '{rmv['next_refresh_time']}'")
|
|
||||||
|
|
||||||
rmv2 = get_rmv_info(node, "test_rmv", wait_status="Scheduled")
|
rmv2 = get_rmv_info(node, "test_rmv", wait_status="Scheduled")
|
||||||
|
|
||||||
assert rmv2["exception"] is None
|
assert rmv2["exception"] is None
|
||||||
|
|
||||||
node.query("SYSTEM SYNC DATABASE REPLICA ON CLUSTER default default")
|
|
||||||
if empty:
|
|
||||||
expect = "2\n"
|
expect = "2\n"
|
||||||
|
|
||||||
if not with_append:
|
|
||||||
expect = "2\n"
|
|
||||||
|
|
||||||
if with_append and not empty:
|
if with_append and not empty:
|
||||||
expect = "4\n"
|
expect = "4\n"
|
||||||
|
|
||||||
@ -373,6 +370,9 @@ def test_real_wait_refresh(
|
|||||||
empty,
|
empty,
|
||||||
to_clause,
|
to_clause,
|
||||||
):
|
):
|
||||||
|
if node.is_built_with_sanitizer():
|
||||||
|
pytest.skip("Disabled for sanitizers")
|
||||||
|
|
||||||
table_clause, to_clause_, tgt = to_clause
|
table_clause, to_clause_, tgt = to_clause
|
||||||
|
|
||||||
create_sql = CREATE_RMV.render(
|
create_sql = CREATE_RMV.render(
|
||||||
@ -380,7 +380,7 @@ def test_real_wait_refresh(
|
|||||||
refresh_interval="EVERY 10 SECOND",
|
refresh_interval="EVERY 10 SECOND",
|
||||||
to_clause=to_clause_,
|
to_clause=to_clause_,
|
||||||
table_clause=table_clause,
|
table_clause=table_clause,
|
||||||
select_query="SELECT now() as a, b FROM src1",
|
select_query="SELECT now() as a, b FROM src1 SETTINGS insert_deduplicate=0",
|
||||||
with_append=append,
|
with_append=append,
|
||||||
on_cluster="default",
|
on_cluster="default",
|
||||||
empty=empty,
|
empty=empty,
|
||||||
|
Loading…
Reference in New Issue
Block a user