Repository: mesos
Updated Branches:
  refs/heads/master 2190e6e83 -> a8ff88e7f


Added a nested container test for 3 levels of nesting.

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


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

Branch: refs/heads/master
Commit: a8ff88e7f6373bbd4e7b7483202f68c672e20392
Parents: 2190e6e
Author: Jie Yu <yujie....@gmail.com>
Authored: Tue Oct 18 17:12:28 2016 -0700
Committer: Jie Yu <yujie....@gmail.com>
Committed: Tue Oct 18 17:12:41 2016 -0700

----------------------------------------------------------------------
 .../nested_mesos_containerizer_tests.cpp        | 83 ++++++++++++++++++++
 1 file changed, 83 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a8ff88e7/src/tests/containerizer/nested_mesos_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/nested_mesos_containerizer_tests.cpp 
b/src/tests/containerizer/nested_mesos_containerizer_tests.cpp
index c690b41..1eae272 100644
--- a/src/tests/containerizer/nested_mesos_containerizer_tests.cpp
+++ b/src/tests/containerizer/nested_mesos_containerizer_tests.cpp
@@ -1526,6 +1526,89 @@ TEST_F(NestedMesosContainerizerTest, 
ROOT_CGROUPS_Environment)
   EXPECT_WTERMSIG_EQ(SIGKILL, wait.get()->status());
 }
 
+
+TEST_F(NestedMesosContainerizerTest, ROOT_CGROUPS_LaunchNestedThreeLevels)
+{
+  slave::Flags flags = CreateSlaveFlags();
+  flags.launcher = "linux";
+  flags.isolation = "cgroups/cpu,filesystem/linux,namespaces/pid";
+
+  Fetcher fetcher;
+
+  Try<MesosContainerizer*> create = MesosContainerizer::create(
+      flags,
+      false,
+      &fetcher);
+
+  ASSERT_SOME(create);
+
+  Owned<MesosContainerizer> containerizer(create.get());
+
+  SlaveState state;
+  state.id = SlaveID();
+
+  AWAIT_READY(containerizer->recover(state));
+
+  ContainerID level1ContainerId;
+  level1ContainerId.set_value(UUID::random().toString());
+
+  Try<string> directory = environment->mkdtemp();
+  ASSERT_SOME(directory);
+
+  Future<bool> launch = containerizer->launch(
+      level1ContainerId,
+      None(),
+      createExecutorInfo("executor", "sleep 1000", "cpus:1"),
+      directory.get(),
+      None(),
+      state.id,
+      map<string, string>(),
+      true); // TODO(benh): Ever want to test not checkpointing?
+
+  AWAIT_ASSERT_TRUE(launch);
+
+  ContainerID level2ContainerId;
+  level2ContainerId.mutable_parent()->CopyFrom(level1ContainerId);
+  level2ContainerId.set_value(UUID::random().toString());
+
+  launch = containerizer->launch(
+      level2ContainerId,
+      createCommandInfo("sleep 1000"),
+      None(),
+      None(),
+      state.id);
+
+  AWAIT_ASSERT_TRUE(launch);
+
+  ContainerID level3ContainerId;
+  level3ContainerId.mutable_parent()->CopyFrom(level2ContainerId);
+  level3ContainerId.set_value(UUID::random().toString());
+
+  launch = containerizer->launch(
+      level3ContainerId,
+      createCommandInfo("exit 42"),
+      None(),
+      None(),
+      state.id);
+
+  Future<Option<ContainerTermination>> wait =
+    containerizer->wait(level3ContainerId);
+
+  AWAIT_READY(wait);
+  ASSERT_SOME(wait.get());
+  ASSERT_TRUE(wait.get()->has_status());
+  EXPECT_WEXITSTATUS_EQ(42, wait.get()->status());
+
+  wait = containerizer->wait(level1ContainerId);
+
+  containerizer->destroy(level1ContainerId);
+
+  AWAIT_READY(wait);
+  ASSERT_SOME(wait.get());
+  ASSERT_TRUE(wait.get()->has_status());
+  EXPECT_WTERMSIG_EQ(SIGKILL, wait.get()->status());
+}
+
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {

Reply via email to