You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2014/07/01 21:39:28 UTC

git commit: Made sure Cluster::Masters::start() returns when the Master is ready for incoming requests. i.e., after it has finished executing _recover().

Repository: mesos
Updated Branches:
  refs/heads/master 8015e6e3c -> 2b90dd07b


Made sure Cluster::Masters::start() returns when the Master is ready for incoming requests. i.e., after it has finished executing _recover().

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


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

Branch: refs/heads/master
Commit: 2b90dd07baa4462cd44ac8e0c253360bc2640856
Parents: 8015e6e
Author: Jiang Yan Xu <ya...@jxu.me>
Authored: Tue Jul 1 11:49:44 2014 -0700
Committer: Jiang Yan Xu <ya...@jxu.me>
Committed: Tue Jul 1 11:49:44 2014 -0700

----------------------------------------------------------------------
 src/tests/cluster.hpp | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2b90dd07/src/tests/cluster.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cluster.hpp b/src/tests/cluster.hpp
index a83a60e..89aecf3 100644
--- a/src/tests/cluster.hpp
+++ b/src/tests/cluster.hpp
@@ -23,6 +23,7 @@
 
 #include <mesos/mesos.hpp>
 
+#include <process/clock.hpp>
 #include <process/future.hpp>
 #include <process/gmock.hpp>
 #include <process/gtest.hpp>
@@ -423,12 +424,24 @@ inline Try<process::PID<master::Master> > Cluster::Masters::start(
   // Speed up the tests by ensuring that the Master is recovered
   // before the test proceeds. Otherwise, authentication and
   // registration messages may be dropped, causing delayed retries.
-  // NOTE: The tests may still need to settle the Clock while it's
-  // paused to ensure that the Master finishes executing _recover().
-  if (!_recover.await(Seconds(10))) {
+  // NOTE: We use process::internal::await() to avoid awaiting a
+  // Future forever when the Clock is paused.
+  if (!process::internal::await(_recover, Seconds(10))) {
     LOG(FATAL) << "Failed to wait for _recover";
   }
 
+  bool paused = process::Clock::paused();
+
+  // Need to settle the Clock to ensure that the Master finishes
+  // executing _recover() before we return.
+  process::Clock::pause();
+  process::Clock::settle();
+
+  // Return the Clock to its original state.
+  if (!paused) {
+    process::Clock::resume();
+  }
+
   return pid;
 }