Repository: mesos
Updated Branches:
  refs/heads/master 8e1596396 -> 559066638


Added a test to verify persistent volume mount points removal.

This test is used to catch regression related to MESOS-7366.

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


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

Branch: refs/heads/master
Commit: 5590666384bcaab457a4d727de9a39818b84e2a3
Parents: cf7d1ae
Author: Jie Yu <[email protected]>
Authored: Fri Apr 7 16:41:45 2017 -0700
Committer: Jie Yu <[email protected]>
Committed: Tue Apr 11 16:31:06 2017 -0700

----------------------------------------------------------------------
 .../linux_filesystem_isolator_tests.cpp         | 77 ++++++++++++++++++++
 1 file changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/55906663/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 5e489ef..70a0dce 100644
--- a/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
+++ b/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
@@ -811,6 +811,83 @@ TEST_F(LinuxFilesystemIsolatorTest, 
ROOT_WorkDirMountNeeded)
 }
 
 
+// This test tries to catch the regression for MESOS-7366. It verifies
+// that the persistent volume mount points in the sandbox will be
+// cleaned up even if there is still reference to the volume.
+TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeMountPointCleanup)
+{
+  slave::Flags flags = CreateSlaveFlags();
+  flags.isolation = "filesystem/linux";
+
+  Try<MesosContainerizer*> create =
+    MesosContainerizer::create(flags, true, &fetcher);
+
+  ASSERT_SOME(create);
+
+  Owned<Containerizer> containerizer(create.get());
+
+  ContainerID containerId;
+  containerId.set_value(UUID::random().toString());
+
+  ExecutorInfo executor = createExecutorInfo(
+      "test_executor",
+      "sleep 1000");
+
+  // Create a persistent volume.
+  executor.add_resources()->CopyFrom(createPersistentVolume(
+      Megabytes(32),
+      "test_role",
+      "persistent_volume_id",
+      "volume"));
+
+  string volume = slave::paths::getPersistentVolumePath(
+      flags.work_dir,
+      "test_role",
+      "persistent_volume_id");
+
+  ASSERT_SOME(os::mkdir(volume));
+
+  string directory = path::join(flags.work_dir, "sandbox");
+  ASSERT_SOME(os::mkdir(directory));
+
+  Future<bool> launch = containerizer->launch(
+      containerId,
+      None(),
+      executor,
+      directory,
+      None(),
+      SlaveID(),
+      map<string, string>(),
+      false);
+
+  AWAIT_READY(launch);
+
+  ASSERT_SOME(os::touch(path::join(directory, "volume", "abc")));
+
+  // This keeps a reference to the persistent volume mount.
+  Try<int_fd> fd = os::open(
+      path::join(directory, "volume", "abc"),
+      O_WRONLY | O_TRUNC | O_CLOEXEC,
+      S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+  ASSERT_SOME(fd);
+
+  containerizer->destroy(containerId);
+
+  Future<Option<ContainerTermination>> wait = containerizer->wait(containerId);
+
+  AWAIT_READY(wait);
+  ASSERT_SOME(wait.get());
+  ASSERT_TRUE(wait->get().has_status());
+  EXPECT_WTERMSIG_EQ(SIGKILL, wait.get()->status());
+
+  // Verifies that mount point has been removed.
+  EXPECT_FALSE(os::exists(path::join(directory, "volume", "abc")));
+
+  os::close(fd.get());
+}
+
+
 // End to end Mesos integration tests for linux filesystem isolator.
 class LinuxFilesystemIsolatorMesosTest : public LinuxFilesystemIsolatorTest {};
 

Reply via email to