You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/01/11 17:28:31 UTC
[3/6] mesos git commit: Added nested container tests for docker
runtime isolator.
Added nested container tests for docker runtime isolator.
Review: https://reviews.apache.org/r/52612/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0282c428
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0282c428
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0282c428
Branch: refs/heads/master
Commit: 0282c42875692e5be0fa3334062ae7f2029b0b11
Parents: af11ad3
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jan 11 09:01:32 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jan 11 09:01:32 2017 -0800
----------------------------------------------------------------------
.../containerizer/runtime_isolator_tests.cpp | 116 ++++++++++++++++++-
1 file changed, 115 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0282c428/src/tests/containerizer/runtime_isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/runtime_isolator_tests.cpp b/src/tests/containerizer/runtime_isolator_tests.cpp
index c0c1160..e376187 100644
--- a/src/tests/containerizer/runtime_isolator_tests.cpp
+++ b/src/tests/containerizer/runtime_isolator_tests.cpp
@@ -14,8 +14,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#include <string>
+#include <vector>
+
+#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <mesos/v1/scheduler.hpp>
+
#include <stout/os.hpp>
#include <stout/path.hpp>
#include <stout/try.hpp>
@@ -42,8 +48,14 @@ using master::Master;
using mesos::master::detector::MasterDetector;
+using mesos::v1::scheduler::Event;
+
using slave::Slave;
+using testing::_;
+using testing::DoAll;
+using testing::Return;
+
namespace mesos {
namespace internal {
namespace tests {
@@ -244,7 +256,7 @@ TEST_F(DockerRuntimeIsolatorTest, ROOT_DockerDefaultEntryptLocalPuller)
// correctly using registry puller. This corresponds to the case in runtime
// isolator logic table: sh=0, value=0, argv=1, entrypoint=1, cmd=0.
TEST_F(DockerRuntimeIsolatorTest,
- ROOT_CURL_INTERNET_DockerDefaultEntryptRegistryPuller)
+ ROOT_INTERNET_CURL_DockerDefaultEntryptRegistryPuller)
{
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
@@ -316,6 +328,108 @@ TEST_F(DockerRuntimeIsolatorTest,
driver.join();
}
+
+// This test verifies a simple task with container image can be
+// launched in a nested container using v1 TASK_GROUP API.
+TEST_F(DockerRuntimeIsolatorTest, ROOT_INTERNET_CURL_NestedSimpleCommand)
+{
+ Try<Owned<cluster::Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ // Disable AuthN on the agent.
+ slave::Flags flags = CreateSlaveFlags();
+ flags.isolation = "filesystem/linux,docker/runtime";
+ flags.image_providers = "docker";
+ flags.authenticate_http_readwrite = false;
+
+ Owned<MasterDetector> detector = master.get()->createDetector();
+
+ Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), flags);
+ ASSERT_SOME(slave);
+
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
+
+ v1::FrameworkInfo frameworkInfo = v1::DEFAULT_FRAMEWORK_INFO;
+
+ Future<Nothing> connected;
+ EXPECT_CALL(*scheduler, connected(_))
+ .WillOnce(DoAll(v1::scheduler::SendSubscribe(frameworkInfo),
+ FutureSatisfy(&connected)));
+
+ v1::scheduler::TestMesos mesos(
+ master.get()->pid, ContentType::PROTOBUF, scheduler);
+
+ AWAIT_READY(connected);
+
+ Future<Event::Subscribed> subscribed;
+ EXPECT_CALL(*scheduler, subscribed(_, _))
+ .WillOnce(FutureArg<1>(&subscribed));
+
+ Future<Event::Offers> offers;
+ EXPECT_CALL(*scheduler, offers(_, _))
+ .WillOnce(FutureArg<1>(&offers))
+ .WillRepeatedly(Return());
+
+ EXPECT_CALL(*scheduler, heartbeat(_))
+ .WillRepeatedly(Return()); // Ignore heartbeats.
+
+ AWAIT_READY(subscribed);
+
+ v1::FrameworkID frameworkId(subscribed->framework_id());
+ v1::ExecutorInfo executorInfo = v1::createExecutorInfo(
+ "test_default_executor",
+ None(),
+ "cpus:0.1;mem:32;disk:32",
+ v1::ExecutorInfo::DEFAULT);
+
+ // Update `executorInfo` with the subscribed `frameworkId`.
+ executorInfo.mutable_framework_id()->CopyFrom(frameworkId);
+
+ AWAIT_READY(offers);
+ EXPECT_NE(0, offers->offers().size());
+
+ const v1::Offer& offer = offers->offers(0);
+
+ // NOTE: We use a non-shell command here because 'sh' might not be
+ // in the PATH. 'alpine' does not specify env PATH in the image. On
+ // some linux distribution, '/bin' is not in the PATH by default.
+ v1::TaskInfo taskInfo = v1::createTask(
+ offer.agent_id(),
+ v1::Resources::parse("cpus:0.1;mem:32;disk:32").get(),
+ v1::createCommandInfo("/bin/ls", {"ls", "-al", "/"}));
+
+ taskInfo.mutable_container()->CopyFrom(
+ v1::createContainerInfo("library/alpine"));
+
+ Future<Event::Update> updateRunning;
+ EXPECT_CALL(*scheduler, update(_, _))
+ .WillOnce(DoAll(FutureArg<1>(&updateRunning),
+ v1::scheduler::SendAcknowledge(
+ frameworkId,
+ offer.agent_id())));
+
+ mesos.send(v1::createCallAccept(
+ frameworkId,
+ offer,
+ v1::LAUNCH_GROUP(
+ executorInfo,
+ v1::createTaskGroupInfo({taskInfo}))));
+
+ AWAIT_READY(updateRunning);
+ ASSERT_EQ(TASK_RUNNING, updateRunning->status().state());
+ EXPECT_EQ(taskInfo.task_id(), updateRunning->status().task_id());
+ EXPECT_TRUE(updateRunning->status().has_timestamp());
+
+ Future<Event::Update> updateFinished;
+ EXPECT_CALL(*scheduler, update(_, _))
+ .WillOnce(FutureArg<1>(&updateFinished));
+
+ AWAIT_READY(updateFinished);
+ ASSERT_EQ(TASK_FINISHED, updateFinished->status().state());
+ EXPECT_EQ(taskInfo.task_id(), updateFinished->status().task_id());
+ EXPECT_TRUE(updateFinished->status().has_timestamp());
+}
+
} // namespace tests {
} // namespace internal {
} // namespace mesos {