mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vinodk...@apache.org
Subject [2/5] git commit: Removed the while loops in ZooKeeperTest.
Date Tue, 11 Feb 2014 19:30:52 GMT
Removed the while loops in ZooKeeperTest.

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


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

Branch: refs/heads/master
Commit: 44508c2c7510b1980c502742c4fb3ff1a047a6b6
Parents: 92e2e51
Author: Jiang Yan Xu <yan@jxu.me>
Authored: Tue Feb 11 11:18:04 2014 -0800
Committer: Vinod Kone <vinod@twitter.com>
Committed: Tue Feb 11 11:18:04 2014 -0800

----------------------------------------------------------------------
 src/tests/zookeeper_tests.cpp | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/44508c2c/src/tests/zookeeper_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/zookeeper_tests.cpp b/src/tests/zookeeper_tests.cpp
index 615338a..be9fa06 100644
--- a/src/tests/zookeeper_tests.cpp
+++ b/src/tests/zookeeper_tests.cpp
@@ -213,16 +213,23 @@ TEST_F(ZooKeeperTest, LeaderDetectorTimeoutHandling)
 
   leader = detector.detect(leader.get());
 
+  Future<Nothing> reconnecting = FUTURE_DISPATCH(
+      group.process->self(),
+      &GroupProcess::reconnecting);
+
   server->shutdownNetwork();
 
+  AWAIT_READY(reconnecting);
+
   Clock::pause();
 
-  // We may need to advance multiple times because we could have
-  // advanced the clock before the timer in Group starts.
-  while (leader.isPending()) {
-    Clock::advance(timeout);
-    Clock::settle();
-  }
+  // Settle to make sure 'reconnecting' schedules the timeout before
+  // we advance.
+  Clock::settle();
+  Clock::advance(timeout);
+
+  AWAIT_READY(leader);
+
   Clock::resume();
 
   // The detect operation times out.
@@ -351,16 +358,20 @@ TEST_F(ZooKeeperTest, LeaderContender)
   AWAIT_READY(candidated);
   lostCandidacy = candidated.get();
 
+  Future<Nothing> reconnecting = FUTURE_DISPATCH(
+      group.process->self(),
+      &GroupProcess::reconnecting);
+
   server->shutdownNetwork();
 
+  AWAIT_READY(reconnecting);
+
   Clock::pause();
 
-  // We may need to advance multiple times because we could have
-  // advanced the clock before the timer in Group starts.
-  while (lostCandidacy.isPending()) {
-    Clock::advance(timeout);
-    Clock::settle();
-  }
+  // Settle to make sure 'reconnecting()' schedules the timeout
+  // before we advance.
+  Clock::settle();
+  Clock::advance(timeout);
 
   // Server failure results in candidacy loss.
   AWAIT_READY(lostCandidacy);


Mime
View raw message