You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2013/04/04 22:58:05 UTC
svn commit: r1464758 - in /incubator/mesos/trunk/src/tests: master_tests.cpp
utils.hpp
Author: benh
Date: Thu Apr 4 20:58:05 2013
New Revision: 1464758
URL: http://svn.apache.org/r1464758
Log:
Created FUTURE_PROTOBUF and used new FUTURE_MESSAGE and
FUTURE_DISPATCH in some of the tests.
Modified:
incubator/mesos/trunk/src/tests/master_tests.cpp
incubator/mesos/trunk/src/tests/utils.hpp
Modified: incubator/mesos/trunk/src/tests/master_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/master_tests.cpp?rev=1464758&r1=1464757&r2=1464758&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/master_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/master_tests.cpp Thu Apr 4 20:58:05 2013
@@ -352,12 +352,8 @@ TEST_F(MasterTest, StatusUpdateAck)
EXPECT_CALL(exec, launchTask(_, _))
.WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));
- Future<Nothing> acknowledgement;
- EXPECT_MESSAGE(Eq(StatusUpdateAcknowledgementMessage().GetTypeName()),
- _,
- Eq(slave.get()))
- .WillOnce(DoAll(FutureSatisfy(&acknowledgement),
- Return(false)));
+ Future<StatusUpdateAcknowledgementMessage> acknowledgement =
+ FUTURE_PROTOBUF(StatusUpdateAcknowledgementMessage(), _, Eq(slave.get()));
Future<TaskStatus> status;
EXPECT_CALL(sched, statusUpdate(&driver, _))
@@ -755,10 +751,8 @@ TEST_F(MasterTest, ShutdownUnregisteredE
tasks.push_back(task);
// Drop the registration message from the executor to the slave.
- Future<Nothing> registerExecutor;
- EXPECT_MESSAGE(Eq(RegisterExecutorMessage().GetTypeName()), _, _)
- .WillOnce(DoAll(FutureSatisfy(®isterExecutor),
- Return(true)));
+ Future<process::Message> registerExecutor =
+ DROP_MESSAGE(Eq(RegisterExecutorMessage().GetTypeName()), _, _);
driver.launchTasks(offers.get()[0].id(), tasks);
@@ -771,11 +765,8 @@ TEST_F(MasterTest, ShutdownUnregisteredE
.WillOnce(FutureArg<1>(&status));
// Ensure that the slave times out and kills the executor.
- Future<Nothing> killExecutor;
- EXPECT_DISPATCH(_, &Isolator::killExecutor)
- .WillOnce(DoAll(FutureSatisfy(&killExecutor),
- Return(false)))
- .WillRepeatedly(Return(false)); // TODO(benh): Why is this needed?
+ Future<Nothing> killExecutor =
+ FUTURE_DISPATCH(_, &Isolator::killExecutor);
Clock::advance(cluster.slaves.flags.executor_registration_timeout.secs());
@@ -853,10 +844,8 @@ TEST_F(MasterTest, MasterInfoOnReElectio
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillRepeatedly(Return()); // Ignore offers.
- Future<process::Message> message;
- EXPECT_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _)
- .WillOnce(DoAll(FutureArgField<0>(&process::MessageEvent::message, &message),
- Return(false)));
+ Future<process::Message> message =
+ FUTURE_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _);
driver.start();
@@ -957,10 +946,8 @@ TEST_F(MasterTest, MasterLost)
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillRepeatedly(Return()); // Ignore offers.
- Future<process::Message> message;
- EXPECT_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _)
- .WillOnce(DoAll(FutureArgField<0>(&process::MessageEvent::message, &message),
- Return(false)));
+ Future<process::Message> message =
+ FUTURE_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _);
driver.start();
Modified: incubator/mesos/trunk/src/tests/utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/utils.hpp?rev=1464758&r1=1464757&r2=1464758&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/utils.hpp (original)
+++ incubator/mesos/trunk/src/tests/utils.hpp Thu Apr 4 20:58:05 2013
@@ -31,6 +31,7 @@
#include <mesos/scheduler.hpp>
#include <process/future.hpp>
+#include <process/gmock.hpp>
#include <process/gtest.hpp>
#include <process/http.hpp>
#include <process/process.hpp>
@@ -799,6 +800,35 @@ ACTION_P(SendStatusUpdateFromTaskID, sta
#define AWAIT_UNTIL(future) \
AWAIT_FOR(future, Seconds(2))
+
+#define FUTURE_PROTOBUF(message, from, to) \
+ FutureProtobuf(message, from, to)
+
+
+// Forward declaration.
+template <typename T>
+process::Future<T> _FutureProtobuf(const process::Message& message);
+
+
+template <typename T, typename From, typename To>
+process::Future<T> FutureProtobuf(T t, From from, To to)
+{
+ // Help debugging by adding some "type constraints".
+ { google::protobuf::Message* m = &t; (void) m; }
+
+ return process::FutureMessage(testing::Eq(t.GetTypeName()), from, to)
+ .then(lambda::bind(&_FutureProtobuf<T>, lambda::_1));
+}
+
+
+template <typename T>
+process::Future<T> _FutureProtobuf(const process::Message& message)
+{
+ T t;
+ t.ParseFromString(message.body);
+ return t;
+}
+
} // namespace tests {
} // namespace internal {
} // namespace mesos {