Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
696f7732
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,发现更多精彩内容 >>
提交
696f7732
编写于
8月 15, 2020
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove ZooKeeper from unit tests
上级
e0325930
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
229 deletion
+0
-229
src/Common/ZooKeeper/tests/gtest_zkutil_test_multi_exception.cpp
...mon/ZooKeeper/tests/gtest_zkutil_test_multi_exception.cpp
+0
-229
未找到文件。
src/Common/ZooKeeper/tests/gtest_zkutil_test_multi_exception.cpp
已删除
100644 → 0
浏览文件 @
e0325930
#include <Common/typeid_cast.h>
#include <Common/ZooKeeper/ZooKeeper.h>
#include <Common/ZooKeeper/KeeperException.h>
#include <Common/StringUtils/StringUtils.h>
#include <iostream>
#include <chrono>
#include <gtest/gtest.h>
#include <Common/ShellCommand.h>
using
namespace
DB
;
template
<
typename
...
Args
>
auto
getZooKeeper
(
Args
&&
...
args
)
{
/// In our CI infrastructure it is typical that ZooKeeper is unavailable for some amount of time.
size_t
i
;
for
(
i
=
0
;
i
<
100
;
++
i
)
{
try
{
auto
zookeeper
=
std
::
make_unique
<
zkutil
::
ZooKeeper
>
(
"localhost:2181"
,
std
::
forward
<
Args
>
(
args
)...);
zookeeper
->
exists
(
"/"
);
zookeeper
->
createIfNotExists
(
"/clickhouse_test"
,
"Unit tests of ClickHouse"
);
return
zookeeper
;
}
catch
(...)
{
std
::
cerr
<<
"Zookeeper is unavailable, try "
<<
i
<<
std
::
endl
;
sleep
(
1
);
continue
;
}
}
std
::
cerr
<<
"No zookeeper after "
<<
i
<<
" tries. skip tests."
<<
std
::
endl
;
exit
(
0
);
}
TEST
(
zkutil
,
MultiNiceExceptionMsg
)
{
auto
zookeeper
=
getZooKeeper
();
Coordination
::
Requests
ops
;
ASSERT_NO_THROW
(
zookeeper
->
tryRemoveRecursive
(
"/clickhouse_test/zkutil_multi"
);
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi"
,
"_"
,
zkutil
::
CreateMode
::
Persistent
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi/a"
,
"_"
,
zkutil
::
CreateMode
::
Persistent
));
zookeeper
->
multi
(
ops
);
);
try
{
ops
.
clear
();
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi/c"
,
"_"
,
zkutil
::
CreateMode
::
Persistent
));
ops
.
emplace_back
(
zkutil
::
makeRemoveRequest
(
"/clickhouse_test/zkutil_multi/c"
,
-
1
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi/a"
,
"BadBoy"
,
zkutil
::
CreateMode
::
Persistent
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi/b"
,
"_"
,
zkutil
::
CreateMode
::
Persistent
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi/a"
,
"_"
,
zkutil
::
CreateMode
::
Persistent
));
zookeeper
->
multi
(
ops
);
FAIL
();
}
catch
(...)
{
zookeeper
->
tryRemoveRecursive
(
"/clickhouse_test/zkutil_multi"
);
String
msg
=
getCurrentExceptionMessage
(
false
);
bool
msg_has_reqired_patterns
=
msg
.
find
(
"#2"
)
!=
std
::
string
::
npos
;
EXPECT_TRUE
(
msg_has_reqired_patterns
)
<<
msg
;
}
}
TEST
(
zkutil
,
MultiAsync
)
{
Coordination
::
Requests
ops
;
getZooKeeper
()
->
tryRemoveRecursive
(
"/clickhouse_test/zkutil_multi"
);
{
ops
.
clear
();
auto
zookeeper
=
getZooKeeper
();
auto
fut
=
zookeeper
->
asyncMulti
(
ops
);
}
{
ops
.
clear
();
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi"
,
""
,
zkutil
::
CreateMode
::
Persistent
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi/a"
,
""
,
zkutil
::
CreateMode
::
Persistent
));
auto
zookeeper
=
getZooKeeper
();
auto
fut
=
zookeeper
->
tryAsyncMulti
(
ops
);
ops
.
clear
();
auto
res
=
fut
.
get
();
ASSERT_EQ
(
res
.
error
,
Coordination
::
Error
::
ZOK
);
ASSERT_EQ
(
res
.
responses
.
size
(),
2
);
}
EXPECT_ANY_THROW
(
auto
zookeeper
=
getZooKeeper
();
std
::
vector
<
std
::
future
<
Coordination
::
MultiResponse
>>
futures
;
for
(
size_t
i
=
0
;
i
<
10000
;
++
i
)
{
ops
.
clear
();
ops
.
emplace_back
(
zkutil
::
makeRemoveRequest
(
"/clickhouse_test/zkutil_multi"
,
-
1
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi"
,
"_"
,
zkutil
::
CreateMode
::
Persistent
));
ops
.
emplace_back
(
zkutil
::
makeCheckRequest
(
"/clickhouse_test/zkutil_multi"
,
-
1
));
ops
.
emplace_back
(
zkutil
::
makeSetRequest
(
"/clickhouse_test/zkutil_multi"
,
"xxx"
,
42
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi/a"
,
"_"
,
zkutil
::
CreateMode
::
Persistent
));
futures
.
emplace_back
(
zookeeper
->
asyncMulti
(
ops
));
}
futures
[
0
].
get
();
);
/// Check there are no segfaults for remaining 999 futures
using
namespace
std
::
chrono_literals
;
std
::
this_thread
::
sleep_for
(
1s
);
try
{
ops
.
clear
();
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi"
,
"_"
,
zkutil
::
CreateMode
::
Persistent
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
"/clickhouse_test/zkutil_multi/a"
,
"_"
,
zkutil
::
CreateMode
::
Persistent
));
auto
zookeeper
=
getZooKeeper
();
auto
fut
=
zookeeper
->
tryAsyncMulti
(
ops
);
ops
.
clear
();
auto
res
=
fut
.
get
();
/// The test is quite heavy. It is normal if session is expired during this test.
/// If we don't check that, the test will be flacky.
if
(
res
.
error
!=
Coordination
::
Error
::
ZSESSIONEXPIRED
&&
res
.
error
!=
Coordination
::
Error
::
ZCONNECTIONLOSS
)
{
ASSERT_EQ
(
res
.
error
,
Coordination
::
Error
::
ZNODEEXISTS
);
ASSERT_EQ
(
res
.
responses
.
size
(),
2
);
}
}
catch
(
const
Coordination
::
Exception
&
e
)
{
if
(
e
.
code
!=
Coordination
::
Error
::
ZSESSIONEXPIRED
&&
e
.
code
!=
Coordination
::
Error
::
ZCONNECTIONLOSS
)
throw
;
}
}
TEST
(
zkutil
,
WatchGetChildrenWithChroot
)
{
try
{
const
String
prefix
=
"/clickhouse_test/zkutil/watch_get_children_with_chroot"
;
/// Create chroot node firstly
auto
zookeeper
=
getZooKeeper
();
zookeeper
->
createAncestors
(
prefix
+
"/"
);
zookeeper
=
getZooKeeper
(
""
,
zkutil
::
DEFAULT_SESSION_TIMEOUT
,
zkutil
::
DEFAULT_OPERATION_TIMEOUT
,
prefix
);
String
queue_path
=
"/queue"
;
zookeeper
->
tryRemoveRecursive
(
queue_path
);
zookeeper
->
createAncestors
(
queue_path
+
"/"
);
zkutil
::
EventPtr
event
=
std
::
make_shared
<
Poco
::
Event
>
();
zookeeper
->
getChildren
(
queue_path
,
nullptr
,
event
);
{
auto
zookeeper2
=
getZooKeeper
(
""
,
zkutil
::
DEFAULT_SESSION_TIMEOUT
,
zkutil
::
DEFAULT_OPERATION_TIMEOUT
,
prefix
);
zookeeper2
->
create
(
queue_path
+
"/children-"
,
""
,
zkutil
::
CreateMode
::
PersistentSequential
);
}
event
->
wait
();
}
catch
(...)
{
std
::
cerr
<<
getCurrentExceptionMessage
(
true
);
throw
;
}
}
TEST
(
zkutil
,
MultiCreateSequential
)
{
try
{
const
String
prefix
=
"/clickhouse_test/zkutil"
;
/// Create chroot node firstly
auto
zookeeper
=
getZooKeeper
();
zookeeper
->
createAncestors
(
prefix
+
"/"
);
zookeeper
=
getZooKeeper
(
""
,
zkutil
::
DEFAULT_SESSION_TIMEOUT
,
zkutil
::
DEFAULT_OPERATION_TIMEOUT
,
"/clickhouse_test"
);
String
base_path
=
"/multi_create_sequential"
;
zookeeper
->
tryRemoveRecursive
(
base_path
);
zookeeper
->
createAncestors
(
base_path
+
"/"
);
Coordination
::
Requests
ops
;
String
sequential_node_prefix
=
base_path
+
"/queue-"
;
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
sequential_node_prefix
,
""
,
zkutil
::
CreateMode
::
EphemeralSequential
));
auto
results
=
zookeeper
->
multi
(
ops
);
const
auto
&
sequential_node_result_op
=
dynamic_cast
<
const
Coordination
::
CreateResponse
&>
(
*
results
.
at
(
0
));
EXPECT_FALSE
(
sequential_node_result_op
.
path_created
.
empty
());
EXPECT_GT
(
sequential_node_result_op
.
path_created
.
length
(),
sequential_node_prefix
.
length
());
EXPECT_EQ
(
sequential_node_result_op
.
path_created
.
substr
(
0
,
sequential_node_prefix
.
length
()),
sequential_node_prefix
);
}
catch
(...)
{
std
::
cerr
<<
getCurrentExceptionMessage
(
false
);
throw
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录