You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/05/26 01:41:04 UTC

[13/16] mesos git commit: Added test helpers to tranlate to ContainerConfig.

Added test helpers to tranlate to ContainerConfig.

This adds a helper that emulates the logic in the Agent's launch path.
Now that the Containerizer takes a ContainerConfig instead of
a TaskInfo/ExecutorInfo/Directory/SlaveID/User, tests that call
the containerizer directly will need to translate to
ContainerConfig.

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


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

Branch: refs/heads/master
Commit: 012e6a26b2d4debe8bd32fb8337d86005217e24b
Parents: 46da722
Author: Joseph Wu <jo...@apache.org>
Authored: Mon May 1 17:12:14 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Thu May 25 18:37:07 2017 -0700

----------------------------------------------------------------------
 src/tests/mesos.hpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/012e6a26/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 9b04a40..48072a9 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -1083,6 +1083,67 @@ inline CommandInfo createCommandInfo(
 }
 
 
+// Almost a direct snippet of code at the bottom of `Slave::launchExecutor`.
+inline mesos::slave::ContainerConfig createContainerConfig(
+    const Option<TaskInfo>& taskInfo,
+    const ExecutorInfo& executorInfo,
+    const std::string& sandboxDirectory,
+    const Option<std::string>& user = None())
+{
+  mesos::slave::ContainerConfig containerConfig;
+  containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
+  containerConfig.mutable_command_info()->CopyFrom(executorInfo.command());
+  containerConfig.mutable_resources()->CopyFrom(executorInfo.resources());
+  containerConfig.set_directory(sandboxDirectory);
+
+  if (user.isSome()) {
+    containerConfig.set_user(user.get());
+  }
+
+  if (taskInfo.isSome()) {
+    containerConfig.mutable_task_info()->CopyFrom(taskInfo.get());
+
+    if (taskInfo.get().has_container()) {
+      containerConfig.mutable_container_info()
+        ->CopyFrom(taskInfo.get().container());
+    }
+  } else {
+    if (executorInfo.has_container()) {
+      containerConfig.mutable_container_info()
+        ->CopyFrom(executorInfo.container());
+    }
+  }
+
+  return containerConfig;
+}
+
+
+// Almost a direct snippet of code in `Slave::Http::_launchNestedContainer`.
+inline mesos::slave::ContainerConfig createContainerConfig(
+    const CommandInfo& commandInfo,
+    const Option<ContainerInfo>& containerInfo = None(),
+    const Option<mesos::slave::ContainerClass>& containerClass = None(),
+    const Option<std::string>& user = None())
+{
+  mesos::slave::ContainerConfig containerConfig;
+  containerConfig.mutable_command_info()->CopyFrom(commandInfo);
+
+  if (user.isSome()) {
+    containerConfig.set_user(user.get());
+  }
+
+  if (containerInfo.isSome()) {
+    containerConfig.mutable_container_info()->CopyFrom(containerInfo.get());
+  }
+
+  if (containerClass.isSome()) {
+    containerConfig.set_container_class(containerClass.get());
+  }
+
+  return containerConfig;
+}
+
+
 template <typename... Args>
 inline Image createDockerImage(Args&&... args)
 {