You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/04/05 01:03:05 UTC

[1/3] mesos git commit: Updated testing `Environment` to remove temp dirs after each test.

Repository: mesos
Updated Branches:
  refs/heads/master cab5812b4 -> c06d95cfe


Updated testing `Environment` to remove temp dirs after each test.

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


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

Branch: refs/heads/master
Commit: c06d95cfebbe98c1100ca569090ce79208b0feb8
Parents: f228c49
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Thu Mar 31 14:01:44 2016 +0200
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Mon Apr 4 18:53:23 2016 -0400

----------------------------------------------------------------------
 src/tests/environment.cpp | 41 ++++++++++++++++++++++++++++++-----------
 src/tests/environment.hpp | 19 ++++++++++++++++---
 2 files changed, 46 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c06d95cf/src/tests/environment.cpp
----------------------------------------------------------------------
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index 90dbe94..2afaa32 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -721,6 +721,11 @@ Environment::Environment(const Flags& _flags) : flags(_flags)
 
   listeners.Append(process::FilterTestEventListener::instance());
   listeners.Append(process::ClockTestEventListener::instance());
+
+  // Add the temporary directory event listener which will clean up
+  // any directories created after each test finishes.
+  temporaryDirectoryEventListener = new TemporaryDirectoryEventListener();
+  listeners.Append(temporaryDirectoryEventListener);
 }
 
 
@@ -756,6 +761,29 @@ void Environment::SetUp()
 
 void Environment::TearDown()
 {
+  // Make sure we haven't left any child processes lying around.
+  // TODO(benh): Look for processes in the same group or session that
+  // might have been reparented.
+  // TODO(jmlvanre): Consider doing this `OnTestEnd` in a listener so
+  // that we can identify leaked processes more precisely.
+  Try<os::ProcessTree> pstree = os::pstree(0);
+
+  if (pstree.isSome() && !pstree.get().children.empty()) {
+    FAIL() << "Tests completed with child processes remaining:\n"
+           << pstree.get();
+  }
+}
+
+
+Try<string> Environment::mkdtemp()
+{
+  return temporaryDirectoryEventListener->mkdtemp();
+}
+
+
+void tests::Environment::TemporaryDirectoryEventListener::OnTestEnd(
+    const testing::TestInfo&)
+{
   foreach (const string& directory, directories) {
 #ifdef __linux__
     // Try to remove any mounts under 'directory'.
@@ -779,21 +807,12 @@ void Environment::TearDown()
                  << "': " << rmdir.error();
     }
   }
-  directories.clear();
 
-  // Make sure we haven't left any child processes lying around.
-  // TODO(benh): Look for processes in the same group or session that
-  // might have been reparented.
-  Try<os::ProcessTree> pstree = os::pstree(0);
-
-  if (pstree.isSome() && !pstree.get().children.empty()) {
-    FAIL() << "Tests completed with child processes remaining:\n"
-           << pstree.get();
-  }
+  directories.clear();
 }
 
 
-Try<string> Environment::mkdtemp()
+Try<string> Environment::TemporaryDirectoryEventListener::mkdtemp()
 {
   const ::testing::TestInfo* const testInfo =
     ::testing::UnitTest::GetInstance()->current_test_info();

http://git-wip-us.apache.org/repos/asf/mesos/blob/c06d95cf/src/tests/environment.hpp
----------------------------------------------------------------------
diff --git a/src/tests/environment.hpp b/src/tests/environment.hpp
index 9932f7c..06b6d54 100644
--- a/src/tests/environment.hpp
+++ b/src/tests/environment.hpp
@@ -43,14 +43,27 @@ public:
   // case name and test name (derived from TestInfo via
   // ::testing::UnitTest::GetInstance()->current_test_info()). Note
   // that the directory will automagically get removed when the
-  // environment is teared down.
+  // test finishes.
   Try<std::string> mkdtemp();
 
 private:
-  // Temporary directories that we created and need to remove.
-  std::list<std::string> directories;
+  // Used to clean up temporary directories after tests finish.
+  class TemporaryDirectoryEventListener
+    : public ::testing::EmptyTestEventListener
+  {
+  public:
+    Try<std::string> mkdtemp();
+
+  protected:
+    virtual void OnTestEnd(const ::testing::TestInfo&);
+
+    // Temporary directories that we created and need to remove.
+    std::list<std::string> directories;
+  };
 
   const Flags flags;
+
+  TemporaryDirectoryEventListener* temporaryDirectoryEventListener;
 };
 
 


[3/3] mesos git commit: Fixed PersistentVolumeTest `TearDown`.

Posted by jo...@apache.org.
Fixed PersistentVolumeTest `TearDown`.

The super-class `TearDown` was not being invoked properly.

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


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

Branch: refs/heads/master
Commit: 04044e375930b718a936f737d72109852d65018b
Parents: cab5812
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Thu Mar 31 10:47:04 2016 +0200
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Mon Apr 4 18:53:23 2016 -0400

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/04044e37/src/tests/persistent_volume_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/persistent_volume_tests.cpp b/src/tests/persistent_volume_tests.cpp
index 7cb153c..695f692 100644
--- a/src/tests/persistent_volume_tests.cpp
+++ b/src/tests/persistent_volume_tests.cpp
@@ -122,6 +122,7 @@ protected:
       }
     }
 #endif // __linux__
+    MesosTest::TearDown();
   }
 
   master::Flags MasterFlags(const vector<FrameworkInfo>& frameworks)


[2/3] mesos git commit: Cleaned up temporary directories in `PersistentVolumeTest`.

Posted by jo...@apache.org.
Cleaned up temporary directories in `PersistentVolumeTest`.

Added missing `path::join()` call.

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


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

Branch: refs/heads/master
Commit: f228c49a0ae46462a909f0d5e3b97a631bba4ec7
Parents: 04044e3
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Mon Apr 4 18:39:27 2016 -0400
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Mon Apr 4 18:53:23 2016 -0400

----------------------------------------------------------------------
 src/tests/persistent_volume_tests.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f228c49a/src/tests/persistent_volume_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/persistent_volume_tests.cpp b/src/tests/persistent_volume_tests.cpp
index 695f692..4786750 100644
--- a/src/tests/persistent_volume_tests.cpp
+++ b/src/tests/persistent_volume_tests.cpp
@@ -171,7 +171,7 @@ protected:
             "role1",
             None(),
             None(),
-            createDiskSourcePath(diskPath + "disk" + stringify(id)));
+            createDiskSourcePath(path::join(diskPath, "disk" + stringify(id))));
 
         break;
       }
@@ -182,7 +182,7 @@ protected:
             None(),
             None(),
             createDiskSourceMount(
-                path::join(diskPath, + "disk" + stringify(id))));
+                path::join(diskPath, "disk" + stringify(id))));
 
         break;
       }