You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/12/12 00:35:09 UTC
[1/5] mesos git commit: Added new test for
LAUNCH_NESTED_CONTAINER_SESSION.
Repository: mesos
Updated Branches:
refs/heads/master f5c69c4e1 -> 3dac2664f
Added new test for LAUNCH_NESTED_CONTAINER_SESSION.
This test verifies that launch results in output being streamed.
Review: https://reviews.apache.org/r/54281
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8de25f9e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8de25f9e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8de25f9e
Branch: refs/heads/master
Commit: 8de25f9ef94cab8b67b0ce4c22da26a0a6275a79
Parents: fdc366c
Author: Vinod Kone <vi...@gmail.com>
Authored: Wed Nov 30 14:00:01 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sun Dec 11 16:17:18 2016 -0800
----------------------------------------------------------------------
src/tests/api_tests.cpp | 109 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8de25f9e/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 6d3e861..023c1f2 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -3752,6 +3752,115 @@ TEST_P(AgentAPITest, LaunchNestedContainerSessionAttachFailure)
}
+// This test verifies that launching a nested container session results
+// in stdout and stderr being streamed correctly.
+TEST_P(AgentAPITest, LaunchNestedContainerSession)
+{
+ ContentType contentType = GetParam();
+
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ slave::Flags flags = CreateSlaveFlags();
+ Fetcher fetcher;
+
+ Try<MesosContainerizer*> _containerizer =
+ MesosContainerizer::create(flags, false, &fetcher);
+
+ ASSERT_SOME(_containerizer);
+
+ Owned<slave::Containerizer> containerizer(_containerizer.get());
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+
+ Try<Owned<cluster::Slave>> slave =
+ StartSlave(detector.get(), containerizer.get(), flags);
+
+ ASSERT_SOME(slave);
+
+ MockScheduler sched;
+ MesosSchedulerDriver driver(
+ &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
+
+ EXPECT_CALL(sched, registered(&driver, _, _));
+
+ Future<vector<Offer>> offers;
+ EXPECT_CALL(sched, resourceOffers(_, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.start();
+
+ AWAIT_READY(offers);
+ EXPECT_NE(0u, offers.get().size());
+
+ Future<TaskStatus> status;
+ EXPECT_CALL(sched, statusUpdate(_, _))
+ .WillOnce(FutureArg<1>(&status));
+
+ TaskInfo task = createTask(offers.get()[0], "sleep 1000");
+
+ driver.launchTasks(offers.get()[0].id(), {task});
+
+ AWAIT_READY(status);
+ ASSERT_EQ(TASK_RUNNING, status->state());
+
+ // Launch a nested container session that runs a command
+ // that writes something to stdout and stderr and exits.
+
+ Future<hashset<ContainerID>> containerIds = containerizer->containers();
+ AWAIT_READY(containerIds);
+ ASSERT_EQ(1u, containerIds->size());
+
+ v1::ContainerID containerId;
+ containerId.set_value(UUID::random().toString());
+ containerId.mutable_parent()->set_value(containerIds->begin()->value());
+
+ string output = "output";
+ string error = "error";
+ string command = "printf " + output + " && printf " + error + " 1>&2";
+
+ v1::agent::Call call;
+ call.set_type(v1::agent::Call::LAUNCH_NESTED_CONTAINER_SESSION);
+
+ call.mutable_launch_nested_container_session()->mutable_container_id()
+ ->CopyFrom(containerId);
+
+ call.mutable_launch_nested_container_session()->mutable_command()->set_value(
+ command);
+
+ http::Headers headers = createBasicAuthHeaders(DEFAULT_CREDENTIAL);
+ headers["Accept"] = stringify(contentType);
+
+ Future<http::Response> response = http::streaming::post(
+ slave.get()->pid,
+ "api/v1",
+ headers,
+ serialize(contentType, call),
+ stringify(contentType));
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
+ ASSERT_EQ(stringify(contentType), response->headers.at("Content-Type"));
+ ASSERT_EQ(http::Response::PIPE, response->type);
+
+ ASSERT_SOME(response->reader);
+ Future<tuple<string, string>> received =
+ getProcessIOData(contentType, response->reader.get());
+
+ AWAIT_READY(received);
+
+ string stdoutReceived;
+ string stderrReceived;
+
+ tie(stdoutReceived, stderrReceived) = received.get();
+
+ EXPECT_EQ(output, stdoutReceived);
+ EXPECT_EQ(error, stderrReceived);
+
+ driver.stop();
+ driver.join();
+}
+
+
// TODO(vinod): Update the test when mesos containerizer
// adds support for `attach`.
TEST_P(AgentAPITest, AttachContainerOutputFailure)
[3/5] mesos git commit: Added a TTY test for
LAUNCH_NESTED_CONTAINER_SESSION.
Posted by vi...@apache.org.
Added a TTY test for LAUNCH_NESTED_CONTAINER_SESSION.
Test verifies that output and error are sent as stdout to client.
Review: https://reviews.apache.org/r/54508
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8804fd3e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8804fd3e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8804fd3e
Branch: refs/heads/master
Commit: 8804fd3edbbb8a9f34688ada44251be40f460a87
Parents: 8de25f9
Author: Vinod Kone <vi...@gmail.com>
Authored: Wed Dec 7 15:50:07 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sun Dec 11 16:20:05 2016 -0800
----------------------------------------------------------------------
src/tests/api_tests.cpp | 115 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8804fd3e/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 023c1f2..4f6f206 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -3861,6 +3861,121 @@ TEST_P(AgentAPITest, LaunchNestedContainerSession)
}
+// This test verifies that launching a nested container session with `TTYInfo`
+// results in stdout and stderr being streamed to the client as stdout.
+TEST_P(AgentAPITest, LaunchNestedContainerSessionWithTTY)
+{
+ ContentType contentType = GetParam();
+
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ slave::Flags flags = CreateSlaveFlags();
+ Fetcher fetcher;
+
+ Try<MesosContainerizer*> _containerizer =
+ MesosContainerizer::create(flags, false, &fetcher);
+
+ ASSERT_SOME(_containerizer);
+
+ Owned<slave::Containerizer> containerizer(_containerizer.get());
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+
+ Try<Owned<cluster::Slave>> slave =
+ StartSlave(detector.get(), containerizer.get(), flags);
+
+ ASSERT_SOME(slave);
+
+ MockScheduler sched;
+ MesosSchedulerDriver driver(
+ &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
+
+ EXPECT_CALL(sched, registered(&driver, _, _));
+
+ Future<vector<Offer>> offers;
+ EXPECT_CALL(sched, resourceOffers(_, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.start();
+
+ AWAIT_READY(offers);
+ EXPECT_NE(0u, offers.get().size());
+
+ Future<TaskStatus> status;
+ EXPECT_CALL(sched, statusUpdate(_, _))
+ .WillOnce(FutureArg<1>(&status));
+
+ TaskInfo task = createTask(offers.get()[0], "sleep 1000");
+
+ driver.launchTasks(offers.get()[0].id(), {task});
+
+ AWAIT_READY(status);
+ ASSERT_EQ(TASK_RUNNING, status->state());
+
+ // Launch a nested container session that runs a command
+ // that writes something to stdout and stderr and exits.
+
+ Future<hashset<ContainerID>> containerIds = containerizer->containers();
+ AWAIT_READY(containerIds);
+ ASSERT_EQ(1u, containerIds->size());
+
+ v1::ContainerID containerId;
+ containerId.set_value(UUID::random().toString());
+ containerId.mutable_parent()->set_value(containerIds->begin()->value());
+
+ string output = "output";
+ string error = "error";
+ string command = "printf " + output + " && printf " + error + " 1>&2";
+
+ v1::agent::Call call;
+ call.set_type(v1::agent::Call::LAUNCH_NESTED_CONTAINER_SESSION);
+
+ call.mutable_launch_nested_container_session()->mutable_container_id()
+ ->CopyFrom(containerId);
+
+ call.mutable_launch_nested_container_session()->mutable_command()->set_value(
+ command);
+
+ call.mutable_launch_nested_container_session()->mutable_container()->set_type(
+ mesos::v1::ContainerInfo::MESOS);
+
+ call.mutable_launch_nested_container_session()->mutable_container()
+ ->mutable_tty_info();
+
+ http::Headers headers = createBasicAuthHeaders(DEFAULT_CREDENTIAL);
+ headers["Accept"] = stringify(contentType);
+
+ Future<http::Response> response = http::streaming::post(
+ slave.get()->pid,
+ "api/v1",
+ headers,
+ serialize(contentType, call),
+ stringify(contentType));
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
+ ASSERT_EQ(stringify(contentType), response->headers.at("Content-Type"));
+ ASSERT_EQ(http::Response::PIPE, response->type);
+
+ ASSERT_SOME(response->reader);
+ Future<tuple<string, string>> received =
+ getProcessIOData(contentType, response->reader.get());
+
+ AWAIT_READY(received);
+
+ string stdoutReceived;
+ string stderrReceived;
+
+ tie(stdoutReceived, stderrReceived) = received.get();
+
+ EXPECT_EQ(output + error, stdoutReceived);
+ EXPECT_EQ("", stderrReceived);
+
+ driver.stop();
+ driver.join();
+}
+
+
// TODO(vinod): Update the test when mesos containerizer
// adds support for `attach`.
TEST_P(AgentAPITest, AttachContainerOutputFailure)
[2/5] mesos git commit: Cleaned up expectations in api_tests.cpp.
Posted by vi...@apache.org.
Cleaned up expectations in api_tests.cpp.
Changed `EXPECT_EQ` to `ASSERRT_EQ` for cases where assertion is more
appropriate.
Review: https://reviews.apache.org/r/54545
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fdc366cf
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fdc366cf
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fdc366cf
Branch: refs/heads/master
Commit: fdc366cf4d474b8f123b0f7dd4b02cffc1d90031
Parents: f5c69c4
Author: Vinod Kone <vi...@gmail.com>
Authored: Thu Dec 8 13:13:17 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sun Dec 11 16:17:18 2016 -0800
----------------------------------------------------------------------
src/tests/api_tests.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/fdc366cf/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 0988048..6d3e861 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -3473,7 +3473,7 @@ TEST_P(AgentAPITest, NestedContainerLaunchFalse)
Future<hashset<ContainerID>> containerIds = containerizer.containers();
AWAIT_READY(containerIds);
- EXPECT_EQ(1u, containerIds->size());
+ ASSERT_EQ(1u, containerIds->size());
// Try to launch an "unsupported" container.
v1::ContainerID containerId;
@@ -3596,7 +3596,7 @@ TEST_P(AgentAPITest, NestedContainerLaunch)
Future<hashset<ContainerID>> containerIds = containerizer.containers();
AWAIT_READY(containerIds);
- EXPECT_EQ(1u, containerIds->size());
+ ASSERT_EQ(1u, containerIds->size());
// Launch a nested container and wait for it to finish.
v1::ContainerID containerId;
@@ -3713,7 +3713,7 @@ TEST_P(AgentAPITest, LaunchNestedContainerSessionAttachFailure)
Future<hashset<ContainerID>> containerIds = containerizer.containers();
AWAIT_READY(containerIds);
- EXPECT_EQ(1u, containerIds->size());
+ ASSERT_EQ(1u, containerIds->size());
v1::ContainerID containerId;
containerId.set_value(UUID::random().toString());
@@ -3741,7 +3741,7 @@ TEST_P(AgentAPITest, LaunchNestedContainerSessionAttachFailure)
// Attach failure should result in the destruction of nested container.
containerIds = containerizer.containers();
AWAIT_READY(containerIds);
- EXPECT_EQ(1u, containerIds->size());
+ ASSERT_EQ(1u, containerIds->size());
EXPECT_FALSE(containerIds->contains(devolve(containerId)));
EXPECT_CALL(exec, shutdown(_))
@@ -4044,7 +4044,7 @@ TEST_P(AgentAPIStreamingTest, AttachContainerInput)
Future<hashset<ContainerID>> containerIds = containerizer->containers();
AWAIT_READY(containerIds);
- EXPECT_EQ(1u, containerIds->size());
+ ASSERT_EQ(1u, containerIds->size());
v1::ContainerID containerId;
containerId.set_value(UUID::random().toString());
[5/5] mesos git commit: Added
AgentAPITest.LaunchNestedContainerSessionDisconnected.
Posted by vi...@apache.org.
Added AgentAPITest.LaunchNestedContainerSessionDisconnected.
Tests that when a client is disconnected the container is destroyed.
Review: https://reviews.apache.org/r/54544
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3dac2664
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3dac2664
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3dac2664
Branch: refs/heads/master
Commit: 3dac2664fe96eb4562e567ce0b58ede0041c0789
Parents: f874d31
Author: Vinod Kone <vi...@gmail.com>
Authored: Thu Dec 8 12:21:18 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sun Dec 11 16:32:21 2016 -0800
----------------------------------------------------------------------
src/tests/api_tests.cpp | 113 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/3dac2664/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 8bb01de..0fcbfcf 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -3976,6 +3976,119 @@ TEST_P(AgentAPITest, LaunchNestedContainerSessionWithTTY)
}
+// This test verifies that the nested container session is destroyed
+// upon a client disconnection.
+TEST_P(AgentAPITest, LaunchNestedContainerSessionDisconnected)
+{
+ ContentType contentType = GetParam();
+
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ slave::Flags flags = CreateSlaveFlags();
+ Fetcher fetcher;
+
+ Try<MesosContainerizer*> _containerizer =
+ MesosContainerizer::create(flags, false, &fetcher);
+
+ ASSERT_SOME(_containerizer);
+
+ Owned<slave::Containerizer> containerizer(_containerizer.get());
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+
+ Try<Owned<cluster::Slave>> slave =
+ StartSlave(detector.get(), containerizer.get(), flags);
+
+ ASSERT_SOME(slave);
+
+ MockScheduler sched;
+ MesosSchedulerDriver driver(
+ &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
+
+ EXPECT_CALL(sched, registered(&driver, _, _));
+
+ Future<vector<Offer>> offers;
+ EXPECT_CALL(sched, resourceOffers(_, _))
+ .WillOnce(FutureArg<1>(&offers));
+
+ driver.start();
+
+ AWAIT_READY(offers);
+ EXPECT_NE(0u, offers.get().size());
+
+ Future<TaskStatus> status;
+ EXPECT_CALL(sched, statusUpdate(_, _))
+ .WillOnce(FutureArg<1>(&status));
+
+ TaskInfo task = createTask(offers.get()[0], "sleep 1000");
+
+ driver.launchTasks(offers.get()[0].id(), {task});
+
+ AWAIT_READY(status);
+ ASSERT_EQ(TASK_RUNNING, status->state());
+
+ // Launch a nested container session that runs `cat` so that it never exits.
+
+ Future<hashset<ContainerID>> containerIds = containerizer->containers();
+ AWAIT_READY(containerIds);
+ ASSERT_EQ(1u, containerIds->size());
+
+ v1::ContainerID containerId;
+ containerId.set_value(UUID::random().toString());
+ containerId.mutable_parent()->set_value(containerIds->begin()->value());
+
+ v1::agent::Call call;
+ call.set_type(v1::agent::Call::LAUNCH_NESTED_CONTAINER_SESSION);
+
+ call.mutable_launch_nested_container_session()->mutable_container_id()
+ ->CopyFrom(containerId);
+
+ call.mutable_launch_nested_container_session()->mutable_command()->set_value(
+ "cat");
+
+ // TODO(vinod): Ideally, we can use `http::post` here but we cannot currently
+ // because the caller currently doesn't have a way to disconnect the
+ // connection (e.g., by closing the response reader pipe).
+ http::URL agent = http::URL(
+ "http",
+ slave.get()->pid.address.ip,
+ slave.get()->pid.address.port,
+ slave.get()->pid.id +
+ "/api/v1");
+
+ Future<http::Connection> _connection = http::connect(agent);
+ AWAIT_READY(_connection);
+
+ http::Connection connection = _connection.get(); // Remove const.
+
+ http::Headers headers = createBasicAuthHeaders(DEFAULT_CREDENTIAL);
+ headers["Accept"] = stringify(contentType);
+ headers["Content-Type"] = stringify(contentType);
+
+ http::Request request;
+ request.url = agent;
+ request.method = "POST";
+ request.headers = headers;
+ request.body = serialize(contentType, call);
+
+ Future<http::Response> response = connection.send(request, true);
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(http::OK().status, response);
+ ASSERT_EQ(stringify(contentType), response->headers.at("Content-Type"));
+ ASSERT_EQ(http::Response::PIPE, response->type);
+
+ // Disconnect the launch connection. This should
+ // result in the nested container being destroyed.
+ AWAIT_READY(connection.disconnect());
+
+ AWAIT_READY(containerizer->wait(devolve(containerId)));
+
+ driver.stop();
+ driver.join();
+}
+
+
TEST_P(AgentAPITest, AttachContainerOutputFailure)
{
ContentType contentType = GetParam();
[4/5] mesos git commit: Removed the TODO in
AgentAPITest.AttachContainerOutputFailure test.
Posted by vi...@apache.org.
Removed the TODO in AgentAPITest.AttachContainerOutputFailure test.
This test is still valuable to test the case when a containerizer
does not support `attach`, e.g., DockerContainerizer.
Review: https://reviews.apache.org/r/54516
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f874d31c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f874d31c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f874d31c
Branch: refs/heads/master
Commit: f874d31c36b5172e7a187ac346f6474dd90d5af0
Parents: 8804fd3
Author: Vinod Kone <vi...@gmail.com>
Authored: Wed Dec 7 16:24:40 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Sun Dec 11 16:20:09 2016 -0800
----------------------------------------------------------------------
src/tests/api_tests.cpp | 2 --
1 file changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f874d31c/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 4f6f206..8bb01de 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -3976,8 +3976,6 @@ TEST_P(AgentAPITest, LaunchNestedContainerSessionWithTTY)
}
-// TODO(vinod): Update the test when mesos containerizer
-// adds support for `attach`.
TEST_P(AgentAPITest, AttachContainerOutputFailure)
{
ContentType contentType = GetParam();