You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2015/10/11 09:55:07 UTC

incubator-zeppelin git commit: [ZEPPELIN-319]wait an additional .5 seconds, if assertion will fail

Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master e39dcd3e4 -> 24aeec402


[ZEPPELIN-319]wait an additional .5 seconds, if assertion will fail

This test failed randomly during a build. To make sure this is not due to timing issues, we can optionally wait an additional .5 seconds.
This is a band-aid around bad design, but I'm pragmatically trying to get the build to be more stable. This should also help determine if there is an actual (randomly striking) issue in the underlying procedure being tested, by making the test more reliable.

Please review, and if you can come up with a better designed test (and avoid waiting for threads to finish in a fixed time interval) we should discuss it here or in the issue.

Author: Rick Moritz <ra...@gmail.com>

Closes #323 from RPCMoritz/ZEPPELIN-319 and squashes the following commits:

27b6608 [Rick Moritz] Switched to isTerminated() for clearer semantics
5e4b8d3 [Rick Moritz] added assertEquals import
10fd22d [Rick Moritz] Fix build and cosmetics
0455a66 [Rick Moritz] Refactoring and moving to job.isRunning check
528dbfa [Rick Moritz] ZEPPELIN-319 optionally wait an additional .5 seconds, if assertion can be expected to fail


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

Branch: refs/heads/master
Commit: 24aeec402a3680d22b6768f5eaa0ce2b5ef43a46
Parents: e39dcd3
Author: Rick Moritz <ra...@gmail.com>
Authored: Mon Oct 5 16:59:26 2015 +0200
Committer: Lee moon soo <mo...@apache.org>
Committed: Sun Oct 11 09:55:46 2015 +0200

----------------------------------------------------------------------
 .../zeppelin/scheduler/RemoteSchedulerTest.java | 21 +++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/24aeec40/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java
index 3c9a475..08fe190 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/RemoteSchedulerTest.java
@@ -18,6 +18,7 @@
 package org.apache.zeppelin.scheduler;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.util.HashMap;
@@ -39,6 +40,8 @@ import org.junit.Test;
 public class RemoteSchedulerTest {
 
   private SchedulerFactory schedulerSvc;
+  private static final int TICK_WAIT = 100;
+  private static final int MAX_WAIT_CYCLES = 100;
 
   @Before
   public void setUp() throws Exception{
@@ -108,16 +111,24 @@ public class RemoteSchedulerTest {
     };
     scheduler.submit(job);
 
-    while (job.isRunning() == false) {
-      Thread.sleep(100);
+    int cycles = 0;
+    while (!job.isRunning() && cycles < MAX_WAIT_CYCLES) {
+      Thread.sleep(TICK_WAIT);
+      cycles++;
     }
+    assertTrue(job.isRunning());
 
-    Thread.sleep(500);
+    Thread.sleep(5*TICK_WAIT);
     assertEquals(0, scheduler.getJobsWaiting().size());
     assertEquals(1, scheduler.getJobsRunning().size());
 
-    Thread.sleep(500);
-
+    cycles = 0;
+    while (!job.isTerminated() && cycles < MAX_WAIT_CYCLES) {
+      Thread.sleep(TICK_WAIT);
+      cycles++;
+    }
+    
+    assertTrue(job.isTerminated());
     assertEquals(0, scheduler.getJobsWaiting().size());
     assertEquals(0, scheduler.getJobsRunning().size());