CURATOR-490

Various changes to make tests run better: using Timing object in TestCleanState 
and few tests where it was missing; set the exclude groups in zk34, and set 
retry tests as status skip


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

Branch: refs/heads/master
Commit: 4c993572f01e1368bd6898cf1fc6ab3eb59d8688
Parents: 85161ab
Author: randgalt <randg...@apache.org>
Authored: Sat Dec 8 23:15:44 2018 -0500
Committer: randgalt <randg...@apache.org>
Committed: Sat Dec 8 23:15:44 2018 -0500

----------------------------------------------------------------------
 .../org/apache/curator/framework/imps/TestCleanState.java    | 4 +++-
 .../org/apache/curator/framework/imps/TestFramework.java     | 3 ++-
 .../apache/curator/framework/imps/TestFrameworkEdges.java    | 4 ++--
 .../curator/framework/recipes/cache/TestNodeCache.java       | 8 +++++---
 .../framework/recipes/cache/TestPathChildrenCache.java       | 2 +-
 curator-test-zk34/pom.xml                                    | 3 ++-
 .../main/java/org/apache/curator/test/BaseClassForTests.java | 1 +
 7 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/4c993572/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..d80e053 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 )
@@ -60,7 +62,7 @@ public class TestCleanState
                 {
                     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/4c993572/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
----------------------------------------------------------------------
diff --git 
a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
 
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
index 0a01679..fe49ad7 100644
--- 
a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
+++ 
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
@@ -32,6 +32,7 @@ import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.BaseClassForTests;
 import org.apache.curator.test.Timing;
 import org.apache.curator.test.compatibility.Timing2;
+import org.apache.curator.test.compatibility.Zk35MethodInterceptor;
 import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.utils.EnsurePath;
 import org.apache.curator.utils.ZKPaths;
@@ -76,7 +77,7 @@ public class TestFramework extends BaseClassForTests
         super.teardown();
     }
 
-    @Test
+    @Test(groups = Zk35MethodInterceptor.zk35Group)
     public void testWaitForShutdownTimeoutMs() throws Exception
     {
         final BlockingQueue<Integer> timeoutQueue = new 
ArrayBlockingQueue<>(1);

http://git-wip-us.apache.org/repos/asf/curator/blob/4c993572/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
----------------------------------------------------------------------
diff --git 
a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
 
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
index f9b16af..0d832f1 100644
--- 
a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
+++ 
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
@@ -696,7 +696,7 @@ public class TestFrameworkEdges extends BaseClassForTests
                 }
             }).start();
 
-            Thread.sleep(20L);
+            timing.sleepABit();
             try
             {
                 client2.delete().forPath("/parent/child" + (childCount / 2));
@@ -713,7 +713,7 @@ public class TestFrameworkEdges extends BaseClassForTests
                 }
             }
 
-            Assert.assertTrue(countDownLatch.await(10, TimeUnit.SECONDS));
+            Assert.assertTrue(timing.awaitLatch(countDownLatch));
 
             Assert.assertNull(client2.checkExists().forPath("/parent"));
         }

http://git-wip-us.apache.org/repos/asf/curator/blob/4c993572/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
----------------------------------------------------------------------
diff --git 
a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
index 2e81034..253c777 100644
--- 
a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
+++ 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java
@@ -21,6 +21,7 @@ package org.apache.curator.framework.recipes.cache;
 import org.apache.curator.framework.imps.TestCleanState;
 import org.apache.curator.test.BaseClassForTests;
 import org.apache.curator.test.compatibility.KillSession2;
+import org.apache.curator.test.compatibility.Timing2;
 import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -106,6 +107,7 @@ public class TestNodeCache extends BaseClassForTests
     @Test
     public void     testRebuildAgainstOtherProcesses() throws Exception
     {
+        Timing2                 timing2 = new Timing2();
         NodeCache               cache = null;
         final CuratorFramework  client = 
CuratorFrameworkFactory.newClient(server.getConnectString(), new 
RetryOneTime(1));
         client.start();
@@ -138,7 +140,7 @@ public class TestNodeCache extends BaseClassForTests
                     @Override
                     public Object call() throws Exception
                     {
-                        finalCache.rebuildTestExchanger.exchange(new Object(), 
10, TimeUnit.SECONDS);
+                        finalCache.rebuildTestExchanger.exchange(new Object(), 
timing2.forWaiting().seconds(), TimeUnit.SECONDS);
 
                         // simulate another process updating the node while 
we're rebuilding
                         client.setData().forPath("/test/snafu", 
"other".getBytes());
@@ -146,7 +148,7 @@ public class TestNodeCache extends BaseClassForTests
                         ChildData       currentData = 
finalCache.getCurrentData();
                         Assert.assertNotNull(currentData);
 
-                        finalCache.rebuildTestExchanger.exchange(new Object(), 
10, TimeUnit.SECONDS);
+                        finalCache.rebuildTestExchanger.exchange(new Object(), 
timing2.forWaiting().seconds(), TimeUnit.SECONDS);
 
                         return null;
                     }
@@ -155,7 +157,7 @@ public class TestNodeCache extends BaseClassForTests
             cache.start(false);
             future.get();
 
-            Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+            Assert.assertTrue(timing2.awaitLatch(latch));
             Assert.assertNotNull(cache.getCurrentData());
             Assert.assertEquals(cache.getCurrentData().getData(), 
"other".getBytes());
         }

http://git-wip-us.apache.org/repos/asf/curator/blob/4c993572/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
----------------------------------------------------------------------
diff --git 
a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
index d2f8cc0..edaac37 100644
--- 
a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
+++ 
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
@@ -56,6 +56,7 @@ public class TestPathChildrenCache extends BaseClassForTests
         try
         {
             client.start();
+            client.blockUntilConnected();   // avoid PathChildrenCache 
connected events
 
             final BlockingQueue<PathChildrenCacheEvent.Type> events = 
Queues.newLinkedBlockingQueue();
             PathChildrenCacheListener listener = new 
PathChildrenCacheListener()
@@ -68,7 +69,6 @@ public class TestPathChildrenCache extends BaseClassForTests
             };
             cache.getListenable().addListener(listener);
             cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
-            
Assert.assertEquals(events.poll(timing.forWaiting().milliseconds(), 
TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.CONNECTION_RECONNECTED);
             
Assert.assertEquals(events.poll(timing.forWaiting().milliseconds(), 
TimeUnit.MILLISECONDS), PathChildrenCacheEvent.Type.INITIALIZED);
 
             client.create().forPath("/a/b/test/one");

http://git-wip-us.apache.org/repos/asf/curator/blob/4c993572/curator-test-zk34/pom.xml
----------------------------------------------------------------------
diff --git a/curator-test-zk34/pom.xml b/curator-test-zk34/pom.xml
index ff063d4..c2c74fa 100644
--- a/curator-test-zk34/pom.xml
+++ b/curator-test-zk34/pom.xml
@@ -168,6 +168,7 @@
                         
<dependency>org.apache.curator:curator-framework</dependency>
                         
<dependency>org.apache.curator:curator-recipes</dependency>
                     </dependenciesToScan>
+                    <excludedGroups>zk35</excludedGroups>
                 </configuration>
             </plugin>
 
@@ -195,4 +196,4 @@
             </plugin>
         </plugins>
     </build>
-</project>
\ No newline at end of file
+</project>

http://git-wip-us.apache.org/repos/asf/curator/blob/4c993572/curator-test/src/main/java/org/apache/curator/test/BaseClassForTests.java
----------------------------------------------------------------------
diff --git 
a/curator-test/src/main/java/org/apache/curator/test/BaseClassForTests.java 
b/curator-test/src/main/java/org/apache/curator/test/BaseClassForTests.java
index 7c4af65..9ae6a5d 100644
--- a/curator-test/src/main/java/org/apache/curator/test/BaseClassForTests.java
+++ b/curator-test/src/main/java/org/apache/curator/test/BaseClassForTests.java
@@ -160,6 +160,7 @@ public class BaseClassForTests
                 return false;
             }
 
+            result.setStatus(ITestResult.SKIP);
             if ( result.getThrowable() != null )
             {
                 log.error("Retrying 1 time", result.getThrowable());

Reply via email to