Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
75735f1e
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
75735f1e
编写于
3月 25, 2020
作者:
V
Vitaly Baranov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test
上级
34984d4a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
33 addition
and
89 deletion
+33
-89
dbms/src/Interpreters/ClientInfo.h
dbms/src/Interpreters/ClientInfo.h
+0
-4
dbms/src/Storages/Distributed/DirectoryMonitor.cpp
dbms/src/Storages/Distributed/DirectoryMonitor.cpp
+2
-2
dbms/tests/integration/test_settings_constraints_distributed/configs/remote_servers.xml
...ttings_constraints_distributed/configs/remote_servers.xml
+2
-2
dbms/tests/integration/test_settings_constraints_distributed/configs/users_on_cluster.xml
...ings_constraints_distributed/configs/users_on_cluster.xml
+0
-33
dbms/tests/integration/test_settings_constraints_distributed/configs/users_on_distributed.xml
..._constraints_distributed/configs/users_on_distributed.xml
+0
-36
dbms/tests/integration/test_settings_constraints_distributed/test.py
...integration/test_settings_constraints_distributed/test.py
+29
-12
未找到文件。
dbms/src/Interpreters/ClientInfo.h
浏览文件 @
75735f1e
...
...
@@ -77,10 +77,6 @@ public:
bool
empty
()
const
{
return
query_kind
==
QueryKind
::
NO_QUERY
;
}
auto
toTuple
()
const
{
return
std
::
tie
(
current_query_id
,
initial_query_id
,
current_address
,
initial_address
,
query_kind
,
current_user
,
initial_user
,
current_password
,
interface
,
os_user
,
client_hostname
,
client_name
,
client_version_major
,
client_version_minor
,
client_version_patch
,
client_revision
,
http_method
,
http_user_agent
,
quota_key
);
}
friend
bool
operator
==
(
const
ClientInfo
&
lhs
,
const
ClientInfo
&
rhs
)
{
return
lhs
.
toTuple
()
==
rhs
.
toTuple
();
}
friend
bool
operator
!=
(
const
ClientInfo
&
lhs
,
const
ClientInfo
&
rhs
)
{
return
!
(
lhs
==
rhs
);
}
/** Serialization and deserialization.
* Only values that are not calculated automatically or passed separately are serialized.
* Revisions are passed to use format that server will understand or client was used.
...
...
dbms/src/Storages/Distributed/DirectoryMonitor.cpp
浏览文件 @
75735f1e
...
...
@@ -370,8 +370,8 @@ struct StorageDistributedDirectoryMonitor::BatchHeader
bool
operator
==
(
const
BatchHeader
&
other
)
const
{
return
settings
==
other
.
settings
&&
query
==
other
.
query
&&
client_info
==
other
.
client_info
&&
blocksHaveEqualStructure
(
sample_block
,
other
.
sample_block
);
return
settings
==
other
.
settings
&&
query
==
other
.
query
&&
client_info
.
query_kind
==
other
.
client_info
.
query_kind
&&
blocksHaveEqualStructure
(
sample_block
,
other
.
sample_block
);
}
struct
Hash
...
...
dbms/tests/integration/test_settings_constraints_distributed/configs/remote_servers.xml
浏览文件 @
75735f1e
...
...
@@ -5,14 +5,14 @@
<replica>
<host>
node1
</host>
<port>
9000
</port>
<user>
normal
</user>
<user>
shard
</user>
</replica>
</shard>
<shard>
<replica>
<host>
node2
</host>
<port>
9000
</port>
<user>
readonly
</user>
<user>
shard
</user>
</replica>
</shard>
</test_cluster>
...
...
dbms/tests/integration/test_settings_constraints_distributed/configs/users_on_cluster.xml
已删除
100644 → 0
浏览文件 @
34984d4a
<yandex>
<profiles>
<default>
</default>
<normal>
<max_memory_usage>
50000000
</max_memory_usage>
<constraints>
<max_memory_usage>
<min>
11111111
</min>
<max>
99999999
</max>
</max_memory_usage>
</constraints>
</normal>
<readonly>
<readonly>
1
</readonly>
</readonly>
</profiles>
<users>
<default>
<profile>
default
</profile>
<password></password>
</default>
<normal>
<profile>
normal
</profile>
<password></password>
</normal>
<readonly>
<profile>
readonly
</profile>
<password></password>
</readonly>
</users>
</yandex>
dbms/tests/integration/test_settings_constraints_distributed/configs/users_on_distributed.xml
已删除
100644 → 0
浏览文件 @
34984d4a
<yandex>
<profiles>
<default>
</default>
<normal>
<max_memory_usage>
80000000
</max_memory_usage>
<use_uncompressed_cache>
0
</use_uncompressed_cache>
<load_balancing>
random
</load_balancing>
</normal>
<wasteful>
<max_memory_usage>
2000000000
</max_memory_usage>
</wasteful>
<readonly>
<readonly>
1
</readonly>
</readonly>
</profiles>
<users>
<default>
<profile>
default
</profile>
<password></password>
</default>
<normal>
<profile>
normal
</profile>
<password></password>
</normal>
<wasteful>
<profile>
wasteful
</profile>
<password></password>
</wasteful>
<readonly>
<profile>
readonly
</profile>
<password></password>
</readonly>
</users>
</yandex>
dbms/tests/integration/test_settings_constraints_distributed/test.py
浏览文件 @
75735f1e
...
...
@@ -8,10 +8,9 @@ from helpers.test_tools import assert_eq_with_retry
cluster
=
ClickHouseCluster
(
__file__
)
node1
=
cluster
.
add_instance
(
'node1'
,
user_configs
=
[
'configs/users_on_cluster.xml'
])
node2
=
cluster
.
add_instance
(
'node2'
,
user_configs
=
[
'configs/users_on_cluster.xml'
])
distributed
=
cluster
.
add_instance
(
'distributed'
,
main_configs
=
[
'configs/remote_servers.xml'
],
user_configs
=
[
'configs/users_on_distributed.xml'
])
node1
=
cluster
.
add_instance
(
'node1'
)
node2
=
cluster
.
add_instance
(
'node2'
)
distributed
=
cluster
.
add_instance
(
'distributed'
,
main_configs
=
[
'configs/remote_servers.xml'
])
@
pytest
.
fixture
(
scope
=
"module"
)
...
...
@@ -20,11 +19,15 @@ def started_cluster():
cluster
.
start
()
for
node
in
[
node1
,
node2
]:
node
.
query
(
"CREATE TABLE sometable(date Date, id UInt32, value Int32) ENGINE = MergeTree() ORDER BY id;"
)
node
.
query
(
"INSERT INTO sometable VALUES (toDate('2020-01-20'), 1, 1)"
)
node
.
query
(
"CREATE TABLE sometable (date Date, id UInt32, value Int32) ENGINE = MergeTree() ORDER BY id;"
)
node
.
query
(
"INSERT INTO sometable VALUES (toDate('2010-01-10'), 1, 1)"
)
node
.
query
(
"CREATE USER shard"
)
node
.
query
(
"GRANT ALL ON *.* TO shard"
)
distributed
.
query
(
"CREATE TABLE proxy (date Date, id UInt32, value Int32) ENGINE = Distributed(test_cluster, default, sometable);"
)
distributed
.
query
(
"CREATE TABLE sysproxy (name String, value String) ENGINE = Distributed(test_cluster, system, settings);"
)
distributed
.
query
(
"CREATE TABLE proxy (date Date, id UInt32, value Int32) ENGINE = Distributed(test_cluster, default, sometable, toUInt64(date));"
)
distributed
.
query
(
"CREATE TABLE shard_settings (name String, value String) ENGINE = Distributed(test_cluster, system, settings);"
)
distributed
.
query
(
"CREATE ROLE admin"
)
distributed
.
query
(
"GRANT ALL ON *.* TO admin"
)
yield
cluster
...
...
@@ -32,7 +35,14 @@ def started_cluster():
cluster
.
shutdown
()
def
test_shard_doesnt_throw_on_constraint_violation
(
started_cluster
):
def
test_select_clamps_settings
(
started_cluster
):
distributed
.
query
(
"CREATE USER normal DEFAULT ROLE admin SETTINGS max_memory_usage = 80000000"
)
distributed
.
query
(
"CREATE USER wasteful DEFAULT ROLE admin SETTINGS max_memory_usage = 2000000000"
)
distributed
.
query
(
"CREATE USER readonly DEFAULT ROLE admin SETTINGS readonly = 1"
)
node1
.
query
(
"ALTER USER shard SETTINGS max_memory_usage = 50000000 MIN 11111111 MAX 99999999"
)
node2
.
query
(
"ALTER USER shard SETTINGS readonly = 1"
)
# Check that shards doesn't throw exceptions on constraints violation
query
=
"SELECT COUNT() FROM proxy"
assert
distributed
.
query
(
query
)
==
'2
\n
'
assert
distributed
.
query
(
query
,
user
=
'normal'
)
==
'2
\n
'
...
...
@@ -47,9 +57,8 @@ def test_shard_doesnt_throw_on_constraint_violation(started_cluster):
assert
distributed
.
query
(
query
,
user
=
'normal'
)
==
'2
\n
'
assert
distributed
.
query
(
query
,
user
=
'wasteful'
)
==
'2
\n
'
def
test_shard_clamps_settings
(
started_cluster
):
query
=
"SELECT hostName() as host, name, value FROM sysproxy WHERE name = 'max_memory_usage' OR name = 'readonly' ORDER BY host, name, value"
# Check that shards clamp passed settings.
query
=
"SELECT hostName() as host, name, value FROM shard_settings WHERE name = 'max_memory_usage' OR name = 'readonly' ORDER BY host, name, value"
assert
distributed
.
query
(
query
)
==
'node1
\t
max_memory_usage
\t
99999999
\n
'
\
'node1
\t
readonly
\t
0
\n
'
\
'node2
\t
max_memory_usage
\t
10000000000
\n
'
\
...
...
@@ -79,3 +88,11 @@ def test_shard_clamps_settings(started_cluster):
'node1
\t
readonly
\t
2
\n
'
\
'node2
\t
max_memory_usage
\t
10000000000
\n
'
\
'node2
\t
readonly
\t
1
\n
'
def
test_insert_clamps_settings
(
started_cluster
):
node1
.
query
(
"ALTER USER shard SETTINGS max_memory_usage = 50000000 MIN 11111111 MAX 99999999"
)
node2
.
query
(
"ALTER USER shard SETTINGS max_memory_usage = 50000000 MIN 11111111 MAX 99999999"
)
distributed
.
query
(
"INSERT INTO proxy VALUES (toDate('2020-02-20'), 2, 2)"
)
distributed
.
query
(
"INSERT INTO proxy VALUES (toDate('2020-02-21'), 2, 2)"
,
settings
=
{
"max_memory_usage"
:
5000000
})
assert
distributed
.
query
(
"SELECT COUNT() FROM proxy"
)
==
"4
\n
"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录