You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by dm...@apache.org on 2015/02/04 19:01:13 UTC

[2/2] mesos git commit: Refactor and increase test coverage for slave paths.

Refactor and increase test coverage for slave paths.

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


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

Branch: refs/heads/master
Commit: ffddcfb53168d42f92e4771c6f8a8a9a818fd6b8
Parents: 7075ef8
Author: Dominic Hamon <dm...@twitter.com>
Authored: Wed Feb 4 09:16:41 2015 -0800
Committer: Dominic Hamon <dm...@twitter.com>
Committed: Wed Feb 4 10:00:22 2015 -0800

----------------------------------------------------------------------
 src/tests/paths_tests.cpp | 118 +++++++++++++++++++++++++++++++++++------
 1 file changed, 101 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ffddcfb5/src/tests/paths_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/paths_tests.cpp b/src/tests/paths_tests.cpp
index 417aa51..9b71796 100644
--- a/src/tests/paths_tests.cpp
+++ b/src/tests/paths_tests.cpp
@@ -42,7 +42,7 @@ using strings::format;
 class PathsTest : public ::testing::Test
 {
 public:
-  PathsTest()
+  virtual void SetUp()
   {
     slaveId.set_value("slave1");
     frameworkId.set_value("framework1");
@@ -57,7 +57,7 @@ public:
     rootDir = path.get();
   }
 
-  virtual ~PathsTest()
+  virtual void TearDown()
   {
      os::rmdir(rootDir);
   }
@@ -95,32 +95,116 @@ TEST_F(PathsTest, CreateExecutorDirectory)
 }
 
 
-TEST_F(PathsTest, Format)
+TEST_F(PathsTest, Meta)
 {
-  string dir = rootDir;
+  EXPECT_EQ(path::join(rootDir, "meta"), paths::getMetaRootDir(rootDir));
+}
 
-  dir = path::join(dir, "slaves", slaveId.value());
 
-  EXPECT_EQ(dir, paths::getSlavePath(rootDir, slaveId));
+TEST_F(PathsTest, Archive)
+{
+  EXPECT_EQ(path::join(rootDir, "archive"), paths::getArchiveDir(rootDir));
+}
 
-  dir = path::join(dir, "frameworks", frameworkId.value());
 
-  EXPECT_EQ(dir, paths::getFrameworkPath(rootDir, slaveId, frameworkId));
+TEST_F(PathsTest, BootId)
+{
+  EXPECT_EQ(path::join(rootDir, "boot_id"), paths::getBootIdPath(rootDir));
+}
 
-  dir = path::join(dir, "executors", executorId.value());
 
-  EXPECT_EQ(dir, paths::getExecutorPath(
-      rootDir, slaveId, frameworkId, executorId));
+TEST_F(PathsTest, Slave)
+{
+  const string slavesRoot = path::join(rootDir, "slaves");
 
-  dir = path::join(dir, "runs", containerId.value());
+  EXPECT_EQ(path::join(slavesRoot, "latest"),
+            paths::getLatestSlavePath(rootDir));
+
+  EXPECT_EQ(path::join(slavesRoot, slaveId.value()),
+            paths::getSlavePath(rootDir, slaveId));
+}
 
-  EXPECT_EQ(dir, paths::getExecutorRunPath(
-      rootDir, slaveId, frameworkId, executorId, containerId));
 
-  dir = path::join(dir, "tasks", taskId.value());
+TEST_F(PathsTest, Framework)
+{
+  const string frameworksRoot =
+      path::join(paths::getSlavePath(rootDir, slaveId), "frameworks");
+
+  EXPECT_EQ(path::join(frameworksRoot, frameworkId.value()),
+            paths::getFrameworkPath(rootDir, slaveId, frameworkId));
+}
 
-  EXPECT_EQ(dir, paths::getTaskPath(
-      rootDir, slaveId, frameworkId, executorId, containerId, taskId));
+
+TEST_F(PathsTest, Executor)
+{
+  const string executorsRoot =
+      path::join(
+          paths::getFrameworkPath(
+              rootDir,
+              slaveId,
+              frameworkId),
+          "executors");
+
+  EXPECT_EQ(path::join(executorsRoot, executorId.value()),
+            paths::getExecutorPath(rootDir, slaveId, frameworkId, executorId));
+
+  EXPECT_EQ(
+      path::join(
+          executorsRoot,
+          executorId.value(),
+          "runs",
+          containerId.value()),
+      paths::getExecutorRunPath(
+          rootDir,
+          slaveId,
+          frameworkId,
+          executorId,
+          containerId));
+}
+
+
+TEST_F(PathsTest, LibProcessPid)
+{
+  EXPECT_EQ(
+      path::join(
+          getExecutorRunPath(
+              rootDir,
+              slaveId,
+              frameworkId,
+              executorId,
+              containerId),
+          "pids",
+          "libprocess.pid"),
+      paths::getLibprocessPidPath(
+          rootDir,
+          slaveId,
+          frameworkId,
+          executorId,
+          containerId));
+}
+
+
+TEST_F(PathsTest, Task)
+{
+  const string tasksRoot =
+      path::join(
+          paths::getExecutorRunPath(
+              rootDir,
+              slaveId,
+              frameworkId,
+              executorId,
+              containerId),
+          "tasks");
+
+  EXPECT_EQ(
+      path::join(tasksRoot, taskId.value()),
+      paths::getTaskPath(
+          rootDir,
+          slaveId,
+          frameworkId,
+          executorId,
+          containerId,
+          taskId));
 }