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/07/10 19:41:05 UTC

[3/4] curator git commit: Must use timing for ttls so that Jenkins can have appropriate values

Must use timing for ttls so that Jenkins can have appropriate values


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

Branch: refs/heads/master
Commit: 4ad1fb8e5867648e311200edbba773b203c546ad
Parents: 1b2598d
Author: randgalt <ra...@apache.org>
Authored: Mon Jul 10 14:40:20 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Jul 10 14:40:20 2017 -0500

----------------------------------------------------------------------
 .../recipes/nodes/TestPersistentTtlNode.java         | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/4ad1fb8e/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
index 43f5cc0..573a867 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentTtlNode.java
@@ -39,6 +39,7 @@ import static org.apache.curator.framework.recipes.cache.PathChildrenCache.Start
 public class TestPersistentTtlNode extends BaseClassForTests
 {
     private final Timing timing = new Timing();
+    private final long ttlMs = timing.multiple(.10).milliseconds(); // a small number
 
     @BeforeMethod
     @Override
@@ -63,14 +64,14 @@ public class TestPersistentTtlNode extends BaseClassForTests
         {
             client.start();
 
-            try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", 100, new byte[0]))
+            try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", ttlMs, new byte[0]))
             {
                 node.start();
                 Assert.assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
 
-                for ( int i = 0; i < 10; ++i )
+                for ( int i = 0; i < 5; ++i )
                 {
-                    Thread.sleep(110);  // sleep a bit more than the TTL
+                    Thread.sleep(ttlMs + (ttlMs / 2));  // sleep a bit more than the TTL
                     Assert.assertNotNull(client.checkExists().forPath("/test"));
                 }
             }
@@ -88,14 +89,14 @@ public class TestPersistentTtlNode extends BaseClassForTests
         {
             client.start();
 
-            try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", 10, new byte[0]))
+            try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", ttlMs, new byte[0]))
             {
                 node.start();
                 Assert.assertTrue(node.waitForInitialCreate(timing.session(), TimeUnit.MILLISECONDS));
 
-                for ( int i = 0; i < 10; ++i )
+                for ( int i = 0; i < 5; ++i )
                 {
-                    Thread.sleep(10);
+                    Thread.sleep(ttlMs);
                     client.delete().quietly().forPath(ZKPaths.makePath("test", PersistentTtlNode.DEFAULT_CHILD_NODE_NAME));
                 }
 
@@ -112,7 +113,7 @@ public class TestPersistentTtlNode extends BaseClassForTests
         {
             client.start();
 
-            try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", 10, new byte[0]))
+            try (PersistentTtlNode node = new PersistentTtlNode(client, "/test", ttlMs, new byte[0]))
             {
                 try(PathChildrenCache cache = new PathChildrenCache(client, "/", true))
                 {