Repository: mesos
Updated Branches:
  refs/heads/master f433cdd0c -> 5e23edd51


Pulled out the mock containerizer into a header for reuse.

This also adds a mock of the newly introduce nested container
`launch()` member function.

Review: https://reviews.apache.org/r/52134


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/60ee7315
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/60ee7315
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/60ee7315

Branch: refs/heads/master
Commit: 60ee731561d876690f329661ae030111f068f519
Parents: f433cdd
Author: Benjamin Mahler <bmah...@apache.org>
Authored: Wed Sep 21 13:31:14 2016 -0700
Committer: Benjamin Mahler <bmah...@apache.org>
Committed: Thu Sep 22 11:46:00 2016 -0700

----------------------------------------------------------------------
 src/Makefile.am                                 |  1 +
 .../composing_containerizer_tests.cpp           | 48 +---------
 src/tests/containerizer/mock_containerizer.hpp  | 95 ++++++++++++++++++++
 3 files changed, 98 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/60ee7315/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 239e5af..bfdb66a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1002,6 +1002,7 @@ libmesos_no_3rdparty_la_SOURCES +=                        
                \
   tests/containerizer/isolator.hpp                                     \
   tests/containerizer/launcher.hpp                                     \
   tests/containerizer/memory_test_helper.hpp                           \
+  tests/containerizer/mock_containerizer.hpp                           \
   tests/containerizer/rootfs.hpp                                       \
   tests/containerizer/setns_test_helper.hpp                            \
   tests/containerizer/store.hpp                                                
\

http://git-wip-us.apache.org/repos/asf/mesos/blob/60ee7315/src/tests/containerizer/composing_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/composing_containerizer_tests.cpp 
b/src/tests/containerizer/composing_containerizer_tests.cpp
index 6772c7e..631328a 100644
--- a/src/tests/containerizer/composing_containerizer_tests.cpp
+++ b/src/tests/containerizer/composing_containerizer_tests.cpp
@@ -33,6 +33,8 @@
 
 #include "tests/mesos.hpp"
 
+#include "tests/containerizer/mock_containerizer.hpp"
+
 using namespace mesos::internal::slave;
 
 using namespace process;
@@ -49,54 +51,8 @@ namespace mesos {
 namespace internal {
 namespace tests {
 
-
 class ComposingContainerizerTest : public MesosTest {};
 
-class MockContainerizer : public slave::Containerizer
-{
-public:
-  MOCK_METHOD1(
-      recover,
-      process::Future<Nothing>(
-          const Option<slave::state::SlaveState>&));
-
-  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));
-
-  MOCK_METHOD2(
-      update,
-      process::Future<Nothing>(
-          const ContainerID&,
-          const Resources&));
-
-  MOCK_METHOD1(
-      usage,
-      process::Future<ResourceStatistics>(
-          const ContainerID&));
-
-  MOCK_METHOD1(
-      wait,
-      process::Future<Option<ContainerTermination>>(
-          const ContainerID&));
-
-  MOCK_METHOD1(
-      destroy,
-      process::Future<bool>(const ContainerID&));
-
-  MOCK_METHOD0(
-      containers,
-      process::Future<hashset<ContainerID>>());
-};
-
 
 // This test ensures that destroy can be called while in the
 // launch loop. The composing containerizer still calls the

http://git-wip-us.apache.org/repos/asf/mesos/blob/60ee7315/src/tests/containerizer/mock_containerizer.hpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/mock_containerizer.hpp 
b/src/tests/containerizer/mock_containerizer.hpp
new file mode 100644
index 0000000..840c511
--- /dev/null
+++ b/src/tests/containerizer/mock_containerizer.hpp
@@ -0,0 +1,95 @@
+// 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 <map>
+#include <string>
+
+#include <gmock/gmock.h>
+
+#include <mesos/mesos.hpp>
+#include <mesos/resources.hpp>
+
+#include <mesos/slave/containerizer.hpp>
+
+#include <process/future.hpp>
+#include <process/gmock.hpp>
+
+#include <stout/hashset.hpp>
+#include <stout/nothing.hpp>
+#include <stout/option.hpp>
+
+#include "slave/containerizer/containerizer.hpp"
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+class MockContainerizer : public slave::Containerizer
+{
+public:
+  MOCK_METHOD1(
+      recover,
+      process::Future<Nothing>(
+          const Option<slave::state::SlaveState>&));
+
+  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));
+
+  MOCK_METHOD4(
+      launch,
+      process::Future<Nothing>(
+          const ContainerID& containerId,
+          const CommandInfo& commandInfo,
+          const Option<ContainerInfo>& containerInfo,
+          const Resources& resources));
+
+  MOCK_METHOD2(
+      update,
+      process::Future<Nothing>(
+          const ContainerID&,
+          const Resources&));
+
+  MOCK_METHOD1(
+      usage,
+      process::Future<ResourceStatistics>(
+          const ContainerID&));
+
+  MOCK_METHOD1(
+      wait,
+      process::Future<Option<mesos::slave::ContainerTermination>>(
+          const ContainerID&));
+
+  MOCK_METHOD1(
+      destroy,
+      process::Future<bool>(const ContainerID&));
+
+  MOCK_METHOD0(
+      containers,
+      process::Future<hashset<ContainerID>>());
+};
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {

Reply via email to