Fix test_distributed_inter_server_secret under ASAN

And also cover both cases:
- settings from DDL
- settings from TCP protocol
This commit is contained in:
Azat Khuzhin 2020-10-03 11:01:59 +03:00
parent f25c1742b8
commit 84583faa43

View File

@ -79,6 +79,20 @@ def get_query_user_info(node, query_pattern):
type = 'QueryFinish'
""".format(query_pattern)).strip().split('\t')
# @return -- settings
def get_query_setting_on_shard(node, query_pattern, setting):
node.query("SYSTEM FLUSH LOGS")
return node.query("""
SELECT (arrayFilter(x -> ((x.1) = '{}'), arrayZip(Settings.Names, Settings.Values))[1]).2
FROM system.query_log
WHERE
query LIKE '%{}%' AND
NOT is_initial_query AND
query NOT LIKE '%system.query_log%' AND
type = 'QueryFinish'
LIMIT 1
""".format(setting, query_pattern)).strip()
def test_insecure():
n1.query('SELECT * FROM dist_insecure')
@ -149,28 +163,45 @@ def test_user_secure_cluster(user, password):
assert get_query_user_info(n1, id_) == [user, user]
assert get_query_user_info(n2, id_) == [user, user]
# settings in the protocol cannot be used since they will be applied to early
# and it will not even enter execution of distributed query
@users
def test_per_user_settings_insecure_cluster(user, password):
id_ = 'query-settings-dist_insecure-' + user
def test_per_user_inline_settings_insecure_cluster(user, password):
id_ = 'query-ddl-settings-dist_insecure-' + user
query_with_id(n1, id_, """
SELECT * FROM dist_insecure
SETTINGS
prefer_localhost_replica=0,
max_memory_usage_for_user=100,
max_memory_usage_for_user=1e9,
max_untracked_memory=0
""", user=user, password=password)
assert get_query_setting_on_shard(n1, id_, 'max_memory_usage_for_user') == ''
@users
def test_per_user_settings_secure_cluster(user, password):
id_ = 'query-settings-dist_secure-' + user
with pytest.raises(QueryRuntimeException):
query_with_id(n1, id_, """
SELECT * FROM dist_secure
SETTINGS
prefer_localhost_replica=0,
max_memory_usage_for_user=100,
max_untracked_memory=0
""", user=user, password=password)
def test_per_user_inline_settings_secure_cluster(user, password):
id_ = 'query-ddl-settings-dist_secure-' + user
query_with_id(n1, id_, """
SELECT * FROM dist_secure
SETTINGS
prefer_localhost_replica=0,
max_memory_usage_for_user=1e9,
max_untracked_memory=0
""", user=user, password=password)
assert int(get_query_setting_on_shard(n1, id_, 'max_memory_usage_for_user')) == int(1e9)
@users
def test_per_user_protocol_settings_insecure_cluster(user, password):
id_ = 'query-protocol-settings-dist_insecure-' + user
query_with_id(n1, id_, 'SELECT * FROM dist_insecure', user=user, password=password, settings={
'prefer_localhost_replica': 0,
'max_memory_usage_for_user': int(1e9),
'max_untracked_memory': 0,
})
assert get_query_setting_on_shard(n1, id_, 'max_memory_usage_for_user') == ''
@users
def test_per_user_protocol_settings_secure_cluster(user, password):
id_ = 'query-protocol-settings-dist_secure-' + user
query_with_id(n1, id_, 'SELECT * FROM dist_secure', user=user, password=password, settings={
'prefer_localhost_replica': 0,
'max_memory_usage_for_user': int(1e9),
'max_untracked_memory': 0,
})
assert int(get_query_setting_on_shard(n1, id_, 'max_memory_usage_for_user')) == int(1e9)
# TODO: check user for INSERT