Repository: mesos Updated Branches: refs/heads/master 6b1b66df7 -> 51c2b523d
Added FUTURE_CALL, DROP_CALL, DROP_CALLS and EXPECT_NO_FUTURE_CALLS. Review: https://reviews.apache.org/r/36462 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/415f7b15 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/415f7b15 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/415f7b15 Branch: refs/heads/master Commit: 415f7b15028a1d367836599fac7df73690d5c499 Parents: 5329851 Author: Vinod Kone <[email protected]> Authored: Fri Jul 10 15:50:38 2015 -0700 Committer: Vinod Kone <[email protected]> Committed: Fri Jul 17 10:43:58 2015 -0700 ---------------------------------------------------------------------- src/tests/mesos.hpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/415f7b15/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index 9157ac0..23d9841 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -1324,6 +1324,39 @@ ACTION_P(SendStatusUpdateFromTaskID, state) #define EXPECT_NO_FUTURE_PROTOBUFS(message, from, to) \ ExpectNoFutureProtobufs(message, from, to) + +// These are specialized versions of {FUTURE,DROP}_PROTOBUF that +// capture a scheduler/executor Call protobuf of the given 'type'. +// Note that we name methods as '*ProtobufUnion()' because these could +// be reused for macros that capture any protobufs that are described +// using the standard protocol buffer "union" trick (e.g., +// FUTURE_EVENT to capture scheduler::Event), see +// https://developers.google.com/protocol-buffers/docs/techniques#union. + +#define FUTURE_CALL(message, unionType, from, to) \ + FutureUnionProtobuf(message, unionType, from, to) + + +#define DROP_CALL(message, unionType, from, to) \ + FutureUnionProtobuf(message, unionType, from, to, true) + + +#define DROP_CALLS(message, unionType, from, to) \ + DropUnionProtobufs(message, unionType, from, to) + + +#define EXPECT_NO_FUTURE_CALLS(message, unionType, from, to) \ + ExpectNoFutureUnionProtobufs(message, unionType, from, to) + + +#define FUTURE_CALL_MESSAGE(message, unionType, from, to) \ + process::FutureUnionMessage(message, unionType, from, to) + + +#define DROP_CALL_MESSAGE(message, unionType, from, to) \ + process::FutureUnionMessage(message, unionType, from, to, true) + + // Forward declaration. template <typename T> T _FutureProtobuf(const process::Message& message); @@ -1340,6 +1373,18 @@ process::Future<T> FutureProtobuf(T t, From from, To to, bool drop = false) } +template <typename Message, typename UnionType, typename From, typename To> +process::Future<Message> FutureUnionProtobuf( + Message message, UnionType unionType, From from, To to, bool drop = false) +{ + // Help debugging by adding some "type constraints". + { google::protobuf::Message* m = &message; (void) m; } + + return process::FutureUnionMessage(message, unionType, from, to, drop) + .then(lambda::bind(&_FutureProtobuf<Message>, lambda::_1)); +} + + template <typename T> T _FutureProtobuf(const process::Message& message) { @@ -1359,6 +1404,16 @@ void DropProtobufs(T t, From from, To to) } +template <typename Message, typename UnionType, typename From, typename To> +void DropUnionProtobufs(Message message, UnionType unionType, From from, To to) +{ + // Help debugging by adding some "type constraints". + { google::protobuf::Message* m = &message; (void) m; } + + process::DropUnionMessages(message, unionType, from, to); +} + + template <typename T, typename From, typename To> void ExpectNoFutureProtobufs(T t, From from, To to) { @@ -1369,6 +1424,17 @@ void ExpectNoFutureProtobufs(T t, From from, To to) } +template <typename Message, typename UnionType, typename From, typename To> +void ExpectNoFutureUnionProtobufs( + Message message, UnionType unionType, From from, To to) +{ + // Help debugging by adding some "type constraints". + { google::protobuf::Message* m = &message; (void) m; } + + process::ExpectNoFutureUnionMessages(message, unionType, from, to); +} + + // This matcher is used to match the task ids of TaskStatus messages. // Suppose we set up N futures for LaunchTasks and N futures for StatusUpdates. // (This is a common pattern). We get into a situation where all StatusUpdates
