You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@twill.apache.org by ch...@apache.org on 2014/07/29 08:56:46 UTC

[7/7] git commit: Better test case.

Better test case.

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

Branch: refs/heads/feature/travis-build
Commit: aa1ed65eb350a0a2d623be0573a106a05697257e
Parents: 69dbd5b
Author: Terence Yim <ch...@apache.org>
Authored: Mon Jul 28 23:56:35 2014 -0700
Committer: Terence Yim <ch...@apache.org>
Committed: Mon Jul 28 23:56:35 2014 -0700

----------------------------------------------------------------------
 .../org/apache/twill/yarn/LogHandlerTestRun.java  | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/aa1ed65e/twill-yarn/src/test/java/org/apache/twill/yarn/LogHandlerTestRun.java
----------------------------------------------------------------------
diff --git a/twill-yarn/src/test/java/org/apache/twill/yarn/LogHandlerTestRun.java b/twill-yarn/src/test/java/org/apache/twill/yarn/LogHandlerTestRun.java
index 8a60174..7e6d78c 100644
--- a/twill-yarn/src/test/java/org/apache/twill/yarn/LogHandlerTestRun.java
+++ b/twill-yarn/src/test/java/org/apache/twill/yarn/LogHandlerTestRun.java
@@ -24,7 +24,6 @@ import org.apache.twill.api.logging.LogEntry;
 import org.apache.twill.api.logging.LogHandler;
 import org.apache.twill.api.logging.LogThrowable;
 import org.apache.twill.api.logging.PrinterLogHandler;
-import org.apache.twill.common.Services;
 import org.junit.Assert;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -68,8 +67,11 @@ public class LogHandlerTestRun extends BaseYarnTest {
                                        .addLogHandler(logHandler)
                                        .start();
 
-    Services.getCompletionFuture(controller).get();
-    Assert.assertTrue(latch.await(100, TimeUnit.SECONDS));
+    try {
+      Assert.assertTrue(latch.await(100, TimeUnit.SECONDS));
+    } finally {
+      controller.stopAndWait();
+    }
 
     // Verify the log throwable
     Assert.assertEquals(1, throwables.size());
@@ -90,7 +92,7 @@ public class LogHandlerTestRun extends BaseYarnTest {
   public static final class LogRunnable extends AbstractTwillRunnable {
 
     private static final Logger LOG = LoggerFactory.getLogger(LogRunnable.class);
-
+    private final CountDownLatch stopLatch = new CountDownLatch(1);
 
     @Override
     public void run() {
@@ -105,11 +107,17 @@ public class LogHandlerTestRun extends BaseYarnTest {
       } catch (Throwable t) {
         LOG.error("Got exception", t);
       }
+
+      try {
+        stopLatch.await();
+      } catch (InterruptedException e) {
+        LOG.error("Interrupted", e);
+      }
     }
 
     @Override
     public void stop() {
-
+      stopLatch.countDown();
     }
   }
 }