You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2016/12/01 06:43:39 UTC
[6/7] mesos git commit: Added a test for the `ATTACH_CONTAINER_INPUT`
call on the Agent API.
Added a test for the `ATTACH_CONTAINER_INPUT` call on the Agent API.
Review: https://reviews.apache.org/r/54242/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/db4b832c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/db4b832c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/db4b832c
Branch: refs/heads/master
Commit: db4b832cbc66e1540a897b02d1cedb48c93c0722
Parents: 7e472c3
Author: Anand Mazumdar <an...@apache.org>
Authored: Wed Nov 30 22:42:05 2016 -0800
Committer: Anand Mazumdar <an...@apache.org>
Committed: Wed Nov 30 22:42:05 2016 -0800
----------------------------------------------------------------------
src/tests/api_tests.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/db4b832c/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index b2a70f3..a803408 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -3653,6 +3653,57 @@ TEST_P(AgentAPITest, AttachContainerOutputFailure)
AWAIT_EXPECT_RESPONSE_BODY_EQ("Unsupported", response);
}
+
+TEST_F(AgentAPITest, AttachContainerInputFailure)
+{
+ Clock::pause();
+
+ Future<Nothing> __recover = FUTURE_DISPATCH(_, &Slave::__recover);
+
+ StandaloneMasterDetector detector;
+ MockContainerizer mockContainerizer;
+
+ EXPECT_CALL(mockContainerizer, recover(_))
+ .WillOnce(Return(Future<Nothing>(Nothing())));
+
+ Try<Owned<cluster::Slave>> slave = StartSlave(&detector, &mockContainerizer);
+
+ ASSERT_SOME(slave);
+
+ // Wait for the agent to finish recovery.
+ AWAIT_READY(__recover);
+ Clock::settle();
+
+ v1::agent::Call call;
+ call.set_type(v1::agent::Call::ATTACH_CONTAINER_INPUT);
+
+ call.mutable_attach_container_input()->mutable_container_id()
+ ->set_value(UUID::random().toString());
+
+ ContentType contentType = ContentType::STREAMING_PROTOBUF;
+
+ ::recordio::Encoder<v1::agent::Call> encoder(lambda::bind(
+ serialize, contentType, lambda::_1));
+
+ EXPECT_CALL(mockContainerizer, attach(_))
+ .WillOnce(Return(process::Failure("Unsupported")));
+
+ Future<http::Response> response = http::post(
+ slave.get()->pid,
+ "api/v1",
+ createBasicAuthHeaders(DEFAULT_CREDENTIAL),
+ encoder.encode(call),
+ stringify(contentType));
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::InternalServerError().status, response);
+ AWAIT_EXPECT_RESPONSE_BODY_EQ("Unsupported", 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>()));
+}
+
} // namespace tests {
} // namespace internal {
} // namespace mesos {