You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/04/17 04:28:15 UTC
[2/6] git commit: Used LogStorage for all tests.
Used LogStorage for all tests.
Review: https://reviews.apache.org/r/20431
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7bf1e8a6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7bf1e8a6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7bf1e8a6
Branch: refs/heads/master
Commit: 7bf1e8a6b6d1160c65d37a03f38341604a122078
Parents: a378360
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Wed Apr 16 15:57:28 2014 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Apr 16 19:17:04 2014 -0700
----------------------------------------------------------------------
src/master/master.hpp | 7 ++++---
src/tests/cluster.hpp | 41 +++++++++++++++++++++++++++++++++++------
2 files changed, 39 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/7bf1e8a6/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 2fe0379..e4c7862 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -190,6 +190,10 @@ public:
// Made public for testing purposes.
void lostCandidacy(const process::Future<Nothing>& lost);
+ // Continuation of recover().
+ // Made public for testing purposes.
+ process::Future<Nothing> _recover(const Registry& registry);
+
MasterInfo info() const
{
return info_;
@@ -203,7 +207,6 @@ protected:
// Recovers state from the registrar.
process::Future<Nothing> recover();
- process::Future<Nothing> _recover(const Registry& registry);
void recoveredSlavesTimeout(const Registry& registry);
void _registerSlave(
@@ -354,8 +357,6 @@ private:
Master(const Master&); // No copying.
Master& operator = (const Master&); // No assigning.
- friend struct SlaveRegistrar;
- friend struct SlaveReregistrar;
friend struct OfferVisitor;
const Flags flags;
http://git-wip-us.apache.org/repos/asf/mesos/blob/7bf1e8a6/src/tests/cluster.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cluster.hpp b/src/tests/cluster.hpp
index 49d1f40..21a081c 100644
--- a/src/tests/cluster.hpp
+++ b/src/tests/cluster.hpp
@@ -21,6 +21,8 @@
#include <map>
+#include <process/gmock.hpp>
+#include <process/gtest.hpp>
#include <process/owned.hpp>
#include <process/pid.hpp>
#include <process/process.hpp>
@@ -40,6 +42,10 @@
#include "linux/cgroups.hpp"
#endif // __linux__
+#include "log/log.hpp"
+
+#include "log/tool/initialize.hpp"
+
#include "master/allocator.hpp"
#include "master/contender.hpp"
#include "master/detector.hpp"
@@ -54,6 +60,7 @@
#include "slave/slave.hpp"
#include "state/in_memory.hpp"
+#include "state/log.hpp"
#include "state/protobuf.hpp"
#include "state/storage.hpp"
@@ -115,12 +122,18 @@ public:
: master(NULL),
allocator(NULL),
allocatorProcess(NULL),
+ log(NULL),
+ storage(NULL),
+ state(NULL),
+ registrar(NULL),
+ repairer(NULL),
contender(NULL),
detector(NULL) {}
master::Master* master;
master::allocator::Allocator* allocator;
master::allocator::AllocatorProcess* allocatorProcess;
+ log::Log* log;
state::Storage* storage;
state::protobuf::State* state;
master::Registrar* registrar;
@@ -275,12 +288,18 @@ inline Try<process::PID<master::Master> > Cluster::Masters::start(
new master::allocator::Allocator(allocatorProcess.get());
}
- if (flags.registry == "in_memory") {
- master.storage = new state::InMemoryStorage();
- } else {
- return Error("'" + flags.registry + "' is not a supported"
- " option for registry persistence");
- }
+ // TODO(bmahler): Add flag support for the replicated log and then
+ // just construct based on the flags.
+ log::tool::Initialize initializer;
+
+ initializer.flags.path = path::join(flags.work_dir, ".log");
+ initializer.execute();
+
+ master.log = new log::Log(
+ 1,
+ initializer.flags.path.get(),
+ std::set<process::UPID>());
+ master.storage = new state::LogStorage(master.log);
CHECK_NOTNULL(master.storage);
@@ -315,6 +334,16 @@ inline Try<process::PID<master::Master> > Cluster::Masters::start(
masters[pid] = master;
+ // 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.
+ process::Future<Nothing> _recover =
+ FUTURE_DISPATCH(pid, &master::Master::_recover);
+
+ if (!_recover.await(Seconds(10))) {
+ LOG(FATAL) << "Failed to wait for _recover";
+ }
+
return pid;
}