curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [5/8] git commit: Added more timing to tests
Date Tue, 20 May 2014 15:32:23 GMT
Added more timing to tests


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

Branch: refs/heads/master
Commit: 460a9b373a7c58ec250b5045d4485ba3d0c726e6
Parents: 5dbd672
Author: randgalt <randgalt@apache.org>
Authored: Thu May 15 15:05:08 2014 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Thu May 15 15:05:08 2014 -0500

----------------------------------------------------------------------
 .../nodes/TestPersistentEphemeralNode.java      | 37 +++++++++-----------
 1 file changed, 17 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/460a9b37/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
index 4ca487a..35cb9e8 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
@@ -20,7 +20,6 @@ package org.apache.curator.framework.recipes.nodes;
 
 import com.google.common.base.Throwables;
 import com.google.common.collect.Lists;
-import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
 import org.apache.curator.framework.recipes.BaseClassForTests;
@@ -30,7 +29,7 @@ import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.KillSession;
 import org.apache.curator.test.TestingServer;
 import org.apache.curator.test.Timing;
-import org.apache.curator.utils.DebugUtils;
+import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.utils.ZKPaths;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
@@ -55,6 +54,8 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
     private final Collection<CuratorFramework> curatorInstances = Lists.newArrayList();
     private final Collection<PersistentEphemeralNode> createdNodes = Lists.newArrayList();
 
+    private final Timing timing = new Timing();
+
     @AfterMethod
     public void teardown() throws Exception
     {
@@ -76,7 +77,6 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
     {
         server.close();
 
-        Timing timing = new Timing();
         CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(),
timing.session(), timing.connection(), new RetryOneTime(1));
         try
         {
@@ -124,7 +124,6 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
     {
         server.close();
 
-        Timing timing = new Timing();
         CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(),
timing.session(), timing.connection(), new RetryOneTime(1));
         try
         {
@@ -193,14 +192,13 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
     public void testSettingData() throws Exception
     {
         PersistentEphemeralNode node = null;
-        Timing timing = new Timing();
         CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(),
timing.session(), timing.connection(), new RetryOneTime(1));
         try
         {
             client.start();
             node = new PersistentEphemeralNode(client, PersistentEphemeralNode.Mode.EPHEMERAL,
PATH, "a".getBytes());
             node.start();
-            Assert.assertTrue(node.waitForInitialCreate(5, TimeUnit.SECONDS));
+            Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS));
 
             Assert.assertEquals(node.getActualPath(), PATH);
             Assert.assertEquals(client.getData().forPath(PATH), "a".getBytes());
@@ -266,7 +264,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
 
         PersistentEphemeralNode node = new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL,
PATH, new byte[0]);
         node.start();
-        node.waitForInitialCreate(5, TimeUnit.SECONDS);
+        node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
 
         String path = node.getActualPath();
         node.close();
@@ -286,7 +284,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
         node.start();
         try
         {
-            node.waitForInitialCreate(5, TimeUnit.SECONDS);
+            node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
             assertNodeExists(observer, node.getActualPath());
 
             // Register a watch that will fire when the node is deleted...
@@ -296,7 +294,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
             killSession(curator);
 
             // Make sure the node got deleted
-            assertTrue(deletedTrigger.firedWithin(10, TimeUnit.SECONDS));
+            assertTrue(deletedTrigger.firedWithin(timing.forWaiting().seconds(), TimeUnit.SECONDS));
         }
         finally
         {
@@ -323,12 +321,12 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
             killSession(curator);
 
             // Make sure the node got deleted...
-            assertTrue(deletedTrigger.firedWithin(10, TimeUnit.SECONDS));
+            assertTrue(deletedTrigger.firedWithin(timing.forWaiting().seconds(), TimeUnit.SECONDS));
 
             // Check for it to be recreated...
             Trigger createdTrigger = Trigger.created();
             Stat stat = observer.checkExists().usingWatcher(createdTrigger).forPath(node.getActualPath());
-            assertTrue(stat != null || createdTrigger.firedWithin(10, TimeUnit.SECONDS));
+            assertTrue(stat != null || createdTrigger.firedWithin(timing.forWaiting().seconds(),
TimeUnit.SECONDS));
         }
         finally
         {
@@ -346,7 +344,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
         node.start();
         try
         {
-            node.waitForInitialCreate(5, TimeUnit.SECONDS);
+            node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
             String path = node.getActualPath();
             assertNodeExists(observer, path);
 
@@ -360,12 +358,12 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
                 killSession(curator);
 
                 // Make sure the node ended up getting deleted...
-                assertTrue(deletionTrigger.firedWithin(10, TimeUnit.SECONDS));
+                assertTrue(deletionTrigger.firedWithin(timing.forWaiting().seconds(), TimeUnit.SECONDS));
 
                 // Now put a watch in the background looking to see if it gets created...
                 Trigger creationTrigger = Trigger.created();
                 Stat stat = observer.checkExists().usingWatcher(creationTrigger).forPath(path);
-                assertTrue(stat != null || creationTrigger.firedWithin(10, TimeUnit.SECONDS));
+                assertTrue(stat != null || creationTrigger.firedWithin(timing.forWaiting().seconds(),
TimeUnit.SECONDS));
             }
         }
         finally
@@ -383,7 +381,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
         node.start();
         try
         {
-            node.waitForInitialCreate(5, TimeUnit.SECONDS);
+            node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
             String originalNode = node.getActualPath();
             assertNodeExists(curator, originalNode);
 
@@ -394,7 +392,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
             // node that gets created is going to be exactly the same as the original.
             Trigger createdWatchTrigger = Trigger.created();
             Stat stat = curator.checkExists().usingWatcher(createdWatchTrigger).forPath(originalNode);
-            assertTrue(stat != null || createdWatchTrigger.firedWithin(10, TimeUnit.SECONDS));
+            assertTrue(stat != null || createdWatchTrigger.firedWithin(timing.forWaiting().seconds(),
TimeUnit.SECONDS));
         }
         finally
         {
@@ -411,14 +409,14 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
         node1.start();
         try
         {
-            node1.waitForInitialCreate(5, TimeUnit.SECONDS);
+            node1.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
             String path1 = node1.getActualPath();
 
             PersistentEphemeralNode node2 = new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL_SEQUENTIAL,
PATH, new byte[0]);
             node2.start();
             try
             {
-                node2.waitForInitialCreate(5, TimeUnit.SECONDS);
+                node2.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
                 String path2 = node2.getActualPath();
 
                 assertFalse(path1.equals(path2));
@@ -444,7 +442,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
         node.start();
         try
         {
-            node.waitForInitialCreate(5, TimeUnit.SECONDS);
+            node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS);
             assertTrue(Arrays.equals(curator.getData().forPath(node.getActualPath()), data));
         }
         finally
@@ -466,7 +464,6 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
 
     private CuratorFramework newCurator() throws IOException
     {
-        Timing timing = new Timing();
         CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(),
timing.session(), timing.connection(), new RetryOneTime(1));
         client.start();
 


Mime
View raw message