You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/11/15 08:13:27 UTC
[03/15] mesos git commit: Added basic tests for launching standalone
containers.
Added basic tests for launching standalone containers.
Within the containerizer, standalone containers are treated like
any other container (such as those with executors/tasks), so the
MesosContainerizerTests focus on the difference in arguments passed
for standalone containers.
Review: https://reviews.apache.org/r/60889
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f370a32d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f370a32d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f370a32d
Branch: refs/heads/master
Commit: f370a32d2c05a7d8d9606aaeb1f6b01dd884abdc
Parents: 1414578
Author: Joseph Wu <jo...@apache.org>
Authored: Wed Jul 12 12:24:59 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Tue Nov 14 16:58:40 2017 -0800
----------------------------------------------------------------------
.../containerizer/mesos_containerizer_tests.cpp | 45 ++++++++++++++++++++
src/tests/mesos.hpp | 27 ++++++++++++
2 files changed, 72 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f370a32d/src/tests/containerizer/mesos_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/mesos_containerizer_tests.cpp b/src/tests/containerizer/mesos_containerizer_tests.cpp
index ef42415..f73e0bf 100644
--- a/src/tests/containerizer/mesos_containerizer_tests.cpp
+++ b/src/tests/containerizer/mesos_containerizer_tests.cpp
@@ -149,6 +149,51 @@ TEST_F(MesosContainerizerTest, Launch)
}
+TEST_F(MesosContainerizerTest, StandaloneLaunch)
+{
+ slave::Flags flags = CreateSlaveFlags();
+ flags.launcher = "posix";
+ flags.isolation = "posix/cpu,posix/mem";
+
+ Fetcher fetcher(flags);
+
+ Try<MesosContainerizer*> create = MesosContainerizer::create(
+ flags,
+ true,
+ &fetcher);
+
+ ASSERT_SOME(create);
+
+ Owned<MesosContainerizer> containerizer(create.get());
+
+ SlaveState state;
+ state.id = SlaveID();
+
+ AWAIT_READY(containerizer->recover(state));
+
+ ContainerID containerId;
+ containerId.set_value(UUID::random().toString());
+
+ Future<bool> launch = containerizer->launch(
+ containerId,
+ createContainerConfig(
+ createCommandInfo("exit 42"),
+ "cpus:1;mem:64",
+ sandbox.get()),
+ map<string, string>(),
+ None());
+
+ AWAIT_ASSERT_TRUE(launch);
+
+ Future<Option<ContainerTermination>> wait = containerizer->wait(containerId);
+
+ AWAIT_READY(wait);
+ ASSERT_SOME(wait.get());
+ ASSERT_TRUE(wait.get()->has_status());
+ EXPECT_WEXITSTATUS_EQ(42, wait.get()->status());
+}
+
+
TEST_F(MesosContainerizerTest, Destroy)
{
slave::Flags flags = CreateSlaveFlags();
http://git-wip-us.apache.org/repos/asf/mesos/blob/f370a32d/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index f251732..345b883 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -1420,6 +1420,33 @@ inline mesos::slave::ContainerConfig createContainerConfig(
}
+// Helper for creating standalone container configs.
+inline mesos::slave::ContainerConfig createContainerConfig(
+ const CommandInfo& commandInfo,
+ const std::string& resources,
+ const std::string& sandboxDirectory,
+ const Option<ContainerInfo>& containerInfo = None(),
+ const Option<std::string>& user = None())
+{
+ mesos::slave::ContainerConfig containerConfig;
+ containerConfig.mutable_command_info()->CopyFrom(commandInfo);
+ containerConfig.mutable_resources()->CopyFrom(
+ Resources::parse(resources).get());
+
+ containerConfig.set_directory(sandboxDirectory);
+
+ if (user.isSome()) {
+ containerConfig.set_user(user.get());
+ }
+
+ if (containerInfo.isSome()) {
+ containerConfig.mutable_container_info()->CopyFrom(containerInfo.get());
+ }
+
+ return containerConfig;
+}
+
+
template <typename... Args>
inline Image createDockerImage(Args&&... args)
{