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 2016/08/25 21:57:54 UTC

[01/11] mesos git commit: Fixed the Cmake build for test helper.

Repository: mesos
Updated Branches:
  refs/heads/master 3ec608018 -> 646eee3e6


Fixed the Cmake build for test helper.


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

Branch: refs/heads/master
Commit: 646eee3e696cb5e41da90335817fc7d1087e7071
Parents: 843ff81
Author: Jie Yu <yu...@gmail.com>
Authored: Thu Aug 25 14:57:14 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/tests/CMakeLists.txt                  | 17 +++++++++++++----
 src/tests/cmake/MesosTestsConfigure.cmake | 16 ++++++++--------
 2 files changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/646eee3e/src/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index fada9fe..a380fed 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -35,13 +35,22 @@ endif (LINUX)
 
 # TODO(hausdorff): Add the other tests here.
 
+# INCLUDE DIRECTIVES (generates, e.g., -I/path/to/thing on Linux).
+##################################################################
+include_directories(${TEST_HELPER_INCLUDE_DIRS})
+
+# LINKING LIBRARIES (might generate, e.g., -L/path/to/thing on Linux).
+######################################################################
+link_directories(${TEST_HELPER_LIB_DIRS})
+
 # THE TEST AND HELPER EXECUTABLEs (generates, e.g., stout_tests, etc., on Linux).
 #################################$###############################################
 add_executable(${TEST_HELPER_TARGET} ${TEST_HELPER_SRC})
 
+# ADD LINKER FLAGS (generates, e.g., -lglog on Linux).
+######################################################
+target_link_libraries(${TEST_HELPER_TARGET} ${TEST_HELPER_LIBS})
+
 # ADD BINARY DEPENDENCIES (tells CMake what to compile/build first).
 ####################################################################
-add_dependencies(${TEST_HELPER_TARGET}
-  ${MESOS_TARGET}
-  ${STOUT_DEPENDENCIES}
-  )
+add_dependencies(${TEST_HELPER_TARGET} ${TEST_HELPER_DEPENDENCIES})

http://git-wip-us.apache.org/repos/asf/mesos/blob/646eee3e/src/tests/cmake/MesosTestsConfigure.cmake
----------------------------------------------------------------------
diff --git a/src/tests/cmake/MesosTestsConfigure.cmake b/src/tests/cmake/MesosTestsConfigure.cmake
index 99435d7..3f543c0 100644
--- a/src/tests/cmake/MesosTestsConfigure.cmake
+++ b/src/tests/cmake/MesosTestsConfigure.cmake
@@ -68,8 +68,8 @@ set(GTEST_LFLAG gtest)
 # DEFINE PROCESS LIBRARY DEPENDENCIES. Tells the process library build targets
 # download/configure/build all third-party libraries before attempting to build.
 ################################################################################
-set(CONTAINERIZER_TEST_DEPENDENCIES
-  ${CONTAINERIZER_TEST_DEPENDENCIES}
+set(TEST_HELPER_DEPENDENCIES
+  ${TEST_HELPER_DEPENDENCIES}
   ${MESOS_TARGET}
   ${GMOCK_TARGET}
   )
@@ -77,8 +77,8 @@ set(CONTAINERIZER_TEST_DEPENDENCIES
 # DEFINE THIRD-PARTY INCLUDE DIRECTORIES. Tells compiler toolchain where to get
 # headers for our third party libs (e.g., -I/path/to/glog on Linux)..
 ###############################################################################
-set(CONTAINERIZER_TEST_INCLUDE_DIRS
-  ${CONTAINERIZER_TEST_INCLUDE_DIRS}
+set(TEST_HELPER_INCLUDE_DIRS
+  ${TEST_HELPER_INCLUDE_DIRS}
   ${GMOCK_INCLUDE_DIR}
   ${GTEST_INCLUDE_DIR}
   )
@@ -87,16 +87,16 @@ set(CONTAINERIZER_TEST_INCLUDE_DIRS
 # toolchain where to find our third party libs (e.g., -L/path/to/glog on
 # Linux).
 ########################################################################
-set(CONTAINERIZER_TEST_LIB_DIRS
-  ${CONTAINERIZER_TEST_LIB_DIRS}
+set(TEST_HELPER_LIB_DIRS
+  ${TEST_HELPER_LIB_DIRS}
   ${GTEST_LIB_DIR}
   )
 
 # DEFINE THIRD-PARTY LIBS. Used to generate flags that the linker uses to
 # include our third-party libs (e.g., -lglog on Linux).
 #########################################################################
-set(CONTAINERIZER_TEST_LIBS
-  ${CONTAINERIZER_TEST_LIBS}
+set(TEST_HELPER_LIBS
+  ${TEST_HELPER_LIBS}
   ${MESOS_TARGET}
   ${PROCESS_TARGET}
   ${GTEST_LFLAG}


[03/11] mesos git commit: Fixed an indentation problem in CMakefile.

Posted by ji...@apache.org.
Fixed an indentation problem in CMakefile.


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

Branch: refs/heads/master
Commit: 4f71e0108cde353b9a3dd359434a16558500f2bc
Parents: 9b04b8d
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Aug 25 16:12:18 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/tests/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4f71e010/src/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 2732a79..085ddf8 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -23,7 +23,7 @@ set(TEST_HELPER_SRC
   flags.cpp
   test_helper_main.cpp
   utils.cpp
-	containerizer/memory_test_helper.cpp
+  containerizer/memory_test_helper.cpp
   )
 
 add_subdirectory(containerizer/)


[02/11] mesos git commit: Moved setns test helper to the common test helper.

Posted by ji...@apache.org.
Moved setns test helper to the common test helper.

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


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

Branch: refs/heads/master
Commit: c1c8b3ef21f98296967a23bd3c2122b8ea9ba2c2
Parents: 6755a1f
Author: Jie Yu <yu...@gmail.com>
Authored: Mon Aug 22 13:07:52 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/Makefile.am                                 | 13 +++------
 src/tests/CMakeLists.txt                        |  7 +++++
 src/tests/cmake/MesosTestsConfigure.cmake       |  7 -----
 src/tests/containerizer/CMakeLists.txt          | 16 -----------
 src/tests/containerizer/ns_tests.cpp            |  4 +--
 src/tests/containerizer/setns_test_helper.cpp   | 11 +++++++-
 src/tests/containerizer/setns_test_helper.hpp   |  8 ++++++
 .../containerizer/setns_test_helper_main.cpp    | 28 --------------------
 src/tests/test_helper_main.cpp                  |  9 +++++++
 9 files changed, 40 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index f226b8f..120a715 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1906,15 +1906,6 @@ disk_full_framework_SOURCES = examples/disk_full_framework.cpp
 disk_full_framework_CPPFLAGS = $(MESOS_CPPFLAGS)
 disk_full_framework_LDADD = libmesos.la $(LDADD)
 
-if OS_LINUX
-check_PROGRAMS += setns-test-helper
-setns_test_helper_SOURCES =					\
-  tests/containerizer/setns_test_helper_main.cpp		\
-  tests/containerizer/setns_test_helper.cpp
-setns_test_helper_CPPFLAGS = $(MESOS_CPPFLAGS)
-setns_test_helper_LDADD = libmesos.la $(LDADD)
-endif
-
 check_PROGRAMS += test-helper
 test_helper_SOURCES =						\
   tests/active_user_test_helper.cpp				\
@@ -1922,6 +1913,10 @@ test_helper_SOURCES =						\
   tests/test_helper_main.cpp					\
   tests/utils.cpp						\
   tests/containerizer/memory_test_helper.cpp
+if OS_LINUX
+test_helper_SOURCES +=						\
+  tests/containerizer/setns_test_helper.cpp
+endif
 test_helper_CPPFLAGS = $(mesos_tests_CPPFLAGS)
 test_helper_LDADD = libmesos.la $(mesos_tests_LDADD)
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 085ddf8..bb9f908 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -26,6 +26,13 @@ set(TEST_HELPER_SRC
   containerizer/memory_test_helper.cpp
   )
 
+if (LINUX)
+  set(TEST_HELPER_SRC
+    ${TEST_HELPER_SRC}
+    containerizer/setns_test_helper.cpp
+    )
+endif (LINUX)
+
 add_subdirectory(containerizer/)
 
 # TODO(hausdorff): Add the other tests here.

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/cmake/MesosTestsConfigure.cmake
----------------------------------------------------------------------
diff --git a/src/tests/cmake/MesosTestsConfigure.cmake b/src/tests/cmake/MesosTestsConfigure.cmake
index d593b54..99435d7 100644
--- a/src/tests/cmake/MesosTestsConfigure.cmake
+++ b/src/tests/cmake/MesosTestsConfigure.cmake
@@ -19,13 +19,6 @@ set(
   CACHE STRING "Test helper target to run tests that require a subprocess."
   )
 
-if (LINUX)
-  set(
-    SETNS_TEST_HELPER_TARGET setns-test-helper
-    CACHE STRING "Test helper target that allows changing the test to its parent namespace."
-    )
-endif (LINUX)
-
 # COMPILER CONFIGURATION.
 #########################
 if (WIN32)

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/CMakeLists.txt b/src/tests/containerizer/CMakeLists.txt
index 031823e..7a2dc0a 100644
--- a/src/tests/containerizer/CMakeLists.txt
+++ b/src/tests/containerizer/CMakeLists.txt
@@ -16,13 +16,6 @@
 
 # CONTAINERIZER TESTS.
 ######################
-if (LINUX)
-  set(SETNS_TEST_HELPER_SRC
-    ${SETNS_TEST_HELPER_SRC}
-    setns_test_helper_main.cpp
-    setns_test_helper.cpp
-    )
-endif (LINUX)
 
 # INCLUDE DIRECTIVES FOR CONTAINERIZER TEST BINARY (generates, e.g., -I/path/to/thing
 # on Linux).
@@ -36,18 +29,9 @@ link_directories(${CONTAINERIZER_TEST_LIB_DIRS})
 
 # THE CONTAINERIZER TEST EXECUTABLE (generates, e.g., stout_tests, etc., on Linux).
 ###########################################################################
-if (LINUX)
-  add_executable(${SETNS_TEST_HELPER_TARGET} ${SETNS_TEST_HELPER_SRC})
-endif (LINUX)
 
 # ADD LINKER FLAGS (generates, e.g., -lglog on Linux).
 ######################################################
-if (LINUX)
-  target_link_libraries(${SETNS_TEST_HELPER_TARGET} ${CONTAINERIZER_TEST_LIBS})
-endif (LINUX)
 
 # ADD BINARY DEPENDENCIES (tells CMake what to compile/build first).
 ####################################################################
-if (LINUX)
-  add_dependencies(${SETNS_TEST_HELPER_TARGET} ${CONTAINERIZER_TEST_DEPENDENCIES})
-endif (LINUX)

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/ns_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/ns_tests.cpp b/src/tests/containerizer/ns_tests.cpp
index cd668eb..1f9d679 100644
--- a/src/tests/containerizer/ns_tests.cpp
+++ b/src/tests/containerizer/ns_tests.cpp
@@ -78,11 +78,11 @@ TEST(NsTest, ROOT_setns)
   }
 
   vector<string> argv;
-  argv.push_back("setns-test-helper");
+  argv.push_back("test-helper");
   argv.push_back(SetnsTestHelper::NAME);
 
   Try<Subprocess> s = subprocess(
-      getTestHelperPath("setns-test-helper"),
+      getTestHelperPath("test-helper"),
       argv,
       Subprocess::FD(STDIN_FILENO),
       Subprocess::FD(STDOUT_FILENO),

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/setns_test_helper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/setns_test_helper.cpp b/src/tests/containerizer/setns_test_helper.cpp
index b7788ab..045caf6 100644
--- a/src/tests/containerizer/setns_test_helper.cpp
+++ b/src/tests/containerizer/setns_test_helper.cpp
@@ -28,7 +28,12 @@
 using std::set;
 using std::string;
 
-const char SetnsTestHelper::NAME[] = "SetnsTestHelper";
+namespace mesos {
+namespace internal {
+namespace tests {
+
+const char SetnsTestHelper::NAME[] = "Setns";
+
 
 int SetnsTestHelper::execute()
 {
@@ -59,3 +64,7 @@ int SetnsTestHelper::execute()
 
   return 0;
 }
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/setns_test_helper.hpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/setns_test_helper.hpp b/src/tests/containerizer/setns_test_helper.hpp
index bd1a985..b052497 100644
--- a/src/tests/containerizer/setns_test_helper.hpp
+++ b/src/tests/containerizer/setns_test_helper.hpp
@@ -19,6 +19,10 @@
 
 #include <stout/subcommand.hpp>
 
+namespace mesos {
+namespace internal {
+namespace tests {
+
 class SetnsTestHelper : public Subcommand
 {
 public:
@@ -30,4 +34,8 @@ protected:
   virtual int execute();
 };
 
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {
+
 #endif // __SETNS_TEST_HELPER_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/containerizer/setns_test_helper_main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/setns_test_helper_main.cpp b/src/tests/containerizer/setns_test_helper_main.cpp
deleted file mode 100644
index b8f20c3..0000000
--- a/src/tests/containerizer/setns_test_helper_main.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <stout/subcommand.hpp>
-
-#include "tests/containerizer/setns_test_helper.hpp"
-
-int main(int argc, char** argv)
-{
-  return Subcommand::dispatch(
-      None(),
-      argc,
-      argv,
-      new SetnsTestHelper());
-}

http://git-wip-us.apache.org/repos/asf/mesos/blob/c1c8b3ef/src/tests/test_helper_main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/test_helper_main.cpp b/src/tests/test_helper_main.cpp
index dd1be67..06aacc3 100644
--- a/src/tests/test_helper_main.cpp
+++ b/src/tests/test_helper_main.cpp
@@ -20,9 +20,15 @@
 #include "tests/active_user_test_helper.hpp"
 
 #include "tests/containerizer/memory_test_helper.hpp"
+#ifdef __linux__
+#include "tests/containerizer/setns_test_helper.hpp"
+#endif
 
 using mesos::internal::tests::ActiveUserTestHelper;
 using mesos::internal::tests::MemoryTestHelper;
+#ifdef __linux__
+using mesos::internal::tests::SetnsTestHelper;
+#endif
 
 
 int main(int argc, char** argv)
@@ -31,6 +37,9 @@ int main(int argc, char** argv)
       None(),
       argc,
       argv,
+#ifdef __linux__
+      new SetnsTestHelper(),
+#endif
       new ActiveUserTestHelper(),
       new MemoryTestHelper());
 }


[10/11] mesos git commit: Removed the unused containerizer test CMakefile.

Posted by ji...@apache.org.
Removed the unused containerizer test CMakefile.


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

Branch: refs/heads/master
Commit: 843ff81a4f7fe10d682f8694f14cb68954f84870
Parents: c1c8b3e
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Aug 25 16:45:22 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/tests/CMakeLists.txt               |  2 --
 src/tests/containerizer/CMakeLists.txt | 37 -----------------------------
 2 files changed, 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/843ff81a/src/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index bb9f908..fada9fe 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -33,8 +33,6 @@ if (LINUX)
     )
 endif (LINUX)
 
-add_subdirectory(containerizer/)
-
 # TODO(hausdorff): Add the other tests here.
 
 # THE TEST AND HELPER EXECUTABLEs (generates, e.g., stout_tests, etc., on Linux).

http://git-wip-us.apache.org/repos/asf/mesos/blob/843ff81a/src/tests/containerizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/CMakeLists.txt b/src/tests/containerizer/CMakeLists.txt
deleted file mode 100644
index 7a2dc0a..0000000
--- a/src/tests/containerizer/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# CONTAINERIZER TESTS.
-######################
-
-# INCLUDE DIRECTIVES FOR CONTAINERIZER TEST BINARY (generates, e.g., -I/path/to/thing
-# on Linux).
-#############################################################################
-include_directories(${CONTAINERIZER_TEST_INCLUDE_DIRS})
-
-# LINKING LIBRARIES BY DIRECTORY (might generate, e.g., -L/path/to/thing on
-# Linux).
-###########################################################################
-link_directories(${CONTAINERIZER_TEST_LIB_DIRS})
-
-# THE CONTAINERIZER TEST EXECUTABLE (generates, e.g., stout_tests, etc., on Linux).
-###########################################################################
-
-# ADD LINKER FLAGS (generates, e.g., -lglog on Linux).
-######################################################
-
-# ADD BINARY DEPENDENCIES (tells CMake what to compile/build first).
-####################################################################


[06/11] mesos git commit: Added a missing stout header.

Posted by ji...@apache.org.
Added a missing stout header.


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

Branch: refs/heads/master
Commit: 7a1bdf30ea9f16273e804f35f895b0d33297f03c
Parents: 27f7773
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Aug 25 16:32:08 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/tests/test_helper_main.cpp | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7a1bdf30/src/tests/test_helper_main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/test_helper_main.cpp b/src/tests/test_helper_main.cpp
index 120e881..de95682 100644
--- a/src/tests/test_helper_main.cpp
+++ b/src/tests/test_helper_main.cpp
@@ -14,6 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include <stout/none.hpp>
 #include <stout/subcommand.hpp>
 
 #include "tests/active_user_test_helper.hpp"


[09/11] mesos git commit: Used `->` to replace `.get()` in memory test helper.

Posted by ji...@apache.org.
Used `->` to replace `.get()` in memory test helper.


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

Branch: refs/heads/master
Commit: 692a41004a69117fd66a758a472e0aca13e61d3b
Parents: 3d873ec
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Aug 25 16:17:29 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/memory_test_helper.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/692a4100/src/tests/containerizer/memory_test_helper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/memory_test_helper.cpp b/src/tests/containerizer/memory_test_helper.cpp
index 1a33b7b..b94f0aa 100644
--- a/src/tests/containerizer/memory_test_helper.cpp
+++ b/src/tests/containerizer/memory_test_helper.cpp
@@ -106,7 +106,7 @@ Try<Nothing> MemoryTestHelper::spawn()
   // Otherwise, the user might set the memory limit too earlier, and
   // cause the child oom-killed because 'ld' could use a lot of
   // memory.
-  Result<string> read = os::read(s.get().out().get(), sizeof(STARTED));
+  Result<string> read = os::read(s->out().get(), sizeof(STARTED));
   if (!read.isSome() || read.get() != string(sizeof(STARTED), STARTED)) {
     cleanup();
     return Error("Failed to sync with the subprocess");
@@ -122,8 +122,8 @@ void MemoryTestHelper::cleanup()
     // We just want to make sure the subprocess is terminated in case
     // it's stuck, but we don't care about its status. Any error
     // should have been logged in the subprocess directly.
-    ::kill(s.get().pid(), SIGKILL);
-    ::waitpid(s.get().pid(), nullptr, 0);
+    ::kill(s->pid(), SIGKILL);
+    ::waitpid(s->pid(), nullptr, 0);
     s = None();
   }
 }
@@ -135,7 +135,7 @@ Try<pid_t> MemoryTestHelper::pid()
     return Error("The subprocess has not been spawned yet");
   }
 
-  return s.get().pid();
+  return s->pid();
 }
 
 
@@ -147,13 +147,13 @@ Try<Nothing> MemoryTestHelper::requestAndWait(const string& request)
     return Error("The subprocess has not been spawned yet");
   }
 
-  Try<Nothing> write = os::write(s.get().in().get(), request + "\n");
+  Try<Nothing> write = os::write(s->in().get(), request + "\n");
   if (write.isError()) {
     cleanup();
     return Error("Fail to sync with the subprocess: " + write.error());
   }
 
-  Result<string> read = os::read(s.get().out().get(), sizeof(DONE));
+  Result<string> read = os::read(s->out().get(), sizeof(DONE));
   if (!read.isSome() || read.get() != string(sizeof(DONE), DONE)) {
     cleanup();
     return Error("Failed to sync with the subprocess");
@@ -262,7 +262,7 @@ static Try<Nothing> doIncreasePageCache(const vector<string>& tokens)
 
   // NOTE: We are doing round-down here to calculate the number of
   // writes to do.
-  for (uint64_t i = 0; i < size.get().bytes() / UNIT.bytes(); i++) {
+  for (uint64_t i = 0; i < size->bytes() / UNIT.bytes(); i++) {
     // Write UNIT size to disk at a time. The content isn't important.
     Try<Nothing> write = os::write(fd.get(), string(UNIT.bytes(), 'a'));
     if (write.isError()) {


[04/11] mesos git commit: Refactored the test helper to use a single binary.

Posted by ji...@apache.org.
Refactored the test helper to use a single binary.

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


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

Branch: refs/heads/master
Commit: f5f919907a0b89ad69ef351fe3958760286c266b
Parents: 3ec6080
Author: Jie Yu <yu...@gmail.com>
Authored: Mon Aug 22 13:07:41 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/Makefile.am                           | 12 ++++---
 src/tests/CMakeLists.txt                  |  9 ++---
 src/tests/active_user_test_helper.cpp     | 41 +++++++++++++++-------
 src/tests/active_user_test_helper.hpp     | 48 ++++++++++++++++++++++++++
 src/tests/cmake/MesosTestsConfigure.cmake |  4 +--
 src/tests/slave_tests.cpp                 | 14 +++++---
 src/tests/test_helper_main.cpp            | 31 +++++++++++++++++
 7 files changed, 131 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f5f91990/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 69e5655..11bd72a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -980,6 +980,7 @@ libmesos_no_3rdparty_la_SOURCES +=					\
   slave/containerizer/mesos/provisioner/docker/store.hpp		\
   slave/qos_controllers/noop.hpp					\
   slave/resource_estimators/noop.hpp					\
+  tests/active_user_test_helper.hpp					\
   tests/allocator.hpp							\
   tests/cluster.hpp							\
   tests/containerizer.hpp						\
@@ -1923,10 +1924,12 @@ memory_test_helper_SOURCES =					\
 memory_test_helper_CPPFLAGS = $(mesos_tests_CPPFLAGS)
 memory_test_helper_LDADD = $(mesos_tests_LDADD)
 
-check_PROGRAMS += active-user-test-helper
-active_user_test_helper_SOURCES = tests/active_user_test_helper.cpp
-active_user_test_helper_CPPFLAGS = $(MESOS_CPPFLAGS)
-active_user_test_helper_LDADD = libmesos.la $(LDADD)
+check_PROGRAMS += test-helper
+test_helper_SOURCES =						\
+  tests/active_user_test_helper.cpp				\
+  tests/test_helper_main.cpp
+test_helper_CPPFLAGS = $(MESOS_CPPFLAGS)
+test_helper_LDADD = libmesos.la $(LDADD)
 
 check_PROGRAMS += mesos-tests
 
@@ -2059,6 +2062,7 @@ endif
 
 mesos_tests_SOURCES =						\
   slave/qos_controllers/load.cpp				\
+  tests/active_user_test_helper.cpp				\
   tests/anonymous_tests.cpp					\
   tests/api_tests.cpp						\
   tests/attributes_tests.cpp					\

http://git-wip-us.apache.org/repos/asf/mesos/blob/f5f91990/src/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 1ea8b21..9df2804 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -17,9 +17,10 @@
 include(MesosTestsConfigure)
 
 ######################
-set(ACTIVE_USER_TEST_HELPER_SRC
-  ${ACTIVE_USER_TEST_HELPER_SRC}
+set(TEST_HELPER_SRC
+  ${TEST_HELPER_SRC}
   active_user_test_helper.cpp
+  test_helper_main.cpp
   )
 
 add_subdirectory(containerizer/)
@@ -28,8 +29,8 @@ add_subdirectory(containerizer/)
 
 # THE TEST AND HELPER EXECUTABLEs (generates, e.g., stout_tests, etc., on Linux).
 #################################$###############################################
-add_executable(${ACTIVE_USER_TEST_HELPER_TARGET} ${ACTIVE_USER_TEST_HELPER_SRC})
+add_executable(${TEST_HELPER_TARGET} ${TEST_HELPER_SRC})
 
 # ADD BINARY DEPENDENCIES (tells CMake what to compile/build first).
 ####################################################################
-add_dependencies(${ACTIVE_USER_TEST_HELPER_TARGET} ${STOUT_DEPENDENCIES})
+add_dependencies(${TEST_HELPER_TARGET} ${STOUT_DEPENDENCIES})

http://git-wip-us.apache.org/repos/asf/mesos/blob/f5f91990/src/tests/active_user_test_helper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/active_user_test_helper.cpp b/src/tests/active_user_test_helper.cpp
index 54e8668..80bd0ac 100644
--- a/src/tests/active_user_test_helper.cpp
+++ b/src/tests/active_user_test_helper.cpp
@@ -14,26 +14,41 @@
 // See the License for the specific language governing permissions and
 // limitations under the License
 
-#include <iostream>
 #include <string>
 
 #include <stout/os.hpp>
 
-// This helper program takes an expected user.
-// Returns 0 if the current username equals the expected username.
-// Returns 1 otherwise.
-int main(int argc, char **argv) {
-  if (argc < 2) {
-    std::cerr << "Usage: " << argv[0] << " <expected username>" << std::endl;
-    return 1;
-  }
+#include "tests/active_user_test_helper.hpp"
+
+using std::string;
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+const char ActiveUserTestHelper::NAME[] = "ActiveUser";
 
-  const std::string expected(argv[1]);
 
-  Result<std::string> user = os::user();
-  if (user.isSome() && user.get() == expected) {
-      return 0;
+ActiveUserTestHelper::Flags::Flags()
+{
+  add(&user,
+      "user",
+      "The expected user name.");
+}
+
+
+// This test helper returns 0 if the current username equals the
+// expected username. Returns 1 otherwise.
+int ActiveUserTestHelper::execute()
+{
+  Result<string> user = os::user();
+  if (user.isSome() && user.get() == flags.user) {
+    return 0;
   }
 
   return 1;
 }
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/f5f91990/src/tests/active_user_test_helper.hpp
----------------------------------------------------------------------
diff --git a/src/tests/active_user_test_helper.hpp b/src/tests/active_user_test_helper.hpp
new file mode 100644
index 0000000..b99d1e4
--- /dev/null
+++ b/src/tests/active_user_test_helper.hpp
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+
+#include <string>
+
+#include <stout/subcommand.hpp>
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+class ActiveUserTestHelper : public Subcommand
+{
+public:
+  static const char NAME[];
+
+  struct Flags : public flags::FlagsBase
+  {
+    Flags();
+
+    std::string user;
+  };
+
+  ActiveUserTestHelper() : Subcommand(NAME) {}
+
+  Flags flags;
+
+protected:
+  virtual int execute();
+  virtual flags::FlagsBase* getFlags() { return &flags; }
+};
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/f5f91990/src/tests/cmake/MesosTestsConfigure.cmake
----------------------------------------------------------------------
diff --git a/src/tests/cmake/MesosTestsConfigure.cmake b/src/tests/cmake/MesosTestsConfigure.cmake
index 3610320..8ab4ca3 100644
--- a/src/tests/cmake/MesosTestsConfigure.cmake
+++ b/src/tests/cmake/MesosTestsConfigure.cmake
@@ -20,8 +20,8 @@ set(
   )
 
 set(
-  ACTIVE_USER_TEST_HELPER_TARGET active-user-test-helper
-  CACHE STRING "Test helper target required to run tests with a user."
+  TEST_HELPER_TARGET test-helper
+  CACHE STRING "Test helper target to run tests that require a subprocess."
   )
 
 if (LINUX)

http://git-wip-us.apache.org/repos/asf/mesos/blob/f5f91990/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 84ee37c..701fab2 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -60,6 +60,7 @@
 
 #include "slave/containerizer/mesos/containerizer.hpp"
 
+#include "tests/active_user_test_helper.hpp"
 #include "tests/containerizer.hpp"
 #include "tests/environment.hpp"
 #include "tests/flags.hpp"
@@ -991,14 +992,15 @@ TEST_F(SlaveTest, ROOT_RunTaskWithCommandInfoWithoutUser)
   CHECK_SOME(user) << "Failed to get current user name"
                    << (user.isError() ? ": " + user.error() : "");
 
-  const string helper = getTestHelperPath("active-user-test-helper");
+  const string helper = getTestHelperPath("test-helper");
 
   // Command executor will run as user running test.
   CommandInfo command;
   command.set_shell(false);
   command.set_value(helper);
   command.add_arguments(helper);
-  command.add_arguments(user.get());
+  command.add_arguments(ActiveUserTestHelper::NAME);
+  command.add_arguments("--user=" + user.get());
 
   task.mutable_command()->MergeFrom(command);
 
@@ -1071,7 +1073,7 @@ TEST_F(SlaveTest, DISABLED_ROOT_RunTaskWithCommandInfoWithUser)
 
   Future<TaskStatus> statusRunning;
   Future<TaskStatus> statusFinished;
-  const string helper = getTestHelperPath("active-user-test-helper");
+  const string helper = getTestHelperPath("test-helper");
 
   Future<vector<Offer>> offers;
   EXPECT_CALL(sched, resourceOffers(&driver, _))
@@ -1107,7 +1109,8 @@ TEST_F(SlaveTest, DISABLED_ROOT_RunTaskWithCommandInfoWithUser)
   prepareCommand.set_shell(false);
   prepareCommand.set_value(helper);
   prepareCommand.add_arguments(helper);
-  prepareCommand.add_arguments(user.get());
+  prepareCommand.add_arguments(ActiveUserTestHelper::NAME);
+  prepareCommand.add_arguments("--user=" + user.get());
   prepareTask.mutable_command()->CopyFrom(prepareCommand);
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
@@ -1146,7 +1149,8 @@ TEST_F(SlaveTest, DISABLED_ROOT_RunTaskWithCommandInfoWithUser)
   command.set_shell(false);
   command.set_value(helper);
   command.add_arguments(helper);
-  command.add_arguments(testUser);
+  command.add_arguments(ActiveUserTestHelper::NAME);
+  command.add_arguments("--user=" + testUser);
 
   task.mutable_command()->CopyFrom(command);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/f5f91990/src/tests/test_helper_main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/test_helper_main.cpp b/src/tests/test_helper_main.cpp
new file mode 100644
index 0000000..120e881
--- /dev/null
+++ b/src/tests/test_helper_main.cpp
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <stout/subcommand.hpp>
+
+#include "tests/active_user_test_helper.hpp"
+
+using mesos::internal::tests::ActiveUserTestHelper;
+
+
+int main(int argc, char** argv)
+{
+  return Subcommand::dispatch(
+      None(),
+      argc,
+      argv,
+      new ActiveUserTestHelper());
+}


[05/11] mesos git commit: Fixed the test helper dependency in CMake.

Posted by ji...@apache.org.
Fixed the test helper dependency in CMake.


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

Branch: refs/heads/master
Commit: 27f7773eee378011b2331d09045410f19428ef11
Parents: f5f9199
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Aug 25 16:31:08 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/tests/CMakeLists.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/27f7773e/src/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 9df2804..45e3a55 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -33,4 +33,7 @@ add_executable(${TEST_HELPER_TARGET} ${TEST_HELPER_SRC})
 
 # ADD BINARY DEPENDENCIES (tells CMake what to compile/build first).
 ####################################################################
-add_dependencies(${TEST_HELPER_TARGET} ${STOUT_DEPENDENCIES})
+add_dependencies(${TEST_HELPER_TARGET}
+  ${MESOS_TARGET}
+  ${STOUT_DEPENDENCIES}
+  )


[11/11] mesos git commit: Removed unused comments about test target in containerizer CMakefile.

Posted by ji...@apache.org.
Removed unused comments about test target in containerizer CMakefile.


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

Branch: refs/heads/master
Commit: 6755a1f6d324cdfc712d8b2f5a430a26ea5931fd
Parents: 692a410
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Aug 25 16:44:20 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/CMakeLists.txt | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6755a1f6/src/tests/containerizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/CMakeLists.txt b/src/tests/containerizer/CMakeLists.txt
index 4f5461b..031823e 100644
--- a/src/tests/containerizer/CMakeLists.txt
+++ b/src/tests/containerizer/CMakeLists.txt
@@ -51,6 +51,3 @@ endif (LINUX)
 if (LINUX)
   add_dependencies(${SETNS_TEST_HELPER_TARGET} ${CONTAINERIZER_TEST_DEPENDENCIES})
 endif (LINUX)
-
-# ADD TEST TARGET (runs when you do, e.g., `make check`).
-#########################################################


[08/11] mesos git commit: Moved memory test helper to the common test helper.

Posted by ji...@apache.org.
Moved memory test helper to the common test helper.

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


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

Branch: refs/heads/master
Commit: 9b04b8df50cfdea6c3700ba031b7fdfd60a909a4
Parents: 7a1bdf3
Author: Jie Yu <yu...@gmail.com>
Authored: Mon Aug 22 13:07:50 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/Makefile.am                                |  18 +-
 src/tests/CMakeLists.txt                       |   3 +
 src/tests/cmake/MesosTestsConfigure.cmake      |   5 -
 src/tests/containerizer/CMakeLists.txt         |  15 --
 src/tests/containerizer/memory_test_helper.cpp | 217 ++++++++++----------
 src/tests/containerizer/memory_test_helper.hpp |  25 +--
 src/tests/test_helper_main.cpp                 |   6 +-
 7 files changed, 132 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9b04b8df/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 11bd72a..f226b8f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1915,21 +1915,15 @@ setns_test_helper_CPPFLAGS = $(MESOS_CPPFLAGS)
 setns_test_helper_LDADD = libmesos.la $(LDADD)
 endif
 
-check_PROGRAMS += memory-test-helper
-memory_test_helper_SOURCES =					\
-  tests/flags.cpp						\
-  tests/utils.cpp						\
-  tests/containerizer/memory_test_helper_main.cpp		\
-  tests/containerizer/memory_test_helper.cpp
-memory_test_helper_CPPFLAGS = $(mesos_tests_CPPFLAGS)
-memory_test_helper_LDADD = $(mesos_tests_LDADD)
-
 check_PROGRAMS += test-helper
 test_helper_SOURCES =						\
   tests/active_user_test_helper.cpp				\
-  tests/test_helper_main.cpp
-test_helper_CPPFLAGS = $(MESOS_CPPFLAGS)
-test_helper_LDADD = libmesos.la $(LDADD)
+  tests/flags.cpp						\
+  tests/test_helper_main.cpp					\
+  tests/utils.cpp						\
+  tests/containerizer/memory_test_helper.cpp
+test_helper_CPPFLAGS = $(mesos_tests_CPPFLAGS)
+test_helper_LDADD = libmesos.la $(mesos_tests_LDADD)
 
 check_PROGRAMS += mesos-tests
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/9b04b8df/src/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 45e3a55..2732a79 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -20,7 +20,10 @@ include(MesosTestsConfigure)
 set(TEST_HELPER_SRC
   ${TEST_HELPER_SRC}
   active_user_test_helper.cpp
+  flags.cpp
   test_helper_main.cpp
+  utils.cpp
+	containerizer/memory_test_helper.cpp
   )
 
 add_subdirectory(containerizer/)

http://git-wip-us.apache.org/repos/asf/mesos/blob/9b04b8df/src/tests/cmake/MesosTestsConfigure.cmake
----------------------------------------------------------------------
diff --git a/src/tests/cmake/MesosTestsConfigure.cmake b/src/tests/cmake/MesosTestsConfigure.cmake
index 8ab4ca3..d593b54 100644
--- a/src/tests/cmake/MesosTestsConfigure.cmake
+++ b/src/tests/cmake/MesosTestsConfigure.cmake
@@ -15,11 +15,6 @@
 # limitations under the License.
 
 set(
-  CONTAINERIZER_MEMORY_TESTS_TARGET mesos-containerizer-memory_test
-  CACHE STRING "Target we use to refer to tests for mesos containerizer tests"
-  )
-
-set(
   TEST_HELPER_TARGET test-helper
   CACHE STRING "Test helper target to run tests that require a subprocess."
   )

http://git-wip-us.apache.org/repos/asf/mesos/blob/9b04b8df/src/tests/containerizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/CMakeLists.txt b/src/tests/containerizer/CMakeLists.txt
index 2c52e43..4f5461b 100644
--- a/src/tests/containerizer/CMakeLists.txt
+++ b/src/tests/containerizer/CMakeLists.txt
@@ -16,14 +16,6 @@
 
 # CONTAINERIZER TESTS.
 ######################
-set(CONTAINERIZER_MEMORY_TESTS_SRC
-  ${CONTAINERIZER_MEMORY_TESTS_SRC}
-  ${MESOS_SRC_DIR}/tests/flags.cpp
-  ${MESOS_SRC_DIR}/tests/utils.cpp
-  memory_test_helper_main.cpp
-  memory_test_helper.cpp
-  )
-
 if (LINUX)
   set(SETNS_TEST_HELPER_SRC
     ${SETNS_TEST_HELPER_SRC}
@@ -44,28 +36,21 @@ link_directories(${CONTAINERIZER_TEST_LIB_DIRS})
 
 # THE CONTAINERIZER TEST EXECUTABLE (generates, e.g., stout_tests, etc., on Linux).
 ###########################################################################
-add_executable(${CONTAINERIZER_MEMORY_TESTS_TARGET} ${CONTAINERIZER_MEMORY_TESTS_SRC})
-
 if (LINUX)
   add_executable(${SETNS_TEST_HELPER_TARGET} ${SETNS_TEST_HELPER_SRC})
 endif (LINUX)
 
 # ADD LINKER FLAGS (generates, e.g., -lglog on Linux).
 ######################################################
-target_link_libraries(${CONTAINERIZER_MEMORY_TESTS_TARGET} ${CONTAINERIZER_TEST_LIBS})
-
 if (LINUX)
   target_link_libraries(${SETNS_TEST_HELPER_TARGET} ${CONTAINERIZER_TEST_LIBS})
 endif (LINUX)
 
 # ADD BINARY DEPENDENCIES (tells CMake what to compile/build first).
 ####################################################################
-add_dependencies(${CONTAINERIZER_MEMORY_TESTS_TARGET} ${CONTAINERIZER_TEST_DEPENDENCIES})
-
 if (LINUX)
   add_dependencies(${SETNS_TEST_HELPER_TARGET} ${CONTAINERIZER_TEST_DEPENDENCIES})
 endif (LINUX)
 
 # ADD TEST TARGET (runs when you do, e.g., `make check`).
 #########################################################
-add_test(NAME MesosContainerizerMemoryTests COMMAND ${CMAKE_BINARY_DIR}/src/${CONTAINERIZER_MEMORY_TESTS_TARGET})

http://git-wip-us.apache.org/repos/asf/mesos/blob/9b04b8df/src/tests/containerizer/memory_test_helper.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/memory_test_helper.cpp b/src/tests/containerizer/memory_test_helper.cpp
index e850b37..1a33b7b 100644
--- a/src/tests/containerizer/memory_test_helper.cpp
+++ b/src/tests/containerizer/memory_test_helper.cpp
@@ -73,6 +73,109 @@ const char INCREASE_RSS[] = "INCREASE_RSS";
 const char INCREASE_PAGE_CACHE[] = "INCREASE_PAGE_CACHE";
 
 
+MemoryTestHelper::~MemoryTestHelper()
+{
+  cleanup();
+}
+
+
+Try<Nothing> MemoryTestHelper::spawn()
+{
+  if (s.isSome()) {
+    return Error("A subprocess has been spawned already");
+  }
+
+  vector<string> argv;
+  argv.push_back("test-helper");
+  argv.push_back(MemoryTestHelper::NAME);
+
+  Try<Subprocess> process = subprocess(
+      getTestHelperPath("test-helper"),
+      argv,
+      Subprocess::PIPE(),
+      Subprocess::PIPE(),
+      Subprocess::FD(STDERR_FILENO));
+
+  if (process.isError()) {
+    return Error("Failed to spawn a subprocess: " + process.error());
+  }
+
+  s = process.get();
+
+  // Wait for the child to inform it has started before returning.
+  // Otherwise, the user might set the memory limit too earlier, and
+  // cause the child oom-killed because 'ld' could use a lot of
+  // memory.
+  Result<string> read = os::read(s.get().out().get(), sizeof(STARTED));
+  if (!read.isSome() || read.get() != string(sizeof(STARTED), STARTED)) {
+    cleanup();
+    return Error("Failed to sync with the subprocess");
+  }
+
+  return Nothing();
+}
+
+
+void MemoryTestHelper::cleanup()
+{
+  if (s.isSome()) {
+    // We just want to make sure the subprocess is terminated in case
+    // it's stuck, but we don't care about its status. Any error
+    // should have been logged in the subprocess directly.
+    ::kill(s.get().pid(), SIGKILL);
+    ::waitpid(s.get().pid(), nullptr, 0);
+    s = None();
+  }
+}
+
+
+Try<pid_t> MemoryTestHelper::pid()
+{
+  if (s.isNone()) {
+    return Error("The subprocess has not been spawned yet");
+  }
+
+  return s.get().pid();
+}
+
+
+// Send a request to the subprocess and wait for its signal that the
+// work has been done.
+Try<Nothing> MemoryTestHelper::requestAndWait(const string& request)
+{
+  if (s.isNone()) {
+    return Error("The subprocess has not been spawned yet");
+  }
+
+  Try<Nothing> write = os::write(s.get().in().get(), request + "\n");
+  if (write.isError()) {
+    cleanup();
+    return Error("Fail to sync with the subprocess: " + write.error());
+  }
+
+  Result<string> read = os::read(s.get().out().get(), sizeof(DONE));
+  if (!read.isSome() || read.get() != string(sizeof(DONE), DONE)) {
+    cleanup();
+    return Error("Failed to sync with the subprocess");
+  }
+
+  return Nothing();
+}
+
+
+Try<Nothing> MemoryTestHelper::increaseRSS(const Bytes& size)
+{
+  return requestAndWait(string(INCREASE_RSS) + " " + stringify(size));
+}
+
+
+Try<Nothing> MemoryTestHelper::increasePageCache(const Bytes& size)
+{
+  return requestAndWait(string(INCREASE_PAGE_CACHE) + " " + stringify(size));
+}
+
+
+
 // This helper allocates memory and prevents the compiler from
 // optimizing that allocation away by locking the allocated pages.
 static Try<void*> allocateRSS(const Bytes& size)
@@ -108,7 +211,7 @@ static Try<void*> allocateRSS(const Bytes& size)
 }
 
 
-static Try<Nothing> increaseRSS(const vector<string>& tokens)
+static Try<Nothing> doIncreaseRSS(const vector<string>& tokens)
 {
   if (tokens.size() < 2) {
     return Error("Expect at least one argument");
@@ -128,7 +231,7 @@ static Try<Nothing> increaseRSS(const vector<string>& tokens)
 }
 
 
-static Try<Nothing> increasePageCache(const vector<string>& tokens)
+static Try<Nothing> doIncreasePageCache(const vector<string>& tokens)
 {
   const Bytes UNIT = Megabytes(1);
 
@@ -180,116 +283,14 @@ static Try<Nothing> increasePageCache(const vector<string>& tokens)
 }
 
 
-MemoryTestHelper::~MemoryTestHelper()
-{
-  cleanup();
-}
-
-
-Try<Nothing> MemoryTestHelper::spawn()
-{
-  if (s.isSome()) {
-    return Error("A subprocess has been spawned already");
-  }
-
-  vector<string> argv;
-  argv.push_back("memory-test-helper");
-  argv.push_back(MemoryTestHelperMain::NAME);
-
-  Try<Subprocess> process = subprocess(
-      getTestHelperPath("memory-test-helper"),
-      argv,
-      Subprocess::PIPE(),
-      Subprocess::PIPE(),
-      Subprocess::FD(STDERR_FILENO));
-
-  if (process.isError()) {
-    return Error("Failed to spawn a subprocess: " + process.error());
-  }
-
-  s = process.get();
-
-  // Wait for the child to inform it has started before returning.
-  // Otherwise, the user might set the memory limit too earlier, and
-  // cause the child oom-killed because 'ld' could use a lot of
-  // memory.
-  Result<string> read = os::read(s.get().out().get(), sizeof(STARTED));
-  if (!read.isSome() || read.get() != string(sizeof(STARTED), STARTED)) {
-    cleanup();
-    return Error("Failed to sync with the subprocess");
-  }
-
-  return Nothing();
-}
-
-
-void MemoryTestHelper::cleanup()
-{
-  if (s.isSome()) {
-    // We just want to make sure the subprocess is terminated in case
-    // it's stuck, but we don't care about its status. Any error
-    // should have been logged in the subprocess directly.
-    ::kill(s.get().pid(), SIGKILL);
-    ::waitpid(s.get().pid(), nullptr, 0);
-    s = None();
-  }
-}
-
-
-Try<pid_t> MemoryTestHelper::pid()
-{
-  if (s.isNone()) {
-    return Error("The subprocess has not been spawned yet");
-  }
-
-  return s.get().pid();
-}
-
-
-// Send a request to the subprocess and wait for its signal that the
-// work has been done.
-Try<Nothing> MemoryTestHelper::requestAndWait(const string& request)
-{
-  if (s.isNone()) {
-    return Error("The subprocess has not been spawned yet");
-  }
-
-  Try<Nothing> write = os::write(s.get().in().get(), request + "\n");
-  if (write.isError()) {
-    cleanup();
-    return Error("Fail to sync with the subprocess: " + write.error());
-  }
-
-  Result<string> read = os::read(s.get().out().get(), sizeof(DONE));
-  if (!read.isSome() || read.get() != string(sizeof(DONE), DONE)) {
-    cleanup();
-    return Error("Failed to sync with the subprocess");
-  }
-
-  return Nothing();
-}
-
-
-Try<Nothing> MemoryTestHelper::increaseRSS(const Bytes& size)
-{
-  return requestAndWait(string(INCREASE_RSS) + " " + stringify(size));
-}
-
-
-Try<Nothing> MemoryTestHelper::increasePageCache(const Bytes& size)
-{
-  return requestAndWait(string(INCREASE_PAGE_CACHE) + " " + stringify(size));
-}
-
-
-const char MemoryTestHelperMain::NAME[] = "MemoryTestHelperMain";
+const char MemoryTestHelper::NAME[] = "Memory";
 
 
-int MemoryTestHelperMain::execute()
+int MemoryTestHelper::execute()
 {
   hashmap<string, Try<Nothing>(*)(const vector<string>&)> commands;
-  commands[INCREASE_RSS] = &increaseRSS;
-  commands[INCREASE_PAGE_CACHE] = &increasePageCache;
+  commands[INCREASE_RSS] = &doIncreaseRSS;
+  commands[INCREASE_PAGE_CACHE] = &doIncreasePageCache;
 
   // Tell the parent that child has started.
   cout << STARTED << flush;

http://git-wip-us.apache.org/repos/asf/mesos/blob/9b04b8df/src/tests/containerizer/memory_test_helper.hpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/memory_test_helper.hpp b/src/tests/containerizer/memory_test_helper.hpp
index 86a9b57..cddfbf1 100644
--- a/src/tests/containerizer/memory_test_helper.hpp
+++ b/src/tests/containerizer/memory_test_helper.hpp
@@ -31,10 +31,12 @@ namespace tests {
 // The abstraction for controlling the memory usage of a subprocess.
 // TODO(chzhcn): Currently, this helper is only supposed to be used by
 // one thread. Consider making it thread safe.
-class MemoryTestHelper
+class MemoryTestHelper : public Subcommand
 {
 public:
-  MemoryTestHelper() {}
+  static const char NAME[];
+
+  MemoryTestHelper() : Subcommand(NAME) {}
   ~MemoryTestHelper();
 
   // Spawns a subprocess.
@@ -60,26 +62,17 @@ public:
   // TODO(chzhcn): Consider returning a future instead of blocking.
   Try<Nothing> increasePageCache(const Bytes& size = Megabytes(1));
 
+protected:
+  // The main function of the subprocess. It runs in a loop and
+  // executes commands passed from stdin.
+  virtual int execute();
+
 private:
   Try<Nothing> requestAndWait(const std::string& request);
 
   Option<process::Subprocess> s;
 };
 
-
-// The actual subprocess behind MemoryTestHelper. It runs in a loop
-// and executes commands passed from stdin.
-class MemoryTestHelperMain : public Subcommand
-{
-public:
-  static const char NAME[];
-
-  MemoryTestHelperMain() : Subcommand(NAME) {}
-
-protected:
-  virtual int execute();
-};
-
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/9b04b8df/src/tests/test_helper_main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/test_helper_main.cpp b/src/tests/test_helper_main.cpp
index de95682..dd1be67 100644
--- a/src/tests/test_helper_main.cpp
+++ b/src/tests/test_helper_main.cpp
@@ -19,7 +19,10 @@
 
 #include "tests/active_user_test_helper.hpp"
 
+#include "tests/containerizer/memory_test_helper.hpp"
+
 using mesos::internal::tests::ActiveUserTestHelper;
+using mesos::internal::tests::MemoryTestHelper;
 
 
 int main(int argc, char** argv)
@@ -28,5 +31,6 @@ int main(int argc, char** argv)
       None(),
       argc,
       argv,
-      new ActiveUserTestHelper());
+      new ActiveUserTestHelper(),
+      new MemoryTestHelper());
 }


[07/11] mesos git commit: Made the destructor virtual in memory test helper.

Posted by ji...@apache.org.
Made the destructor virtual in memory test helper.


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

Branch: refs/heads/master
Commit: 3d873ec86cc33dc00b134595ec00e5fa92acbe9d
Parents: 4f71e01
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Aug 25 16:13:26 2016 +0200
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Aug 25 14:57:50 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/memory_test_helper.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3d873ec8/src/tests/containerizer/memory_test_helper.hpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/memory_test_helper.hpp b/src/tests/containerizer/memory_test_helper.hpp
index cddfbf1..26e295b 100644
--- a/src/tests/containerizer/memory_test_helper.hpp
+++ b/src/tests/containerizer/memory_test_helper.hpp
@@ -37,7 +37,7 @@ public:
   static const char NAME[];
 
   MemoryTestHelper() : Subcommand(NAME) {}
-  ~MemoryTestHelper();
+  virtual ~MemoryTestHelper();
 
   // Spawns a subprocess.
   // TODO(chzhcn): Consider returning a future instead of blocking.