You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2014/04/23 21:09:16 UTC

git commit: Added a test for testing the base set in log ZooKeeper network.

Repository: mesos
Updated Branches:
  refs/heads/master 0165cdfc0 -> 89d400629


Added a test for testing the base set in log ZooKeeper network.

Review: https://reviews.apache.org/r/20618


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/89d40062
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/89d40062
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/89d40062

Branch: refs/heads/master
Commit: 89d40062938e220c86d50a02e688c1cba6aca461
Parents: 0165cdf
Author: Jie Yu <yu...@gmail.com>
Authored: Wed Apr 23 11:36:50 2014 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Apr 23 12:08:47 2014 -0700

----------------------------------------------------------------------
 src/log/network.hpp     |  3 +++
 src/tests/log_tests.cpp | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/89d40062/src/log/network.hpp
----------------------------------------------------------------------
diff --git a/src/log/network.hpp b/src/log/network.hpp
index ad9854b..fc85a57 100644
--- a/src/log/network.hpp
+++ b/src/log/network.hpp
@@ -391,6 +391,9 @@ inline ZooKeeperNetwork::ZooKeeperNetwork(
   : group(servers, timeout, znode, auth),
     base(_base)
 {
+  // PIDs from the base set are in the network from beginning.
+  set(base);
+
   watch(std::set<zookeeper::Group::Membership>());
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/89d40062/src/tests/log_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/log_tests.cpp b/src/tests/log_tests.cpp
index db91ef8..b60577d 100644
--- a/src/tests/log_tests.cpp
+++ b/src/tests/log_tests.cpp
@@ -2006,6 +2006,44 @@ TEST_F(LogZooKeeperTest, WriteRead)
   EXPECT_EQ(position.get().get(), entries.get().front().position);
   EXPECT_EQ("hello world", entries.get().front().data);
 }
+
+
+TEST_F(LogZooKeeperTest, LostZooKeeper)
+{
+  const string path = os::getcwd() + "/.log";
+  const string servers = server->connectString();
+
+  // We reply on auto-initialization to initialize the log.
+  Log log(1, path, servers, NO_TIMEOUT, "/log/", None(), true);
+
+  Log::Writer writer(&log);
+
+  Future<Option<Log::Position> > start = writer.start();
+
+  AWAIT_READY(start);
+  ASSERT_SOME(start.get());
+
+  // Shutdown ZooKeeper network.
+  server->shutdownNetwork();
+
+  // We should still be able to append as the local replica is in the
+  // base set of the ZooKeeper network.
+  Future<Option<Log::Position> > position = writer.append("hello world");
+
+  AWAIT_READY(position);
+  ASSERT_SOME(position.get());
+
+  Log::Reader reader(&log);
+
+  Future<list<Log::Entry> > entries =
+    reader.read(position.get().get(), position.get().get());
+
+  AWAIT_READY(entries);
+
+  ASSERT_EQ(1u, entries.get().size());
+  EXPECT_EQ(position.get().get(), entries.get().front().position);
+  EXPECT_EQ("hello world", entries.get().front().data);
+}
 #endif // MESOS_HAS_JAVA