Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
7c37450c
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,发现更多精彩内容 >>
提交
7c37450c
编写于
8月 01, 2019
作者:
A
alesapin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Better code and tests
上级
5b4b8754
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
10 deletion
+40
-10
dbms/src/Common/ErrorCodes.cpp
dbms/src/Common/ErrorCodes.cpp
+1
-0
dbms/src/Core/SettingsCommon.cpp
dbms/src/Core/SettingsCommon.cpp
+20
-5
dbms/tests/integration/test_replica_can_become_leader/configs/notleader.xml
...tion/test_replica_can_become_leader/configs/notleader.xml
+1
-1
dbms/tests/integration/test_replica_can_become_leader/configs/notleaderignorecase.xml
...replica_can_become_leader/configs/notleaderignorecase.xml
+5
-0
dbms/tests/integration/test_replica_can_become_leader/test.py
.../tests/integration/test_replica_can_become_leader/test.py
+13
-4
未找到文件。
dbms/src/Common/ErrorCodes.cpp
浏览文件 @
7c37450c
...
...
@@ -441,6 +441,7 @@ namespace ErrorCodes
extern
const
int
CANNOT_PARSE_ELF
=
464
;
extern
const
int
CANNOT_PARSE_DWARF
=
465
;
extern
const
int
INSECURE_PATH
=
466
;
extern
const
int
CANNOT_PARSE_BOOL
=
467
;
extern
const
int
KEEPER_EXCEPTION
=
999
;
extern
const
int
POCO_EXCEPTION
=
1000
;
...
...
dbms/src/Core/SettingsCommon.cpp
浏览文件 @
7c37450c
...
...
@@ -4,6 +4,7 @@
#include <Common/getNumberOfPhysicalCPUCores.h>
#include <Common/FieldVisitors.h>
#include <IO/ReadHelpers.h>
#include <IO/ReadBufferFromString.h>
#include <IO/WriteHelpers.h>
...
...
@@ -26,6 +27,7 @@ namespace ErrorCodes
extern
const
int
SIZE_OF_FIXED_STRING_DOESNT_MATCH
;
extern
const
int
BAD_ARGUMENTS
;
extern
const
int
UNKNOWN_SETTING
;
extern
const
int
CANNOT_PARSE_BOOL
;
}
...
...
@@ -66,12 +68,25 @@ void SettingNumber<Type>::set(const String & x)
template
<
>
void
SettingNumber
<
bool
>::
set
(
const
String
&
x
)
{
if
(
x
==
"false"
)
set
(
false
);
else
if
(
x
==
"true"
)
set
(
true
);
if
(
x
.
size
()
==
1
)
{
if
(
x
[
0
]
==
'0'
)
set
(
false
);
else
if
(
x
[
0
]
==
'1'
)
set
(
true
);
else
throw
Exception
(
"Cannot parse bool from string '"
+
x
+
"'"
,
ErrorCodes
::
CANNOT_PARSE_BOOL
);
}
else
set
(
parse
<
bool
>
(
x
));
{
ReadBufferFromString
buf
(
x
);
if
(
checkStringCaseInsensitive
(
"true"
,
buf
))
set
(
true
);
else
if
(
checkStringCaseInsensitive
(
"false"
,
buf
))
set
(
false
);
else
throw
Exception
(
"Cannot parse bool from string '"
+
x
+
"'"
,
ErrorCodes
::
CANNOT_PARSE_BOOL
);
}
}
template
<
typename
Type
>
...
...
dbms/tests/integration/test_replica_can_become_leader/configs/notleader.xml
浏览文件 @
7c37450c
<yandex>
<merge_tree>
<replicated_can_become_leader>
false
</replicated_can_become_leader>
<replicated_can_become_leader>
0
</replicated_can_become_leader>
</merge_tree>
</yandex>
dbms/tests/integration/test_replica_can_become_leader/configs/notleaderignorecase.xml
0 → 100644
浏览文件 @
7c37450c
<yandex>
<merge_tree>
<replicated_can_become_leader>
FAlse
</replicated_can_become_leader>
</merge_tree>
</yandex>
dbms/tests/integration/test_replica_can_become_leader/test.py
浏览文件 @
7c37450c
import
pytest
from
helpers.cluster
import
ClickHouseCluster
from
helpers.client
import
QueryRuntimeException
cluster
=
ClickHouseCluster
(
__file__
)
node1
=
cluster
.
add_instance
(
'node1'
,
main_configs
=
[
'configs/notleader.xml'
],
with_zookeeper
=
True
)
node2
=
cluster
.
add_instance
(
'node2'
,
with_zookeeper
=
True
)
node2
=
cluster
.
add_instance
(
'node2'
,
main_configs
=
[
'configs/notleaderignorecase.xml'
],
with_zookeeper
=
True
)
node3
=
cluster
.
add_instance
(
'node3'
,
with_zookeeper
=
True
)
@
pytest
.
fixture
(
scope
=
"module"
)
...
...
@@ -12,7 +13,7 @@ def start_cluster():
try
:
cluster
.
start
()
for
i
,
node
in
enumerate
((
node1
,
node2
,
node3
)):
for
i
,
node
in
enumerate
((
node1
,
node2
)):
node
.
query
(
'''
CREATE TABLE test_table(date Date, id UInt32, dummy UInt32)
...
...
@@ -21,6 +22,15 @@ def start_cluster():
'''
.
format
(
i
)
)
with
pytest
.
raises
(
QueryRuntimeException
):
node3
.
query
(
'''
CREATE TABLE test_table(date Date, id UInt32, dummy UInt32)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_table', '{}')
PARTITION BY date ORDER BY id SETTINGS replicated_can_become_leader=0sad
'''
.
format
(
3
)
)
yield
cluster
finally
:
...
...
@@ -29,5 +39,4 @@ def start_cluster():
def
test_can_become_leader
(
start_cluster
):
assert
node1
.
query
(
"select can_become_leader from system.replicas where table = 'test_table'"
)
==
'0
\n
'
assert
node2
.
query
(
"select can_become_leader from system.replicas where table = 'test_table'"
)
==
'1
\n
'
assert
node3
.
query
(
"select can_become_leader from system.replicas where table = 'test_table'"
)
==
'1
\n
'
assert
node2
.
query
(
"select can_become_leader from system.replicas where table = 'test_table'"
)
==
'0
\n
'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录