Fix flaky tests.

This commit is contained in:
Vitaly Baranov 2021-03-30 18:13:25 +03:00
parent 6acb9bc827
commit 2162a19d35
2 changed files with 30 additions and 23 deletions

View File

@ -372,6 +372,7 @@ def test_dcl_management():
def test_users_xml_is_readonly():
assert re.search("storage is readonly", instance.query_and_get_error("DROP QUOTA myQuota"))
def test_query_inserts():
check_system_quotas([["myQuota", "e651da9c-a748-8703-061a-7e5e5096dae7", "users.xml", "['user_name']", [31556952],
0, "['default']", "[]"]])
@ -380,9 +381,16 @@ def test_query_inserts():
system_quotas_usage(
[["myQuota", "default", 1, 31556952, 0, 1000, 0, 500, 0, 500, 0, "\\N", 0, "\\N", 0, "\\N", 0, 1000, 0, "\\N", "\\N"]])
instance.query("INSERT INTO test_table values(1)")
instance.query("DROP TABLE IF EXISTS test_table_ins")
instance.query("CREATE TABLE test_table_ins(x UInt32) ENGINE = MergeTree ORDER BY tuple()")
system_quota_usage(
[["myQuota", "default", 31556952, 1, 1000, 0, 500, 1, 500, 0, "\\N", 0, "\\N", 0, "\\N", 0, 1000, 0, "\\N", "\\N"]])
[["myQuota", "default", 31556952, 2, 1000, 0, 500, 0, 500, 0, "\\N", 0, "\\N", 0, "\\N", 0, 1000, 0, "\\N", "\\N"]])
instance.query("INSERT INTO test_table_ins values(1)")
system_quota_usage(
[["myQuota", "default", 31556952, 3, 1000, 0, 500, 1, 500, 0, "\\N", 0, "\\N", 0, "\\N", 0, 1000, 0, "\\N", "\\N"]])
instance.query("DROP TABLE test_table_ins")
def test_consumption_of_show_tables():
assert instance.query("SHOW TABLES") == "test_table\n"

View File

@ -409,32 +409,31 @@ def test_tags_with_db_and_table_names():
def test_miscellaneous_engines():
copy_policy_xml('normal_filters.xml')
node.query("CREATE ROW POLICY OR REPLACE pC ON mydb.other_table FOR SELECT USING a = 1 TO default")
assert node.query("SHOW ROW POLICIES ON mydb.other_table") == "pC\n"
# ReplicatedMergeTree
node.query("DROP TABLE mydb.filtered_table1")
node.query(
"CREATE TABLE mydb.filtered_table1 (a UInt8, b UInt8) ENGINE ReplicatedMergeTree('/clickhouse/tables/00-00/filtered_table1', 'replica1') ORDER BY a")
node.query("INSERT INTO mydb.filtered_table1 values (0, 0), (0, 1), (1, 0), (1, 1)")
assert node.query("SELECT * FROM mydb.filtered_table1") == TSV([[1, 0], [1, 1]])
node.query("DROP TABLE IF EXISTS mydb.other_table")
node.query("CREATE TABLE mydb.other_table (a UInt8, b UInt8) ENGINE ReplicatedMergeTree('/clickhouse/tables/00-00/filtered_table1', 'replica1') ORDER BY a")
node.query("INSERT INTO mydb.other_table values (0, 0), (0, 1), (1, 0), (1, 1)")
assert node.query("SELECT * FROM mydb.other_table") == TSV([[1, 0], [1, 1]])
# CollapsingMergeTree
node.query("DROP TABLE mydb.filtered_table1")
node.query("CREATE TABLE mydb.filtered_table1 (a UInt8, b Int8) ENGINE CollapsingMergeTree(b) ORDER BY a")
node.query("INSERT INTO mydb.filtered_table1 values (0, 1), (0, 1), (1, 1), (1, 1)")
assert node.query("SELECT * FROM mydb.filtered_table1") == TSV([[1, 1], [1, 1]])
node.query("DROP TABLE mydb.other_table")
node.query("CREATE TABLE mydb.other_table (a UInt8, b Int8) ENGINE CollapsingMergeTree(b) ORDER BY a")
node.query("INSERT INTO mydb.other_table values (0, 1), (0, 1), (1, 1), (1, 1)")
assert node.query("SELECT * FROM mydb.other_table") == TSV([[1, 1], [1, 1]])
# ReplicatedCollapsingMergeTree
node.query("DROP TABLE mydb.filtered_table1")
node.query(
"CREATE TABLE mydb.filtered_table1 (a UInt8, b Int8) ENGINE ReplicatedCollapsingMergeTree('/clickhouse/tables/00-01/filtered_table1', 'replica1', b) ORDER BY a")
node.query("INSERT INTO mydb.filtered_table1 values (0, 1), (0, 1), (1, 1), (1, 1)")
assert node.query("SELECT * FROM mydb.filtered_table1") == TSV([[1, 1], [1, 1]])
node.query("DROP TABLE mydb.other_table")
node.query("CREATE TABLE mydb.other_table (a UInt8, b Int8) ENGINE ReplicatedCollapsingMergeTree('/clickhouse/tables/00-01/filtered_table1', 'replica1', b) ORDER BY a")
node.query("INSERT INTO mydb.other_table values (0, 1), (0, 1), (1, 1), (1, 1)")
assert node.query("SELECT * FROM mydb.other_table") == TSV([[1, 1], [1, 1]])
node.query("DROP ROW POLICY pC ON mydb.other_table")
# DistributedMergeTree
node.query("DROP TABLE IF EXISTS mydb.not_filtered_table")
node.query(
"CREATE TABLE mydb.not_filtered_table (a UInt8, b UInt8) ENGINE Distributed('test_local_cluster', mydb, local)")
assert node.query("SELECT * FROM mydb.not_filtered_table", user="another") == TSV([[1, 0], [1, 1], [1, 0], [1, 1]])
assert node.query("SELECT sum(a), b FROM mydb.not_filtered_table GROUP BY b ORDER BY b", user="another") == TSV(
[[2, 0], [2, 1]])
node.query("DROP TABLE IF EXISTS mydb.other_table")
node.query("CREATE TABLE mydb.other_table (a UInt8, b UInt8) ENGINE Distributed('test_local_cluster', mydb, local)")
assert node.query("SELECT * FROM mydb.other_table", user="another") == TSV([[1, 0], [1, 1], [1, 0], [1, 1]])
assert node.query("SELECT sum(a), b FROM mydb.other_table GROUP BY b ORDER BY b", user="another") == TSV([[2, 0], [2, 1]])