You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gi...@apache.org on 2018/12/11 08:05:51 UTC

[mesos] branch master updated (577c0a2 -> 4803af1)

This is an automated email from the ASF dual-hosted git repository.

gilbert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from 577c0a2  Removed unnecessary '--all-cpus' option from perf documentation.
     new ab7edeb  Added `ROOT_PseudoDevicesWithRootFilesystem` test.
     new 4803af1  Refactored `LinuxFilesystemIsolator{Test,MesosTest}` tests.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../linux_filesystem_isolator_tests.cpp            | 155 +++++++++++----------
 src/tests/containerizer/rootfs.cpp                 |   1 +
 2 files changed, 81 insertions(+), 75 deletions(-)


[mesos] 02/02: Refactored `LinuxFilesystemIsolator{Test, MesosTest}` tests.

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gilbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 4803af11bcb038193c238c049ea67c73b1bfd9a1
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Mon Dec 10 16:00:32 2018 -0800

    Refactored `LinuxFilesystemIsolator{Test,MesosTest}` tests.
    
    This patch factors out boilerplate code related to initialization of
    the agent flags.
    
    Review: https://reviews.apache.org/r/69545/
---
 .../linux_filesystem_isolator_tests.cpp            | 113 ++++++---------------
 1 file changed, 32 insertions(+), 81 deletions(-)

diff --git a/src/tests/containerizer/linux_filesystem_isolator_tests.cpp b/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
index 99af704..250ead9 100644
--- a/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
+++ b/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
@@ -69,21 +69,34 @@ namespace mesos {
 namespace internal {
 namespace tests {
 
-class LinuxFilesystemIsolatorTest : public MesosTest {};
+class LinuxFilesystemIsolatorTest : public MesosTest
+{
+protected:
+  slave::Flags CreateSlaveFlags() override
+  {
+    slave::Flags flags = MesosTest::CreateSlaveFlags();
+    flags.isolation = "filesystem/linux,docker/runtime";
+    flags.docker_registry = GetRegistryPath();
+    flags.docker_store_dir = path::join(sandbox.get(), "store");
+    flags.image_providers = "docker";
+
+    return flags;
+  }
+
+  string GetRegistryPath() const
+  {
+    return path::join(sandbox.get(), "registry");
+  }
+};
 
 
 // This test verifies that the root filesystem of the container is
 // properly changed to the one that's provisioned by the provisioner.
 TEST_F(LinuxFilesystemIsolatorTest, ROOT_ChangeRootFilesystem)
 {
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "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";
 
   Fetcher fetcher(flags);
 
@@ -127,14 +140,9 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_ChangeRootFilesystem)
 // in the container's root filesystem.
 TEST_F(LinuxFilesystemIsolatorTest, ROOT_PseudoDevicesWithRootFilesystem)
 {
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "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";
 
   Fetcher fetcher(flags);
 
@@ -181,14 +189,9 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_PseudoDevicesWithRootFilesystem)
 // that have root filesystem specified is correctly reported.
 TEST_F(LinuxFilesystemIsolatorTest, ROOT_Metrics)
 {
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "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";
 
   Fetcher fetcher(flags);
 
@@ -241,14 +244,9 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_Metrics)
 // the container's root filesystem.
 TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithRootFilesystem)
 {
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "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";
 
   Fetcher fetcher(flags);
 
@@ -312,14 +310,9 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithRootFilesystem)
 TEST_F(LinuxFilesystemIsolatorTest,
        ROOT_PersistentVolumeAndHostVolumeWithRootFilesystem)
 {
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "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";
 
   Fetcher fetcher(flags);
 
@@ -384,14 +377,7 @@ TEST_F(LinuxFilesystemIsolatorTest,
 // the container does not specify a root filesystem.
 TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithoutRootFilesystem)
 {
-  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";
 
   Fetcher fetcher(flags);
 
@@ -449,15 +435,10 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeWithoutRootFilesystem)
 // launched simultaneously with no interference.
 TEST_F(LinuxFilesystemIsolatorTest, ROOT_MultipleContainers)
 {
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image1"));
-  AWAIT_READY(DockerArchive::create(registry, "test_image2"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "test_image1"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "test_image2"));
 
   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";
 
   Fetcher fetcher(flags);
 
@@ -633,7 +614,6 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_WorkDirMountNeeded)
 TEST_F(LinuxFilesystemIsolatorTest, ROOT_PersistentVolumeMountPointCleanup)
 {
   slave::Flags flags = CreateSlaveFlags();
-  flags.isolation = "filesystem/linux";
 
   Fetcher fetcher(flags);
 
@@ -714,14 +694,9 @@ TEST_F(LinuxFilesystemIsolatorMesosTest,
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "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";
 
   Owned<MasterDetector> detector = master.get()->createDetector();
 
@@ -790,15 +765,10 @@ TEST_F(LinuxFilesystemIsolatorMesosTest,
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "test_image"));
 
   slave::Flags flags = CreateSlaveFlags();
   flags.resources = "cpus:2;mem:1024;disk(role1):1024";
-  flags.isolation = "filesystem/linux,docker/runtime";
-  flags.docker_registry = registry;
-  flags.docker_store_dir = path::join(sandbox.get(), "store");
-  flags.image_providers = "docker";
 
   Owned<MasterDetector> detector = master.get()->createDetector();
 
@@ -920,15 +890,10 @@ TEST_F(LinuxFilesystemIsolatorMesosTest,
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "test_image"));
 
   slave::Flags flags = CreateSlaveFlags();
   flags.resources = "cpus:2;mem:1024;disk(role1):1024";
-  flags.isolation = "filesystem/linux,docker/runtime";
-  flags.docker_registry = registry;
-  flags.docker_store_dir = path::join(sandbox.get(), "store");
-  flags.image_providers = "docker";
 
   Fetcher fetcher(flags);
 
@@ -1077,14 +1042,9 @@ TEST_F(LinuxFilesystemIsolatorMesosTest, ROOT_SandboxEnvironmentVariable)
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "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";
 
   Owned<MasterDetector> detector = master.get()->createDetector();
 
@@ -1158,15 +1118,11 @@ TEST_F(LinuxFilesystemIsolatorMesosTest,
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "test_image"));
 
   slave::Flags flags = CreateSlaveFlags();
   flags.resources = "cpus:2;mem:128;disk(role1):128";
   flags.isolation = "disk/du,filesystem/linux,docker/runtime";
-  flags.docker_registry = registry;
-  flags.docker_store_dir = path::join(sandbox.get(), "store");
-  flags.image_providers = "docker";
 
   // NOTE: We can't pause the clock because we need the reaper to reap
   // the 'du' subprocess.
@@ -1261,15 +1217,10 @@ TEST_F(LinuxFilesystemIsolatorMesosTest,
   Try<Owned<cluster::Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  string registry = path::join(sandbox.get(), "registry");
-  AWAIT_READY(DockerArchive::create(registry, "test_image"));
+  AWAIT_READY(DockerArchive::create(GetRegistryPath(), "test_image"));
 
   slave::Flags flags = CreateSlaveFlags();
   flags.resources = "cpus:2;mem:128;disk(role1):128";
-  flags.isolation = "filesystem/linux,docker/runtime";
-  flags.docker_registry = registry;
-  flags.docker_store_dir = path::join(sandbox.get(), "store");
-  flags.image_providers = "docker";
 
   Owned<MasterDetector> detector = master.get()->createDetector();
 


[mesos] 01/02: Added `ROOT_PseudoDevicesWithRootFilesystem` test.

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gilbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit ab7edeb490e0fa6dab8b5d5ed700c59834455955
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Mon Dec 10 16:00:30 2018 -0800

    Added `ROOT_PseudoDevicesWithRootFilesystem` test.
    
    This test verifies that pseudo devices like /dev/random are properly
    mounted in the container's root filesystem.
    
    Review: https://reviews.apache.org/r/69540/
---
 .../linux_filesystem_isolator_tests.cpp            | 54 ++++++++++++++++++++++
 src/tests/containerizer/rootfs.cpp                 |  1 +
 2 files changed, 55 insertions(+)

diff --git a/src/tests/containerizer/linux_filesystem_isolator_tests.cpp b/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
index 84b342c..99af704 100644
--- a/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
+++ b/src/tests/containerizer/linux_filesystem_isolator_tests.cpp
@@ -123,6 +123,60 @@ TEST_F(LinuxFilesystemIsolatorTest, ROOT_ChangeRootFilesystem)
 }
 
 
+// This test verifies that pseudo devices like /dev/random are properly mounted
+// in the container's root filesystem.
+TEST_F(LinuxFilesystemIsolatorTest, ROOT_PseudoDevicesWithRootFilesystem)
+{
+  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";
+
+  Fetcher fetcher(flags);
+
+  Try<MesosContainerizer*> create =
+    MesosContainerizer::create(flags, true, &fetcher);
+
+  ASSERT_SOME(create);
+
+  Owned<Containerizer> containerizer(create.get());
+
+  ContainerID containerId;
+  containerId.set_value(id::UUID::random().toString());
+
+  ExecutorInfo executor = createExecutorInfo(
+      "test_executor",
+      "dd if=/dev/zero of=/dev/null bs=1024 count=1 &&"
+      "dd if=/dev/random of=/dev/null bs=1024 count=1 &&"
+      "dd if=/dev/urandom of=/dev/null bs=1024 count=1 &&"
+      "dd if=/dev/full of=/dev/null bs=1024 count=1");
+
+  executor.mutable_container()->CopyFrom(createContainerInfo("test_image"));
+
+  string directory = path::join(flags.work_dir, "sandbox");
+  ASSERT_SOME(os::mkdir(directory));
+
+  Future<Containerizer::LaunchResult> launch = containerizer->launch(
+      containerId,
+      createContainerConfig(None(), executor, directory),
+      map<string, string>(),
+      None());
+
+  AWAIT_ASSERT_EQ(Containerizer::LaunchResult::SUCCESS, 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 metrics about the number of executors
 // that have root filesystem specified is correctly reported.
 TEST_F(LinuxFilesystemIsolatorTest, ROOT_Metrics)
diff --git a/src/tests/containerizer/rootfs.cpp b/src/tests/containerizer/rootfs.cpp
index 83662fc..48eb010 100644
--- a/src/tests/containerizer/rootfs.cpp
+++ b/src/tests/containerizer/rootfs.cpp
@@ -128,6 +128,7 @@ Try<process::Owned<Rootfs>> LinuxRootfs::create(const string& root)
 
   const vector<string> programs = {
     "/bin/cat",
+    "/bin/dd",
     "/bin/echo",
     "/bin/ls",
     "/bin/ping",