Repository: mesos Updated Branches: refs/heads/master ae12bb2fe -> 686de9b0a
Moved `MockDocker` and related declarations to separate files. Review: https://reviews.apache.org/r/51152/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/97c78552 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/97c78552 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/97c78552 Branch: refs/heads/master Commit: 97c785521a2e62316f96f7a566830648d5daae4b Parents: 5bd5549 Author: Neil Conway <neil.con...@gmail.com> Authored: Tue Sep 13 19:17:13 2016 +0200 Committer: Michael Park <mp...@apache.org> Committed: Wed Sep 14 15:01:58 2016 +0200 ---------------------------------------------------------------------- src/Makefile.am | 2 + src/tests/container_logger_tests.cpp | 1 + .../docker_containerizer_tests.cpp | 1 + .../docker_volume_isolator_tests.cpp | 1 + src/tests/health_check_tests.cpp | 1 + src/tests/hook_tests.cpp | 1 + src/tests/mesos.cpp | 70 ----- src/tests/mesos.hpp | 224 --------------- src/tests/mock_docker.cpp | 109 ++++++++ src/tests/mock_docker.hpp | 271 +++++++++++++++++++ 10 files changed, 387 insertions(+), 294 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/Makefile.am ---------------------------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index b6b64bc..1a9210d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -988,6 +988,7 @@ libmesos_no_3rdparty_la_SOURCES += \ tests/flags.hpp \ tests/limiter.hpp \ tests/mesos.hpp \ + tests/mock_docker.hpp \ tests/module.hpp \ tests/script.hpp \ tests/utils.hpp \ @@ -2095,6 +2096,7 @@ mesos_tests_SOURCES = \ tests/master_validation_tests.cpp \ tests/mesos.cpp \ tests/metrics_tests.cpp \ + tests/mock_docker.cpp \ tests/module.cpp \ tests/module_tests.cpp \ tests/oversubscription_tests.cpp \ http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/tests/container_logger_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/container_logger_tests.cpp b/src/tests/container_logger_tests.cpp index cfbc103..1b121a2 100644 --- a/src/tests/container_logger_tests.cpp +++ b/src/tests/container_logger_tests.cpp @@ -56,6 +56,7 @@ #include "tests/flags.hpp" #include "tests/mesos.hpp" +#include "tests/mock_docker.hpp" #include "tests/utils.hpp" #include "tests/containerizer/launcher.hpp" http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/tests/containerizer/docker_containerizer_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/docker_containerizer_tests.cpp b/src/tests/containerizer/docker_containerizer_tests.cpp index 28cd3fa..1671d45 100644 --- a/src/tests/containerizer/docker_containerizer_tests.cpp +++ b/src/tests/containerizer/docker_containerizer_tests.cpp @@ -43,6 +43,7 @@ #include "tests/flags.hpp" #include "tests/mesos.hpp" +#include "tests/mock_docker.hpp" using namespace mesos::internal::slave::paths; using namespace mesos::internal::slave::state; http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/tests/containerizer/docker_volume_isolator_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/docker_volume_isolator_tests.cpp b/src/tests/containerizer/docker_volume_isolator_tests.cpp index 236834e..ca7bffd 100644 --- a/src/tests/containerizer/docker_volume_isolator_tests.cpp +++ b/src/tests/containerizer/docker_volume_isolator_tests.cpp @@ -35,6 +35,7 @@ #include "tests/flags.hpp" #include "tests/mesos.hpp" +#include "tests/mock_docker.hpp" namespace slave = mesos::internal::slave; http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/tests/health_check_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/health_check_tests.cpp b/src/tests/health_check_tests.cpp index 50a252b..30b5a2f 100644 --- a/src/tests/health_check_tests.cpp +++ b/src/tests/health_check_tests.cpp @@ -34,6 +34,7 @@ #include "tests/containerizer.hpp" #include "tests/flags.hpp" #include "tests/mesos.hpp" +#include "tests/mock_docker.hpp" #include "tests/utils.hpp" #include "tests/containerizer/docker_archive.hpp" http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/tests/hook_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/hook_tests.cpp b/src/tests/hook_tests.cpp index d864ef3..602bb39 100644 --- a/src/tests/hook_tests.cpp +++ b/src/tests/hook_tests.cpp @@ -50,6 +50,7 @@ #include "tests/containerizer.hpp" #include "tests/flags.hpp" #include "tests/mesos.hpp" +#include "tests/mock_docker.hpp" using namespace mesos::modules; http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/tests/mesos.cpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.cpp b/src/tests/mesos.cpp index b445c99..3d8f16a 100644 --- a/src/tests/mesos.cpp +++ b/src/tests/mesos.cpp @@ -20,8 +20,6 @@ #include <mesos/authorizer/authorizer.hpp> -#include <mesos/slave/container_logger.hpp> - #include <mesos/master/detector.hpp> #include <stout/check.hpp> @@ -55,8 +53,6 @@ using mesos::fetcher::FetcherInfo; using mesos::master::detector::MasterDetector; -using mesos::slave::ContainerLogger; - using std::list; using std::shared_ptr; using std::string; @@ -644,72 +640,6 @@ MockFetcherProcess::MockFetcherProcess() MockFetcherProcess::~MockFetcherProcess() {} -MockDocker::MockDocker( - const string& path, - const string& socket, - const Option<JSON::Object>& config) - : Docker(path, socket, config) -{ - EXPECT_CALL(*this, ps(_, _)) - .WillRepeatedly(Invoke(this, &MockDocker::_ps)); - - EXPECT_CALL(*this, pull(_, _, _)) - .WillRepeatedly(Invoke(this, &MockDocker::_pull)); - - EXPECT_CALL(*this, stop(_, _, _)) - .WillRepeatedly(Invoke(this, &MockDocker::_stop)); - - EXPECT_CALL(*this, run(_, _, _, _, _, _, _, _, _, _)) - .WillRepeatedly(Invoke(this, &MockDocker::_run)); - - EXPECT_CALL(*this, inspect(_, _)) - .WillRepeatedly(Invoke(this, &MockDocker::_inspect)); -} - - -MockDocker::~MockDocker() {} - - -MockDockerContainerizer::MockDockerContainerizer( - const slave::Flags& flags, - slave::Fetcher* fetcher, - const Owned<ContainerLogger>& logger, - Shared<Docker> docker) - : slave::DockerContainerizer(flags, fetcher, logger, docker) -{ - initialize(); -} - - -MockDockerContainerizer::MockDockerContainerizer( - const Owned<slave::DockerContainerizerProcess>& process) - : slave::DockerContainerizer(process) -{ - initialize(); -} - - -MockDockerContainerizer::~MockDockerContainerizer() {} - - -MockDockerContainerizerProcess::MockDockerContainerizerProcess( - const slave::Flags& flags, - slave::Fetcher* fetcher, - const Owned<ContainerLogger>& logger, - const Shared<Docker>& docker) - : slave::DockerContainerizerProcess(flags, fetcher, logger, docker) -{ - EXPECT_CALL(*this, fetch(_, _)) - .WillRepeatedly(Invoke(this, &MockDockerContainerizerProcess::_fetch)); - - EXPECT_CALL(*this, pull(_)) - .WillRepeatedly(Invoke(this, &MockDockerContainerizerProcess::_pull)); -} - - -MockDockerContainerizerProcess::~MockDockerContainerizerProcess() {} - - MockAuthorizer::MockAuthorizer() { // Implementation of the ObjectApprover interface authorizing all objects. http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index de4402e..8471b92 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -17,8 +17,6 @@ #ifndef __TESTS_MESOS_HPP__ #define __TESTS_MESOS_HPP__ -#include <list> -#include <map> #include <memory> #include <string> #include <vector> @@ -74,7 +72,6 @@ #include "slave/slave.hpp" #include "slave/containerizer/containerizer.hpp" -#include "slave/containerizer/docker.hpp" #include "slave/containerizer/fetcher.hpp" #include "slave/containerizer/mesos/containerizer.hpp" @@ -1478,227 +1475,6 @@ public: }; -// Definition of a mock Docker to be used in tests with gmock. -class MockDocker : public Docker -{ -public: - MockDocker( - const std::string& path, - const std::string& socket, - const Option<JSON::Object>& config = None()); - virtual ~MockDocker(); - - MOCK_CONST_METHOD10( - run, - process::Future<Option<int>>( - const mesos::ContainerInfo&, - const mesos::CommandInfo&, - const std::string&, - const std::string&, - const std::string&, - const Option<mesos::Resources>&, - const Option<std::map<std::string, std::string>>&, - const Option<std::vector<Device>>&, - const process::Subprocess::IO&, - const process::Subprocess::IO&)); - - MOCK_CONST_METHOD2( - ps, - process::Future<std::list<Docker::Container>>( - bool, const Option<std::string>&)); - - MOCK_CONST_METHOD3( - pull, - process::Future<Docker::Image>( - const std::string&, - const std::string&, - bool)); - - MOCK_CONST_METHOD3( - stop, - process::Future<Nothing>( - const std::string&, - const Duration&, - bool)); - - MOCK_CONST_METHOD2( - inspect, - process::Future<Docker::Container>( - const std::string&, - const Option<Duration>&)); - - process::Future<Option<int>> _run( - const mesos::ContainerInfo& containerInfo, - const mesos::CommandInfo& commandInfo, - const std::string& name, - const std::string& sandboxDirectory, - const std::string& mappedDirectory, - const Option<mesos::Resources>& resources, - const Option<std::map<std::string, std::string>>& env, - const Option<std::vector<Device>>& devices, - const process::Subprocess::IO& stdout, - const process::Subprocess::IO& stderr) const - { - return Docker::run( - containerInfo, - commandInfo, - name, - sandboxDirectory, - mappedDirectory, - resources, - env, - devices, - stdout, - stderr); - } - - process::Future<std::list<Docker::Container>> _ps( - bool all, - const Option<std::string>& prefix) const - { - return Docker::ps(all, prefix); - } - - process::Future<Docker::Image> _pull( - const std::string& directory, - const std::string& image, - bool force) const - { - return Docker::pull(directory, image, force); - } - - process::Future<Nothing> _stop( - const std::string& containerName, - const Duration& timeout, - bool remove) const - { - return Docker::stop(containerName, timeout, remove); - } - - process::Future<Docker::Container> _inspect( - const std::string& containerName, - const Option<Duration>& retryInterval) - { - return Docker::inspect(containerName, retryInterval); - } -}; - - -// Definition of a mock DockerContainerizer to be used in tests with gmock. -class MockDockerContainerizer : public slave::DockerContainerizer { -public: - MockDockerContainerizer( - const slave::Flags& flags, - slave::Fetcher* fetcher, - const process::Owned<mesos::slave::ContainerLogger>& logger, - process::Shared<Docker> docker); - - MockDockerContainerizer( - const process::Owned<slave::DockerContainerizerProcess>& process); - - virtual ~MockDockerContainerizer(); - - void initialize() - { - // NOTE: See TestContainerizer::setup for why we use - // 'EXPECT_CALL' and 'WillRepeatedly' here instead of - // 'ON_CALL' and 'WillByDefault'. - EXPECT_CALL(*this, launch(_, _, _, _, _, _, _, _)) - .WillRepeatedly(Invoke(this, &MockDockerContainerizer::_launch)); - - EXPECT_CALL(*this, update(_, _)) - .WillRepeatedly(Invoke(this, &MockDockerContainerizer::_update)); - } - - MOCK_METHOD8( - launch, - process::Future<bool>( - const ContainerID&, - const Option<TaskInfo>&, - const ExecutorInfo&, - const std::string&, - const Option<std::string>&, - const SlaveID&, - const std::map<std::string, std::string>&, - bool checkpoint)); - - MOCK_METHOD2( - update, - process::Future<Nothing>( - const ContainerID&, - const Resources&)); - - // Default 'launch' implementation (necessary because we can't just - // use &slave::DockerContainerizer::launch with 'Invoke'). - process::Future<bool> _launch( - const ContainerID& containerId, - const Option<TaskInfo>& taskInfo, - const ExecutorInfo& executorInfo, - const std::string& directory, - const Option<std::string>& user, - const SlaveID& slaveId, - const std::map<std::string, std::string>& environment, - bool checkpoint) - { - return slave::DockerContainerizer::launch( - containerId, - taskInfo, - executorInfo, - directory, - user, - slaveId, - environment, - checkpoint); - } - - process::Future<Nothing> _update( - const ContainerID& containerId, - const Resources& resources) - { - return slave::DockerContainerizer::update( - containerId, - resources); - } -}; - - -// Definition of a mock DockerContainerizerProcess to be used in tests -// with gmock. -class MockDockerContainerizerProcess : public slave::DockerContainerizerProcess -{ -public: - MockDockerContainerizerProcess( - const slave::Flags& flags, - slave::Fetcher* fetcher, - const process::Owned<mesos::slave::ContainerLogger>& logger, - const process::Shared<Docker>& docker); - - virtual ~MockDockerContainerizerProcess(); - - MOCK_METHOD2( - fetch, - process::Future<Nothing>( - const ContainerID& containerId, - const SlaveID& slaveId)); - - MOCK_METHOD1( - pull, - process::Future<Nothing>(const ContainerID& containerId)); - - process::Future<Nothing> _fetch( - const ContainerID& containerId, - const SlaveID& slaveId) - { - return slave::DockerContainerizerProcess::fetch(containerId, slaveId); - } - - process::Future<Nothing> _pull(const ContainerID& containerId) - { - return slave::DockerContainerizerProcess::pull(containerId); - } -}; - - // Definition of a MockAuthorizer that can be used in tests with gmock. class MockAuthorizer : public Authorizer { http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/tests/mock_docker.cpp ---------------------------------------------------------------------- diff --git a/src/tests/mock_docker.cpp b/src/tests/mock_docker.cpp new file mode 100644 index 0000000..6a0e613 --- /dev/null +++ b/src/tests/mock_docker.cpp @@ -0,0 +1,109 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include <string> + +#include <mesos/slave/container_logger.hpp> + +#include <process/owned.hpp> +#include <process/shared.hpp> + +#include <stout/json.hpp> +#include <stout/option.hpp> + +#include "slave/containerizer/docker.hpp" + +#include "tests/mock_docker.hpp" + +using mesos::slave::ContainerLogger; + +using std::string; + +using process::Owned; +using process::Shared; + +namespace mesos { +namespace internal { +namespace tests { + +MockDocker::MockDocker( + const string& path, + const string& socket, + const Option<JSON::Object>& config) + : Docker(path, socket, config) +{ + EXPECT_CALL(*this, ps(_, _)) + .WillRepeatedly(Invoke(this, &MockDocker::_ps)); + + EXPECT_CALL(*this, pull(_, _, _)) + .WillRepeatedly(Invoke(this, &MockDocker::_pull)); + + EXPECT_CALL(*this, stop(_, _, _)) + .WillRepeatedly(Invoke(this, &MockDocker::_stop)); + + EXPECT_CALL(*this, run(_, _, _, _, _, _, _, _, _, _)) + .WillRepeatedly(Invoke(this, &MockDocker::_run)); + + EXPECT_CALL(*this, inspect(_, _)) + .WillRepeatedly(Invoke(this, &MockDocker::_inspect)); +} + + +MockDocker::~MockDocker() {} + + +MockDockerContainerizer::MockDockerContainerizer( + const slave::Flags& flags, + slave::Fetcher* fetcher, + const Owned<ContainerLogger>& logger, + Shared<Docker> docker) + : slave::DockerContainerizer(flags, fetcher, logger, docker) +{ + initialize(); +} + + +MockDockerContainerizer::MockDockerContainerizer( + const Owned<slave::DockerContainerizerProcess>& process) + : slave::DockerContainerizer(process) +{ + initialize(); +} + + +MockDockerContainerizer::~MockDockerContainerizer() {} + + +MockDockerContainerizerProcess::MockDockerContainerizerProcess( + const slave::Flags& flags, + slave::Fetcher* fetcher, + const Owned<ContainerLogger>& logger, + const Shared<Docker>& docker) + : slave::DockerContainerizerProcess(flags, fetcher, logger, docker) +{ + EXPECT_CALL(*this, fetch(_, _)) + .WillRepeatedly(Invoke(this, &MockDockerContainerizerProcess::_fetch)); + + EXPECT_CALL(*this, pull(_)) + .WillRepeatedly(Invoke(this, &MockDockerContainerizerProcess::_pull)); +} + + +MockDockerContainerizerProcess::~MockDockerContainerizerProcess() {} + +} // namespace tests { +} // namespace internal { +} // namespace mesos { http://git-wip-us.apache.org/repos/asf/mesos/blob/97c78552/src/tests/mock_docker.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mock_docker.hpp b/src/tests/mock_docker.hpp new file mode 100644 index 0000000..1bf09c8 --- /dev/null +++ b/src/tests/mock_docker.hpp @@ -0,0 +1,271 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef __TESTS_MOCKDOCKER_HPP__ +#define __TESTS_MOCKDOCKER_HPP__ + +#include <list> +#include <map> +#include <string> +#include <vector> + +#include <gmock/gmock.h> + +#include <mesos/resources.hpp> + +#include <mesos/slave/container_logger.hpp> + +#include <process/future.hpp> +#include <process/owned.hpp> +#include <process/shared.hpp> + +#include <stout/json.hpp> +#include <stout/option.hpp> + +#include "slave/containerizer/docker.hpp" + +using ::testing::_; +using ::testing::Invoke; + +namespace mesos { +namespace internal { +namespace tests { + +// Definition of a mock Docker to be used in tests with gmock. +class MockDocker : public Docker +{ +public: + MockDocker( + const std::string& path, + const std::string& socket, + const Option<JSON::Object>& config = None()); + virtual ~MockDocker(); + + MOCK_CONST_METHOD10( + run, + process::Future<Option<int>>( + const mesos::ContainerInfo&, + const mesos::CommandInfo&, + const std::string&, + const std::string&, + const std::string&, + const Option<mesos::Resources>&, + const Option<std::map<std::string, std::string>>&, + const Option<std::vector<Device>>&, + const process::Subprocess::IO&, + const process::Subprocess::IO&)); + + MOCK_CONST_METHOD2( + ps, + process::Future<std::list<Docker::Container>>( + bool, const Option<std::string>&)); + + MOCK_CONST_METHOD3( + pull, + process::Future<Docker::Image>( + const std::string&, + const std::string&, + bool)); + + MOCK_CONST_METHOD3( + stop, + process::Future<Nothing>( + const std::string&, + const Duration&, + bool)); + + MOCK_CONST_METHOD2( + inspect, + process::Future<Docker::Container>( + const std::string&, + const Option<Duration>&)); + + process::Future<Option<int>> _run( + const mesos::ContainerInfo& containerInfo, + const mesos::CommandInfo& commandInfo, + const std::string& name, + const std::string& sandboxDirectory, + const std::string& mappedDirectory, + const Option<mesos::Resources>& resources, + const Option<std::map<std::string, std::string>>& env, + const Option<std::vector<Device>>& devices, + const process::Subprocess::IO& stdout, + const process::Subprocess::IO& stderr) const + { + return Docker::run( + containerInfo, + commandInfo, + name, + sandboxDirectory, + mappedDirectory, + resources, + env, + devices, + stdout, + stderr); + } + + process::Future<std::list<Docker::Container>> _ps( + bool all, + const Option<std::string>& prefix) const + { + return Docker::ps(all, prefix); + } + + process::Future<Docker::Image> _pull( + const std::string& directory, + const std::string& image, + bool force) const + { + return Docker::pull(directory, image, force); + } + + process::Future<Nothing> _stop( + const std::string& containerName, + const Duration& timeout, + bool remove) const + { + return Docker::stop(containerName, timeout, remove); + } + + process::Future<Docker::Container> _inspect( + const std::string& containerName, + const Option<Duration>& retryInterval) + { + return Docker::inspect(containerName, retryInterval); + } +}; + + +// Definition of a mock DockerContainerizer to be used in tests with gmock. +class MockDockerContainerizer : public slave::DockerContainerizer { +public: + MockDockerContainerizer( + const slave::Flags& flags, + slave::Fetcher* fetcher, + const process::Owned<mesos::slave::ContainerLogger>& logger, + process::Shared<Docker> docker); + + MockDockerContainerizer( + const process::Owned<slave::DockerContainerizerProcess>& process); + + virtual ~MockDockerContainerizer(); + + void initialize() + { + // NOTE: See TestContainerizer::setup for why we use + // 'EXPECT_CALL' and 'WillRepeatedly' here instead of + // 'ON_CALL' and 'WillByDefault'. + EXPECT_CALL(*this, launch(_, _, _, _, _, _, _, _)) + .WillRepeatedly(Invoke(this, &MockDockerContainerizer::_launch)); + + EXPECT_CALL(*this, update(_, _)) + .WillRepeatedly(Invoke(this, &MockDockerContainerizer::_update)); + } + + MOCK_METHOD8( + launch, + process::Future<bool>( + const ContainerID&, + const Option<TaskInfo>&, + const ExecutorInfo&, + const std::string&, + const Option<std::string>&, + const SlaveID&, + const std::map<std::string, std::string>&, + bool checkpoint)); + + MOCK_METHOD2( + update, + process::Future<Nothing>( + const ContainerID&, + const Resources&)); + + // Default 'launch' implementation (necessary because we can't just + // use &slave::DockerContainerizer::launch with 'Invoke'). + process::Future<bool> _launch( + const ContainerID& containerId, + const Option<TaskInfo>& taskInfo, + const ExecutorInfo& executorInfo, + const std::string& directory, + const Option<std::string>& user, + const SlaveID& slaveId, + const std::map<std::string, std::string>& environment, + bool checkpoint) + { + return slave::DockerContainerizer::launch( + containerId, + taskInfo, + executorInfo, + directory, + user, + slaveId, + environment, + checkpoint); + } + + process::Future<Nothing> _update( + const ContainerID& containerId, + const Resources& resources) + { + return slave::DockerContainerizer::update( + containerId, + resources); + } +}; + + +// Definition of a mock DockerContainerizerProcess to be used in tests +// with gmock. +class MockDockerContainerizerProcess : public slave::DockerContainerizerProcess +{ +public: + MockDockerContainerizerProcess( + const slave::Flags& flags, + slave::Fetcher* fetcher, + const process::Owned<mesos::slave::ContainerLogger>& logger, + const process::Shared<Docker>& docker); + + virtual ~MockDockerContainerizerProcess(); + + MOCK_METHOD2( + fetch, + process::Future<Nothing>( + const ContainerID& containerId, + const SlaveID& slaveId)); + + MOCK_METHOD1( + pull, + process::Future<Nothing>(const ContainerID& containerId)); + + process::Future<Nothing> _fetch( + const ContainerID& containerId, + const SlaveID& slaveId) + { + return slave::DockerContainerizerProcess::fetch(containerId, slaveId); + } + + process::Future<Nothing> _pull(const ContainerID& containerId) + { + return slave::DockerContainerizerProcess::pull(containerId); + } +}; + +} // namespace tests { +} // namespace internal { +} // namespace mesos { + +#endif // __TESTS_MOCKDOCKER_HPP__