Added a persistent volume test for linux filesystem isolator to test case where the container does not specify a root filesystem.
Review: https://reviews.apache.org/r/37422 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fd9b2833 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fd9b2833 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fd9b2833 Branch: refs/heads/master Commit: fd9b283310ad93c02ca1cedea85065dc99b581d1 Parents: 1ff6e26 Author: Jie Yu <[email protected]> Authored: Wed Aug 12 16:32:46 2015 -0700 Committer: Jie Yu <[email protected]> Committed: Wed Aug 12 16:57:23 2015 -0700 ---------------------------------------------------------------------- .../containerizer/filesystem_isolator_tests.cpp | 62 +++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/fd9b2833/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 c00ac80..7003b03 100644 --- a/src/tests/containerizer/filesystem_isolator_tests.cpp +++ b/src/tests/containerizer/filesystem_isolator_tests.cpp @@ -332,7 +332,7 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_VolumeFromHostSandboxMountPoint) // This test verifies that persistent volumes are properly mounted in // the container's root filesystem. -TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolume) +TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithRootFilesystem) { slave::Flags flags = CreateSlaveFlags(); flags.work_dir = os::getcwd(); @@ -390,6 +390,66 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolume) EXPECT_SOME_EQ("abc\n", os::read(path::join(volume, "file"))); } + + +TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithoutRootFilesystem) +{ + 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({}, false)); + + // 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 {
