You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2018/12/06 21:02:06 UTC

curator git commit: CURATOR-490 - include a overridable loop qty

Repository: curator
Updated Branches:
  refs/heads/CURATOR-490 c8e041258 -> 1482370a1


CURATOR-490 - include a overridable loop qty


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

Branch: refs/heads/CURATOR-490
Commit: 1482370a101e308055478ff8c26fc7d46b63646f
Parents: c8e0412
Author: randgalt <ra...@apache.org>
Authored: Thu Dec 6 16:01:58 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Dec 6 16:01:58 2018 -0500

----------------------------------------------------------------------
 .../apache/curator/framework/imps/TestCleanState.java    |  6 ++++--
 .../org/apache/curator/test/compatibility/Timing2.java   | 11 +++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/1482370a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java
index 7a61eea..2b0e4c4 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java
@@ -20,6 +20,7 @@ package org.apache.curator.framework.imps;
 
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.test.WatchersDebug;
+import org.apache.curator.test.compatibility.Timing2;
 import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.utils.Compatibility;
 import org.apache.zookeeper.ZooKeeper;
@@ -42,6 +43,7 @@ public class TestCleanState
 
         try
         {
+            Timing2 timing = new Timing2();
             CuratorFrameworkImpl internalClient = (CuratorFrameworkImpl)client;
             EnsembleTracker ensembleTracker = internalClient.getEnsembleTracker();
             if ( ensembleTracker != null )
@@ -55,12 +57,12 @@ public class TestCleanState
             ZooKeeper zooKeeper = internalClient.getZooKeeper();
             if ( zooKeeper != null )
             {
-                final int maxLoops = 3;
+                final int maxLoops = timing.loopQty();
                 for ( int i = 0; i < maxLoops; ++i )    // it takes time for the watcher removals to settle due to async/watchers, etc. So, if there are remaining watchers, sleep a bit
                 {
                     if ( i > 0 )
                     {
-                        Thread.sleep(500);
+                        timing.multiple(.5).sleepABit();
                     }
                     boolean isLast = (i + 1) == maxLoops;
                     if ( WatchersDebug.getChildWatches(zooKeeper).size() != 0 )

http://git-wip-us.apache.org/repos/asf/curator/blob/1482370a/curator-test/src/main/java/org/apache/curator/test/compatibility/Timing2.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/compatibility/Timing2.java b/curator-test/src/main/java/org/apache/curator/test/compatibility/Timing2.java
index ad105eb..5e0274c 100644
--- a/curator-test/src/main/java/org/apache/curator/test/compatibility/Timing2.java
+++ b/curator-test/src/main/java/org/apache/curator/test/compatibility/Timing2.java
@@ -36,6 +36,7 @@ public class Timing2
     private final TimeUnit unit;
     private final int waitingMultiple;
 
+    private static final int DEFAULT_LOOP_QTY = 3;
     private static final int DEFAULT_SECONDS = 10;
     private static final int DEFAULT_WAITING_MULTIPLE = 5;
     private static final double SESSION_MULTIPLE = 1.5;
@@ -292,6 +293,16 @@ public class Timing2
         return milliseconds();
     }
 
+    /**
+     * For timing loops, etc. the number of times to loop
+     *
+     * @return loop qty
+     */
+    public int loopQty()
+    {
+        return DEFAULT_LOOP_QTY * Integer.getInteger("timing-loop-multiple", 1);
+    }
+
     private static Integer getWaitingMultiple()
     {
         return Integer.getInteger("timing-waiting-multiple", DEFAULT_WAITING_MULTIPLE);