Added a filesystem isolator test to test image in volume while the
container root filesystem is also specified.

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


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

Branch: refs/heads/master
Commit: 33058278e4839fdfaf65b2adc7785e61d74b6775
Parents: 40638c5
Author: Jie Yu <[email protected]>
Authored: Mon Aug 24 16:22:08 2015 -0700
Committer: Jie Yu <[email protected]>
Committed: Wed Aug 26 14:26:29 2015 -0700

----------------------------------------------------------------------
 .../containerizer/filesystem_isolator_tests.cpp | 55 +++++++++++++++++++-
 1 file changed, 53 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/33058278/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 13f629c..ffa371f 100644
--- a/src/tests/containerizer/filesystem_isolator_tests.cpp
+++ b/src/tests/containerizer/filesystem_isolator_tests.cpp
@@ -506,8 +506,9 @@ TEST_F(LinuxFilesystemIsolatorTest, 
ROOT_PersistentVolumeWithoutRootFilesystem)
 
 
 // This test verifies that the image specified in the volume will be
-// properly provisioned and mounted into the container.
-TEST_F(LinuxFilesystemIsolatorTest, ROOT_ImageInVolume)
+// properly provisioned and mounted into the container if container
+// root filesystem is not specified.
+TEST_F(LinuxFilesystemIsolatorTest, ROOT_ImageInVolumeWithoutRootFilesystem)
 {
   slave::Flags flags = CreateSlaveFlags();
 
@@ -552,6 +553,56 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_ImageInVolume)
   EXPECT_TRUE(wait.get().has_status());
   EXPECT_EQ(0, wait.get().status());
 }
+
+
+// This test verifies that the image specified in the volume will be
+// properly provisioned and mounted into the container if container
+// root filesystem is specified.
+TEST_F(LinuxFilesystemIsolatorTest, ROOT_ImageInVolumeWithRootFilesystem)
+{
+  slave::Flags flags = CreateSlaveFlags();
+
+  Try<Owned<MesosContainerizer>> containerizer =
+    createContainerizer(flags, {"test_image_rootfs", "test_image_volume"});
+
+  ASSERT_SOME(containerizer);
+
+  ContainerID containerId;
+  containerId.set_value(UUID::random().toString());
+
+  ExecutorInfo executor = CREATE_EXECUTOR_INFO(
+      "test_executor",
+      "[ ! -d '" + os::getcwd() + "' ] && [ -d rootfs/bin ]");
+
+  executor.mutable_container()->CopyFrom(createContainerInfo(
+      "test_image_rootfs",
+      {createVolumeFromImage("rootfs", "test_image_volume", Volume::RW)}));
+
+  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());
+}
 #endif // __linux__
 
 } // namespace tests {

Reply via email to