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/11/29 19:41:28 UTC
[9/9] mesos git commit: Removed two disabled shared filesystem
isolator tests.
Removed two disabled shared filesystem isolator tests.
Shared filesystem isolator has been deprecated for a while, and those
two tests are disabled all the time. This patch removes them.
Review: https://reviews.apache.org/r/54100
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fbbe2a11
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fbbe2a11
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fbbe2a11
Branch: refs/heads/master
Commit: fbbe2a111b895e53970867c175290d3ef72223fd
Parents: 9d6cbf0
Author: Jie Yu <yu...@gmail.com>
Authored: Sat Nov 26 20:46:20 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Nov 29 11:40:50 2016 -0800
----------------------------------------------------------------------
src/tests/containerizer/isolator_tests.cpp | 273 ++----------------------
1 file changed, 13 insertions(+), 260 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/fbbe2a11/src/tests/containerizer/isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/isolator_tests.cpp b/src/tests/containerizer/isolator_tests.cpp
index 9766aaf..da46278 100644
--- a/src/tests/containerizer/isolator_tests.cpp
+++ b/src/tests/containerizer/isolator_tests.cpp
@@ -16,293 +16,45 @@
#include <unistd.h>
-#include <functional>
-#include <iostream>
#include <string>
-#include <vector>
-
-#include <gmock/gmock.h>
-
-#include <mesos/resources.hpp>
-
-#include <mesos/module/isolator.hpp>
-
-#include <mesos/slave/isolator.hpp>
#include <process/future.hpp>
-#include <process/io.hpp>
#include <process/owned.hpp>
-#include <process/reap.hpp>
-#include <stout/abort.hpp>
-#include <stout/duration.hpp>
#include <stout/gtest.hpp>
-#include <stout/hashset.hpp>
#include <stout/os.hpp>
#include <stout/path.hpp>
+#include <stout/stringify.hpp>
+#include <stout/strings.hpp>
+#include <stout/uuid.hpp>
-#ifdef __linux__
-#include "linux/ns.hpp"
-#endif // __linux__
-
-#include "master/master.hpp"
-
-#include "slave/flags.hpp"
-#include "slave/gc.hpp"
-#include "slave/slave.hpp"
+#include <mesos/mesos.hpp>
#ifdef __linux__
-#include "slave/containerizer/mesos/isolators/filesystem/shared.hpp"
-#endif // __linux__
-#include "slave/containerizer/mesos/isolators/posix.hpp"
+#include "linux/ns.hpp"
+#endif
-#include "slave/containerizer/mesos/launcher.hpp"
-#ifdef __linux__
#include "slave/containerizer/fetcher.hpp"
+
#include "slave/containerizer/mesos/containerizer.hpp"
-#include "slave/containerizer/mesos/launch.hpp"
-#include "slave/containerizer/mesos/linux_launcher.hpp"
-#endif // __linux__
-#include "tests/flags.hpp"
#include "tests/mesos.hpp"
-#include "tests/module.hpp"
-#include "tests/utils.hpp"
-using namespace process;
+using std::string;
+
+using process::Future;
+using process::Owned;
-using mesos::internal::master::Master;
-#ifdef __linux__
using mesos::internal::slave::Fetcher;
-using mesos::internal::slave::LinuxLauncher;
-using mesos::internal::slave::SharedFilesystemIsolatorProcess;
-#endif // __linux__
-using mesos::internal::slave::Launcher;
using mesos::internal::slave::MesosContainerizer;
-using mesos::internal::slave::PosixLauncher;
-using mesos::internal::slave::Slave;
-using mesos::master::detector::MasterDetector;
-
-using mesos::slave::ContainerConfig;
-using mesos::slave::ContainerLaunchInfo;
using mesos::slave::ContainerTermination;
-using mesos::slave::Isolator;
-
-using std::ostringstream;
-using std::set;
-using std::string;
-using std::vector;
namespace mesos {
namespace internal {
namespace tests {
#ifdef __linux__
-class SharedFilesystemIsolatorTest : public MesosTest {};
-
-
-// Test that a container can create a private view of a system
-// directory (/var/tmp). Check that a file written by a process inside
-// the container doesn't appear on the host filesystem but does appear
-// under the container's work directory.
-// This test is disabled since we're planning to remove the shared
-// filesystem isolator and this test is not working on other distros
-// such as CentOS 7.1
-// TODO(tnachen): Remove this test when shared filesystem isolator
-// is removed.
-TEST_F(SharedFilesystemIsolatorTest, DISABLED_ROOT_RelativeVolume)
-{
- slave::Flags flags = CreateSlaveFlags();
- flags.isolation = "filesystem/shared";
-
- Try<Isolator*> _isolator = SharedFilesystemIsolatorProcess::create(flags);
- ASSERT_SOME(_isolator);
- Owned<Isolator> isolator(_isolator.get());
-
- Try<Launcher*> _launcher = LinuxLauncher::create(flags);
- ASSERT_SOME(_launcher);
- Owned<Launcher> launcher(_launcher.get());
-
- // Use /var/tmp so we don't mask the work directory (under /tmp).
- const string containerPath = "/var/tmp";
- ASSERT_TRUE(os::stat::isdir(containerPath));
-
- // Use a host path relative to the container work directory.
- const string hostPath = strings::remove(containerPath, "/", strings::PREFIX);
-
- ContainerInfo containerInfo;
- containerInfo.set_type(ContainerInfo::MESOS);
- containerInfo.add_volumes()->CopyFrom(
- createVolumeFromHostPath(containerPath, hostPath, Volume::RW));
-
- ExecutorInfo executorInfo;
- executorInfo.mutable_container()->CopyFrom(containerInfo);
-
- ContainerID containerId;
- containerId.set_value(UUID::random().toString());
-
- ContainerConfig containerConfig;
- containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
- containerConfig.set_directory(flags.work_dir);
-
- Future<Option<ContainerLaunchInfo>> prepare =
- isolator->prepare(
- containerId,
- containerConfig);
-
- AWAIT_READY(prepare);
- ASSERT_SOME(prepare.get());
- ASSERT_EQ(1, prepare.get().get().pre_exec_commands().size());
- EXPECT_TRUE(prepare.get().get().has_clone_namespaces());
-
- // The test will touch a file in container path.
- const string file = path::join(containerPath, UUID::random().toString());
- ASSERT_FALSE(os::exists(file));
-
- // Manually run the isolator's preparation command first, then touch
- // the file.
- vector<string> args;
- args.push_back("sh");
- args.push_back("-x");
- args.push_back("-c");
- args.push_back(
- prepare.get().get().pre_exec_commands(0).value() + " && touch " + file);
-
- Try<pid_t> pid = launcher->fork(
- containerId,
- "sh",
- args,
- Subprocess::FD(STDIN_FILENO),
- Subprocess::FD(STDOUT_FILENO),
- Subprocess::FD(STDERR_FILENO),
- nullptr,
- None(),
- None(),
- prepare.get().get().clone_namespaces());
- ASSERT_SOME(pid);
-
- // Set up the reaper to wait on the forked child.
- Future<Option<int>> status = process::reap(pid.get());
-
- AWAIT_READY(status);
- EXPECT_SOME_EQ(0, status.get());
-
- // Check the correct hierarchy was created under the container work
- // directory.
- string dir = "/";
- foreach (const string& subdir, strings::tokenize(containerPath, "/")) {
- dir = path::join(dir, subdir);
-
- struct stat hostStat;
- EXPECT_EQ(0, ::stat(dir.c_str(), &hostStat));
-
- struct stat containerStat;
- EXPECT_EQ(0,
- ::stat(path::join(flags.work_dir, dir).c_str(), &containerStat));
-
- EXPECT_EQ(hostStat.st_mode, containerStat.st_mode);
- EXPECT_EQ(hostStat.st_uid, containerStat.st_uid);
- EXPECT_EQ(hostStat.st_gid, containerStat.st_gid);
- }
-
- // Check it did *not* create a file in the host namespace.
- EXPECT_FALSE(os::exists(file));
-
- // Check it did create the file under the container's work directory
- // on the host.
- EXPECT_TRUE(os::exists(path::join(flags.work_dir, file)));
-}
-
-
-// This test is disabled since we're planning to remove the shared
-// filesystem isolator and this test is not working on other distros
-// such as CentOS 7.1
-// TODO(tnachen): Remove this test when shared filesystem isolator
-// is removed.
-TEST_F(SharedFilesystemIsolatorTest, DISABLED_ROOT_AbsoluteVolume)
-{
- slave::Flags flags = CreateSlaveFlags();
- flags.isolation = "filesystem/shared";
-
- Try<Isolator*> _isolator = SharedFilesystemIsolatorProcess::create(flags);
- ASSERT_SOME(_isolator);
- Owned<Isolator> isolator(_isolator.get());
-
- Try<Launcher*> _launcher = LinuxLauncher::create(flags);
- ASSERT_SOME(_launcher);
- Owned<Launcher> launcher(_launcher.get());
-
- // We'll mount the absolute test work directory as /var/tmp in the
- // container.
- const string hostPath = flags.work_dir;
- const string containerPath = "/var/tmp";
-
- ContainerInfo containerInfo;
- containerInfo.set_type(ContainerInfo::MESOS);
- containerInfo.add_volumes()->CopyFrom(
- createVolumeFromHostPath(containerPath, hostPath, Volume::RW));
-
- ExecutorInfo executorInfo;
- executorInfo.mutable_container()->CopyFrom(containerInfo);
-
- ContainerID containerId;
- containerId.set_value(UUID::random().toString());
-
- ContainerConfig containerConfig;
- containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
- containerConfig.set_directory(flags.work_dir);
-
- Future<Option<ContainerLaunchInfo>> prepare =
- isolator->prepare(
- containerId,
- containerConfig);
-
- AWAIT_READY(prepare);
- ASSERT_SOME(prepare.get());
- ASSERT_EQ(1, prepare.get().get().pre_exec_commands().size());
- EXPECT_TRUE(prepare.get().get().has_clone_namespaces());
-
- // Test the volume mounting by touching a file in the container's
- // /tmp, which should then be in flags.work_dir.
- const string filename = UUID::random().toString();
- ASSERT_FALSE(os::exists(path::join(containerPath, filename)));
-
- vector<string> args;
- args.push_back("sh");
- args.push_back("-x");
- args.push_back("-c");
- args.push_back(prepare.get().get().pre_exec_commands(0).value() +
- " && touch " +
- path::join(containerPath, filename));
-
- Try<pid_t> pid = launcher->fork(
- containerId,
- "sh",
- args,
- Subprocess::FD(STDIN_FILENO),
- Subprocess::FD(STDOUT_FILENO),
- Subprocess::FD(STDERR_FILENO),
- nullptr,
- None(),
- None(),
- prepare.get().get().clone_namespaces());
- ASSERT_SOME(pid);
-
- // Set up the reaper to wait on the forked child.
- Future<Option<int>> status = process::reap(pid.get());
-
- AWAIT_READY(status);
- EXPECT_SOME_EQ(0, status.get());
-
- // Check the file was created in flags.work_dir.
- EXPECT_TRUE(os::exists(path::join(hostPath, filename)));
-
- // Check it didn't get created in the host's view of containerPath.
- EXPECT_FALSE(os::exists(path::join(containerPath, filename)));
-}
-
-
class NamespacesPidIsolatorTest : public MesosTest {};
@@ -328,7 +80,7 @@ TEST_F(NamespacesPidIsolatorTest, ROOT_PidNamespace)
const string command =
"stat -c %i /proc/self/ns/pid > ns && (cat /proc/1/comm > init)";
- process::Future<bool> launch = containerizer->launch(
+ Future<bool> launch = containerizer->launch(
containerId,
None(),
createExecutorInfo("executor", command),
@@ -337,6 +89,7 @@ TEST_F(NamespacesPidIsolatorTest, ROOT_PidNamespace)
SlaveID(),
std::map<string, string>(),
false);
+
AWAIT_READY(launch);
ASSERT_TRUE(launch.get());