mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject [3/3] mesos git commit: Update DockerContainerizer tests to pass in a ContainerLogger.
Date Tue, 29 Dec 2015 23:54:14 GMT
Update DockerContainerizer tests to pass in a ContainerLogger.

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


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

Branch: refs/heads/master
Commit: 5f6b1032c46b79a1a6e27e357dd101f99e8476a9
Parents: 1c0c68b
Author: Joseph Wu <joseph@mesosphere.io>
Authored: Tue Dec 29 15:35:14 2015 -0800
Committer: Benjamin Hindman <benjamin.hindman@gmail.com>
Committed: Tue Dec 29 15:35:14 2015 -0800

----------------------------------------------------------------------
 .../docker_containerizer_tests.cpp              | 396 ++++++++++++++-----
 src/tests/hook_tests.cpp                        |  18 +-
 2 files changed, 325 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5f6b1032/src/tests/containerizer/docker_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/docker_containerizer_tests.cpp b/src/tests/containerizer/docker_containerizer_tests.cpp
index a43e355..cb58b71 100644
--- a/src/tests/containerizer/docker_containerizer_tests.cpp
+++ b/src/tests/containerizer/docker_containerizer_tests.cpp
@@ -18,6 +18,8 @@
 
 #include <gtest/gtest.h>
 
+#include <mesos/slave/container_logger.hpp>
+
 #include <process/future.hpp>
 #include <process/gmock.hpp>
 #include <process/owned.hpp>
@@ -51,6 +53,8 @@ using mesos::internal::slave::DockerContainerizerProcess;
 using mesos::internal::slave::Fetcher;
 using mesos::internal::slave::Slave;
 
+using mesos::slave::ContainerLogger;
+
 using process::Future;
 using process::Message;
 using process::PID;
@@ -141,8 +145,7 @@ public:
   virtual void TearDown()
   {
     Try<Docker*> docker =
-      Docker::create(tests::flags.docker, tests::flags.docker_socket,
-      false);
+      Docker::create(tests::flags.docker, tests::flags.docker_socket, false);
 
     ASSERT_SOME(docker);
     Future<list<Docker::Container>> containers =
@@ -178,7 +181,16 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Launch_Executor)
 
   Fetcher fetcher;
 
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
 
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
@@ -295,7 +307,16 @@ TEST_F(DockerContainerizerTest, DISABLED_ROOT_DOCKER_Launch_Executor_Bridged)
 
   Fetcher fetcher;
 
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
 
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
@@ -404,7 +425,16 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Launch)
 
   Fetcher fetcher;
 
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
 
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
@@ -535,7 +565,16 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Kill)
 
   Fetcher fetcher;
 
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
 
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
@@ -643,7 +682,16 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Usage)
 
   Fetcher fetcher;
 
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
 
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
@@ -769,16 +817,25 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Update)
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
 
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
@@ -923,22 +980,31 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Update)
 
 TEST_F(DockerContainerizerTest, ROOT_DOCKER_Recover)
 {
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
+  Fetcher fetcher;
+
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
+
   Future<string> stoppedContainer;
   EXPECT_CALL(*mockDocker, stop(_, _, _))
     .WillOnce(DoAll(FutureArg<0>(&stoppedContainer),
                     Return(Nothing())));
 
-  Fetcher fetcher;
-
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
-
   SlaveID slaveId;
   slaveId.set_value("s1");
   ContainerID containerId;
@@ -1040,16 +1106,25 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Recover)
 // that were started by another containerizer (e.g: mesos).
 TEST_F(DockerContainerizerTest, ROOT_DOCKER_SkipRecoverNonDocker)
 {
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
 
   ContainerID containerId;
   containerId.set_value("c1");
@@ -1095,23 +1170,32 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Logs)
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
+  Fetcher fetcher;
+
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
+
   // We skip stopping the docker container because stopping a container
   // even when it terminated might not flush the logs and we end up
   // not getting stdout/stderr in our tests.
   EXPECT_CALL(*mockDocker, stop(_, _, _))
     .WillRepeatedly(Return(Nothing()));
 
-  Fetcher fetcher;
-
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
-
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
 
@@ -1215,23 +1299,32 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Default_CMD)
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
+  Fetcher fetcher;
+
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
+
   // We skip stopping the docker container because stopping a container
   // even when it terminated might not flush the logs and we end up
   // not getting stdout/stderr in our tests.
   EXPECT_CALL(*mockDocker, stop(_, _, _))
     .WillRepeatedly(Return(Nothing()));
 
-  Fetcher fetcher;
-
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
-
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
 
@@ -1338,23 +1431,32 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Default_CMD_Override)
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
+  Fetcher fetcher;
+
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
+
   // We skip stopping the docker container because stopping  a container
   // even when it terminated might not flush the logs and we end up
   // not getting stdout/stderr in our tests.
   EXPECT_CALL(*mockDocker, stop(_, _, _))
     .WillRepeatedly(Return(Nothing()));
 
-  Fetcher fetcher;
-
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
-
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
 
@@ -1464,23 +1566,32 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Default_CMD_Args)
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
+  Fetcher fetcher;
+
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
+
   // We skip stopping the docker container because stopping a container
   // even when it terminated might not flush the logs and we end up
   // not getting stdout/stderr in our tests.
   EXPECT_CALL(*mockDocker, stop(_, _, _))
     .WillRepeatedly(Return(Nothing()));
 
-  Fetcher fetcher;
-
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
-
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
 
@@ -1592,19 +1703,29 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_SlaveRecoveryTaskContainer)
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
+  // This is owned by the containerizer, so we'll need one per containerizer.
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
   // We put the containerizer on the heap so we can more easily
   // control it's lifetime, i.e., when we invoke the destructor.
   MockDockerContainerizer* dockerContainerizer1 =
-    new MockDockerContainerizer(flags, &fetcher, docker);
+    new MockDockerContainerizer(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   Try<PID<Slave> > slave1 = StartSlave(dockerContainerizer1, flags);
   ASSERT_SOME(slave1);
@@ -1686,8 +1807,16 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_SlaveRecoveryTaskContainer)
     .WillOnce(FutureArg<1>(&status))
     .WillRepeatedly(Return());       // Ignore subsequent updates.
 
+  // This is owned by the containerizer, so we'll need one per containerizer.
+  logger = ContainerLogger::create(flags.container_logger);
+  ASSERT_SOME(logger);
+
   MockDockerContainerizer* dockerContainerizer2 =
-    new MockDockerContainerizer(flags, &fetcher, docker);
+    new MockDockerContainerizer(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   Try<PID<Slave> > slave2 = StartSlave(dockerContainerizer2, flags);
   ASSERT_SOME(slave2);
@@ -1743,17 +1872,29 @@ TEST_F(DockerContainerizerTest,
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
+  // This is owned by the containerizer, so we'll need one per containerizer.
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  // We put the containerizer on the heap so we can more easily
+  // control it's lifetime, i.e., when we invoke the destructor.
   MockDockerContainerizer* dockerContainerizer1 =
-    new MockDockerContainerizer(flags, &fetcher, docker);
+    new MockDockerContainerizer(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   Try<PID<Slave> > slave1 = StartSlave(dockerContainerizer1, flags);
   ASSERT_SOME(slave1);
@@ -1860,8 +2001,16 @@ TEST_F(DockerContainerizerTest,
     .WillOnce(FutureArg<1>(&status))
     .WillRepeatedly(Return());       // Ignore subsequent updates.
 
+  // This is owned by the containerizer, so we'll need one per containerizer.
+  logger = ContainerLogger::create(flags.container_logger);
+  ASSERT_SOME(logger);
+
   MockDockerContainerizer* dockerContainerizer2 =
-    new MockDockerContainerizer(flags, &fetcher, docker);
+    new MockDockerContainerizer(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   Try<PID<Slave> > slave2 = StartSlave(dockerContainerizer2, flags);
   ASSERT_SOME(slave2);
@@ -1901,25 +2050,33 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_NC_PortMapping)
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
-  flags.resources = "cpus:1;mem:1024;ports:[10000-10000]";
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+  flags.resources = "cpus:1;mem:1024;ports:[10000-10000]";
+
+  Fetcher fetcher;
+
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
+
   // We skip stopping the docker container because stopping a container
   // even when it terminated might not flush the logs and we end up
   // not getting stdout/stderr in our tests.
   EXPECT_CALL(*mockDocker, stop(_, _, _))
     .WillRepeatedly(Return(Nothing()));
 
-  Fetcher fetcher;
-
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
-
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
 
@@ -2046,16 +2203,25 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_LaunchSandboxWithColon)
   Try<PID<Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
 
   Try<PID<Slave> > slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);
@@ -2140,19 +2306,28 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_DestroyWhileFetching)
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
   // The docker containerizer will free the process, so we must
   // allocate on the heap.
   MockDockerContainerizerProcess* process =
-    new MockDockerContainerizerProcess(flags, &fetcher, docker);
+    new MockDockerContainerizerProcess(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   MockDockerContainerizer dockerContainerizer(
       (Owned<DockerContainerizerProcess>(process)));
@@ -2247,19 +2422,28 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_DestroyWhilePulling)
   Try<PID<Master> > master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
   // The docker containerizer will free the process, so we must
   // allocate on the heap.
   MockDockerContainerizerProcess* process =
-    new MockDockerContainerizerProcess(flags, &fetcher, docker);
+    new MockDockerContainerizerProcess(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   MockDockerContainerizer dockerContainerizer(
       (Owned<DockerContainerizerProcess>(process)));
@@ -2361,19 +2545,28 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_ExecutorCleanupWhenLaunchFailed)
   Try<PID<Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
   // The docker containerizer will free the process, so we must
   // allocate on the heap.
   MockDockerContainerizerProcess* process =
-    new MockDockerContainerizerProcess(flags, &fetcher, docker);
+    new MockDockerContainerizerProcess(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   MockDockerContainerizer dockerContainerizer(
       (Owned<DockerContainerizerProcess>(process)));
@@ -2461,19 +2654,28 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_FetchFailure)
   Try<PID<Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
   // The docker containerizer will free the process, so we must
   // allocate on the heap.
   MockDockerContainerizerProcess* process =
-    new MockDockerContainerizerProcess(flags, &fetcher, docker);
+    new MockDockerContainerizerProcess(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   MockDockerContainerizer dockerContainerizer(
       (Owned<DockerContainerizerProcess>(process)));
@@ -2564,19 +2766,28 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_DockerPullFailure)
   Try<PID<Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
+  slave::Flags flags = CreateSlaveFlags();
+
   Fetcher fetcher;
 
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
   // The docker containerizer will free the process, so we must
   // allocate on the heap.
   MockDockerContainerizerProcess* process =
-    new MockDockerContainerizerProcess(flags, &fetcher, docker);
+    new MockDockerContainerizerProcess(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   MockDockerContainerizer dockerContainerizer(
       (Owned<DockerContainerizerProcess>(process)));
@@ -2667,32 +2878,41 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_DockerInspectDiscard)
   Try<PID<Master>> master = StartMaster();
   ASSERT_SOME(master);
 
-  slave::Flags flags = CreateSlaveFlags();
-
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
 
   Shared<Docker> docker(mockDocker);
 
-  Future<Docker::Container> inspect;
-  EXPECT_CALL(*mockDocker, inspect(_, _))
-    .WillOnce(FutureResult(&inspect,
-                           Invoke((MockDocker*) docker.get(),
-                                  &MockDocker::_inspect)));
-
-  EXPECT_CALL(*mockDocker, run(_, _, _, _, _, _, _, _, _))
-    .WillOnce(Return(Failure("Run failed")));
+  slave::Flags flags = CreateSlaveFlags();
 
   Fetcher fetcher;
 
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
   // The docker containerizer will free the process, so we must
   // allocate on the heap.
   MockDockerContainerizerProcess* process =
-    new MockDockerContainerizerProcess(flags, &fetcher, docker);
+    new MockDockerContainerizerProcess(
+        flags,
+        &fetcher,
+        Owned<ContainerLogger>(logger.get()),
+        docker);
 
   MockDockerContainerizer dockerContainerizer(
       (Owned<DockerContainerizerProcess>(process)));
 
+  Future<Docker::Container> inspect;
+  EXPECT_CALL(*mockDocker, inspect(_, _))
+    .WillOnce(FutureResult(&inspect,
+                           Invoke((MockDocker*) docker.get(),
+                                  &MockDocker::_inspect)));
+
+  EXPECT_CALL(*mockDocker, run(_, _, _, _, _, _, _, _, _))
+    .WillOnce(Return(Failure("Run failed")));
+
   Try<PID<Slave>> slave = StartSlave(&dockerContainerizer);
   ASSERT_SOME(slave);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/5f6b1032/src/tests/hook_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hook_tests.cpp b/src/tests/hook_tests.cpp
index e034534..715b0b0 100644
--- a/src/tests/hook_tests.cpp
+++ b/src/tests/hook_tests.cpp
@@ -16,9 +16,12 @@
 
 #include <mesos/module.hpp>
 
+#include <mesos/slave/container_logger.hpp>
+
 #include <process/clock.hpp>
 #include <process/future.hpp>
 #include <process/gmock.hpp>
+#include <process/owned.hpp>
 #include <process/pid.hpp>
 
 #include <stout/option.hpp>
@@ -60,8 +63,11 @@ using mesos::internal::slave::Fetcher;
 using mesos::internal::slave::MesosContainerizer;
 using mesos::internal::slave::Slave;
 
+using mesos::slave::ContainerLogger;
+
 using process::Clock;
 using process::Future;
+using process::Owned;
 using process::PID;
 using process::Shared;
 
@@ -611,13 +617,23 @@ TEST_F(HookTest, ROOT_DOCKER_VerifySlavePreLaunchDockerHook)
 
   MockDocker* mockDocker =
     new MockDocker(tests::flags.docker, tests::flags.docker_socket);
+
   Shared<Docker> docker(mockDocker);
 
   slave::Flags flags = CreateSlaveFlags();
 
   Fetcher fetcher;
 
-  MockDockerContainerizer dockerContainerizer(flags, &fetcher, docker);
+  Try<ContainerLogger*> logger =
+    ContainerLogger::create(flags.container_logger);
+
+  ASSERT_SOME(logger);
+
+  MockDockerContainerizer dockerContainerizer(
+      flags,
+      &fetcher,
+      Owned<ContainerLogger>(logger.get()),
+      docker);
 
   Try<PID<Slave>> slave = StartSlave(&dockerContainerizer, flags);
   ASSERT_SOME(slave);


Mime
View raw message