You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/10/15 23:17:13 UTC

git commit: Fixed example tests to properly wait for the scheduler process to terminate.

Updated Branches:
  refs/heads/master 3540ee4d3 -> 30f8d4764


Fixed example tests to properly wait for the scheduler process to
terminate.

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


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

Branch: refs/heads/master
Commit: 30f8d4764249ab22beb5f13966ec46ed528d24b4
Parents: 3540ee4
Author: Vinod Kone <vi...@twitter.com>
Authored: Mon Oct 14 17:17:30 2013 -0700
Committer: Vinod Kone <vi...@twitter.com>
Committed: Tue Oct 15 14:16:38 2013 -0700

----------------------------------------------------------------------
 include/mesos/scheduler.hpp                   | 4 +++-
 src/examples/balloon_framework.cpp            | 3 +++
 src/examples/java/TestExceptionFramework.java | 7 ++++++-
 src/examples/java/TestFramework.java          | 5 ++---
 src/examples/long_lived_framework.cpp         | 3 +++
 src/examples/no_executor_framework.cpp        | 3 +++
 src/examples/python/test_framework.py         | 7 ++++++-
 src/examples/test_framework.cpp               | 3 +++
 8 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/30f8d476/include/mesos/scheduler.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/scheduler.hpp b/include/mesos/scheduler.hpp
index 4c04216..fa1ffe8 100644
--- a/include/mesos/scheduler.hpp
+++ b/include/mesos/scheduler.hpp
@@ -181,6 +181,7 @@ class SchedulerDriver
 public:
   /**
    * Empty virtual destructor (necessary to instantiate subclasses).
+   * It is expected that 'stop()' is called before this is called.
    */
   virtual ~SchedulerDriver() {}
 
@@ -207,7 +208,8 @@ public:
    * separated so that code can detect an aborted driver (i.e., via
    * the return status of SchedulerDriver::join, see below), and
    * instantiate and start another driver if desired (from within the
-   * same process).
+   * same process). Note that 'stop()' is not automatically called
+   * inside 'abort()'.
    */
   virtual Status abort() = 0;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/30f8d476/src/examples/balloon_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/balloon_framework.cpp b/src/examples/balloon_framework.cpp
index c4e8776..f5eda5e 100644
--- a/src/examples/balloon_framework.cpp
+++ b/src/examples/balloon_framework.cpp
@@ -256,6 +256,9 @@ int main(int argc, char** argv)
 
   int status = driver->run() == DRIVER_STOPPED ? 0 : 1;
 
+  // Ensure that the driver process terminates.
+  driver->stop();
+
   delete driver;
   return status;
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/30f8d476/src/examples/java/TestExceptionFramework.java
----------------------------------------------------------------------
diff --git a/src/examples/java/TestExceptionFramework.java b/src/examples/java/TestExceptionFramework.java
index 4474a91..464b3b0 100644
--- a/src/examples/java/TestExceptionFramework.java
+++ b/src/examples/java/TestExceptionFramework.java
@@ -116,6 +116,11 @@ public class TestExceptionFramework {
           args[0]);
     }
 
-    System.exit(driver.run() == Status.DRIVER_STOPPED ? 0 : 1);
+    int status = driver.run() == Status.DRIVER_STOPPED ? 0 : 1;
+
+    // Ensure that the driver process terminates.
+    driver.stop();
+
+    System.exit(status);
   }
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/30f8d476/src/examples/java/TestFramework.java
----------------------------------------------------------------------
diff --git a/src/examples/java/TestFramework.java b/src/examples/java/TestFramework.java
index 884a49d..65ee2dc 100644
--- a/src/examples/java/TestFramework.java
+++ b/src/examples/java/TestFramework.java
@@ -189,9 +189,8 @@ public class TestFramework {
 
     int status = driver.run() == Status.DRIVER_STOPPED ? 0 : 1;
 
-    // NOTE: We sleep for a second here to wait for the scheduler driver
-    // process to terminate. This is a hack for now.
-    Thread.sleep(1000);
+    // Ensure that the driver process terminates.
+    driver.stop();
 
     System.exit(status);
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/30f8d476/src/examples/long_lived_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/long_lived_framework.cpp b/src/examples/long_lived_framework.cpp
index 5b76939..dc123cd 100644
--- a/src/examples/long_lived_framework.cpp
+++ b/src/examples/long_lived_framework.cpp
@@ -210,6 +210,9 @@ int main(int argc, char** argv)
 
   int status = driver->run() == DRIVER_STOPPED ? 0 : 1;
 
+  // Ensure that the driver process terminates.
+  driver->stop();
+
   delete driver;
   return status;
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/30f8d476/src/examples/no_executor_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/no_executor_framework.cpp b/src/examples/no_executor_framework.cpp
index 813e3fe..0cb987c 100644
--- a/src/examples/no_executor_framework.cpp
+++ b/src/examples/no_executor_framework.cpp
@@ -205,6 +205,9 @@ int main(int argc, char** argv)
 
   int status = driver->run() == DRIVER_STOPPED ? 0 : 1;
 
+  // Ensure that the driver process terminates.
+  driver->stop();
+
   delete driver;
   return status;
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/30f8d476/src/examples/python/test_framework.py
----------------------------------------------------------------------
diff --git a/src/examples/python/test_framework.py b/src/examples/python/test_framework.py
index fb8a730..deca48e 100755
--- a/src/examples/python/test_framework.py
+++ b/src/examples/python/test_framework.py
@@ -161,4 +161,9 @@ if __name__ == "__main__":
         framework,
         sys.argv[1])
 
-  sys.exit(0 if driver.run() == mesos_pb2.DRIVER_STOPPED else 1)
+  status = 0 if driver.run() == mesos_pb2.DRIVER_STOPPED else 1
+
+  # Ensure that the driver process terminates.
+  driver.stop();
+
+  sys.exit(status)

http://git-wip-us.apache.org/repos/asf/mesos/blob/30f8d476/src/examples/test_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_framework.cpp b/src/examples/test_framework.cpp
index ebfedf4..66ce3a6 100644
--- a/src/examples/test_framework.cpp
+++ b/src/examples/test_framework.cpp
@@ -243,6 +243,9 @@ int main(int argc, char** argv)
 
   int status = driver->run() == DRIVER_STOPPED ? 0 : 1;
 
+  // Ensure that the driver process terminates.
+  driver->stop();
+
   delete driver;
   return status;
 }