Skip to content

Commit

Permalink
Made sure Cluster::Masters::start() returns when the Master is ready …
Browse files Browse the repository at this point in the history
…for incoming requests. i.e., after it has finished executing _recover().

Review: https://reviews.apache.org/r/22857
  • Loading branch information
xujyan committed Jul 1, 2014
1 parent 8015e6e commit 2b90dd0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/tests/cluster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <mesos/mesos.hpp>

#include <process/clock.hpp>
#include <process/future.hpp>
#include <process/gmock.hpp>
#include <process/gtest.hpp>
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2b90dd0

Please sign in to comment.