mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge branch 'debug/test_concurrent_ttl_merges' of https://github.com/qoega/ClickHouse into fix_flaky_test_multiple_ttl
This commit is contained in:
commit
4a6aef5421
@ -38,6 +38,9 @@ class TSV:
|
||||
def __str__(self):
|
||||
return '\n'.join(self.lines)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.lines)
|
||||
|
||||
@staticmethod
|
||||
def toMat(contents):
|
||||
return [line.split("\t") for line in contents.split("\n") if line.strip()]
|
||||
|
@ -2,7 +2,7 @@ import time
|
||||
|
||||
import pytest
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
from helpers.test_tools import assert_eq_with_retry
|
||||
from helpers.test_tools import assert_eq_with_retry, TSV
|
||||
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
node1 = cluster.add_instance('node1', main_configs=['configs/fast_background_pool.xml', 'configs/log_conf.xml'], with_zookeeper=True)
|
||||
@ -28,12 +28,13 @@ def count_ttl_merges_in_queue(node, table):
|
||||
return int(result.strip())
|
||||
|
||||
|
||||
def count_ttl_merges_in_background_pool(node, table):
|
||||
result = node.query(
|
||||
"SELECT count() FROM system.merges WHERE merge_type = 'TTL_DELETE' and table = '{}'".format(table))
|
||||
if not result:
|
||||
return 0
|
||||
return int(result.strip())
|
||||
def count_ttl_merges_in_background_pool(node, table, level):
|
||||
result = TSV(node.query(
|
||||
"SELECT * FROM system.merges WHERE merge_type = 'TTL_DELETE' and table = '{}'".format(table)))
|
||||
count = len(result)
|
||||
if count >= level:
|
||||
print("count_ttl_merges_in_background_pool: merges more than warn level:\n{}".format(result))
|
||||
return count
|
||||
|
||||
|
||||
def count_regular_merges_in_background_pool(node, table):
|
||||
@ -67,7 +68,7 @@ def test_no_ttl_merges_in_busy_pool(started_cluster):
|
||||
|
||||
while count_running_mutations(node1, "test_ttl") < 6:
|
||||
print("Mutations count", count_running_mutations(node1, "test_ttl"))
|
||||
assert count_ttl_merges_in_background_pool(node1, "test_ttl") == 0
|
||||
assert count_ttl_merges_in_background_pool(node1, "test_ttl", 1) == 0
|
||||
time.sleep(0.5)
|
||||
|
||||
node1.query("SYSTEM START TTL MERGES")
|
||||
@ -100,7 +101,7 @@ def test_limited_ttl_merges_in_empty_pool(started_cluster):
|
||||
|
||||
merges_with_ttl_count = set({})
|
||||
while True:
|
||||
merges_with_ttl_count.add(count_ttl_merges_in_background_pool(node1, "test_ttl_v2"))
|
||||
merges_with_ttl_count.add(count_ttl_merges_in_background_pool(node1, "test_ttl_v2", 3))
|
||||
time.sleep(0.01)
|
||||
if node1.query("SELECT COUNT() FROM test_ttl_v2") == "0\n":
|
||||
break
|
||||
@ -124,7 +125,7 @@ def test_limited_ttl_merges_in_empty_pool_replicated(started_cluster):
|
||||
merges_with_ttl_count = set({})
|
||||
entries_with_ttl_count = set({})
|
||||
while True:
|
||||
merges_with_ttl_count.add(count_ttl_merges_in_background_pool(node1, "replicated_ttl"))
|
||||
merges_with_ttl_count.add(count_ttl_merges_in_background_pool(node1, "replicated_ttl", 3))
|
||||
entries_with_ttl_count.add(count_ttl_merges_in_queue(node1, "replicated_ttl"))
|
||||
time.sleep(0.01)
|
||||
if node1.query("SELECT COUNT() FROM replicated_ttl") == "0\n":
|
||||
@ -159,8 +160,8 @@ def test_limited_ttl_merges_two_replicas(started_cluster):
|
||||
merges_with_ttl_count_node1 = set({})
|
||||
merges_with_ttl_count_node2 = set({})
|
||||
while True:
|
||||
merges_with_ttl_count_node1.add(count_ttl_merges_in_background_pool(node1, "replicated_ttl_2"))
|
||||
merges_with_ttl_count_node2.add(count_ttl_merges_in_background_pool(node2, "replicated_ttl_2"))
|
||||
merges_with_ttl_count_node1.add(count_ttl_merges_in_background_pool(node1, "replicated_ttl_2", 3))
|
||||
merges_with_ttl_count_node2.add(count_ttl_merges_in_background_pool(node2, "replicated_ttl_2", 3))
|
||||
if node1.query("SELECT COUNT() FROM replicated_ttl_2") == "0\n" and node2.query(
|
||||
"SELECT COUNT() FROM replicated_ttl_2") == "0\n":
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user