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 2015/11/07 01:46:57 UTC
[1/3] mesos git commit: TemporaryDirectoryTest Merge: Elevate
`TemporaryDirectoryTest::sandbox` from private to protected.
Repository: mesos
Updated Branches:
refs/heads/master 202dacdd8 -> 5f8c7dc09
TemporaryDirectoryTest Merge: Elevate `TemporaryDirectoryTest::sandbox`
from private to protected.
Some tests, such as those in `provisioner_backend_tests.cpp`, need to
refer to the `sandbox` variable during their tear down.
Review: https://reviews.apache.org/r/40035
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c10391f6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c10391f6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c10391f6
Branch: refs/heads/master
Commit: c10391f67b0aa6fc975c887880dfe3cbb865b79c
Parents: 202dacd
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Fri Nov 6 16:14:36 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Nov 6 16:14:36 2015 -0800
----------------------------------------------------------------------
.../libprocess/3rdparty/stout/include/stout/tests/utils.hpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/c10391f6/3rdparty/libprocess/3rdparty/stout/include/stout/tests/utils.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/tests/utils.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/tests/utils.hpp
index 8934ba7..141003c 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/tests/utils.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/tests/utils.hpp
@@ -53,9 +53,12 @@ protected:
}
}
+ // A temporary directory for test purposes.
+ // Not to be confused with the "sandbox" that tasks are run in.
+ Option<std::string> sandbox;
+
private:
std::string cwd;
- Option<std::string> sandbox;
};
#endif // __STOUT_TESTS_UTILS_HPP__
[2/3] mesos git commit: TemporaryDirectoryTest Merge: Point tests to
the Stout version of the `TemporaryDirectoryTest`.
Posted by ji...@apache.org.
TemporaryDirectoryTest Merge: Point tests to the Stout version of the
`TemporaryDirectoryTest`.
We have two `TemporaryDirectoryTest` classes, which have almost
identical contents.
Note: The `LinuxFilesystemIsolatorTest` will be changed separately, as
it requires some special cleanup.
Review: https://reviews.apache.org/r/40000
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2d066793
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2d066793
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2d066793
Branch: refs/heads/master
Commit: 2d066793cc0dd060a7ca4a7d329d4da11c576adb
Parents: c10391f
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Fri Nov 6 16:14:52 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Nov 6 16:14:53 2015 -0800
----------------------------------------------------------------------
src/tests/containerizer/fs_tests.cpp | 4 ++--
src/tests/containerizer/launch_tests.cpp | 3 ++-
src/tests/containerizer/provisioner_appc_tests.cpp | 4 ++--
src/tests/containerizer/provisioner_backend_tests.cpp | 3 ++-
src/tests/files_tests.cpp | 4 ++--
src/tests/log_tests.cpp | 3 ++-
src/tests/protobuf_io_tests.cpp | 4 ++--
src/tests/registrar_tests.cpp | 6 ++----
src/tests/state_tests.cpp | 4 ++--
9 files changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d066793/src/tests/containerizer/fs_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/fs_tests.cpp b/src/tests/containerizer/fs_tests.cpp
index 7fb4133..5f88d95 100644
--- a/src/tests/containerizer/fs_tests.cpp
+++ b/src/tests/containerizer/fs_tests.cpp
@@ -27,9 +27,9 @@
#include <stout/os.hpp>
#include <stout/try.hpp>
-#include "linux/fs.hpp"
+#include <stout/tests/utils.hpp>
-#include "tests/utils.hpp"
+#include "linux/fs.hpp"
using std::string;
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d066793/src/tests/containerizer/launch_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/launch_tests.cpp b/src/tests/containerizer/launch_tests.cpp
index de655ec..79ceb5e 100644
--- a/src/tests/containerizer/launch_tests.cpp
+++ b/src/tests/containerizer/launch_tests.cpp
@@ -27,6 +27,8 @@
#include <stout/os.hpp>
#include <stout/try.hpp>
+#include <stout/tests/utils.hpp>
+
#include <process/gtest.hpp>
#include <process/reap.hpp>
#include <process/subprocess.hpp>
@@ -34,7 +36,6 @@
#include "slave/containerizer/mesos/launch.hpp"
#include "tests/flags.hpp"
-#include "tests/utils.hpp"
#include "tests/containerizer/rootfs.hpp"
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d066793/src/tests/containerizer/provisioner_appc_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/provisioner_appc_tests.cpp b/src/tests/containerizer/provisioner_appc_tests.cpp
index 213e9c0..80dd752 100644
--- a/src/tests/containerizer/provisioner_appc_tests.cpp
+++ b/src/tests/containerizer/provisioner_appc_tests.cpp
@@ -29,6 +29,8 @@
#include <stout/stringify.hpp>
#include <stout/uuid.hpp>
+#include <stout/tests/utils.hpp>
+
#include "slave/paths.hpp"
#include "slave/containerizer/mesos/provisioner/paths.hpp"
@@ -37,8 +39,6 @@
#include "slave/containerizer/mesos/provisioner/appc/spec.hpp"
#include "slave/containerizer/mesos/provisioner/appc/store.hpp"
-#include "tests/utils.hpp"
-
using std::list;
using std::string;
using std::vector;
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d066793/src/tests/containerizer/provisioner_backend_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/provisioner_backend_tests.cpp b/src/tests/containerizer/provisioner_backend_tests.cpp
index 3347d58..1b14659 100644
--- a/src/tests/containerizer/provisioner_backend_tests.cpp
+++ b/src/tests/containerizer/provisioner_backend_tests.cpp
@@ -25,6 +25,8 @@
#include <stout/path.hpp>
#include <stout/strings.hpp>
+#include <stout/tests/utils.hpp>
+
#ifdef __linux__
#include "linux/fs.hpp"
#endif // __linux__
@@ -33,7 +35,6 @@
#include "slave/containerizer/mesos/provisioner/backends/copy.hpp"
#include "tests/flags.hpp"
-#include "tests/utils.hpp"
using namespace process;
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d066793/src/tests/files_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/files_tests.cpp b/src/tests/files_tests.cpp
index 4b13f5b..4e66917 100644
--- a/src/tests/files_tests.cpp
+++ b/src/tests/files_tests.cpp
@@ -31,9 +31,9 @@
#include <stout/os.hpp>
#include <stout/stringify.hpp>
-#include "files/files.hpp"
+#include <stout/tests/utils.hpp>
-#include "tests/utils.hpp"
+#include "files/files.hpp"
using process::Future;
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d066793/src/tests/log_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/log_tests.cpp b/src/tests/log_tests.cpp
index bbf7a7e..4ff7a6a 100644
--- a/src/tests/log_tests.cpp
+++ b/src/tests/log_tests.cpp
@@ -42,6 +42,8 @@
#include <stout/stopwatch.hpp>
#include <stout/try.hpp>
+#include <stout/tests/utils.hpp>
+
#include "log/catchup.hpp"
#include "log/coordinator.hpp"
#include "log/leveldb.hpp"
@@ -53,7 +55,6 @@
#include "log/tool/initialize.hpp"
#include "tests/environment.hpp"
-#include "tests/utils.hpp"
#ifdef MESOS_HAS_JAVA
#include "tests/zookeeper.hpp"
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d066793/src/tests/protobuf_io_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/protobuf_io_tests.cpp b/src/tests/protobuf_io_tests.cpp
index f5e041c..61146ed 100644
--- a/src/tests/protobuf_io_tests.cpp
+++ b/src/tests/protobuf_io_tests.cpp
@@ -28,9 +28,9 @@
#include <stout/protobuf.hpp>
#include <stout/result.hpp>
-#include "messages/messages.hpp"
+#include <stout/tests/utils.hpp>
-#include "tests/utils.hpp"
+#include "messages/messages.hpp"
using std::string;
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d066793/src/tests/registrar_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/registrar_tests.cpp b/src/tests/registrar_tests.cpp
index 2610a56..f4ed01e 100644
--- a/src/tests/registrar_tests.cpp
+++ b/src/tests/registrar_tests.cpp
@@ -36,6 +36,8 @@
#include <stout/stopwatch.hpp>
#include <stout/uuid.hpp>
+#include <stout/tests/utils.hpp>
+
#include "common/protobuf_utils.hpp"
#include "log/log.hpp"
@@ -54,8 +56,6 @@
#include "state/protobuf.hpp"
#include "state/storage.hpp"
-#include "tests/utils.hpp"
-
using namespace mesos::internal::master;
using namespace process;
@@ -84,8 +84,6 @@ using testing::DoAll;
using testing::Eq;
using testing::Return;
-using mesos::internal::tests::TemporaryDirectoryTest;
-
using ::testing::WithParamInterface;
namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d066793/src/tests/state_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/state_tests.cpp b/src/tests/state_tests.cpp
index b8cddc5..7cee17d 100644
--- a/src/tests/state_tests.cpp
+++ b/src/tests/state_tests.cpp
@@ -34,9 +34,10 @@
#include <stout/gtest.hpp>
#include <stout/option.hpp>
#include <stout/os.hpp>
+#include <stout/protobuf.hpp>
#include <stout/try.hpp>
-#include <stout/protobuf.hpp>
+#include <stout/tests/utils.hpp>
#include "log/log.hpp"
#include "log/replica.hpp"
@@ -54,7 +55,6 @@
#include "state/storage.hpp"
#include "state/zookeeper.hpp"
-#include "tests/utils.hpp"
#ifdef MESOS_HAS_JAVA
#include "tests/zookeeper.hpp"
#endif
[3/3] mesos git commit: TemporaryDirectoryTest Merge: Remove
non-Stout version of `TemporaryDirectoryTest`.
Posted by ji...@apache.org.
TemporaryDirectoryTest Merge: Remove non-Stout version of
`TemporaryDirectoryTest`.
The special cleanup in the non-Stout `TemporaryDirectoryTest` was moved
into `LinuxFilesystemIsolatorTest`. `LinuxFilesystemIsolatorTest`
creates additional mounts as part of its tests. No other tests require
the special cleanup logic to pass.
Review: https://reviews.apache.org/r/40001
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5f8c7dc0
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5f8c7dc0
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5f8c7dc0
Branch: refs/heads/master
Commit: 5f8c7dc0918204d234698a1f963244e3f6d05d39
Parents: 2d06679
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Fri Nov 6 16:15:10 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Nov 6 16:46:39 2015 -0800
----------------------------------------------------------------------
.../containerizer/filesystem_isolator_tests.cpp | 23 +++++++-
src/tests/utils.cpp | 60 --------------------
src/tests/utils.hpp | 20 -------
3 files changed, 21 insertions(+), 82 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f8c7dc0/src/tests/containerizer/filesystem_isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/filesystem_isolator_tests.cpp b/src/tests/containerizer/filesystem_isolator_tests.cpp
index f1ab98a..7032095 100644
--- a/src/tests/containerizer/filesystem_isolator_tests.cpp
+++ b/src/tests/containerizer/filesystem_isolator_tests.cpp
@@ -85,9 +85,28 @@ namespace internal {
namespace tests {
#ifdef __linux__
-class LinuxFilesystemIsolatorTest: public MesosTest
+class LinuxFilesystemIsolatorTest : public MesosTest
{
-public:
+protected:
+ virtual void TearDown()
+ {
+ // Try to remove any mounts under sandbox.
+ if (::geteuid() == 0) {
+ Try<string> umount = os::shell(
+ "grep '%s' /proc/mounts | "
+ "cut -d' ' -f2 | "
+ "xargs --no-run-if-empty umount -l",
+ sandbox.get().c_str());
+
+ if (umount.isError()) {
+ LOG(ERROR) << "Failed to umount for sandbox '" << sandbox.get()
+ << "': " << umount.error();
+ }
+ }
+
+ MesosTest::TearDown();
+ }
+
// This helper creates a MesosContainerizer instance that uses the
// LinuxFilesystemIsolator. The filesystem isolator takes a
// TestAppcProvisioner which provisions APPC images by copying files
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f8c7dc0/src/tests/utils.cpp
----------------------------------------------------------------------
diff --git a/src/tests/utils.cpp b/src/tests/utils.cpp
index cc3e9e9..0578e63 100644
--- a/src/tests/utils.cpp
+++ b/src/tests/utils.cpp
@@ -16,10 +16,6 @@
* limitations under the License.
*/
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-
#include <gtest/gtest.h>
#include <process/future.hpp>
@@ -29,70 +25,14 @@
#include <process/process.hpp>
#include <stout/gtest.hpp>
-#include <stout/os.hpp>
-#include <stout/path.hpp>
-#include <stout/strings.hpp>
-#include "tests/environment.hpp"
#include "tests/flags.hpp"
#include "tests/utils.hpp"
-using std::string;
-
namespace mesos {
namespace internal {
namespace tests {
-void TemporaryDirectoryTest::SetUp()
-{
- // Save the current working directory.
- cwd = os::getcwd();
-
- // Create a temporary directory for the test.
- Try<string> directory = environment->mkdtemp();
-
- ASSERT_SOME(directory) << "Failed to mkdtemp";
-
- sandbox = directory.get();
-
- if (flags.verbose) {
- std::cout << "Using temporary directory '"
- << sandbox.get() << "'" << std::endl;
- }
-
- // Run the test out of the temporary directory we created.
- ASSERT_SOME(os::chdir(sandbox.get()))
- << "Failed to chdir into '" << sandbox.get() << "'";
-}
-
-
-void TemporaryDirectoryTest::TearDown()
-{
- // Return to previous working directory and cleanup the sandbox.
- ASSERT_SOME(os::chdir(cwd));
-
- if (sandbox.isSome()) {
-#ifdef __linux__
- // Try to remove any mounts under sandbox.
- if (::geteuid() == 0) {
- Try<string> umount = os::shell(
- "grep '%s' /proc/mounts | "
- "cut -d' ' -f2 | "
- "xargs --no-run-if-empty umount -l",
- sandbox.get().c_str());
-
- if (umount.isError()) {
- LOG(ERROR) << "Failed to umount for sandbox '" << sandbox.get()
- << "': " << umount.error();
- }
- }
-#endif
-
- ASSERT_SOME(os::rmdir(sandbox.get()));
- }
-}
-
-
JSON::Object Metrics()
{
process::UPID upid("metrics", process::address());
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f8c7dc0/src/tests/utils.hpp
----------------------------------------------------------------------
diff --git a/src/tests/utils.hpp b/src/tests/utils.hpp
index d4fc6ac..1497013 100644
--- a/src/tests/utils.hpp
+++ b/src/tests/utils.hpp
@@ -19,32 +19,12 @@
#ifndef __TESTS_UTILS_HPP__
#define __TESTS_UTILS_HPP__
-#include <gtest/gtest.h>
-
-#include <string>
-
#include <stout/json.hpp>
-#include <stout/option.hpp>
namespace mesos {
namespace internal {
namespace tests {
-// Test fixture for creating a temporary directory for each test.
-// TODO(vinod): Fold this into stout/tests/utils.hpp.
-class TemporaryDirectoryTest : public ::testing::Test
-{
-protected:
- virtual void SetUp();
- virtual void TearDown();
-
- Option<std::string> sandbox;
-
-private:
- std::string cwd;
-};
-
-
// Get the metrics snapshot.
// TODO(vinod): Move this into a libprocess utility header.
JSON::Object Metrics();