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 2018/02/08 01:25:54 UTC

[04/12] mesos git commit: Cleaned up endpoint directories after SLRP tests.

Cleaned up endpoint directories after SLRP tests.

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


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

Branch: refs/heads/master
Commit: bc2ec03ba3946275d8d230bd55ce5347391c2280
Parents: e39a610
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Wed Feb 7 16:03:56 2018 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Feb 7 16:03:56 2018 -0800

----------------------------------------------------------------------
 .../storage_local_resource_provider_tests.cpp   | 44 +++++++++++++++++++-
 1 file changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/bc2ec03b/src/tests/storage_local_resource_provider_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/storage_local_resource_provider_tests.cpp b/src/tests/storage_local_resource_provider_tests.cpp
index 67dc8e6..dd8bc52 100644
--- a/src/tests/storage_local_resource_provider_tests.cpp
+++ b/src/tests/storage_local_resource_provider_tests.cpp
@@ -71,7 +71,7 @@ class StorageLocalResourceProviderTest
 public:
   virtual void SetUp()
   {
-    MesosTest::SetUp();
+    ContainerizerTest<slave::MesosContainerizer>::SetUp();
 
     testCsiPluginWorkDir = path::join(sandbox.get(), "test");
     ASSERT_SOME(os::mkdir(testCsiPluginWorkDir));
@@ -95,7 +95,46 @@ public:
       }
     }
 
-    MesosTest::TearDown();
+    foreach (const string& slaveWorkDir, slaveWorkDirs) {
+      // Clean up CSI endpoint directories if there is any.
+      const string csiRootDir = slave::paths::getCsiRootDir(slaveWorkDir);
+
+      Try<list<string>> csiContainerPaths =
+        csi::paths::getContainerPaths(csiRootDir, "*", "*");
+      ASSERT_SOME(csiContainerPaths);
+
+      foreach (const string& path, csiContainerPaths.get()) {
+        Try<csi::paths::ContainerPath> containerPath =
+          csi::paths::parseContainerPath(csiRootDir, path);
+        ASSERT_SOME(containerPath);
+
+        Result<string> endpointDir =
+          os::realpath(csi::paths::getEndpointDirSymlinkPath(
+              csiRootDir,
+              containerPath->type,
+              containerPath->name,
+              containerPath->containerId));
+
+        if (endpointDir.isSome()) {
+          ASSERT_SOME(os::rmdir(endpointDir.get()));
+        }
+      }
+    }
+
+    ContainerizerTest<slave::MesosContainerizer>::TearDown();
+  }
+
+  virtual slave::Flags CreateSlaveFlags()
+  {
+    slave::Flags flags =
+      ContainerizerTest<slave::MesosContainerizer>::CreateSlaveFlags();
+
+    // Store the agent work directory for cleaning up CSI endpoint
+    // directories during teardown.
+    // NOTE: DO NOT change the work directory afterward.
+    slaveWorkDirs.push_back(flags.work_dir);
+
+    return flags;
   }
 
   void loadUriDiskProfileModule()
@@ -219,6 +258,7 @@ public:
 
 protected:
   Modules modules;
+  vector<string> slaveWorkDirs;
   string resourceProviderConfigDir;
   string testCsiPluginWorkDir;
   string uriDiskProfileConfigPath;