You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/10/07 16:38:58 UTC

[08/10] mesos git commit: Moved a few test helpers to the common header.

Moved a few test helpers to the common header.

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


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

Branch: refs/heads/master
Commit: 1c27db568fcc09714b5a89a6498467d309d18c66
Parents: bafcbf7
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Oct 4 22:43:11 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Oct 7 09:31:17 2016 -0700

----------------------------------------------------------------------
 .../linux_filesystem_isolator_tests.cpp         | 25 ---------------
 src/tests/mesos.hpp                             | 32 ++++++++++++++++++--
 2 files changed, 30 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1c27db56/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/linux_filesystem_isolator_tests.cpp b/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
index 756c175..83b2f6a 100644
--- a/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
+++ b/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
@@ -85,29 +85,6 @@ protected:
     MesosTest::TearDown();
   }
 
-  // TODO(jieyu): Move this to the common test utils file.
-  ContainerInfo createContainerInfo(
-      const Option<string>& imageName = None(),
-      const vector<Volume>& volumes = vector<Volume>())
-  {
-    ContainerInfo info;
-    info.set_type(ContainerInfo::MESOS);
-
-    if (imageName.isSome()) {
-      Image* image = info.mutable_mesos()->mutable_image();
-      image->set_type(Image::DOCKER);
-
-      Image::Docker* docker = image->mutable_docker();
-      docker->set_name(imageName.get());
-    }
-
-    foreach (const Volume& volume, volumes) {
-      info.add_volumes()->CopyFrom(volume);
-    }
-
-    return info;
-  }
-
   Fetcher fetcher;
 };
 
@@ -623,8 +600,6 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithoutRootFilesystem)
       "persistent_volume_id",
       "volume"));
 
-  executor.mutable_container()->CopyFrom(createContainerInfo());
-
   // Create a persistent volume.
   string volume = slave::paths::getPersistentVolumePath(
       flags.work_dir,

http://git-wip-us.apache.org/repos/asf/mesos/blob/1c27db56/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 54c035d..8bda440 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -421,6 +421,15 @@ inline CommandInfo createCommandInfo(const std::string& command)
 }
 
 
+inline Image createDockerImage(const std::string& imageName)
+{
+  Image image;
+  image.set_type(Image::DOCKER);
+  image.mutable_docker()->set_name(imageName);
+  return image;
+}
+
+
 inline Volume createVolumeFromHostPath(
     const std::string& containerPath,
     const std::string& hostPath,
@@ -442,12 +451,31 @@ inline Volume createVolumeFromDockerImage(
   Volume volume;
   volume.set_container_path(containerPath);
   volume.set_mode(mode);
-  volume.mutable_image()->set_type(Image::DOCKER);
-  volume.mutable_image()->mutable_docker()->set_name(imageName);
+  volume.mutable_image()->CopyFrom(createDockerImage(imageName));
   return volume;
 }
 
 
+inline ContainerInfo createContainerInfo(
+    const Option<std::string> imageName = None(),
+    const vector<Volume>& volumes = {})
+{
+  ContainerInfo info;
+  info.set_type(ContainerInfo::MESOS);
+
+  if (imageName.isSome()) {
+    Image* image = info.mutable_mesos()->mutable_image();
+    image->CopyFrom(createDockerImage(imageName.get()));
+  }
+
+  foreach (const Volume& volume, volumes) {
+    info.add_volumes()->CopyFrom(volume);
+  }
+
+  return info;
+}
+
+
 // TODO(bmahler): Refactor this to make the distinction between
 // command tasks and executor tasks clearer.
 inline TaskInfo createTask(