Introduced gtest actions for subscribe, sending updates. This change adds some gtest actions that can be used to subscribe/send status updates using the executor library. These are in similar vein to the existing actions like `SendStatusUpdateFromTask`.
Review: https://reviews.apache.org/r/43225/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/97d35271 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/97d35271 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/97d35271 Branch: refs/heads/master Commit: 97d35271d18eeb2b0c487aab65c74c95b25f4614 Parents: 49c8895 Author: Anand Mazumdar <[email protected]> Authored: Tue Feb 9 11:17:20 2016 -0800 Committer: Vinod Kone <[email protected]> Committed: Tue Feb 9 11:17:20 2016 -0800 ---------------------------------------------------------------------- src/tests/mesos.hpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/97d35271/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index e382d91..c0997db 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -971,6 +971,63 @@ private: using TestV1Mesos = TestMesos<mesos::v1::executor::Mesos, mesos::v1::executor::Event>; + +// TODO(anand): Move these actions to the `v1::executor` namespace. +ACTION_P2(SendSubscribe, frameworkId, executorId) +{ + v1::executor::Call call; + call.mutable_framework_id()->CopyFrom(frameworkId); + call.mutable_executor_id()->CopyFrom(executorId); + + call.set_type(v1::executor::Call::SUBSCRIBE); + + call.mutable_subscribe(); + + arg0->send(call); +} + + +ACTION_P3(SendUpdateFromTask, frameworkId, executorId, state) +{ + v1::TaskStatus status; + status.mutable_task_id()->CopyFrom(arg1.task().task_id()); + status.mutable_executor_id()->CopyFrom(executorId); + status.set_state(state); + status.set_source(v1::TaskStatus::SOURCE_EXECUTOR); + status.set_uuid(UUID::random().toBytes()); + + v1::executor::Call call; + call.mutable_framework_id()->CopyFrom(frameworkId); + call.mutable_executor_id()->CopyFrom(executorId); + + call.set_type(v1::executor::Call::UPDATE); + + call.mutable_update()->mutable_status()->CopyFrom(status); + + arg0->send(call); +} + + +ACTION_P3(SendUpdateFromTaskID, frameworkId, executorId, state) +{ + v1::TaskStatus status; + status.mutable_task_id()->CopyFrom(arg1.task_id()); + status.mutable_executor_id()->CopyFrom(executorId); + status.set_state(state); + status.set_source(v1::TaskStatus::SOURCE_EXECUTOR); + status.set_uuid(UUID::random().toBytes()); + + v1::executor::Call call; + call.mutable_framework_id()->CopyFrom(frameworkId); + call.mutable_executor_id()->CopyFrom(executorId); + + call.set_type(v1::executor::Call::UPDATE); + + call.mutable_update()->mutable_status()->CopyFrom(status); + + arg0->send(call); +} + } // namespace executor {
