17 #ifndef __TESTS_ZOOKEEPER_HPP__ 18 #define __TESTS_ZOOKEEPER_HPP__ 22 #include <condition_variable> 26 #include <gtest/gtest.h> 39 const char* expectedExpr,
42 const std::string& expected,
44 const std::string&
path)
47 int code = zk->
get(path,
false, &result,
nullptr);
49 if (expected == result) {
50 return ::testing::AssertionSuccess();
52 return ::testing::AssertionFailure()
53 <<
"Expected data at znode '" << pathExpr <<
"' " 54 <<
"to be '" << expected <<
"', but actually '" << result <<
"'";
57 return ::testing::AssertionFailure()
58 <<
"(" << zkExpr <<
").get(" << pathExpr <<
", ...): " 63 #define ASSERT_ZK_GET(expected, zk, path) \ 64 ASSERT_PRED_FORMAT3(mesos::internal::tests::AssertZKGet, expected, zk, path) 82 Event(
int _type,
int _state,
const std::string& _path)
96 const std::string&
path)
override;
111 std::queue<Event> events;
113 std::condition_variable cond;
122 void SetUp()
override;
135 #endif // __ZOOKEEPER_TEST_HPP__
const int type
Definition: zookeeper.hpp:84
Definition: zookeeper.hpp:115
Event(int _type, int _state, const std::string &_path)
Definition: zookeeper.hpp:82
static void SetUpTestCase()
Definition: duration.hpp:32
const int state
Definition: zookeeper.hpp:85
void process(int type, int state, int64_t sessionId, const std::string &path) override
~TestWatcher() override=default
inline::testing::AssertionResult AssertZKGet(const char *expectedExpr, const char *zkExpr, const char *pathExpr, const std::string &expected, ZooKeeper *zk, const std::string &path)
Definition: zookeeper.hpp:38
This interface specifies the public interface an event handler class must implement.
Definition: zookeeper.hpp:59
Definition: zookeeper.hpp:77
~ZooKeeperTest() override
Definition: zookeeper.hpp:120
ZooKeeperTest()
Definition: zookeeper.hpp:119
int get(const std::string &path, bool watch, std::string *result, Stat *stat)
gets the data associated with a node synchronously.
ZooKeeperTestServer * server
Definition: zookeeper.hpp:128
void awaitSessionEvent(int state)
static const Duration NO_TIMEOUT
Definition: zookeeper.hpp:125
const std::string path
Definition: zookeeper.hpp:86
Definition: attributes.hpp:24
void awaitCreated(const std::string &path)
Definition: zookeeper_test_server.hpp:36
Definition: zookeeper.hpp:81
Definition: zookeeper.hpp:72
std::string message(int code) const
return a message describing the return code.