You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/10/27 00:07:37 UTC

svn commit: r1402699 - in /incubator/mesos/trunk/src: ./ tests/ tests/external/CgroupsIsolation/ tests/external/ExamplesTest/ tests/external/KillTree/ tests/external/LxcIsolation/

Author: benh
Date: Fri Oct 26 22:07:36 2012
New Revision: 1402699

URL: http://svn.apache.org/viewvc?rev=1402699&view=rev
Log:
Refactored TEST_EXTERNAL to TEST_SCRIPT (a simplification that uses
much less convention and therefore is hopefully more straightforward).
Also removed all LXC tests as we are soon to remove the LXC isolation
module.

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

Added:
    incubator/mesos/trunk/src/tests/balloon_framework_test.sh
      - copied, changed from r1402698, incubator/mesos/trunk/src/tests/external/CgroupsIsolation/ROOT_CGROUPS_BalloonFramework.sh
    incubator/mesos/trunk/src/tests/java_exception_test.sh
      - copied, changed from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/JavaExceptionFramework.sh
    incubator/mesos/trunk/src/tests/java_framework_test.sh
      - copied, changed from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/JavaFramework.sh
    incubator/mesos/trunk/src/tests/killtree_test.sh
      - copied, changed from r1402698, incubator/mesos/trunk/src/tests/external/KillTree/KillTreeTest.sh
    incubator/mesos/trunk/src/tests/no_executor_framework_test.sh
      - copied, changed from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/NoExecutorFramework.sh
    incubator/mesos/trunk/src/tests/python_framework_test.sh
      - copied, changed from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/PythonFramework.sh
    incubator/mesos/trunk/src/tests/script.cpp
      - copied, changed from r1402698, incubator/mesos/trunk/src/tests/external.cpp
    incubator/mesos/trunk/src/tests/script.hpp
      - copied, changed from r1402698, incubator/mesos/trunk/src/tests/external.hpp
    incubator/mesos/trunk/src/tests/test_framework_test.sh
      - copied, changed from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/CppFramework.sh
Removed:
    incubator/mesos/trunk/src/tests/external.cpp
    incubator/mesos/trunk/src/tests/external.hpp
    incubator/mesos/trunk/src/tests/external/CgroupsIsolation/ROOT_CGROUPS_BalloonFramework.sh
    incubator/mesos/trunk/src/tests/external/ExamplesTest/CppFramework.sh
    incubator/mesos/trunk/src/tests/external/ExamplesTest/JavaExceptionFramework.sh
    incubator/mesos/trunk/src/tests/external/ExamplesTest/JavaFramework.sh
    incubator/mesos/trunk/src/tests/external/ExamplesTest/NoExecutorFramework.sh
    incubator/mesos/trunk/src/tests/external/ExamplesTest/PythonFramework.sh
    incubator/mesos/trunk/src/tests/external/KillTree/KillTreeTest.sh
    incubator/mesos/trunk/src/tests/external/LxcIsolation/HoldMoreMemThanRequested.sh
    incubator/mesos/trunk/src/tests/external/LxcIsolation/ScaleUpAndDown.sh
    incubator/mesos/trunk/src/tests/external/LxcIsolation/TwoSeparateTasks.sh
    incubator/mesos/trunk/src/tests/external/LxcIsolation/run_scheduled_memhog_test.sh
Modified:
    incubator/mesos/trunk/src/Makefile.am
    incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp
    incubator/mesos/trunk/src/tests/examples_tests.cpp
    incubator/mesos/trunk/src/tests/killtree_tests.cpp

Modified: incubator/mesos/trunk/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/Makefile.am?rev=1402699&r1=1402698&r2=1402699&view=diff
==============================================================================
--- incubator/mesos/trunk/src/Makefile.am (original)
+++ incubator/mesos/trunk/src/Makefile.am Fri Oct 26 22:07:36 2012
@@ -211,7 +211,7 @@ libmesos_no_third_party_la_SOURCES += co
 	slave/paths.hpp slave/state.hpp					\
 	slave/process_based_isolation_module.hpp slave/reaper.hpp	\
 	slave/slave.hpp slave/solaris_project_isolation_module.hpp	\
-	slave/webui.hpp tests/environment.hpp tests/external.hpp	\
+	slave/webui.hpp tests/environment.hpp tests/script.hpp		\
 	tests/zookeeper_test.hpp tests/flags.hpp tests/utils.hpp	\
 	tests/filter.hpp                                                \
 	tests/zookeeper_test_server.hpp zookeeper/authentication.hpp	\
@@ -775,12 +775,11 @@ mesos_tests_SOURCES = tests/main.cpp tes
 	              tests/fault_tolerance_tests.cpp			\
 	              tests/files_tests.cpp tests/flags_tests.cpp	\
 	              tests/log_tests.cpp tests/resources_tests.cpp	\
-	              tests/external.cpp				\
+	              tests/script.cpp					\
 	              tests/examples_tests.cpp				\
 	              tests/configurator_tests.cpp			\
 	              tests/multihashmap_tests.cpp			\
 	              tests/protobuf_io_tests.cpp			\
-	              tests/lxc_isolation_tests.cpp			\
 	              tests/stout_tests.cpp				\
 	              tests/zookeeper_url_tests.cpp			\
 	              tests/killtree_tests.cpp				\
@@ -842,20 +841,14 @@ EXTRA_DIST += examples/python/test_frame
 	      examples/python/test_executor.py
 
 
-EXTERNALSCRIPTS =							\
-  tests/external/CgroupsIsolation/ROOT_CGROUPS_BalloonFramework.sh	\
-  tests/external/LxcIsolation/HoldMoreMemThanRequested.sh		\
-  tests/external/LxcIsolation/ScaleUpAndDown.sh				\
-  tests/external/LxcIsolation/TwoSeparateTasks.sh			\
-  tests/external/LxcIsolation/run_scheduled_memhog_test.sh		\
-  tests/external/SampleFrameworks/CppFramework.sh			\
-  tests/external/SampleFrameworks/NoExecutorFramework.sh		\
-  tests/external/SampleFrameworks/JavaExceptionFramework.sh		\
-  tests/external/SampleFrameworks/JavaFramework.sh			\
-  tests/external/SampleFrameworks/PythonFramework.sh			\
-  tests/external/KillTree/KillTreeTest.sh
-
-dist_check_SCRIPTS += $(EXTERNALSCRIPTS)
+dist_check_SCRIPTS +=				\
+  tests/balloon_framework_test.sh		\
+  tests/test_framework_test.sh			\
+  tests/no_executor_framework_test.sh		\
+  tests/java_exception_test.sh			\
+  tests/java_framework_test.sh			\
+  tests/python_framework_test.sh		\
+  tests/killtree_test.sh
 
 TESTS += mesos-tests
 

Copied: incubator/mesos/trunk/src/tests/balloon_framework_test.sh (from r1402698, incubator/mesos/trunk/src/tests/external/CgroupsIsolation/ROOT_CGROUPS_BalloonFramework.sh)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/balloon_framework_test.sh?p2=incubator/mesos/trunk/src/tests/balloon_framework_test.sh&p1=incubator/mesos/trunk/src/tests/external/CgroupsIsolation/ROOT_CGROUPS_BalloonFramework.sh&r1=1402698&r2=1402699&rev=1402699&view=diff
==============================================================================
    (empty)

Modified: incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp?rev=1402699&r1=1402698&r2=1402699&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp Fri Oct 26 22:07:36 2012
@@ -18,7 +18,9 @@
 
 #include <gtest/gtest.h>
 
-#include "tests/external.hpp"
+#include "tests/script.hpp"
 
-// Run the balloon framework under cgroups isolation.
-TEST_EXTERNAL(CgroupsIsolation, ROOT_CGROUPS_BalloonFramework)
+// Run the balloon framework under the cgroups isolation module.
+TEST_SCRIPT(CgroupsIsolationTest,
+            ROOT_CGROUPS_BalloonFramework,
+            "balloon_framework_test.sh")

Modified: incubator/mesos/trunk/src/tests/examples_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/examples_tests.cpp?rev=1402699&r1=1402698&r2=1402699&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/examples_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/examples_tests.cpp Fri Oct 26 22:07:36 2012
@@ -18,18 +18,18 @@
 
 #include <gtest/gtest.h>
 
-#include "tests/external.hpp"
+#include "tests/script.hpp"
 
 
 // Run each of the sample frameworks in local mode.
-TEST_EXTERNAL(ExamplesTest, CppFramework)
-TEST_EXTERNAL(ExamplesTest, NoExecutorFramework)
+TEST_SCRIPT(ExamplesTest, TestFramework, "test_framework_test.sh")
+TEST_SCRIPT(ExamplesTest, NoExecutorFramework, "no_executor_framework_test.sh")
 
 #ifdef MESOS_HAS_JAVA
-  TEST_EXTERNAL(ExamplesTest, JavaFramework)
-  TEST_EXTERNAL(ExamplesTest, JavaExceptionFramework)
+TEST_SCRIPT(ExamplesTest, JavaFramework, "java_framework_test.sh")
+TEST_SCRIPT(ExamplesTest, JavaException, "java_exception_test.sh")
 #endif
 
 #ifdef MESOS_HAS_PYTHON
-  TEST_EXTERNAL(ExamplesTest, PythonFramework)
+TEST_SCRIPT(ExamplesTest, PythonFramework, "python_framework_test.sh")
 #endif

Copied: incubator/mesos/trunk/src/tests/java_exception_test.sh (from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/JavaExceptionFramework.sh)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/java_exception_test.sh?p2=incubator/mesos/trunk/src/tests/java_exception_test.sh&p1=incubator/mesos/trunk/src/tests/external/ExamplesTest/JavaExceptionFramework.sh&r1=1402698&r2=1402699&rev=1402699&view=diff
==============================================================================
    (empty)

Copied: incubator/mesos/trunk/src/tests/java_framework_test.sh (from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/JavaFramework.sh)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/java_framework_test.sh?p2=incubator/mesos/trunk/src/tests/java_framework_test.sh&p1=incubator/mesos/trunk/src/tests/external/ExamplesTest/JavaFramework.sh&r1=1402698&r2=1402699&rev=1402699&view=diff
==============================================================================
    (empty)

Copied: incubator/mesos/trunk/src/tests/killtree_test.sh (from r1402698, incubator/mesos/trunk/src/tests/external/KillTree/KillTreeTest.sh)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/killtree_test.sh?p2=incubator/mesos/trunk/src/tests/killtree_test.sh&p1=incubator/mesos/trunk/src/tests/external/KillTree/KillTreeTest.sh&r1=1402698&r2=1402699&rev=1402699&view=diff
==============================================================================
    (empty)

Modified: incubator/mesos/trunk/src/tests/killtree_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/killtree_tests.cpp?rev=1402699&r1=1402698&r2=1402699&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/killtree_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/killtree_tests.cpp Fri Oct 26 22:07:36 2012
@@ -18,8 +18,7 @@
 
 #include <gtest/gtest.h>
 
-#include "tests/external.hpp"
+#include "tests/script.hpp"
 
 
-// Run a number of tests for the LXC isolation module.
-TEST_EXTERNAL(KillTree, KillTreeTest)
+TEST_SCRIPT(KillTreeTest, KillTree, "killtree_test.sh")

Copied: incubator/mesos/trunk/src/tests/no_executor_framework_test.sh (from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/NoExecutorFramework.sh)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/no_executor_framework_test.sh?p2=incubator/mesos/trunk/src/tests/no_executor_framework_test.sh&p1=incubator/mesos/trunk/src/tests/external/ExamplesTest/NoExecutorFramework.sh&r1=1402698&r2=1402699&rev=1402699&view=diff
==============================================================================
    (empty)

Copied: incubator/mesos/trunk/src/tests/python_framework_test.sh (from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/PythonFramework.sh)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/python_framework_test.sh?p2=incubator/mesos/trunk/src/tests/python_framework_test.sh&p1=incubator/mesos/trunk/src/tests/external/ExamplesTest/PythonFramework.sh&r1=1402698&r2=1402699&rev=1402699&view=diff
==============================================================================
    (empty)

Copied: incubator/mesos/trunk/src/tests/script.cpp (from r1402698, incubator/mesos/trunk/src/tests/external.cpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/script.cpp?p2=incubator/mesos/trunk/src/tests/script.cpp&p1=incubator/mesos/trunk/src/tests/external.cpp&r1=1402698&r2=1402699&rev=1402699&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/external.cpp (original)
+++ incubator/mesos/trunk/src/tests/script.cpp Fri Oct 26 22:07:36 2012
@@ -17,20 +17,18 @@
  */
 
 #include <signal.h> // For strsignal.
-#include <stdio.h> // For freopen.
+#include <stdio.h>  // For freopen.
 #include <string.h> // For strlen, strerror.
 
 #include <sys/wait.h> // For wait (and associated macros).
 
-#include <gtest/gtest.h>
-
 #include <string>
 
 #include <stout/os.hpp>
 #include <stout/path.hpp>
 #include <stout/strings.hpp>
 
-#include "tests/external.hpp"
+#include "tests/script.hpp"
 #include "tests/utils.hpp"
 
 using std::string;
@@ -38,18 +36,9 @@ using std::string;
 namespace mesos {
 namespace internal {
 namespace tests {
-namespace external {
 
-void run(const char* testCase, const char* testName)
+void execute(const string& script)
 {
-  // Adjust the test name to remove any 'DISABLED_' prefix (in order
-  // to lookup the test). While this might seem alarming, if we are
-  // "running" a disabled test it must be the case that the test was
-  // explicitly enabled (e.g., via 'gtest_filter').
-  if (strings::startsWith(testName, "DISABLED_")) {
-    testName += strlen("DISABLED_");
-  }
-
   // Create a temporary directory for the test.
   Try<string> directory = mkdtemp();
 
@@ -62,22 +51,17 @@ void run(const char* testCase, const cha
   }
 
   // Determine the path for the script.
-  Try<string> script =
-    os::realpath(path::join(flags.source_dir,
-                            "src",
-                            "tests",
-                            "external",
-                            testCase,
-                            testName) + ".sh");
+  Try<string> path =
+    os::realpath(path::join(flags.source_dir, "src", "tests", script));
 
-  if (script.isError()) {
-    FAIL() << "Failed to locate script: " << script.error();
+  if (path.isError()) {
+    FAIL() << "Failed to locate script: " << path.error();
   }
 
   // Fork a process to change directory and run the test.
   pid_t pid;
   if ((pid = fork()) == -1) {
-    FAIL() << "Failed to fork to launch external test";
+    FAIL() << "Failed to fork to launch script";
   }
 
   if (pid) {
@@ -88,14 +72,16 @@ void run(const char* testCase, const cha
 
     if (WIFEXITED(status)) {
       if (WEXITSTATUS(status) != 0) {
-        FAIL() << script.get() << " exited with status " << WEXITSTATUS(status);
+        FAIL() << script << " exited with status " << WEXITSTATUS(status);
       }
     } else {
-      FAIL() << script.get() << " terminated with signal '"
+      FAIL() << script << " terminated with signal '"
              << strsignal(WTERMSIG(status)) << "'";
     }
   } else {
-    // In child process, start by cd'ing into the temporary directory.
+    // In child process, DO NOT USE GLOG!
+
+    // Start by cd'ing into the temporary directory.
     if (!os::chdir(directory.get())) {
       std::cerr << "Failed to chdir to '" << directory.get() << "'" << std::endl;
       abort();
@@ -118,15 +104,14 @@ void run(const char* testCase, const cha
     os::setenv("MESOS_LAUNCHER_DIR", path::join(flags.build_dir, "src"));
 
     // Now execute the script.
-    execl(script.get().c_str(), script.get().c_str(), (char*) NULL);
+    execl(path.get().c_str(), path.get().c_str(), (char*) NULL);
 
-    std::cerr << "Failed to execute '" << script.get() << "': "
+    std::cerr << "Failed to execute '" << script << "': "
               << strerror(errno) << std::endl;
     abort();
   }
 }
 
-} // namespace external {
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {

Copied: incubator/mesos/trunk/src/tests/script.hpp (from r1402698, incubator/mesos/trunk/src/tests/external.hpp)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/script.hpp?p2=incubator/mesos/trunk/src/tests/script.hpp&p1=incubator/mesos/trunk/src/tests/external.hpp&r1=1402698&r2=1402699&rev=1402699&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/external.hpp (original)
+++ incubator/mesos/trunk/src/tests/script.hpp Fri Oct 26 22:07:36 2012
@@ -16,34 +16,30 @@
  * limitations under the License.
  */
 
-#ifndef __TESTS_EXTERNAL_HPP__
-#define __TESTS_EXTERNAL_HPP__
+#ifndef __TESTS_SCRIPT_HPP__
+#define __TESTS_SCRIPT_HPP__
 
 #include <gtest/gtest.h>
 
-// Run an external test with the given name. The test is expected to
-// be located in src/tests/external/<testCase>/<testName>.sh. We
-// execute this script in temporary directory and pipe its output to
-// '/dev/null' unless the verbose option is specified. The "test"
-// passes if the script returns 0.
-#define TEST_EXTERNAL(testCase, testName)                               \
-  TEST(testCase, testName) {                                            \
-    mesos::internal::tests::external::run(#testCase, #testName);        \
-  }
-
-
 namespace mesos {
 namespace internal {
 namespace tests {
-namespace external {
 
-// Function called by TEST_EXTERNAL to execute external tests. See
-// explanation of parameters at definition of TEST_EXTERNAL.
-void run(const char* testCase, const char* testName);
+// Helper used by TEST_SCRIPT to execute the script.
+void execute(const std::string& script);
 
-} // namespace external {
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {
 
-#endif // __TESTS_EXTERNAL_HPP__
+
+// Runs the given script (relative to src/tests). We execute this
+// script in temporary directory and pipe its output to '/dev/null'
+// unless the verbose option is specified. The "test" passes if the
+// script returns 0.
+#define TEST_SCRIPT(test_case_name, test_name, script)      \
+  TEST(test_case_name, test_name) {                         \
+    mesos::internal::tests::execute(script);                \
+  }
+
+#endif // __TESTS_SCRIPT_HPP__

Copied: incubator/mesos/trunk/src/tests/test_framework_test.sh (from r1402698, incubator/mesos/trunk/src/tests/external/ExamplesTest/CppFramework.sh)
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/test_framework_test.sh?p2=incubator/mesos/trunk/src/tests/test_framework_test.sh&p1=incubator/mesos/trunk/src/tests/external/ExamplesTest/CppFramework.sh&r1=1402698&r2=1402699&rev=1402699&view=diff
==============================================================================
    (empty)