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 2017/05/09 21:17:01 UTC

[2/6] curator git commit: CURATOR-410: Fix testPathsFromProtectingInBackground failing due to new CreateModes in Zookeeper 3.5.3

CURATOR-410: Fix testPathsFromProtectingInBackground failing due to new CreateModes in Zookeeper 3.5.3


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

Branch: refs/heads/CURATOR-397
Commit: 2e69bbf7cc2a128f1e2f98ee6a02ba6d1e47c34f
Parents: f898959
Author: Stig Rohde Døssing <sd...@it-minds.dk>
Authored: Sat May 6 01:29:30 2017 +0200
Committer: Stig Rohde Døssing <sd...@it-minds.dk>
Committed: Sat May 6 09:52:49 2017 +0200

----------------------------------------------------------------------
 .../framework/imps/TestFrameworkEdges.java      | 26 ++++++++++++++------
 1 file changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/2e69bbf7/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 bf1c281..6acbaf6 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
@@ -29,7 +29,6 @@ import org.apache.curator.framework.api.CuratorEventType;
 import org.apache.curator.framework.api.CuratorListener;
 import org.apache.curator.framework.state.ConnectionState;
 import org.apache.curator.framework.state.ConnectionStateListener;
-import org.apache.curator.retry.RetryForever;
 import org.apache.curator.retry.RetryNTimes;
 import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.BaseClassForTests;
@@ -53,6 +52,7 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.curator.framework.api.CreateBuilder;
 
 public class TestFrameworkEdges extends BaseClassForTests
 {
@@ -64,7 +64,7 @@ public class TestFrameworkEdges extends BaseClassForTests
         final int serverPort = server.getPort();
         server.close();
 
-        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), 1000, 1000, new RetryForever(100));
+        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), 1000, 1000, new RetryNTimes(10, timing.forSleepingABit().milliseconds()));
         try
         {
             new Thread()
@@ -178,10 +178,17 @@ public class TestFrameworkEdges extends BaseClassForTests
                 }
             };
             final String TEST_PATH = "/a/b/c/test-";
-            client.create().withMode(mode).inBackground(callback).forPath(TEST_PATH);
+            long ttl = timing.forWaiting().milliseconds()*1000;
+            CreateBuilder firstCreateBuilder = client.create();
+            if(mode.isTTL()) {
+                firstCreateBuilder.withTtl(ttl);
+            }
+            firstCreateBuilder.withMode(mode).inBackground(callback).forPath(TEST_PATH);
 
-            String name1 = paths.take();
-            String path1 = paths.take();
+            String name1 = paths.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
+            String path1 = paths.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
+            Assert.assertNotNull(name1);
+            Assert.assertNotNull(path1);
 
             client.close();
 
@@ -190,14 +197,19 @@ public class TestFrameworkEdges extends BaseClassForTests
             
             CreateBuilderImpl createBuilder = (CreateBuilderImpl)client.create();
             createBuilder.withProtection();
+            if(mode.isTTL()) {
+                createBuilder.withTtl(ttl);
+            }
 
             client.create().forPath(createBuilder.adjustPath(TEST_PATH));
 
             createBuilder.debugForceFindProtectedNode = true;
             createBuilder.withMode(mode).inBackground(callback).forPath(TEST_PATH);
 
-            String name2 = paths.take();
-            String path2 = paths.take();
+            String name2 = paths.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
+            String path2 = paths.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
+            Assert.assertNotNull(name2);
+            Assert.assertNotNull(path2);
 
             Assert.assertEquals(ZKPaths.getPathAndNode(name1).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());
             Assert.assertEquals(ZKPaths.getPathAndNode(name2).getPath(), ZKPaths.getPathAndNode(TEST_PATH).getPath());