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 2015/08/13 02:29:07 UTC
[5/6] mesos git commit: Added a persistent volume test for linux
filesystem isolator.
Added a persistent volume test for linux filesystem isolator.
Review: https://reviews.apache.org/r/37334
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1ff6e269
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1ff6e269
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1ff6e269
Branch: refs/heads/master
Commit: 1ff6e269b70164409fec359644a1674cf02947cb
Parents: 0b3cdec
Author: Jie Yu <yu...@gmail.com>
Authored: Mon Aug 10 18:57:05 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Aug 12 16:53:44 2015 -0700
----------------------------------------------------------------------
.../containerizer/filesystem_isolator_tests.cpp | 64 ++++++++++++++++++++
1 file changed, 64 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1ff6e269/src/tests/containerizer/filesystem_isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/filesystem_isolator_tests.cpp b/src/tests/containerizer/filesystem_isolator_tests.cpp
index 98320ee..c00ac80 100644
--- a/src/tests/containerizer/filesystem_isolator_tests.cpp
+++ b/src/tests/containerizer/filesystem_isolator_tests.cpp
@@ -30,6 +30,8 @@
#include <stout/path.hpp>
#include <stout/uuid.hpp>
+#include "slave/paths.hpp"
+
#ifdef __linux__
#include "slave/containerizer/linux_launcher.hpp"
@@ -326,6 +328,68 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_VolumeFromHostSandboxMountPoint)
EXPECT_TRUE(wait.get().has_status());
EXPECT_EQ(0, wait.get().status());
}
+
+
+// This test verifies that persistent volumes are properly mounted in
+// the container's root filesystem.
+TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolume)
+{
+ slave::Flags flags = CreateSlaveFlags();
+ flags.work_dir = os::getcwd();
+
+ Try<Owned<MesosContainerizer>> containerizer = createContainerizer(flags);
+ ASSERT_SOME(containerizer);
+
+ ContainerID containerId;
+ containerId.set_value(UUID::random().toString());
+
+ ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+ "test_executor",
+ "echo abc > volume/file");
+
+ executor.add_resources()->CopyFrom(createPersistentVolume(
+ Megabytes(32),
+ "test_role",
+ "persistent_volume_id",
+ "volume"));
+
+ executor.mutable_container()->CopyFrom(createContainerInfo());
+
+ // Create a persistent volume.
+ string volume = slave::paths::getPersistentVolumePath(
+ os::getcwd(),
+ "test_role",
+ "persistent_volume_id");
+
+ ASSERT_SOME(os::mkdir(volume));
+
+ string directory = path::join(os::getcwd(), "sandbox");
+ ASSERT_SOME(os::mkdir(directory));
+
+ Future<bool> launch = containerizer.get()->launch(
+ containerId,
+ executor,
+ directory,
+ None(),
+ SlaveID(),
+ PID<Slave>(),
+ false);
+
+ // Wait for the launch to complete.
+ AWAIT_READY(launch);
+
+ // Wait on the container.
+ Future<containerizer::Termination> wait =
+ containerizer.get()->wait(containerId);
+
+ AWAIT_READY(wait);
+
+ // Check the executor exited correctly.
+ EXPECT_TRUE(wait.get().has_status());
+ EXPECT_EQ(0, wait.get().status());
+
+ EXPECT_SOME_EQ("abc\n", os::read(path::join(volume, "file")));
+}
#endif // __linux__
} // namespace tests {