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:33 UTC
[09/15] mesos git commit: Moved and refactored some nested container
tests.
Moved and refactored some nested container tests.
This moves tests for the Nested container API found in `api_tests.cpp`
into `agent_container_api_tests.cpp` and refactors the moved tests to:
* Exercise the MesosContainerizer, rather than mocks.
* Parameterize tests to use the Standalone container API or Nested
container API.
* Parameterize tests to exercise different isolator combinations.
Additionally, the `NestedContainerWaitNotFound` and
`NestedContainerKillNotFound` tests are now combined into
`NestedContainerNotFound`.
>From the `nested_mesos_containerizer_tests.cpp`, the `WaitAfterDestroy`
and `LaunchNestedThreeLevels` were deleted as the same codepaths are now
covered by `NestedContainerLaunch` and `TwoLevelNestedContainerLaunch`
respectively.
Review: https://reviews.apache.org/r/63057
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fd4b9af1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fd4b9af1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fd4b9af1
Branch: refs/heads/master
Commit: fd4b9af1473c8773e08970c8e6aa2eaf27733c42
Parents: e5323f0
Author: Joseph Wu <jo...@apache.org>
Authored: Fri Oct 13 14:18:43 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Tue Nov 14 17:16:21 2017 -0800
----------------------------------------------------------------------
src/tests/agent_container_api_tests.cpp | 207 ++++++++++
src/tests/api_tests.cpp | 376 -------------------
.../nested_mesos_containerizer_tests.cpp | 165 --------
3 files changed, 207 insertions(+), 541 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/fd4b9af1/src/tests/agent_container_api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/agent_container_api_tests.cpp b/src/tests/agent_container_api_tests.cpp
index 88c33ae..6b9bace 100644
--- a/src/tests/agent_container_api_tests.cpp
+++ b/src/tests/agent_container_api_tests.cpp
@@ -530,6 +530,213 @@ TEST_P_TEMP_DISABLED_ON_WINDOWS(AgentContainerAPITest, NestedContainerLaunch)
EXPECT_TRUE(checkWaitContainerResponse(wait, SIGKILL));
}
+
+// This test launches a parent and nested container, simulates an agent
+// failover, and then waits/kills the containers.
+TEST_P_TEMP_DISABLED_ON_WINDOWS(AgentContainerAPITest, RecoverNestedContainer)
+{
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+
+ slave::Flags slaveFlags = CreateSlaveFlags();
+ slaveFlags.launcher = std::get<1>(std::get<3>(GetParam()));
+ slaveFlags.isolation = std::get<0>(std::get<3>(GetParam()));
+
+ Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), slaveFlags);
+ ASSERT_SOME(slave);
+
+ Try<v1::ContainerID> parentContainerId =
+ launchParentContainer(master.get()->pid, slave.get()->pid);
+
+ ASSERT_SOME(parentContainerId);
+
+ // Launch a nested container.
+ v1::ContainerID containerId;
+ containerId.set_value(UUID::random().toString());
+ containerId.mutable_parent()->CopyFrom(parentContainerId.get());
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::OK().status,
+ launchNestedContainer(slave.get()->pid, containerId));
+
+ // Simulate an agent failover.
+ Future<SlaveReregisteredMessage> slaveReregisteredMessage =
+ FUTURE_PROTOBUF(SlaveReregisteredMessage(), _, _);
+
+ slave.get()->terminate();
+ slave = StartSlave(detector.get(), slaveFlags);
+ ASSERT_SOME(slave);
+
+ AWAIT_READY(slaveReregisteredMessage);
+
+ // Now kill and wait for the (recovered) container to exit.
+ Future<v1::agent::Response> wait =
+ deserialize(waitNestedContainer(slave.get()->pid, containerId));
+
+ EXPECT_TRUE(wait.isPending());
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::OK().status,
+ killNestedContainer(slave.get()->pid, containerId));
+
+ AWAIT_READY(wait);
+ EXPECT_TRUE(checkWaitContainerResponse(wait, SIGKILL));
+}
+
+
+// This test checks that using the KILL or WAIT container calls on
+// a non-existent ContainerID returns a 404 Not Found.
+TEST_P_TEMP_DISABLED_ON_WINDOWS(AgentContainerAPITest, NestedContainerNotFound)
+{
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+
+ slave::Flags slaveFlags = CreateSlaveFlags();
+ slaveFlags.launcher = std::get<1>(std::get<3>(GetParam()));
+ slaveFlags.isolation = std::get<0>(std::get<3>(GetParam()));
+
+ Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), slaveFlags);
+ ASSERT_SOME(slave);
+
+ // Wait for the agent to finish registering.
+ Future<SlaveRegisteredMessage> slaveRegisteredMessage =
+ FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);
+ AWAIT_READY(slaveRegisteredMessage);
+
+ v1::ContainerID unknownContainerId;
+ unknownContainerId.set_value(UUID::random().toString());
+ unknownContainerId.mutable_parent()->set_value(UUID::random().toString());
+
+ // Expect a 404 for waiting on unknown containers.
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::NotFound().status,
+ waitNestedContainer(slave.get()->pid, unknownContainerId));
+
+ // Expect a 404 for waiting on unknown containers.
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::NotFound().status,
+ killNestedContainer(slave.get()->pid, unknownContainerId));
+}
+
+
+// This test attempts to give invalid ContainerInfo when launching a
+// nested container. The invalid nested container LAUNCH call is expected
+// to give a 400 Bad Request, but the parent container should be otherwise
+// unaffected.
+TEST_P_TEMP_DISABLED_ON_WINDOWS(
+ AgentContainerAPITest, NestedContainerLaunchFalse)
+{
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+
+ slave::Flags slaveFlags = CreateSlaveFlags();
+ slaveFlags.launcher = std::get<1>(std::get<3>(GetParam()));
+ slaveFlags.isolation = std::get<0>(std::get<3>(GetParam()));
+
+ Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), slaveFlags);
+ ASSERT_SOME(slave);
+
+ Try<v1::ContainerID> parentContainerId =
+ launchParentContainer(master.get()->pid, slave.get()->pid);
+
+ ASSERT_SOME(parentContainerId);
+
+ // Try to launch an "unsupported" container.
+ // In this case, we try to specify a nested container that expects
+ // the Docker containerizer, even though the parent was made with
+ // the Mesos containerizer.
+ v1::ContainerID containerId;
+ containerId.set_value(UUID::random().toString());
+ containerId.mutable_parent()->CopyFrom(parentContainerId.get());
+
+ mesos::v1::ContainerInfo containerInfo;
+ containerInfo.set_type(mesos::v1::ContainerInfo::DOCKER);
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::BadRequest().status,
+ launchNestedContainer(
+ slave.get()->pid, containerId, None(), containerInfo));
+}
+
+
+// This test launches three total layers of nested containers,
+// one parent, nested, and double-nested container. Each nested container
+// is killed and reaped like any other nested container.
+TEST_P_TEMP_DISABLED_ON_WINDOWS(
+ AgentContainerAPITest, TwoLevelNestedContainerLaunch)
+{
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+
+ slave::Flags slaveFlags = CreateSlaveFlags();
+ slaveFlags.launcher = std::get<1>(std::get<3>(GetParam()));
+ slaveFlags.isolation = std::get<0>(std::get<3>(GetParam()));
+
+ Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), slaveFlags);
+ ASSERT_SOME(slave);
+
+ Try<v1::ContainerID> parentContainerId =
+ launchParentContainer(master.get()->pid, slave.get()->pid);
+
+ ASSERT_SOME(parentContainerId);
+
+ // Launch the first nested container and wait for it to finish.
+ v1::ContainerID childContainerId;
+ childContainerId.set_value(UUID::random().toString());
+ childContainerId.mutable_parent()->CopyFrom(parentContainerId.get());
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::OK().status,
+ launchNestedContainer(slave.get()->pid, childContainerId));
+
+ // Launch the second nested container underneath the first nested contaienr
+ // and wait for it to finish.
+ v1::ContainerID grandchildContainerId;
+ grandchildContainerId.set_value(UUID::random().toString());
+ grandchildContainerId.mutable_parent()->CopyFrom(childContainerId);
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::OK().status,
+ launchNestedContainer(slave.get()->pid, grandchildContainerId));
+
+ // Start waiting for each nested container to exit.
+ Future<v1::agent::Response> waitChild =
+ deserialize(waitNestedContainer(slave.get()->pid, childContainerId));
+
+ Future<v1::agent::Response> waitgrandChild =
+ deserialize(waitNestedContainer(slave.get()->pid, grandchildContainerId));
+
+ EXPECT_TRUE(waitChild.isPending());
+ EXPECT_TRUE(waitgrandChild.isPending());
+
+ // Kill the grandchild container.
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::OK().status,
+ killNestedContainer(slave.get()->pid, grandchildContainerId));
+
+ AWAIT_READY(waitgrandChild);
+ EXPECT_TRUE(checkWaitContainerResponse(waitgrandChild, SIGKILL));
+
+ // The child container should still be running.
+ EXPECT_TRUE(waitChild.isPending());
+
+ // Kill the child container.
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(
+ http::OK().status,
+ killNestedContainer(slave.get()->pid, childContainerId));
+
+ AWAIT_READY(waitChild);
+ EXPECT_TRUE(checkWaitContainerResponse(waitChild, SIGKILL));
+}
+
} // namespace tests {
} // namespace internal {
} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/fd4b9af1/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 5fc89be..c9c50b9 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -4930,382 +4930,6 @@ TEST_P_TEMP_DISABLED_ON_WINDOWS(AgentAPITest, GetState)
}
-TEST_P(AgentAPITest, NestedContainerWaitNotFound)
-{
- ContentType contentType = GetParam();
-
- Clock::pause();
-
- StandaloneMasterDetector detector;
- MockContainerizer mockContainerizer;
-
- EXPECT_CALL(mockContainerizer, recover(_))
- .WillOnce(Return(Future<Nothing>(Nothing())));
-
- Future<Nothing> __recover = FUTURE_DISPATCH(_, &Slave::__recover);
-
- Try<Owned<cluster::Slave>> slave =
- StartSlave(&detector, &mockContainerizer);
-
- ASSERT_SOME(slave);
-
- // Wait for the agent to finish recovery.
- AWAIT_READY(__recover);
- Clock::settle();
-
- // Expect a 404 for waiting on unknown containers.
- {
- v1::agent::Call call;
- call.set_type(v1::agent::Call::WAIT_NESTED_CONTAINER);
-
- v1::ContainerID unknownContainerId;
- unknownContainerId.set_value(UUID::random().toString());
- unknownContainerId.mutable_parent()->set_value(UUID::random().toString());
-
- call.mutable_wait_nested_container()->mutable_container_id()
- ->CopyFrom(unknownContainerId);
-
- Future<http::Response> response = http::post(
- slave.get()->pid,
- "api/v1",
- createBasicAuthHeaders(DEFAULT_CREDENTIAL),
- serialize(contentType, call),
- stringify(contentType));
-
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::NotFound().status, response);
- }
-
- // The destructor of `cluster::Slave` will try to clean up any
- // remaining containers by inspecting the result of `containers()`.
- EXPECT_CALL(mockContainerizer, containers())
- .WillRepeatedly(Return(hashset<ContainerID>()));
-}
-
-
-TEST_P(AgentAPITest, NestedContainerKillNotFound)
-{
- ContentType contentType = GetParam();
-
- Clock::pause();
-
- StandaloneMasterDetector detector;
- MockContainerizer mockContainerizer;
-
- EXPECT_CALL(mockContainerizer, recover(_))
- .WillOnce(Return(Future<Nothing>(Nothing())));
-
- Future<Nothing> __recover = FUTURE_DISPATCH(_, &Slave::__recover);
-
- Try<Owned<cluster::Slave>> slave =
- StartSlave(&detector, &mockContainerizer);
-
- ASSERT_SOME(slave);
-
- // Wait for the agent to finish recovery.
- AWAIT_READY(__recover);
- Clock::settle();
-
- // Expect a 404 for killing unknown containers.
- {
- v1::agent::Call call;
- call.set_type(v1::agent::Call::KILL_NESTED_CONTAINER);
-
- v1::ContainerID unknownContainerId;
- unknownContainerId.set_value(UUID::random().toString());
- unknownContainerId.mutable_parent()->set_value(UUID::random().toString());
-
- call.mutable_kill_nested_container()->mutable_container_id()
- ->CopyFrom(unknownContainerId);
-
- Future<http::Response> response = http::post(
- slave.get()->pid,
- "api/v1",
- createBasicAuthHeaders(DEFAULT_CREDENTIAL),
- serialize(contentType, call),
- stringify(contentType));
-
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::NotFound().status, response);
- }
-
- // The destructor of `cluster::Slave` will try to clean up any
- // remaining containers by inspecting the result of `containers()`.
- EXPECT_CALL(mockContainerizer, containers())
- .WillRepeatedly(Return(hashset<ContainerID>()));
-}
-
-
-// When containerizer returns false from launching a nested
-// container, it is considered a bad request (e.g. image
-// type is not supported).
-TEST_P_TEMP_DISABLED_ON_WINDOWS(AgentAPITest, NestedContainerLaunchFalse)
-{
- ContentType contentType = GetParam();
-
- Clock::pause();
-
- Try<Owned<cluster::Master>> master = StartMaster();
- ASSERT_SOME(master);
-
- Owned<MasterDetector> detector = master.get()->createDetector();
-
- MockExecutor exec(DEFAULT_EXECUTOR_ID);
- TestContainerizer containerizer(&exec);
-
- slave::Flags agentFlags = CreateSlaveFlags();
- Try<Owned<cluster::Slave>> slave =
- StartSlave(detector.get(), &containerizer, agentFlags);
-
- ASSERT_SOME(slave);
-
- MockScheduler sched;
- MesosSchedulerDriver driver(
- &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
-
- EXPECT_CALL(sched, registered(&driver, _, _));
-
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(LaunchTasks(DEFAULT_EXECUTOR_INFO, 1, 0.1, 32, "*"))
- .WillRepeatedly(Return()); // Ignore subsequent offers.
-
- Future<Nothing> executorRegistered;
- EXPECT_CALL(exec, registered(_, _, _, _))
- .WillOnce(FutureSatisfy(&executorRegistered));
-
- EXPECT_CALL(exec, launchTask(_, _));
-
- driver.start();
-
- // Trigger authentication and registration for the agent.
- Clock::advance(agentFlags.authentication_backoff_factor);
- Clock::advance(agentFlags.registration_backoff_factor);
-
- AWAIT_READY(executorRegistered);
-
- Future<hashset<ContainerID>> containerIds = containerizer.containers();
- AWAIT_READY(containerIds);
- ASSERT_EQ(1u, containerIds->size());
-
- // Try to launch an "unsupported" container.
- v1::ContainerID containerId;
- containerId.set_value(UUID::random().toString());
- containerId.mutable_parent()->set_value(containerIds->begin()->value());
-
- {
- // Return false here to indicate "unsupported".
- EXPECT_CALL(containerizer, launch(_, _, _, _))
- .WillOnce(Return(Future<bool>(false)));
-
- v1::agent::Call call;
- call.set_type(v1::agent::Call::LAUNCH_NESTED_CONTAINER);
-
- call.mutable_launch_nested_container()->mutable_container_id()
- ->CopyFrom(containerId);
-
- Future<http::Response> response = http::post(
- slave.get()->pid,
- "api/v1",
- createBasicAuthHeaders(DEFAULT_CREDENTIAL),
- serialize(contentType, call),
- stringify(contentType));
-
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::BadRequest().status, response);
- }
-
- EXPECT_CALL(exec, shutdown(_))
- .Times(AtMost(1));
-
- driver.stop();
- driver.join();
-}
-
-
-TEST_P_TEMP_DISABLED_ON_WINDOWS(AgentAPITest, TwoLevelNestedContainerLaunch)
-{
- ContentType contentType = GetParam();
-
- Clock::pause();
-
- Try<Owned<cluster::Master>> master = StartMaster();
- ASSERT_SOME(master);
-
- Owned<MasterDetector> detector = master.get()->createDetector();
-
- MockExecutor exec(DEFAULT_EXECUTOR_ID);
- TestContainerizer containerizer(&exec);
-
- slave::Flags agentFlags = CreateSlaveFlags();
- Try<Owned<cluster::Slave>> slave =
- StartSlave(detector.get(), &containerizer, agentFlags);
-
- ASSERT_SOME(slave);
-
- MockScheduler sched;
- MesosSchedulerDriver driver(
- &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
-
- EXPECT_CALL(sched, registered(&driver, _, _));
-
- EXPECT_CALL(sched, resourceOffers(&driver, _))
- .WillOnce(LaunchTasks(DEFAULT_EXECUTOR_INFO, 1, 0.1, 32, "*"))
- .WillRepeatedly(Return()); // Ignore subsequent offers.
-
- Future<Nothing> executorRegistered;
- EXPECT_CALL(exec, registered(_, _, _, _))
- .WillOnce(FutureSatisfy(&executorRegistered));
-
- EXPECT_CALL(exec, launchTask(_, _));
-
- driver.start();
-
- // Trigger authentication and registration for the agent.
- Clock::advance(agentFlags.authentication_backoff_factor);
- Clock::advance(agentFlags.registration_backoff_factor);
-
- AWAIT_READY(executorRegistered);
-
- Future<hashset<ContainerID>> containerIds = containerizer.containers();
- AWAIT_READY(containerIds);
- ASSERT_EQ(1u, containerIds->size());
-
- // Launch a two level nested parent/child container and then wait for them to
- // finish.
- v1::ContainerID parentContainerId;
- parentContainerId.set_value(UUID::random().toString());
- parentContainerId.mutable_parent()->set_value(containerIds->begin()->value());
-
- // Launch the parent container.
- {
- v1::agent::Call call;
- call.set_type(v1::agent::Call::LAUNCH_NESTED_CONTAINER);
-
- call.mutable_launch_nested_container()->mutable_container_id()
- ->CopyFrom(parentContainerId);
-
- Future<http::Response> response = http::post(
- slave.get()->pid,
- "api/v1",
- createBasicAuthHeaders(DEFAULT_CREDENTIAL),
- serialize(contentType, call),
- stringify(contentType));
-
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
- }
-
- // Launch the child container.
- v1::ContainerID childContainerId;
- childContainerId.set_value(UUID::random().toString());
- childContainerId.mutable_parent()->CopyFrom(parentContainerId);
-
- {
- v1::agent::Call call;
- call.set_type(v1::agent::Call::LAUNCH_NESTED_CONTAINER);
-
- call.mutable_launch_nested_container()->mutable_container_id()
- ->CopyFrom(childContainerId);
-
- Future<http::Response> response = http::post(
- slave.get()->pid,
- "api/v1",
- createBasicAuthHeaders(DEFAULT_CREDENTIAL),
- serialize(contentType, call),
- stringify(contentType));
-
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
- }
-
- // Wait for the parent container.
- Future<v1::agent::Response> waitParent;
-
- {
- v1::agent::Call call;
- call.set_type(v1::agent::Call::WAIT_NESTED_CONTAINER);
-
- call.mutable_wait_nested_container()->mutable_container_id()
- ->CopyFrom(parentContainerId);
-
- waitParent = post(slave.get()->pid, call, contentType);
-
- Clock::settle();
-
- EXPECT_TRUE(waitParent.isPending());
- }
-
- // Wait for the child container.
- Future<v1::agent::Response> waitChild;
-
- {
- v1::agent::Call call;
- call.set_type(v1::agent::Call::WAIT_NESTED_CONTAINER);
-
- call.mutable_wait_nested_container()->mutable_container_id()
- ->CopyFrom(childContainerId);
-
- waitChild = post(slave.get()->pid, call, contentType);
-
- Clock::settle();
-
- EXPECT_TRUE(waitChild.isPending());
- }
-
- // Kill the child container.
- {
- v1::agent::Call call;
- call.set_type(v1::agent::Call::KILL_NESTED_CONTAINER);
-
- call.mutable_kill_nested_container()->mutable_container_id()
- ->CopyFrom(childContainerId);
-
- Future<http::Response> response = http::post(
- slave.get()->pid,
- "api/v1",
- createBasicAuthHeaders(DEFAULT_CREDENTIAL),
- serialize(contentType, call),
- stringify(contentType));
-
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
- }
-
- AWAIT_READY(waitChild);
- ASSERT_EQ(v1::agent::Response::WAIT_NESTED_CONTAINER, waitChild->type());
-
- // The test containerizer sets exit status to 0 when destroyed.
- EXPECT_EQ(0, waitChild->wait_nested_container().exit_status());
-
- // The parent container should still be running.
- EXPECT_TRUE(waitParent.isPending());
-
- // Kill the parent container.
- {
- v1::agent::Call call;
- call.set_type(v1::agent::Call::KILL_NESTED_CONTAINER);
-
- call.mutable_kill_nested_container()->mutable_container_id()
- ->CopyFrom(parentContainerId);
-
- Future<http::Response> response = http::post(
- slave.get()->pid,
- "api/v1",
- createBasicAuthHeaders(DEFAULT_CREDENTIAL),
- serialize(contentType, call),
- stringify(contentType));
-
- AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
- }
-
- AWAIT_READY(waitParent);
- ASSERT_EQ(v1::agent::Response::WAIT_NESTED_CONTAINER, waitParent->type());
-
- // The test containerizer sets exit status to 0 when destroyed.
- EXPECT_EQ(0, waitParent->wait_nested_container().exit_status());
-
- EXPECT_CALL(exec, shutdown(_))
- .Times(AtMost(1));
-
- driver.stop();
- driver.join();
-}
-
-
// This test verifies that launch nested container session fails when
// attaching to the output of the container fails. Consequently, the
// launched container should be destroyed.
http://git-wip-us.apache.org/repos/asf/mesos/blob/fd4b9af1/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 3e2a2d1..983ecd1 100644
--- a/src/tests/containerizer/nested_mesos_containerizer_tests.cpp
+++ b/src/tests/containerizer/nested_mesos_containerizer_tests.cpp
@@ -2325,91 +2325,6 @@ TEST_F(NestedMesosContainerizerTest,
ASSERT_FALSE(containers->contains(containerId));
}
-
-TEST_F(NestedMesosContainerizerTest, ROOT_CGROUPS_WaitAfterDestroy)
-{
- slave::Flags flags = CreateSlaveFlags();
- flags.launcher = "linux";
- flags.isolation = "cgroups/cpu,filesystem/linux,namespaces/pid";
-
- Fetcher fetcher(flags);
-
- Try<MesosContainerizer*> create = MesosContainerizer::create(
- flags,
- true,
- &fetcher);
-
- ASSERT_SOME(create);
-
- Owned<MesosContainerizer> containerizer(create.get());
-
- // Launch a top-level container.
- ContainerID containerId;
- containerId.set_value(UUID::random().toString());
-
- Try<string> directory = environment->mkdtemp();
- ASSERT_SOME(directory);
-
- Future<bool> launch = containerizer->launch(
- containerId,
- createContainerConfig(
- None(),
- createExecutorInfo("executor", "sleep 1000", "cpus:1"),
- directory.get()),
- map<string, string>(),
- None());
-
- AWAIT_ASSERT_TRUE(launch);
-
- // Launch a nested container.
- ContainerID nestedContainerId;
- nestedContainerId.mutable_parent()->CopyFrom(containerId);
- nestedContainerId.set_value(UUID::random().toString());
-
- launch = containerizer->launch(
- nestedContainerId,
- createContainerConfig(createCommandInfo("exit 42")),
- map<string, string>(),
- None());
-
- AWAIT_ASSERT_TRUE(launch);
-
- // Wait once (which does a destroy),
- // then wait again on the nested container.
- Future<Option<ContainerTermination>> nestedWait = containerizer->wait(
- nestedContainerId);
-
- AWAIT_READY(nestedWait);
- ASSERT_SOME(nestedWait.get());
- ASSERT_TRUE(nestedWait.get()->has_status());
- EXPECT_WEXITSTATUS_EQ(42, nestedWait.get()->status());
-
- nestedWait = containerizer->wait(nestedContainerId);
-
- AWAIT_READY(nestedWait);
- ASSERT_SOME(nestedWait.get());
- ASSERT_TRUE(nestedWait.get()->has_status());
- EXPECT_WEXITSTATUS_EQ(42, nestedWait.get()->status());
-
- // Destroy the top-level container.
- Future<Option<ContainerTermination>> wait = containerizer->wait(
- containerId);
-
- AWAIT_READY(containerizer->destroy(containerId));
-
- AWAIT_READY(wait);
- ASSERT_SOME(wait.get());
- ASSERT_TRUE(wait.get()->has_status());
- EXPECT_WTERMSIG_EQ(SIGKILL, wait.get()->status());
-
- // Wait on nested container again.
- nestedWait = containerizer->wait(nestedContainerId);
-
- AWAIT_READY(nestedWait);
- ASSERT_NONE(nestedWait.get());
-}
-
-
// This test verifies that agent environment variables are not leaked
// to the nested container, and the environment variables specified in
// the command for the nested container will be honored.
@@ -2501,86 +2416,6 @@ TEST_F(NestedMesosContainerizerTest, ROOT_CGROUPS_AgentEnvironmentNotLeaked)
}
-TEST_F(NestedMesosContainerizerTest, ROOT_CGROUPS_LaunchNestedThreeLevels)
-{
- slave::Flags flags = CreateSlaveFlags();
- flags.launcher = "linux";
- flags.isolation = "cgroups/cpu,filesystem/linux,namespaces/pid";
-
- Fetcher fetcher(flags);
-
- 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,
- createContainerConfig(
- None(),
- createExecutorInfo("executor", "sleep 1000", "cpus:1"),
- directory.get()),
- map<string, string>(),
- None());
-
- AWAIT_ASSERT_TRUE(launch);
-
- ContainerID level2ContainerId;
- level2ContainerId.mutable_parent()->CopyFrom(level1ContainerId);
- level2ContainerId.set_value(UUID::random().toString());
-
- launch = containerizer->launch(
- level2ContainerId,
- createContainerConfig(createCommandInfo("sleep 1000")),
- map<string, string>(),
- None());
-
- AWAIT_ASSERT_TRUE(launch);
-
- ContainerID level3ContainerId;
- level3ContainerId.mutable_parent()->CopyFrom(level2ContainerId);
- level3ContainerId.set_value(UUID::random().toString());
-
- launch = containerizer->launch(
- level3ContainerId,
- createContainerConfig(createCommandInfo("exit 42")),
- map<string, string>(),
- None());
-
- 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());
-}
-
-
TEST_F(NestedMesosContainerizerTest, ROOT_CGROUPS_Remove)
{
slave::Flags flags = CreateSlaveFlags();