mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
zkcpp: added test showing that zkcpp blocks calls forever after session expiration. [#METR-10202]
This commit is contained in:
parent
112ca9720b
commit
d9f3ec0df8
@ -26,7 +26,7 @@ typedef std::shared_ptr<boost::ptr_vector<OpResult> > OpResultsPtr;
|
|||||||
typedef std::vector<std::string> Strings;
|
typedef std::vector<std::string> Strings;
|
||||||
|
|
||||||
typedef boost::function<void (WatchEvent::type event, SessionState::type state,
|
typedef boost::function<void (WatchEvent::type event, SessionState::type state,
|
||||||
const std::string & path)> WatchFunction;
|
const std::string & path)> WatchFunction;
|
||||||
|
|
||||||
struct WatchEventInfo
|
struct WatchEventInfo
|
||||||
{
|
{
|
||||||
|
43
libs/libzkutil/src/tests/zkcpp_expiration_test.cpp
Normal file
43
libs/libzkutil/src/tests/zkcpp_expiration_test.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#include <zookeeper/zookeeper.hh>
|
||||||
|
|
||||||
|
namespace zk = org::apache::zookeeper;
|
||||||
|
|
||||||
|
void stateChanged(zk::WatchEvent::type event, zk::SessionState::type state, const std::string & path)
|
||||||
|
{
|
||||||
|
std::cout << "state changed; event: " << zk::WatchEvent::toString(event) << ", state: " << zk::SessionState::toString(state)
|
||||||
|
<< ", path: " << path << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
zk::ZooKeeper zookeeper;
|
||||||
|
zookeeper.init("example1:2181,example2:2181,example3:2181", 5000, nullptr);
|
||||||
|
|
||||||
|
std::vector<std::string> children;
|
||||||
|
zk::data::Stat stat;
|
||||||
|
zk::ReturnCode::type ret = zookeeper.getChildren("/", nullptr, children, stat);
|
||||||
|
|
||||||
|
std::cout << "getChildren returned " << zk::ReturnCode::toString(ret) << std::endl;
|
||||||
|
std::cout << "children of /:" << std::endl;
|
||||||
|
for (const auto & s : children)
|
||||||
|
{
|
||||||
|
std::cout << s << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "break connection to example1:2181,example2:2181,example3:2181 for at least 5 seconds and enter something" << std::endl;
|
||||||
|
std::string unused;
|
||||||
|
std::cin >> unused;
|
||||||
|
|
||||||
|
children.clear();
|
||||||
|
std::cout << "will getChildren" << std::endl;
|
||||||
|
ret = zookeeper.getChildren("/", nullptr, children, stat);
|
||||||
|
|
||||||
|
std::cout << "getChildren returned " << zk::ReturnCode::toString(ret) << std::endl;
|
||||||
|
std::cout << "children of /:" << std::endl;
|
||||||
|
for (const auto & s : children)
|
||||||
|
{
|
||||||
|
std::cout << s << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -48,12 +48,6 @@ int main(int argc, char ** argv)
|
|||||||
|
|
||||||
while (char * line = readline(":3 "))
|
while (char * line = readline(":3 "))
|
||||||
{
|
{
|
||||||
if (zk.disconnected())
|
|
||||||
{
|
|
||||||
std::cerr << "Disconnected" << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::stringstream ss(line);
|
std::stringstream ss(line);
|
||||||
|
Loading…
Reference in New Issue
Block a user