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 2018/02/08 02:59:40 UTC
[6/6] mesos git commit: Added two additional mock methods in mock
slave.
Added two additional mock methods in mock slave.
Review: https://reviews.apache.org/r/65110/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2c31fdc7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2c31fdc7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2c31fdc7
Branch: refs/heads/master
Commit: 2c31fdc7e094b697ae11c37c4eb8885a15e0c4aa
Parents: 0acc7d7
Author: Meng Zhu <mz...@mesosphere.io>
Authored: Wed Feb 7 18:19:39 2018 -0800
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Feb 7 18:41:15 2018 -0800
----------------------------------------------------------------------
src/slave/slave.hpp | 42 +++++++++++++++++++++++-------------------
src/tests/mock_slave.cpp | 31 +++++++++++++++++++++++++++++++
src/tests/mock_slave.hpp | 24 ++++++++++++++++++++++++
3 files changed, 78 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2c31fdc7/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index 38808cb..30151c4 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -170,6 +170,20 @@ public:
const Option<TaskGroupInfo>& taskGroup,
const std::vector<ResourceVersionUUID>& resourceVersionUuids);
+ // This is called when the resource limits of the container have
+ // been updated for the given tasks and task groups. If the update is
+ // successful, we flush the given tasks to the executor by sending
+ // RunTaskMessages or `LAUNCH_GROUP` events.
+ //
+ // Made 'virtual' for Slave mocking.
+ virtual void ___run(
+ const process::Future<Nothing>& future,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ContainerID& containerId,
+ const std::list<TaskInfo>& tasks,
+ const std::list<TaskGroupInfo>& taskGroups);
+
// Made 'virtual' for Slave mocking.
virtual void runTaskGroup(
const process::UPID& from,
@@ -189,6 +203,15 @@ public:
const FrameworkID& frameworkId,
const ExecutorID& executorId);
+ // Shut down an executor. This is a two phase process. First, an
+ // executor receives a shut down message (shut down phase), then
+ // after a configurable timeout the slave actually forces a kill
+ // (kill phase, via the isolator) if the executor has not
+ // exited.
+ //
+ // Made 'virtual' for Slave mocking.
+ virtual void _shutdownExecutor(Framework* framework, Executor* executor);
+
void shutdownFramework(
const process::UPID& from,
const FrameworkID& frameworkId);
@@ -379,18 +402,6 @@ public:
const Option<TaskGroupInfo>& taskGroup,
const std::vector<ResourceVersionUUID>& resourceVersionUuids);
- // This is called when the resource limits of the container have
- // been updated for the given tasks and task groups. If the update is
- // successful, we flush the given tasks to the executor by sending
- // RunTaskMessages or `LAUNCH_GROUP` events.
- void ___run(
- const process::Future<Nothing>& future,
- const FrameworkID& frameworkId,
- const ExecutorID& executorId,
- const ContainerID& containerId,
- const std::list<TaskInfo>& tasks,
- const std::list<TaskGroupInfo>& taskGroups);
-
process::Future<Secret> generateSecret(
const FrameworkID& frameworkId,
const ExecutorID& executorId,
@@ -548,13 +559,6 @@ private:
void _authenticate();
void authenticationTimeout(process::Future<bool> future);
- // Shut down an executor. This is a two phase process. First, an
- // executor receives a shut down message (shut down phase), then
- // after a configurable timeout the slave actually forces a kill
- // (kill phase, via the isolator) if the executor has not
- // exited.
- void _shutdownExecutor(Framework* framework, Executor* executor);
-
// Process creation of persistent volumes (for CREATE) and/or deletion
// of persistent volumes (for DESTROY) as a part of handling
// checkpointed resources, and commit the checkpointed resources on
http://git-wip-us.apache.org/repos/asf/mesos/blob/2c31fdc7/src/tests/mock_slave.cpp
----------------------------------------------------------------------
diff --git a/src/tests/mock_slave.cpp b/src/tests/mock_slave.cpp
index 8357edc..597d7ab 100644
--- a/src/tests/mock_slave.cpp
+++ b/src/tests/mock_slave.cpp
@@ -118,6 +118,8 @@ MockSlave::MockSlave(
authorizer)
{
// Set up default behaviors, calling the original methods.
+ EXPECT_CALL(*this, ___run(_, _, _, _, _, _))
+ .WillRepeatedly(Invoke(this, &MockSlave::unmocked____run));
EXPECT_CALL(*this, runTask(_, _, _, _, _, _))
.WillRepeatedly(Invoke(this, &MockSlave::unmocked_runTask));
EXPECT_CALL(*this, _run(_, _, _, _, _, _))
@@ -138,6 +140,26 @@ MockSlave::MockSlave(
.WillRepeatedly(Invoke(this, &MockSlave::unmocked_executorTerminated));
EXPECT_CALL(*this, shutdownExecutor(_, _, _))
.WillRepeatedly(Invoke(this, &MockSlave::unmocked_shutdownExecutor));
+ EXPECT_CALL(*this, _shutdownExecutor(_, _))
+ .WillRepeatedly(Invoke(this, &MockSlave::unmocked__shutdownExecutor));
+}
+
+
+void MockSlave::unmocked____run(
+ const Future<Nothing>& future,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ContainerID& containerId,
+ const list<TaskInfo>& tasks,
+ const list<TaskGroupInfo>& taskGroups)
+{
+ slave::Slave::___run(
+ future,
+ frameworkId,
+ executorId,
+ containerId,
+ tasks,
+ taskGroups);
}
@@ -242,6 +264,15 @@ void MockSlave::unmocked_shutdownExecutor(
slave::Slave::shutdownExecutor(from, frameworkId, executorId);
}
+
+void MockSlave::unmocked__shutdownExecutor(
+ slave::Framework* framework,
+ slave::Executor* executor)
+{
+ slave::Slave::_shutdownExecutor(framework, executor);
+}
+
+
} // namespace tests {
} // namespace internal {
} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/2c31fdc7/src/tests/mock_slave.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mock_slave.hpp b/src/tests/mock_slave.hpp
index 29ce714..942ead5 100644
--- a/src/tests/mock_slave.hpp
+++ b/src/tests/mock_slave.hpp
@@ -101,6 +101,22 @@ public:
SecretGenerator* secretGenerator,
const Option<Authorizer*>& authorizer);
+ MOCK_METHOD6(___run, void(
+ const process::Future<Nothing>& future,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ContainerID& containerId,
+ const std::list<TaskInfo>& tasks,
+ const std::list<TaskGroupInfo>& taskGroups));
+
+ void unmocked____run(
+ const process::Future<Nothing>& future,
+ const FrameworkID& frameworkId,
+ const ExecutorID& executorId,
+ const ContainerID& containerId,
+ const std::list<TaskInfo>& tasks,
+ const std::list<TaskGroupInfo>& taskGroups);
+
MOCK_METHOD6(runTask, void(
const process::UPID& from,
const FrameworkInfo& frameworkInfo,
@@ -200,6 +216,14 @@ public:
const process::UPID& from,
const FrameworkID& frameworkId,
const ExecutorID& executorId);
+
+ MOCK_METHOD2(_shutdownExecutor, void(
+ slave::Framework* framework,
+ slave::Executor* executor));
+
+ void unmocked__shutdownExecutor(
+ slave::Framework* framework,
+ slave::Executor* executor);
};
} // namespace tests {