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 2016/10/07 16:39:00 UTC

[10/10] mesos git commit: Moved image volume related tests to a separate file.

Moved image volume related tests to a separate file.

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


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

Branch: refs/heads/master
Commit: 131beaec229b8fe2a0b0b5155e4b7fb9dcb3ce43
Parents: 1c27db5
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Oct 4 23:04:52 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Oct 7 09:31:17 2016 -0700

----------------------------------------------------------------------
 src/Makefile.am                                 |   1 +
 .../linux_filesystem_isolator_tests.cpp         | 114 -------------
 .../volume_image_isolator_tests.cpp             | 167 +++++++++++++++++++
 3 files changed, 168 insertions(+), 114 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/131beaec/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index a28abe0..fd01e1d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2169,6 +2169,7 @@ mesos_tests_SOURCES =						\
   tests/containerizer/provisioner_backend_tests.cpp		\
   tests/containerizer/provisioner_docker_tests.cpp		\
   tests/containerizer/provisioner_paths_tests.cpp		\
+  tests/containerizer/volume_image_isolator_tests.cpp		\
   tests/containerizer/volume_sandbox_path_isolator_tests.cpp
 
 if ENABLE_XFS_DISK_ISOLATOR

http://git-wip-us.apache.org/repos/asf/mesos/blob/131beaec/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 83b2f6a..bf8a44d 100644
--- a/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
+++ b/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
@@ -634,120 +634,6 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithoutRootFilesystem)
 }
 
 
-// This test verifies that the image specified in the volume will be
-// properly provisioned and mounted into the container if container
-// root filesystem is not specified.
-TEST_F(LinuxFilesystemIsolatorTest, ROOT_ImageInVolumeWithoutRootFilesystem)
-{
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
-
-  slave::Flags flags = CreateSlaveFlags();
-  flags.isolation = "filesystem/linux,docker/runtime";
-  flags.docker_registry = registry;
-  flags.docker_store_dir = path::join(sandbox.get(), "store");
-  flags.image_providers = "docker";
-
-  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",
-      "test -d rootfs/bin");
-
-  executor.mutable_container()->CopyFrom(createContainerInfo(
-      None(),
-      {createVolumeFromDockerImage("rootfs", "test_image", Volume::RW)}));
-
-  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);
-
-  Future<Option<ContainerTermination>> wait = containerizer->wait(containerId);
-
-  AWAIT_READY(wait);
-  ASSERT_SOME(wait.get());
-  ASSERT_TRUE(wait->get().has_status());
-  EXPECT_WEXITSTATUS_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)
-{
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image_rootfs"));
-  AWAIT_READY(DockerArchive::create(registry, "test_image_volume"));
-
-  slave::Flags flags = CreateSlaveFlags();
-  flags.isolation = "filesystem/linux,docker/runtime";
-  flags.docker_registry = registry;
-  flags.docker_store_dir = path::join(sandbox.get(), "store");
-  flags.image_providers = "docker";
-
-  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",
-      "[ ! -d '" + sandbox.get() + "' ] && [ -d rootfs/bin ]");
-
-  executor.mutable_container()->CopyFrom(createContainerInfo(
-      "test_image_rootfs",
-      {createVolumeFromDockerImage(
-          "rootfs", "test_image_volume", Volume::RW)}));
-
-  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);
-
-  Future<Option<ContainerTermination>> wait = containerizer->wait(containerId);
-
-  AWAIT_READY(wait);
-  ASSERT_SOME(wait.get());
-  ASSERT_TRUE(wait->get().has_status());
-  EXPECT_WEXITSTATUS_EQ(0, wait->get().status());
-}
-
-
 // This test verifies that multiple containers with images can be
 // launched simultaneously with no interference.
 TEST_F(LinuxFilesystemIsolatorTest, ROOT_MultipleContainers)

http://git-wip-us.apache.org/repos/asf/mesos/blob/131beaec/src/tests/containerizer/volume_image_isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/volume_image_isolator_tests.cpp b/src/tests/containerizer/volume_image_isolator_tests.cpp
new file mode 100644
index 0000000..ec207f3
--- /dev/null
+++ b/src/tests/containerizer/volume_image_isolator_tests.cpp
@@ -0,0 +1,167 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <stout/gtest.hpp>
+#include <stout/os.hpp>
+
+#include <process/future.hpp>
+#include <process/gtest.hpp>
+
+#include "slave/containerizer/mesos/containerizer.hpp"
+
+#include "tests/cluster.hpp"
+#include "tests/mesos.hpp"
+
+#include "tests/containerizer/docker_archive.hpp"
+
+using process::Future;
+using process::Owned;
+
+using mesos::internal::slave::Containerizer;
+using mesos::internal::slave::Fetcher;
+using mesos::internal::slave::MesosContainerizer;
+
+using mesos::slave::ContainerTermination;
+
+using std::string;
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+class VolumeImageIsolatorTest : public MesosTest
+{
+protected:
+  Fetcher fetcher;
+};
+
+
+// This test verifies that the image specified in the volume will be
+// properly provisioned and mounted into the container if container
+// root filesystem is not specified.
+TEST_F(VolumeImageIsolatorTest, ROOT_ImageInVolumeWithoutRootFilesystem)
+{
+  string registry = path::join(sandbox.get(), "registry");
+  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+
+  slave::Flags flags = CreateSlaveFlags();
+  flags.isolation = "filesystem/linux,volume/image,docker/runtime";
+  flags.docker_registry = registry;
+  flags.docker_store_dir = path::join(sandbox.get(), "store");
+  flags.image_providers = "docker";
+
+  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",
+      "test -d rootfs/bin");
+
+  executor.mutable_container()->CopyFrom(createContainerInfo(
+      None(),
+      {createVolumeFromDockerImage("rootfs", "test_image", Volume::RW)}));
+
+  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);
+
+  Future<Option<ContainerTermination>> wait = containerizer->wait(containerId);
+
+  AWAIT_READY(wait);
+  ASSERT_SOME(wait.get());
+  ASSERT_TRUE(wait->get().has_status());
+  EXPECT_WEXITSTATUS_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(VolumeImageIsolatorTest, ROOT_ImageInVolumeWithRootFilesystem)
+{
+  string registry = path::join(sandbox.get(), "registry");
+  AWAIT_READY(DockerArchive::create(registry, "test_image_rootfs"));
+  AWAIT_READY(DockerArchive::create(registry, "test_image_volume"));
+
+  slave::Flags flags = CreateSlaveFlags();
+  flags.isolation = "filesystem/linux,volume/image,docker/runtime";
+  flags.docker_registry = registry;
+  flags.docker_store_dir = path::join(sandbox.get(), "store");
+  flags.image_providers = "docker";
+
+  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",
+      "[ ! -d '" + sandbox.get() + "' ] && [ -d rootfs/bin ]");
+
+  executor.mutable_container()->CopyFrom(createContainerInfo(
+      "test_image_rootfs",
+      {createVolumeFromDockerImage(
+          "rootfs", "test_image_volume", Volume::RW)}));
+
+  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);
+
+  Future<Option<ContainerTermination>> wait = containerizer->wait(containerId);
+
+  AWAIT_READY(wait);
+  ASSERT_SOME(wait.get());
+  ASSERT_TRUE(wait->get().has_status());
+  EXPECT_WEXITSTATUS_EQ(0, wait->get().status());
+}
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {